Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(desktop-ui): offer the undelivered documents back instead of resending answered text
Alfredo Lopezbb5c30f0c6a6
diff --git a/desktop-app/ui/src/components/agents/ComposerPanel.tsx b/desktop-app/ui/src/components/agents/ComposerPanel.tsxindex ec6d6ebed..5f022a941 100644--- a/desktop-app/ui/src/components/agents/ComposerPanel.tsx+++ b/desktop-app/ui/src/components/agents/ComposerPanel.tsx@@ -1285,7 +1285,8 @@ export function ComposerPanel({ inline = false, agentSelector }: ComposerPanelPr</details>) : null}<div className="action-row">- {failedAgentSend && (+ {/* A message answered without its documents is never resent. */}+ {failedAgentSend && !failedAgentSend.answeredWithoutFiles && (<Buttoncolor="neutral"onClick={onRetryFailedSend}@@ -1305,7 +1306,7 @@ export function ComposerPanel({ inline = false, agentSelector }: ComposerPanelPr<div className="composer-footer"><div className="action-row"><Button onClick={onRecoverFailedSend} disabled={agentSending} size="xs" variant="ghost">- Recover input+ {failedAgentSend.answeredWithoutFiles ? 'Recover files' : 'Recover input'}</Button><Button onClick={onDiscardFailedSend} disabled={agentSending} size="xs" variant="ghost">Discard failed inputdiff --git a/desktop-app/ui/src/components/agents/__tests__/ComposerPanel.test.tsx b/desktop-app/ui/src/components/agents/__tests__/ComposerPanel.test.tsxindex 4b78a4ea8..f7a1b71e0 100644--- a/desktop-app/ui/src/components/agents/__tests__/ComposerPanel.test.tsx+++ b/desktop-app/ui/src/components/agents/__tests__/ComposerPanel.test.tsx@@ -1133,6 +1133,25 @@ describe('ComposerPanel failed-send recovery actions', () => {expect(actionsMock.handleRetryFailedAgentSend).toHaveBeenCalledTimes(1)})+ it('offers only the files back for a message answered without them', () => {+ composerState.failedAgentSend = { ...failedSend, answeredWithoutFiles: true }+ composerState.agentError = 'The Host does not accept file attachments yet'+ render(<ComposerPanel inline />)++ // A retry would send the answered text again; recovering the input would+ // bring that text back as a draft.+ expect(screen.queryByRole('button', { name: 'Retry last send' })).toBeNull()+ expect(screen.queryByRole('button', { name: 'Recover input' })).toBeNull()++ // Liveness: the failure is shown and its recovery and discard are offered.+ expect(screen.getByText('The Host does not accept file attachments yet')).toBeTruthy()+ fireEvent.click(screen.getByRole('button', { name: 'Recover files' }))+ expect(actionsMock.handleRecoverFailedAgentSend).toHaveBeenCalledTimes(1)+ fireEvent.click(screen.getByRole('button', { name: 'Discard failed input' }))+ expect(actionsMock.handleDiscardFailedAgentSend).toHaveBeenCalledTimes(1)+ expect(actionsMock.handleRetryFailedAgentSend).not.toHaveBeenCalled()+ })+it('disables recovery while a send is in flight', () => {composerState.failedAgentSend = failedSendcomposerState.agentError = 'Sending failed'diff --git a/desktop-app/ui/src/hooks/domain/__tests__/sendAgentMessage.documents.test.tsx b/desktop-app/ui/src/hooks/domain/__tests__/sendAgentMessage.documents.test.tsxindex e267b4756..0c16da3f0 100644--- a/desktop-app/ui/src/hooks/domain/__tests__/sendAgentMessage.documents.test.tsx+++ b/desktop-app/ui/src/hooks/domain/__tests__/sendAgentMessage.documents.test.tsx@@ -7,6 +7,7 @@import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'import { act, waitFor } from '@testing-library/react'import { createHash } from 'node:crypto'+import { getComposerDraft } from '@lib/composerDraftStore'import { loadHostModels, resetHostModelSelectionStore } from '@lib/hostModelSelectionStore'import type { HostModelsResult } from '../../../../../src/types'import { renderController } from './__fixtures__/controllerHarness'@@ -32,6 +33,9 @@ const NOTES_DIGEST = createHash('sha256').update(NOTES_BYTES).digest('hex')const UNSUPPORTED ='The Host does not accept file attachments yet; the message was not delivered with them. Your files are kept so you can retry once the Host is updated.'+/** The Host answered the text and dropped every document (#678 D13). */+const DROPPED =+ 'The Host does not accept file attachments yet; the message was sent without them. Recover the files to attach them again once the Host is updated.'beforeEach(() => {uuidCounter = 0@@ -195,6 +199,8 @@ describe('sendAgentMessage — a Host without file attachments (#678 D13)', () =const failed = rendered.result.current.failedAgentSendexpect(failed?.message).toBe(UNSUPPORTED)expect(failed?.files.map(item => item.id)).toEqual([file.id])+ // Nothing was answered: the whole input is still a retry candidate.+ expect(failed?.answeredWithoutFiles).toBe(false)// The Host was updated in the meantime: it now lists the file it admitted.clerum.rpc.invokeHostMessage.mockResolvedValueOnce({@@ -247,8 +253,8 @@ describe('sendAgentMessage — a Host without file attachments (#678 D13)', () =await rendered.result.current.handleSendAgentMessage('Summarize this')})- expect(rendered.result.current.agentError).toBe(UNSUPPORTED)- expect(rendered.spies.pushToast).toHaveBeenCalledWith(UNSUPPORTED, 'error')+ expect(rendered.result.current.agentError).toBe(DROPPED)+ expect(rendered.spies.pushToast).toHaveBeenCalledWith(DROPPED, 'error')expect(rendered.spies.pushToast).not.toHaveBeenCalledWith('Message sent to agent-x.', 'success')expect(rendered.result.current.failedAgentSend?.files.map(item => item.id)).toEqual([file.id])})@@ -282,7 +288,7 @@ describe('sendAgentMessage — a Host without file attachments (#678 D13)', () =})const partial =- 'The Host did not receive 1 of the attached files. Your files are kept so you can retry.'+ 'The Host did not receive 1 of the attached files; the message was sent without them. Recover the files to attach them again.'expect(rendered.result.current.agentError).toBe(partial)expect(rendered.result.current.failedAgentSend?.files).toHaveLength(2)})@@ -326,9 +332,11 @@ describe('sendAgentMessage — a Host without file attachments (#678 D13)', () =])))- expect(rendered.spies.pushToast).toHaveBeenCalledWith(UNSUPPORTED, 'error')- expect(rendered.result.current.failedAgentSend?.message).toBe(UNSUPPORTED)+ expect(rendered.spies.pushToast).toHaveBeenCalledWith(DROPPED, 'error')+ expect(rendered.result.current.failedAgentSend?.message).toBe(DROPPED)expect(rendered.result.current.failedAgentSend?.files.map(item => item.id)).toEqual([file.id])+ // The task answered the text: only the files are left to recover.+ expect(rendered.result.current.failedAgentSend?.answeredWithoutFiles).toBe(true)})it('titles a new chat from both the images and the documents of a send without text', async () => {@@ -391,6 +399,68 @@ describe('sendAgentMessage — a Host without file attachments (#678 D13)', () =expect(sentAttachments()).toHaveLength(1)expect(rendered.result.current.failedAgentSend).toBeNull()expect(rendered.result.current.agentError).toBeNull()- expect(rendered.spies.pushToast).not.toHaveBeenCalledWith(UNSUPPORTED, 'error')+ expect(rendered.spies.pushToast).not.toHaveBeenCalledWith(DROPPED, 'error')+ })+})++/**+ * jozer-rami review 5437205747 — when the Host answered the text and dropped+ * the documents, a retry would send that text again. The failure offers the+ * files back instead, and nothing is re-sent.+ */+describe('sendAgentMessage — a message answered without its documents', () => {+ async function answeredWithoutFiles(rendered: Rendered) {+ const file = await addReadyFile(rendered)+ clerum.rpc.invokeHostMessage.mockResolvedValueOnce({+ response: 'done',+ acceptedAttachmentIds: [],+ })+ await act(async () => {+ await rendered.result.current.handleSendAgentMessage('Summarize this')+ })+ // Witness: the send went out once with the document and the failure kept it.+ expect(clerum.rpc.invokeHostMessage).toHaveBeenCalledTimes(1)+ expect(sentAttachments()).toEqual([expect.objectContaining({ id: file.id })])+ expect(rendered.result.current.failedAgentSend?.files.map(item => item.id)).toEqual([file.id])+ expect(rendered.result.current.composerFileAttachments).toEqual([])+ return file+ }++ it('marks the failure as answered without its files', async () => {+ const rendered = renderController()+ await settleMount()+ await answeredWithoutFiles(rendered)+ expect(rendered.result.current.failedAgentSend?.answeredWithoutFiles).toBe(true)+ })++ it('refuses to retry, so the answered text is not sent again', async () => {+ const rendered = renderController()+ await settleMount()+ const file = await answeredWithoutFiles(rendered)++ await act(async () => {+ await rendered.result.current.handleRetryFailedAgentSend()+ })++ expect(clerum.rpc.invokeHostMessage).toHaveBeenCalledTimes(1)+ // Liveness: the failure and its files are still there to recover.+ expect(rendered.result.current.failedAgentSend?.files.map(item => item.id)).toEqual([file.id])+ })++ it('recovers only the files into the composer and sends nothing', async () => {+ const rendered = renderController()+ await settleMount()+ const file = await answeredWithoutFiles(rendered)+ const chat = rendered.result.current.activeChatId++ act(() => rendered.result.current.handleRecoverFailedAgentSend())++ expect(rendered.result.current.composerFileAttachments).toEqual([+ expect.objectContaining({ id: file.id, status: 'ready', digestHex: NOTES_DIGEST }),+ ])+ // The text was answered: it does not come back as a draft to send again.+ expect(getComposerDraft(chat, 'agent-x')).toBe('')+ expect(rendered.result.current.failedAgentSend).toBeNull()+ expect(clerum.rpc.invokeHostMessage).toHaveBeenCalledTimes(1)})})diff --git a/desktop-app/ui/src/hooks/domain/useAgentChatController.ts b/desktop-app/ui/src/hooks/domain/useAgentChatController.tsindex 46051b19e..265ae7621 100644--- a/desktop-app/ui/src/hooks/domain/useAgentChatController.ts+++ b/desktop-app/ui/src/hooks/domain/useAgentChatController.ts@@ -148,6 +148,8 @@ const FILE_REFERENCES_NOT_RECEIVED_MESSAGE =// with LLM_INVALID_ATTACHMENT or drops it and still accepts the message.const HOST_FILE_ATTACHMENTS_UNSUPPORTED_MESSAGE ='The Host does not accept file attachments yet; the message was not delivered with them. Your files are kept so you can retry once the Host is updated.'+const HOST_FILE_ATTACHMENTS_DROPPED_MESSAGE =+ 'The Host does not accept file attachments yet; the message was sent without them. Recover the files to attach them again once the Host is updated.'const HOST_INVALID_ATTACHMENT_CODE = 'LLM_INVALID_ATTACHMENT'const LATEST_PAGE_FALLBACK_WINDOW = Symbol('latest-page-fallback-window')const DELTA_RECONCILIATION_WINDOW = Symbol('delta-reconciliation-window')@@ -3227,8 +3229,8 @@ export function useAgentChatController({if (undelivered.length > 0) {filesNotDeliveredMessage =undelivered.length === effectiveFiles.length- ? HOST_FILE_ATTACHMENTS_UNSUPPORTED_MESSAGE- : `The Host did not receive ${undelivered.length} of the attached files. Your files are kept so you can retry.`+ ? HOST_FILE_ATTACHMENTS_DROPPED_MESSAGE+ : `The Host did not receive ${undelivered.length} of the attached files; the message was sent without them. Recover the files to attach them again.`setAgentError(filesNotDeliveredMessage)pushToast(filesNotDeliveredMessage, 'error')}@@ -3315,7 +3317,7 @@ export function useAgentChatController({sendAgent,sendChatId ?? null,userMessageId,- 'host_files_unsupported',+ 'host_files_dropped',filesNotDeliveredMessage,'upstream')@@ -3359,12 +3361,7 @@ export function useAgentChatController({if (filesNotDeliveredMessage) {// The task runs without the documents; the snapshot survives its// success (see releaseSucceededRetainedSendsForTask).- markRetainedSendReason(- taskId,- 'host_files_unsupported',- filesNotDeliveredMessage,- 'upstream'- )+ markRetainedSendReason(taskId, 'host_files_dropped', filesNotDeliveredMessage, 'upstream')}activityTaskToMessageByAgentRef.current[sendAgent] = {...(activityTaskToMessageByAgentRef.current[sendAgent] || {}),@@ -3567,6 +3564,7 @@ export function useAgentChatController({...snapshot,message: snapshot.failure.message,kind: snapshot.failure.kind,+ answeredWithoutFiles: snapshot.reason === 'host_files_dropped',} satisfies FailedAgentSend}, [retainedSends, retainedRevision, selectedAgent, activeChatId])const visibleFailure =@@ -3583,7 +3581,8 @@ export function useAgentChatController({// bytes and still answering `getLatestRetainedSendSnapshotForChat` (which picks// the newest snapshot *carrying a failure*).const handleRetryFailedAgentSend = useCallback(async () => {- if (!visibleFailure) return+ // The Host already answered this text; only its documents are recoverable.+ if (!visibleFailure || visibleFailure.answeredWithoutFiles) returnconst previous = visibleFailureconst retainedBefore = lastRetainedSendIdRef.current// The retained files are already read and hashed: a retry never reads them again.@@ -3641,6 +3640,13 @@ export function useAgentChatController({pushToast('Keep or clear the current draft before recovering the earlier input.', 'error')return}+ if (visibleFailure.answeredWithoutFiles) {+ // The text and the other attachments were answered: bring back only the+ // documents the Host never received, and send nothing.+ handleRestoreComposerFiles(visibleFailure.files)+ handleDiscardFailedAgentSend()+ return+ }setComposerDraft(activeChatId, visibleFailure.content, selectedAgent ?? undefined)handleAddComposerImageAttachments(visibleFailure.attachments.map(attachment => ({diff --git a/desktop-app/ui/src/lib/__tests__/retainedSendStore.test.ts b/desktop-app/ui/src/lib/__tests__/retainedSendStore.test.tsindex c3ac2bb94..aa20d2f11 100644--- a/desktop-app/ui/src/lib/__tests__/retainedSendStore.test.ts+++ b/desktop-app/ui/src/lib/__tests__/retainedSendStore.test.ts@@ -92,32 +92,6 @@ describe('retainedSendStore — superseded failures (#654 M2)', () => {})describe('retainedSendStore — documents the Host never received (#678 D13)', () => {- it('keeps the snapshot of a task that succeeded without its files', () => {- const store = createRetainedSendStore(vi.fn())- store.retainSendSnapshot(snapshot('older', 100))- store.retainSendSnapshot(- snapshot('with-files', 200, { reason: 'awaiting_terminal', failure: undefined })- )- store.attachTaskIdToRetainedSend('agent-x', 'chat-1', 'with-files', 'task-files')- store.markRetainedSendReason(- 'task-files',- 'host_files_unsupported',- 'The Host does not accept file attachments yet.',- 'upstream'- )-- store.releaseSucceededRetainedSendsForTask('task-files')-- // Liveness witness: the flagged snapshot is still there, marked with its reason.- const kept = store.getRetainedSendSnapshot('agent-x', 'chat-1', 'with-files')- expect(kept?.reason).toBe('host_files_unsupported')- // The success released nobody, not even the older failure it would supersede.- expect(held(store, ['chat-1/older', 'chat-1/with-files'])).toEqual([- 'chat-1/older',- 'chat-1/with-files',- ])- })-it('still releases a succeeded task whose files reached the Host', () => {const store = createRetainedSendStore(vi.fn())store.retainSendSnapshot(@@ -131,88 +105,123 @@ describe('retainedSendStore — documents the Host never received (#678 D13)', (expect(held(store, ['chat-1/delivered'])).toEqual([])})- function seedUndeliveredFiles() {- const store = createRetainedSendStore(vi.fn())- store.retainSendSnapshot(- snapshot('undelivered', 100, {- reason: 'host_files_unsupported',- failure: { message: 'The Host did not receive the files.', kind: 'upstream' },- })- )- store.retainSendSnapshot(snapshot('ordinary-failure', 150))- store.retainSendSnapshot(- snapshot('later', 200, { reason: 'awaiting_terminal', failure: undefined })- )- return store- }- const SEEDED = ['chat-1/undelivered', 'chat-1/ordinary-failure', 'chat-1/later']-- it('a later successful send in the chat keeps an older snapshot whose files never arrived', () => {- const store = seedUndeliveredFiles()-- store.releaseSucceededRetainedSend('agent-x', 'chat-1', 'later')-- // Witness: the success did supersede the ordinary older failure.- expect(held(store, SEEDED)).toEqual(['chat-1/undelivered'])- })-- it('a later successful task in the chat keeps an older snapshot whose files never arrived', () => {- const store = seedUndeliveredFiles()- store.attachTaskIdToRetainedSend('agent-x', 'chat-1', 'later', 'task-later')-- store.releaseSucceededRetainedSendsForTask('task-later')-- expect(held(store, SEEDED)).toEqual(['chat-1/undelivered'])- })-- it('a discard still releases an older snapshot whose files never arrived', () => {- const store = seedUndeliveredFiles()-- // The user dismissed the newest failure of the chat, and the ones behind it.- store.releaseRetainedFailuresForChat('agent-x', 'chat-1', 150)-- // Witness: the send still awaiting its terminal is not a failure and stays.- expect(held(store, SEEDED)).toEqual(['chat-1/later'])- })-- it('a later task failure updates the message and keeps the undelivered-files reason', () => {- const store = createRetainedSendStore(vi.fn())- store.retainSendSnapshot(- snapshot('with-files', 200, { reason: 'awaiting_terminal', failure: undefined })- )- store.attachTaskIdToRetainedSend('agent-x', 'chat-1', 'with-files', 'task-files')- store.markRetainedSendReason(- 'task-files',- 'host_files_unsupported',- 'The Host did not receive the files.',- 'upstream'- )-- store.markRetainedSendReason('task-files', 'async_task_failed', 'The task failed.', 'upstream')-- const kept = store.getRetainedSendSnapshot('agent-x', 'chat-1', 'with-files')- // Witness: the second mark ran and replaced the failure message.- expect(kept?.failure).toEqual({ message: 'The task failed.', kind: 'upstream' })- expect(kept?.reason).toBe('host_files_unsupported')- // So the task's later success still keeps it.- store.releaseSucceededRetainedSendsForTask('task-files')- expect(held(store, ['chat-1/with-files'])).toEqual(['chat-1/with-files'])- })-- it('a later send failure updates the message and keeps the undelivered-files reason', () => {- const store = seedUndeliveredFiles()-- store.failRetainedSend(- 'agent-x',- 'chat-1',- 'undelivered',- 'stream_lost',- 'The stream was lost.',- 'network'- )-- const kept = store.getRetainedSendSnapshot('agent-x', 'chat-1', 'undelivered')- expect(kept?.failure).toEqual({ message: 'The stream was lost.', kind: 'network' })- expect(kept?.reason).toBe('host_files_unsupported')+ // Both reasons hold documents that exist nowhere else: a rejected send+ // (nothing answered) and a message answered without its documents.+ describe.each(['host_files_unsupported', 'host_files_dropped'] as const)('%s', reason => {+ it('keeps the snapshot of a task that succeeded without its files', () => {+ const store = createRetainedSendStore(vi.fn())+ store.retainSendSnapshot(snapshot('older', 100))+ store.retainSendSnapshot(+ snapshot('with-files', 200, { reason: 'awaiting_terminal', failure: undefined })+ )+ store.attachTaskIdToRetainedSend('agent-x', 'chat-1', 'with-files', 'task-files')+ store.markRetainedSendReason(+ 'task-files',+ reason,+ 'The Host does not accept file attachments yet.',+ 'upstream'+ )++ store.releaseSucceededRetainedSendsForTask('task-files')++ // Liveness witness: the flagged snapshot is still there, marked with its reason.+ const kept = store.getRetainedSendSnapshot('agent-x', 'chat-1', 'with-files')+ expect(kept?.reason).toBe(reason)+ // The success released nobody, not even the older failure it would supersede.+ expect(held(store, ['chat-1/older', 'chat-1/with-files'])).toEqual([+ 'chat-1/older',+ 'chat-1/with-files',+ ])+ })++ function seedUndeliveredFiles() {+ const store = createRetainedSendStore(vi.fn())+ store.retainSendSnapshot(+ snapshot('undelivered', 100, {+ reason: reason,+ failure: { message: 'The Host did not receive the files.', kind: 'upstream' },+ })+ )+ store.retainSendSnapshot(snapshot('ordinary-failure', 150))+ store.retainSendSnapshot(+ snapshot('later', 200, { reason: 'awaiting_terminal', failure: undefined })+ )+ return store+ }+ const SEEDED = ['chat-1/undelivered', 'chat-1/ordinary-failure', 'chat-1/later']++ it('a later successful send in the chat keeps an older snapshot whose files never arrived', () => {+ const store = seedUndeliveredFiles()++ store.releaseSucceededRetainedSend('agent-x', 'chat-1', 'later')++ // Witness: the success did supersede the ordinary older failure.+ expect(held(store, SEEDED)).toEqual(['chat-1/undelivered'])+ })++ it('a later successful task in the chat keeps an older snapshot whose files never arrived', () => {+ const store = seedUndeliveredFiles()+ store.attachTaskIdToRetainedSend('agent-x', 'chat-1', 'later', 'task-later')++ store.releaseSucceededRetainedSendsForTask('task-later')++ expect(held(store, SEEDED)).toEqual(['chat-1/undelivered'])+ })++ it('a discard still releases an older snapshot whose files never arrived', () => {+ const store = seedUndeliveredFiles()++ // The user dismissed the newest failure of the chat, and the ones behind it.+ store.releaseRetainedFailuresForChat('agent-x', 'chat-1', 150)++ // Witness: the send still awaiting its terminal is not a failure and stays.+ expect(held(store, SEEDED)).toEqual(['chat-1/later'])+ })++ it('a later task failure updates the message and keeps the undelivered-files reason', () => {+ const store = createRetainedSendStore(vi.fn())+ store.retainSendSnapshot(+ snapshot('with-files', 200, { reason: 'awaiting_terminal', failure: undefined })+ )+ store.attachTaskIdToRetainedSend('agent-x', 'chat-1', 'with-files', 'task-files')+ store.markRetainedSendReason(+ 'task-files',+ reason,+ 'The Host did not receive the files.',+ 'upstream'+ )++ store.markRetainedSendReason(+ 'task-files',+ 'async_task_failed',+ 'The task failed.',+ 'upstream'+ )++ const kept = store.getRetainedSendSnapshot('agent-x', 'chat-1', 'with-files')+ // Witness: the second mark ran and replaced the failure message.+ expect(kept?.failure).toEqual({ message: 'The task failed.', kind: 'upstream' })+ expect(kept?.reason).toBe(reason)+ // So the task's later success still keeps it.+ store.releaseSucceededRetainedSendsForTask('task-files')+ expect(held(store, ['chat-1/with-files'])).toEqual(['chat-1/with-files'])+ })++ it('a later send failure updates the message and keeps the undelivered-files reason', () => {+ const store = seedUndeliveredFiles()++ store.failRetainedSend(+ 'agent-x',+ 'chat-1',+ 'undelivered',+ 'stream_lost',+ 'The stream was lost.',+ 'network'+ )++ const kept = store.getRetainedSendSnapshot('agent-x', 'chat-1', 'undelivered')+ expect(kept?.failure).toEqual({ message: 'The stream was lost.', kind: 'network' })+ expect(kept?.reason).toBe(reason)+ })})})diff --git a/desktop-app/ui/src/lib/retainedSendStore.ts b/desktop-app/ui/src/lib/retainedSendStore.tsindex fdf68a0b5..abadd9341 100644--- a/desktop-app/ui/src/lib/retainedSendStore.ts+++ b/desktop-app/ui/src/lib/retainedSendStore.ts@@ -54,8 +54,18 @@ export type RetainedSendReason =| 'sync_error_envelope'| 'async_task_failed'| 'stream_lost'- /** The Host did not confirm every attached document (#678, D13). */+ /** The Host rejected the send because of its documents; nothing was answered (#678, D13). */| 'host_files_unsupported'+ /**+ * The Host answered the text without confirming every document (#678, D13).+ * Only the documents are recoverable: a retry would send the answered text again.+ */+ | 'host_files_dropped'++/** Both reasons hold documents the Host never received, which exist nowhere else. */+export function holdsUndeliveredFiles(reason: RetainedSendReason): boolean {+ return reason === 'host_files_unsupported' || reason === 'host_files_dropped'+}/** Each controller owns its bytes; no module-global data survives an identity change. */export function createRetainedSendStore(changed: () => void) {@@ -145,7 +155,7 @@ export function createRetainedSendStore(changed: () => void) {for (const [key, snapshot] of snapshots) {if (snapshot.agentRef !== agentRef || snapshot.chatId !== chatId) continueif (!snapshot.failure || snapshot.timestamp > upToTimestamp) continue- if (options.keepUndeliveredFiles && snapshot.reason === 'host_files_unsupported') continue+ if (options.keepUndeliveredFiles && holdsUndeliveredFiles(snapshot.reason)) continuesnapshots.delete(key)released = true}@@ -178,7 +188,7 @@ export function createRetainedSendStore(changed: () => void) {*/function releaseSucceededRetainedSendsForTask(taskId: string): void {const succeeded = [...snapshots.values()].filter(- snapshot => snapshot.taskId === taskId && snapshot.reason !== 'host_files_unsupported'+ snapshot => snapshot.taskId === taskId && !holdsUndeliveredFiles(snapshot.reason))for (const snapshot of succeeded) {releaseRetainedFailuresForChat(snapshot.agentRef, snapshot.chatId, snapshot.timestamp, {@@ -197,7 +207,7 @@ export function createRetainedSendStore(changed: () => void) {snapshot: RetainedSendSnapshot,reason: RetainedSendReason): RetainedSendReason {- return snapshot.reason === 'host_files_unsupported' ? snapshot.reason : reason+ return holdsUndeliveredFiles(snapshot.reason) ? snapshot.reason : reason}/**diff --git a/desktop-app/ui/src/uiTypes.ts b/desktop-app/ui/src/uiTypes.tsindex 2e900dcab..192fe810c 100644--- a/desktop-app/ui/src/uiTypes.ts+++ b/desktop-app/ui/src/uiTypes.ts@@ -175,6 +175,11 @@ export type FailedAgentSend = {userMessageId?: string/** Model validated by the image guard when this attempt carried images. */model?: string+ /**+ * The Host answered the text but never received the documents (#678 D13).+ * Only the documents can be recovered; a retry would send the text again.+ */+ answeredWithoutFiles?: boolean}export type HostConnectionTone = 'healthy' | 'degraded' | 'offline'