Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(desktop-app): keep collapsed echo references out of resend
M42dd5656b2c3
diff --git a/desktop-app/src/chatMessageMerge.ts b/desktop-app/src/chatMessageMerge.tsindex f7486a24f..d47279e91 100644--- a/desktop-app/src/chatMessageMerge.ts+++ b/desktop-app/src/chatMessageMerge.ts@@ -80,6 +80,19 @@ function mergeAttachmentChips(]}+function collapseSafeAttachments(+ attachments: ChatMessageAttachment[] | undefined+): ChatMessageAttachment[] | undefined {+ return attachments?.filter(+ attachment =>+ Boolean(attachment.dataBase64) ||+ (attachment.type !== 'plugin' &&+ attachment.type !== 'connector' &&+ attachment.type !== 'agent_file' &&+ attachment.type !== 'global_file')+ )+}+function preferredServerMessage(server: ChatMessage,local: ChatMessage | undefined,@@ -413,10 +426,11 @@ export function mergeAuthoritativeServerMessages(const hydratedReplacements = authoritative.map(message => {const local = localByServerMessage.get(message)let hydrated = preferredServerMessage(message, local, { copyLocalMetadata: Boolean(local) })- // Merge the DURABLE side metadata of a collapsed idle echo onto its- // authoritative slot row (§6.2, R2-M1). Bounded to attachments/toolSteps only,- // gap-filling and non-destructive: whatever `hydrated` already supplies wins, so- // the row only gains fields the reconciled server turn lacked. It deliberately+ // Merge safe side metadata of a collapsed idle echo onto its authoritative+ // slot row (§6.2, R2-M1). A same-text collapse does not prove that a local+ // plugin/file reference belonged to this server turn; Resend must not turn+ // that unverified reference into a new prompt attachment. Keep byte-bearing+ // files and non-reference artifacts, plus toolSteps. It deliberately// does NOT use preferredServerMessage/copyLocalMetadata here: that path also// copies `task_id` (echo identity), which is correct for D-1 replacement (the// server IS the live task's echo) but WRONG for an idle collapse — the task is@@ -429,7 +443,10 @@ export function mergeAuthoritativeServerMessages(if (collapsedEcho) {hydrated = {...hydrated,- attachments: mergeAttachmentChips(hydrated.attachments, collapsedEcho.attachments),+ attachments: mergeAttachmentChips(+ hydrated.attachments,+ collapseSafeAttachments(collapsedEcho.attachments)+ ),toolSteps: hydrated.toolSteps?.length ? hydrated.toolSteps : collapsedEcho.toolSteps,}}diff --git a/desktop-app/ui/src/App.tsx b/desktop-app/ui/src/App.tsxindex b91ede933..74a3eb184 100644--- a/desktop-app/ui/src/App.tsx+++ b/desktop-app/ui/src/App.tsx@@ -131,7 +131,9 @@ const SANDBOX_UI_DEEP_LINK_MANUAL_TEAM_CHANGE_MESSAGE =// stored route untouched — the caller must NOT invoke the setter, because// passing `undefined` to it would erase A's previously-saved route.type OutgoingRouteDecision =- { action: 'set'; routePath: string } | { action: 'clear' } | { action: 'preserve' }+ | { action: 'set'; routePath: string }+ | { action: 'clear' }+ | { action: 'preserve' }async function readOutgoingRouteDecision(outgoingAppRef: string | undefineddiff --git a/desktop-app/ui/src/components/agents/__tests__/ComposerPanel.test.tsx b/desktop-app/ui/src/components/agents/__tests__/ComposerPanel.test.tsxindex bdf8816e1..016621753 100644--- a/desktop-app/ui/src/components/agents/__tests__/ComposerPanel.test.tsx+++ b/desktop-app/ui/src/components/agents/__tests__/ComposerPanel.test.tsx@@ -306,10 +306,12 @@ describe('ComposerPanel reference submenu portaling', () => {it('keeps the menu mounted through a mousedown on a portaled submenu item so its click fires', async () => {// A clickable plugin so the submenu holds a real menuitem, not an empty state.- window.clerum.workflows.list = vi.fn(async (): Promise<WorkflowRecipeListResult> => ({- items: [{ metadata: { namespace: 'ns', name: 'plug-a' } }],- count: 1,- }))+ window.clerum.workflows.list = vi.fn(+ async (): Promise<WorkflowRecipeListResult> => ({+ items: [{ metadata: { namespace: 'ns', name: 'plug-a' } }],+ count: 1,+ })+ )render(<ComposerPanel inline={false} />)fireEvent.click(screen.getByRole('button', { name: 'Add context' }))diff --git a/desktop-app/ui/src/hooks/__tests__/sessionAdapter.test.ts b/desktop-app/ui/src/hooks/__tests__/sessionAdapter.test.tsindex 7561fe069..55836eeab 100644--- a/desktop-app/ui/src/hooks/__tests__/sessionAdapter.test.ts+++ b/desktop-app/ui/src/hooks/__tests__/sessionAdapter.test.ts@@ -203,6 +203,61 @@ describe('turnsToChatMessages', () => {)})+ it('does not resend references from a same-text idle echo onto a context-free server turn', () => {+ const incoming = turnsToChatMessages([+ { number: 1, user_input: 'first', started_at: new Date(1).toISOString() },+ { number: 2, user_input: 'repeat', started_at: new Date(3).toISOString() },+ ])+ const localEcho: ChatMessage = {+ id: 'idle-echo',+ role: 'user',+ content: 'repeat',+ timestamp: 2,+ task_id: 'settled-task',+ attachments: [+ { id: 'plugin', type: 'plugin', label: 'profits/revenue' },+ {+ id: 'agent-file',+ type: 'agent_file',+ label: 'todo.md',+ filesystemName: 'shared-fs',+ path: 'notes/todo.md',+ },+ {+ id: 'global-file',+ type: 'global_file',+ label: 'Report',+ gfsUri: 'gfs://drive-7/res-9',+ drive: 'drive-7',+ resourceId: 'res-9',+ },+ {+ id: 'image',+ type: 'uploaded_file',+ label: 'chart.png',+ filename: 'chart.png',+ mimeType: 'image/png',+ encoding: 'base64',+ dataBase64: 'AQ==',+ sizeBytes: 1,+ },+ ],+ }+ const merged = mergeAuthoritativeServerMessages(+ [incoming[0]!, localEcho, incoming[1]!],+ incoming,+ { activeTaskIds: new Set() }+ )+ expect(merged.map(message => message.id)).toEqual(['turn-1-user', 'turn-2-user'])+ const serverUser = merged[1]!+ expect(serverUser.attachments).toMatchObject([{ type: 'uploaded_file', dataBase64: 'AQ==' }])+ const draft = buildComposerResendDraft(serverUser)+ expect(draft.content).toBe('repeat')+ expect(draft.imageAttachments).toHaveLength(1)+ expect(draft.referenceAttachments).toEqual([])+ expect(draft.unrestorable).toEqual([])+ })+it('preserves turn order for multi-turn transcripts', () => {const msgs = turnsToChatMessages([{ number: 1, user_input: 'a', response: 'A', started_at: '2026-04-22T10:00:00Z' },