Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
address review: structured sync returns, draft dedup, test contract alignment
Adam Eivy9aee4264a15d
diff --git a/client/src/components/messages/MessageDetail.jsx b/client/src/components/messages/MessageDetail.jsxindex dc12274c15..4da94b9741 100644--- a/client/src/components/messages/MessageDetail.jsx+++ b/client/src/components/messages/MessageDetail.jsx@@ -7,6 +7,7 @@ export default function MessageDetail({ message, accounts, onBack }) {const [showReply, setShowReply] = useState(false);const [replyBody, setReplyBody] = useState('');const [generating, setGenerating] = useState(false);+ const [generatedDraftId, setGeneratedDraftId] = useState(null);const account = accounts.find(a => a.id === message.accountId) || accounts[0];@@ -23,6 +24,7 @@ export default function MessageDetail({ message, accounts, onBack }) {setGenerating(false);if (draft) {setReplyBody(draft.body);+ setGeneratedDraftId(draft.id);setShowReply(true);toast.success('AI draft generated');}@@ -30,20 +32,24 @@ export default function MessageDetail({ message, accounts, onBack }) {const handleCreateDraft = async () => {if (!account) return toast.error('No account available');- const result = await api.createMessageDraft({+ const draftData = {accountId: account.id,replyToMessageId: message.id,threadId: message.threadId,to: [message.from?.email].filter(Boolean),subject: `Re: ${message.subject || ''}`,body: replyBody,- generatedBy: 'manual',+ generatedBy: generatedDraftId ? 'ai' : 'manual',sendVia: account.provider- }).catch(() => null);+ };+ const result = generatedDraftId+ ? await api.updateMessageDraft(generatedDraftId, draftData).catch(() => null)+ : await api.createMessageDraft(draftData).catch(() => null);if (!result) return;toast.success('Draft saved');setShowReply(false);setReplyBody('');+ setGeneratedDraftId(null);};return (@@ -107,7 +113,7 @@ export default function MessageDetail({ message, accounts, onBack }) {<Send size={16} /> Save Draft</button><button- onClick={() => { setShowReply(false); setReplyBody(''); }}+ onClick={() => { setShowReply(false); setReplyBody(''); setGeneratedDraftId(null); }}className="px-4 py-2 bg-port-border text-gray-300 rounded-lg text-sm hover:bg-port-border/80 transition-colors">Canceldiff --git a/server/routes/messages.test.js b/server/routes/messages.test.jsindex 152ae74a95..b2227c02fa 100644--- a/server/routes/messages.test.js+++ b/server/routes/messages.test.js@@ -586,12 +586,14 @@ describe('Messages Routes', () => {describe('POST /api/messages/selectors/:provider/test', () => {it('should test selectors for a valid provider', async () => {- messagePlaywrightSync.testSelectors.mockResolvedValue({ success: true, matched: 5 });+ messagePlaywrightSync.testSelectors.mockResolvedValue({ provider: 'teams', results: { matched: 5 }, status: 'ok' });const response = await request(app).post('/api/messages/selectors/teams/test');expect(response.status).toBe(200);- expect(response.body.success).toBe(true);+ expect(response.body.status).toBe('ok');+ expect(response.body.provider).toBe('teams');+ expect(response.body.results).toEqual({ matched: 5 });});it('should return 400 for invalid provider', async () => {diff --git a/server/services/messagePlaywrightSync.js b/server/services/messagePlaywrightSync.jsindex f873905df9..048c75056d 100644--- a/server/services/messagePlaywrightSync.js+++ b/server/services/messagePlaywrightSync.js@@ -130,14 +130,14 @@ export async function syncPlaywright(account, cache, io) {if (!page) {io?.emit('messages:sync:progress', { accountId: account.id, current: 0, total: 0 });console.log(`📧 No CDP browser available — launch browser first`);- return [];+ return { messages: [], status: 'no-browser' };}// Check for auth/login pageif (isAuthPage(page)) {console.log(`📧 Auth required for ${account.type} — login page detected`);io?.emit('messages:sync:auth-required', { accountId: account.id });- return [];+ return { messages: [], status: 'auth-required' };}// Load selectors for this provider