Skip to content

Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure

TypeScript

fix(desktop): stop the collapsed idle echo from leaking task_id onto the server row (R2-M1)

Diego Zacarias103bf1c84c7b
diff --git a/desktop-app/package-lock.json b/desktop-app/package-lock.json
index 8e2fc2f2d..b3b4a4174 100644
--- a/desktop-app/package-lock.json
+++ b/desktop-app/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "evenfire",
- "version": "0.1.349",
+ "version": "0.1.350",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "evenfire",
- "version": "0.1.349",
+ "version": "0.1.350",
"license": "MPL-2.0",
"dependencies": {
"@tanstack/react-query": "5.100.10",
diff --git a/desktop-app/package.json b/desktop-app/package.json
index fd6d13a7d..e31137336 100644
--- a/desktop-app/package.json
+++ b/desktop-app/package.json
@@ -1,7 +1,7 @@
{
"name": "evenfire",
"productName": "Evenfire",
- "version": "0.1.349",
+ "version": "0.1.350",
"private": true,
"license": "MPL-2.0",
"description": "Evenfire desktop client for secure agent and workflow access",
diff --git a/desktop-app/src/__tests__/chatMessageMerge.test.ts b/desktop-app/src/__tests__/chatMessageMerge.test.ts
index e81093245..df7533f1d 100644
--- a/desktop-app/src/__tests__/chatMessageMerge.test.ts
+++ b/desktop-app/src/__tests__/chatMessageMerge.test.ts
@@ -1490,6 +1490,10 @@ describe('mergeAuthoritativeServerMessages — R2-H1 idle echo liveness (§6.1,
expect(authRow?.toolSteps).toEqual(bubbleToolSteps)
expect(authRow?.attachments).toEqual(bubbleAttachments)
}
+ // The done task's identity never leaks onto a numbered server row (§6.2).
+ for (const server of incoming) {
+ expect(merged.find(m => m.id === server.id)?.task_id).toBeUndefined()
+ }
} else {
expect(ids).toContain('sandwiched-bubble')
// The surviving bubble keeps its original text in the output.
@@ -1587,6 +1591,8 @@ describe('mergeAuthoritativeServerMessages — R2-M1 idle echo metadata preceden
expect(outputTurn2Assistant?.attachments).toEqual(optimisticEcho.attachments)
// content is NOT rewritten (loss-safety of text, §6.2).
expect(outputTurn2Assistant?.content).toBe('a2')
+ // The done task's identity is NOT leaked onto the historical server row (§6.2).
+ expect(outputTurn2Assistant?.task_id).toBeUndefined()
// Non-reintroduction of R1-B1: every numbered server row survives.
for (const server of incoming) {
if (messageServerTurnNumber(server) !== undefined) {
@@ -1595,6 +1601,64 @@ describe('mergeAuthoritativeServerMessages — R2-M1 idle echo metadata preceden
}
})
+ it('R2-M1: collapse does not leak the idle echo task_id onto the historical server row', () => {
+ // Extends the ':602' stale-metadata guard to the COLLAPSE path (F1 regression of
+ // d8f45d34): the chained copy used preferredServerMessage, which propagates
+ // task_id (local.task_id ?? server.task_id), tagging the historical numbered row
+ // with the done task's id. That id leak would break task_id-based dedupe in
+ // useAgentChatController (noop) and useChatNotifications (toast dedupe). The
+ // collapse must copy attachments/toolSteps ONLY, never task_id. Server rows are
+ // derived from the real producer (T1).
+ const incoming = turnsToChatMessages([
+ { number: 1, user_input: 'q1', response: 'a1', started_at: new Date(1).toISOString() },
+ { number: 2, user_input: 'q2', response: 'a2', started_at: new Date(2).toISOString() },
+ ])
+ const idleEcho: ChatMessage = {
+ id: 'idle-echo-assistant',
+ role: 'assistant',
+ content: 'a2', // mirrors turn-2-assistant → collapses once idle (I-1)
+ timestamp: 999,
+ task_id: 'done-task',
+ toolSteps: [{ toolName: 'search', displayName: 'Search', state: 'completed' }],
+ }
+ const existing: ChatMessage[] = [
+ {
+ id: 'turn-1-assistant',
+ role: 'assistant',
+ content: 'a1',
+ timestamp: 1,
+ serverTurnNumber: 1,
+ },
+ idleEcho,
+ {
+ id: 'turn-2-assistant',
+ role: 'assistant',
+ content: 'a2',
+ timestamp: 3,
+ serverTurnNumber: 2,
+ },
+ ]
+
+ const merged = mergeAuthoritativeServerMessages(existing, incoming, {
+ activeTaskIds: new Set(),
+ })
+
+ // The echo collapsed; the authoritative row survives.
+ expect(merged.map(m => m.id)).not.toContain('idle-echo-assistant')
+ const outputTurn2Assistant = merged.find(m => m.id === 'turn-2-assistant')
+ expect(outputTurn2Assistant).toBeDefined()
+ // task_id identity is NOT leaked onto the historical server row.
+ expect(outputTurn2Assistant?.task_id).toBeUndefined()
+ // No OTHER authoritative row picks up the done task_id either.
+ for (const server of incoming) {
+ if (messageServerTurnNumber(server) !== undefined) {
+ expect(merged.find(m => m.id === server.id)?.task_id).toBeUndefined()
+ }
+ }
+ // The durable side metadata still survives (the R2-M1 preservation is intact).
+ expect(outputTurn2Assistant?.toolSteps).toEqual(idleEcho.toolSteps)
+ })
+
it('R2-M1: does not collapse a text-less idle bubble on empty-content coincidence', () => {
// The collapse gate used strict equality, so '' === '' fired on an
// attachment-only bubble sandwiched between two empty-content numbered turns.
diff --git a/desktop-app/src/chatMessageMerge.ts b/desktop-app/src/chatMessageMerge.ts
index 1a43e811c..db8416149 100644
--- a/desktop-app/src/chatMessageMerge.ts
+++ b/desktop-app/src/chatMessageMerge.ts
@@ -347,15 +347,27 @@ export function mergeAuthoritativeServerMessages(
const hydratedReplacements = authoritative.map(message => {
const local = localByServerMessage.get(message)
let hydrated = preferredServerMessage(message, local, { copyLocalMetadata: Boolean(local) })
- // Merge the side metadata of a collapsed idle echo onto its authoritative slot
- // row (§6.2, R2-M1). Chained after the positional local so the positional local
- // keeps precedence for any field it supplies; the collapsed echo fills the rest
- // (e.g. toolSteps/attachments the reconciled server row lacks). Content is never
- // rewritten — preferredServerMessage only touches side fields. This does NOT
- // affect localAnchorIndex: the collapse has no positional anchor of its own.
+ // 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
+ // 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
+ // done and the collapse is by content coincidence, not identity. Tagging a
+ // historical server row with a done task's id leaks identity and would break the
+ // task_id-based dedupe consumers rely on (the exact class the ':602' stale-
+ // metadata guard forbids). `content` is never touched either (loss-safety, §6.1).
+ // This does NOT affect localAnchorIndex: the collapse has no positional anchor.
const collapsedEcho = collapsedEchoMetadataByServerMessage.get(message)
if (collapsedEcho) {
- hydrated = preferredServerMessage(hydrated, collapsedEcho, { copyLocalMetadata: true })
+ hydrated = {
+ ...hydrated,
+ attachments: hydrated.attachments?.length
+ ? hydrated.attachments
+ : collapsedEcho.attachments,
+ toolSteps: hydrated.toolSteps?.length ? hydrated.toolSteps : collapsedEcho.toolSteps,
+ }
}
return {
message: hydrated,