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 (round 25): no citations in draft mode, preserve partial text on SSE error
Adam Eivya3c7ee2b5044
diff --git a/client/src/pages/Ask.jsx b/client/src/pages/Ask.jsxindex 44465392fc..d535a2ba41 100644--- a/client/src/pages/Ask.jsx+++ b/client/src/pages/Ask.jsx@@ -310,6 +310,10 @@ export default function Ask() {// doesn't ghost a turn that was never persisted.let streamOpened = false;let streamFailure = null;+ // Captures the message from any in-stream `event: error` frame so we can+ // preserve partial assistant text + flag the failure on the local turn+ // when the server bails after streaming some deltas (provider 5xx, etc.).+ let sseErrorMessage = null;await api.streamAskTurn({ conversationId: persistedConvId, question: trimmed, mode },@@ -338,7 +342,8 @@ export default function Ask() {} else if (event === 'done') {persistedTurn = data.turn || null;} else if (event === 'error') {- toast.error(data.error || 'Stream error');+ sseErrorMessage = data.error || 'Stream error';+ toast.error(sseErrorMessage);}},},@@ -405,6 +410,24 @@ export default function Ask() {}return { ...prev, id: serverConvId, turns: [...existingTurns, persistedTurn], updatedAt: persistedTurn.createdAt };});+ } else if (sseErrorMessage && chunks.length && serverConvId) {+ // Provider/server bailed mid-stream after we already received content.+ // Preserve the partial answer as a local-only assistant turn (no+ // `persistedTurn` from the server) so the user can still read/copy+ // what arrived. Tag with `error` so a future render can style it.+ const partialContent = chunks.join('');+ const partialTurn = {+ id: `partial-${Date.now()}`,+ role: 'assistant',+ content: partialContent,+ sources: collectedSources,+ error: sseErrorMessage,+ createdAt: new Date().toISOString(),+ };+ setActiveConv((prev) => {+ if (!prev || (prev.id !== 'pending' && prev.id !== serverConvId)) return prev;+ return { ...prev, id: serverConvId, turns: [...(prev.turns || []), partialTurn], updatedAt: partialTurn.createdAt };+ });}refreshList();}, [activeConv, mode, navigate, question, refreshList, streaming]);diff --git a/server/services/askService.js b/server/services/askService.jsindex 0b9a8a8ecb..6db4e44380 100644--- a/server/services/askService.js+++ b/server/services/askService.js@@ -350,12 +350,18 @@ export async function buildPrompt({ question, mode = 'ask', sources = [], historconst persona = await buildPersonaPreamble();const directive = MODE_DIRECTIVES[mode] || MODE_DIRECTIVES.ask;const transcript = formatTranscriptForPrompt(history);+ // Citation instruction is only useful for `ask`/`advise` answers — `draft`+ // mode produces text in the user's voice for an external recipient who+ // would never want raw `[1]`-style markers leaking into the output.+ const citeInstruction = mode === 'draft'+ ? 'Use the sources below to inform tone and content, but do NOT include any citation markers, bracket numbers, or source references in the drafted text.'+ : 'Cite sources inline using their bracket numbers, e.g. [1] [3]. Only cite sources you actually relied on.';return [persona,'',directive,'',- 'Cite sources inline using their bracket numbers, e.g. [1] [3]. Only cite sources you actually relied on.',+ citeInstruction,'',formatSourcesForPrompt(sources),'',