[Bug]: Desktop renders one reply twice while its row is already committed (the overlay's fold exempts pending live rows)
Bug Description
Same user-visible symptom as #127288 — one assistant reply rendered twice while state.db holds one row — through a different fold. Reported in the #127288 thread by @jjie60862-art, who reproduced it on a build that already carries #127282's fix (chunk verified loaded) and whose own testing shows that fix is not involved here.
The overlay's stale-row fold overlayConcurrentMessageChanges (apps/desktop/src/app/session/hooks/use-session-actions/utils.ts:1560) drops a live assistant row the page already carries, but exempts pending: true rows outright (current.pending !== true in the guard). A turn persists its assistant row before the tool round runs (agent/turn_tool_round.py, "Persist the tool-call turn before any tool side effects"), so a window that attaches to a still-streaming turn holds exactly the shape that then survives:
page [user, committed assistant row: text + tool occurrence] ← durable, from the mid-turn persist
current [user, assistant-stream-… : same text + same occurrence, pending: true]
overlay → [user, committed row, assistant-stream-…] ← both, i.e. the reply twiceUnit-level comparison of the two folds that see this shape (real functions, current main):
| merge | live.pending = true |
live.pending = false |
|---|---|---|
overlayConcurrentMessageChanges |
keeps both rows (duplicate) | folds to the committed row |
reconcileDurableHistory (resume merge) |
folds to the committed row | folds to the committed row |
So the two merges disagree about the same situation, and the overlay is the one that paints it twice.
Steps to Reproduce
Reporter's sequence (no session switch, no window re-attach), on a build containing #127282:
- Send a prompt whose turn narrates and calls tools.
- While the turn is still running, send a steer (mid-turn user message) — the row lands with
display_kind = 'steer'. - At settle the answer renders twice: one bubble carries the tool chips plus the answer text, the other the same text.
state.db holds exactly one row for that answer; the renderer's own in-flight journal held a pending: true live bubble whose durable row had already landed.
Not yet pinned: the exact re-entry point in that no-re-attach flow. overlayConcurrentMessageChanges is reached on session activation/resume (use-session-actions/index.ts:1714/2059/2087), and the obvious mid-turn refreshes do not run while a turn is live — reconcileActiveTranscript bails on busyRef.current, and the turn-end graft (graftRefreshedTailOntoBackfill) plus the hydrate merge (preserveLocalAssistantErrors) both fold this shape correctly in unit probes. Their Ctrl+R observation (pending) splits the remaining candidates: clears on reload means the pair only ever existed in renderer memory; survives a reload means the journal re-injects it.
Deterministic reproduction of the fold itself (what the fix changes) is the first test in the PR below: red on base, green with the patch.
Expected Behavior
One bubble per stored row: a pending live row folds when the committed row carries its reply in full.
Actual Behavior
Two bubbles for one row. Display-only, self-healing, same as #127288.
Affected Component
Other — desktop app (transcript reconciliation on attach).
Operating System
Windows 11 (reporter), macOS (earlier capture in #127288).
Hermes Version
0.21.5, desktop build 46bcd9458f; fold still present on main at ea114c3e98.
Debug Report
Omitted deliberately (uploads to a public paste); the evidence is structural and lives in the thread.
Root Cause Analysis
overlayConcurrentMessageChanges (utils.ts:1560) — the current.pending !== true test in the stale-row fold. The exemption is right for a row that is still the turn's stream target, but it has no second condition, so a pending row whose reply and tool occurrences are already on the page stays as a second bubble.
Proposed Fix
PR #127666 — a pending row keeps the exemption only while the committed row does not carry it in full: the fold now additionally requires the committed row to hold every tool occurrence the live row has (so a text collision with an unrelated row cannot drop the only copy of a running tool, #123047). Settled rows fold exactly as before.
Are you willing to submit a PR for this?
- I'd like to fix this myself and submit a PR — @Tsuki-hash (finding by @jjie60862-art)
Source: NousResearch/hermes-agent