Repository navigation
Show phone-started turns live on the Mac and clear the stale background marker - #448
Conversation
…nd marker Main serves a per-document observation of the runs it hosts (runs:observeLocal, runs:unobserveLocal) over the host run journal, batched at about 16ms and sent only to the subscribing document. Observations are released on unsubscribe, on destroy and when they end, and cost nothing while nobody watches. Stop for a run this window did not start uses host authority (runs:stopLocal). The renderer replays early frames in LocalHostAdapter.observe, folds them through the remote stream translator into the detached projection store, and the chat pane observes only an active chat it is not running itself. "Response continues in the background" no longer sticks when a newer turn keeps the chat busy: settled detached streams are confirmed with runs:settledLocal, the chat is re-read, and only those streams are released. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The chat goes idle before the run's end frame and before the reply is read, so tying the observation to activity closed it early and the reply flashed away. The pane now starts observing when the chat becomes busy, stops at once only on a chat change, a draft, unmount or its own turn, and on idle releases the run after hand-off (bounded by a grace period and a final read). Hand-off now needs a completed read that holds the run's reply; failed or cancelled reads and reads that predate the reply retry with backoff. A failed read for a new turn is retried, and owed reads retry on the next frame, so the phone's message cannot stay missing for the whole turn. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
very-hermes-bot
left a comment
There was a problem hiding this comment.
Inline review — 1 finding(s) anchored to the diff. See the pinned summary comment for the overview.
| const visibleDetachedProjection = | ||
| cachedMessages?.[cachedMessages.length - 1]?.role === "assistant" ? null : detachedProjection; | ||
| // Run input is admitted only for the document that owns the run, so a | ||
| // mirrored run (a phone's turn) offers Stop and queueing but not Steer. | ||
| const observedRunVisible = visibleDetachedProjection?.observed === true; | ||
| const steerableDetachedProjection = observedRunVisible ? null : visibleDetachedProjection; |
There was a problem hiding this comment.
[P1 · logic] Observed phone-started turns are suppressed in existing chats ending in an assistant message
Confidence: 0.95
When an observed run starts in a chat whose prior turn ended in an assistant message, visibleDetachedProjection is suppressed to null until an async refetch completes, displaying the stale background marker and hiding the live stream.
Repair: Only suppress an observed detached projection if the last cached assistant message matches the observed run's generation ID in its timeline.
There was a problem hiding this comment.
Fixed: Added a check to only suppress the observed projection if the last cached assistant message matches the observed run's generation ID. This allows new observed turns to display even in existing chats that end with a previous assistant message.
The logic now correctly identifies when a cached message belongs to the current observed run versus a prior one, preserving visibility of incoming mirrored turns.
Hermes Review BotConfidence: 5 Engine: SummaryDesktop clients on macOS now mirror turns started on paired devices (such as phones) live in the chat pane and properly clear background drain markers when turns finish. In the main process, Confidence Score: 5/5Fully traced and verified across main process IPC handlers, run observers, lifecycle transitions, renderer projection sync, and test suites. 📁 Important Files Changed
FindingsNo findings. 📊 Sequence DiagramsequenceDiagram
autonumber
actor Phone as Paired Device (Phone)
participant Main as Electron Main (LocalRunObservers)
participant Renderer as Mac Renderer (ChatPane)
participant Store as Chat Store / Cache
Phone->>Main: Starts turn on Chat A
Main-->>Renderer: chats:activity-changed (Chat A active)
Renderer->>Main: runs:observeLocal(chatId)
Main-->>Renderer: PeerRunSubscription (buffered events)
loop Every ~16ms frame while streaming
Main-->>Renderer: runs:local-frame (batched events)
Renderer->>Renderer: Paced live projection in ChatPane
end
Main->>Store: Saves completed assistant reply
Main-->>Renderer: runs:local-frame (run.ended, state:ended)
Renderer->>Store: refetch() (reads persisted reply)
Store-->>Renderer: Transcript containing saved reply
Renderer->>Renderer: handOff() (clears projection, shows message)
Renderer->>Main: runs:unobserveLocal(subscriptionId)
Machine-Readable Findings[]
|
There was a problem hiding this comment.
Important
Two reproduced handoff bugs need fixing: a late idle-release read can remove a newer live turn, and ordinary text-only replies keep the stale background marker after their saved reply has been read.
Reviewed changes Reviewed the document-scoped host-run mirror, renderer projection lifecycle, Stop authority, and per-run detached-marker settlement across both commits.
- Local observation transport: Adds batched, cursor-aware IPC observations with document cleanup, reusing the existing Remote SSE event projections.
- Live desktop transcript: Mirrors phone-started turns into the detached projection store, retains replies during transcript handoff, and offers host-authority Stop without Steer.
- Exact-run settlement: Queries finished generation IDs and refreshes the transcript before clearing their detached markers, independently of newer chat activity.
Validation: focused observation/settlement suites, test:remote-chat, protocol/host-feed/IPC tests, test:ci-policy, and TypeScript checking passed. Two deterministic probes reproduced the inline findings. Both native decoders were inspected; iOS release-policy checks passed, but native XCTest was not run on Linux. The focused Android test attempt returned Tool 'shell' timed out after 120000ms.
gpt-6.1-sol | 𝕏
…e condition, and text-only reply recognition This commit addresses three findings from code review: 1. [chat-pane #1] Observed phone-started turns are no longer suppressed when the chat's cached messages end in an assistant message from a different run. The suppression now checks if the last cached assistant message matches the observed run's generation ID, allowing new observed turns to display even in existing chats. 2. [observed-local-run #2] Fixed a race condition where an obsolete idle-release grace-period read could close a retained observer. After the async read completes, we now recheck the release authority flag before closing, so a retained observation survives if it was claimed by a newer turn. 3. [observed-local-run #3] Text-only replies without timeline fields are now recognized as the current run's saved reply by matching the doneMessageId from the persisted message. The hasReplyFrom predicate now checks both timeline.generationId (for multi-step replies) and doneMessageId (for text-only replies). All observer lifecycle and chat visibility tests pass, including two new tests covering the release race condition and text-only reply handoff. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Keep the original handoff rule for this window's own detached runs, so a text-only reply without a timeline never renders twice, and revoke a grace release by generation so a later release cannot be closed by an older read. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Extract the rule into visibleDetachedLifecycleProjection and cover it with unit cases instead of the source grep that pinned the old chat-pane line. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes Reviewed the two follow-up commits since the previous Pullfrog review, through 2ee74e7.
- Recognized text-only replies: Matched saved assistant messages by
doneMessageIdwhen a timeline is absent, allowing immediate projection handoff. - Revoked obsolete releases: Rechecked release authority after asynchronous reads and used a generation token to prevent an older read from closing a newer observation.
- Scoped projection suppression: Kept phone-started turns visible over previous cached replies while preserving the handoff rule for this window’s owned runs.
Validation: 178 focused tests, a held-read race probe, and TypeScript checking passed.
gpt-6.1-sol | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes Reviewed b12643c, the follow-up commit since the previous Pullfrog review at 2ee74e7.
- Extracted projection visibility: Moved the existing rule into
visibleDetachedLifecycleProjectionwithout changing owned-run handoff or mirrored-run identity checks. - Replaced source-shape coverage: Removed the outdated source-text assertion and added behavioral cases for absent cache data, previous replies, current-run replies, and owned versus mirrored projections.
Validation: all 79 focused projection, observer, adapter, IPC, and existing component-contract tests passed; npx tsc --noEmit -p . also passed. Electron UI tests were not run on this Linux runner.
gpt-6.1-sol | 𝕏
The inline visibility rule pattern that was checked by assert.match on
line 353 was extracted into visibleDetachedLifecycleProjection() in
chat-terminal-sync.ts. That function's behavior is now properly tested
behaviorally in chat-terminal-sync.test.ts ("a saved reply hides an own
run, but a mirrored run only by its own reply"), so the source-grep
assertion is no longer needed.
According to AGENTS.md testing guidelines, source-grep contract tests
should not be grown when the logic they test has been extracted and
tested behaviorally elsewhere.
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes Reviewed 7f7d469, the test-only follow-up since the prior Pullfrog review at b12643c.
- Removed obsolete source-shape coverage: Deleted the assertion for the former inline projection-visibility expression in
chat-transition.test.tsx; the extracted rule remains covered behaviorally inchat-terminal-sync.test.ts, with no application behavior changes.
Validation: all 48 tests in the transition and terminal-sync suites passed. Both suites remain registered for CI. Electron and native-client tests were not rerun for this test-only delta.
gpt-6.1-sol | 𝕏
A phone's run mirrored on this Mac was hidden only by a cached reply stamped with its timeline. A text-only reply is saved without one, so when the chat's settle notice cached it before the observer let go, the reply showed twice. Carry the message id the run reported on done with the projection and hide it when the cache ends with that message, the same rule the observer uses to recognise the saved reply. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Every shown detached projection was passed to the transcript as complete, which suited a route-detached run but also marked a phone's live turn complete from its first frame, skipping the paced reveal and streaming treatment. The observer now reports when the mirrored run has finished, and only then is its text presented as final; a route-detached run is shown complete as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes Reviewed ac451c3 and b37c819, the two follow-up commits since the prior Pullfrog review at 7f7d469.
- Propagated saved-reply identity: Added
doneMessageIdto mirrored projections so a text-only reply cached by another read hides its live duplicate immediately, without mistaking a previous reply for the current turn. - Preserved live presentation: Added terminal-state tracking and kept mirrored replies incomplete while running, enabling paced text reveal and live reasoning while preserving the existing presentation of owned route-detached runs.
- Extended behavioral coverage: Exercised competing-read handoff, live-to-terminal completion, and unchanged owned-run presentation through the real observer and projection store.
Validation: all 108 focused observation, settlement, translation, reveal, IPC, and transition tests passed; npm run test:remote-chat passed all 149 tests; TypeScript checking passed. Electron UI tests were not run on this Linux runner. Native suites were not rerun because this delta changes only desktop renderer behavior, not shared wire contracts. Full CI was still pending when inspected.
gpt-6.1-sol | 𝕏
The observer's refetch and the settled-stream release both cancel and re-read the same chat query, so the release could lose its read and leave "Response continues in the background…" up until the chat went idle. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes Reviewed 292e125, the settled-stream refresh follow-up since the prior Pullfrog review at b37c819.
- Retried cancelled refreshes: Added up to three transcript-refresh attempts before releasing the exact settled streams, preserving newer runs and retaining markers when reads keep failing.
- Extended behavioral coverage: Exercised recovery after a competing read cancels the refresh and continued draining when every refresh fails.
Validation: all 79 focused settlement, observation, adapter, IPC, and transition tests passed; npm run test:remote-chat passed all 149 tests; TypeScript checking passed. An additional probe using the real TanStack QueryClient confirmed cancellation recovery, preservation of a newer retained stream, and rejection of a late cancelled result. Electron and native suites were not rerun for this desktop-only delta; hosted CI for this head was still pending when inspected.
gpt-6.1-sol | 𝕏
…diness-line Resolve the two source-grep conflicts with #448: D1 moved the readiness copy into chatReadinessMessage() and main moved the detached-projection visibility rule into visibleDetachedLifecycleProjection(), so both stale assertions are dropped in favour of their behavioral tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Summary
Part of
docs/plans/live-cross-device-streaming-plan.md(slice D5). A turn started from a phone now streams live in the Mac chat pane instead of appearing only after it finishes, and the stale "Response continues in the background…" marker is cleared correctly.runs:observeLocal/runs:unobserveLocalIPC mirrors runs this Mac hosts (fromHostRunRegistry) to the window that asked. Frames are batched (~16ms, 256 events/flush), sent only to the subscribing document, resumable by cursor, and released on unsubscribe, document destroy/navigate, or run end. Zero cost while nobody watches; no new network calls.LocalHostAdapter.observefolds frames through the existingremote-stream-translatorinto the detached projection store, so the pane shows live text, reasoning, timeline and Stop with no new UI. The pane observes only when the visible chat is active and not owned by this window; the window's own detached run always wins.runs:stopLocal→llmClient.cancel(runId, "user_stop"), the same host authority a paired phone withruns:controluses. Steer stays hidden for mirrored runs.chats:settledfires per run, but the marker waited for the whole chat to go idle; a phone turn starting right after kept it stuck. The window now asksruns:settledLocalwhich of its runs are truly finished and releases only those.Wire events and the Remote protocol are unchanged, so iOS and Android are unaffected.
Tests
main/handlers/local-runs.test.ts: register-and-invoke over the real registry (batching, cross-chat isolation, cursor resume, next-run adoption, release on destroy, input validation, settled query) plus an in-process end-to-end chain (registry → handlers → adapter → observer → store) showing live text before settle, host Stop, and release.renderer/lib/hosts/observed-local-run.test.ts,local-host-adapter.test.ts,chat-terminal-sync.test.ts: idle-before-done ordering keeps the reply on screen, cancelled/stale reads don't hand off, failed start reads retry, stuck-marker reproduction.npm run test:remote-chat,npm run test:aiden-remote,npm run test:ci-policy,npx tsc --noEmit -p .,npm run lintall pass locally.Review follow-ups
Fixed: the settled-stream release re-reads the chat before it drops the marker. If the observer's own refetch cancels that read, the release now retries it up to three times instead of leaving the marker up until the chat goes idle. Covered in
chat-terminal-sync.test.ts, which includes a chat whose read keeps failing.Deferred (P3): the observer's release grace timer closes the mirror even when its final read failed. The chat-level idle re-read still restores the transcript.
Deferred (P3): a journal gap of more than 4,096 events hides live text for the rest of that run. The persisted reply still lands.
Deferred (P3 hardening):
runs:stopLocaldoesn't check that the calling document observes the run. The renderer is first-party, and other stop paths share this trust model.Deferred (P3): when a phone sends its next turn immediately after a reply finishes, the mirrored reply can disappear for one local chat read before the saved message replaces it.
Deferred (P3): if the observe call itself fails, it isn't retried while the chat stays busy. The persisted transcript still lands when the chat settles.
Merge hotspot with Show the composer's readiness message once (D1) #453: both PRs touch
renderer/main/chat-transition.test.tsx(~353) andrenderer/components/environment-subagents-contract.test.ts(~592). Whichever merges second needs a recheck.Flaky tests
tests/e2e/environment-devices-stream.spec.ts:107(Simulator stream, "Float over chat") failed its first attempt: the floated player's x was 285 instead of 285.1875 (a subpixel position mismatch); the retry passed. This spec is not touched by this PR. Run: https://github.com/sambitcreate/aiden-agent/actions/runs/38360883852/job/115188410050🤖 Generated with Claude Code