Repository navigation
fix(transcript): keep a turn started during Stop's settled read in charge of the transcript - #2409
Conversation
…arge of the transcript The native/remote Stop branch clears isRunning as soon as the abort RPC resolves, unlocking the composer, and then awaits a settled-state getSession. A prompt submitted while that read is in flight starts a real turn - optimistic user row, runningSessions and isRunning back to true - and the read then wholesale-replaced messages with its pre-turn snapshot, forced isRunning false, and wrote the stale transcript into the session cache and retained transcripts: the new turn's row vanished, its spinner muted, and double sends became possible. Remote sessions widen the window to network latency. The settled read is now skipped entirely when a turn owns the transcript by the time it resolves (runningSessions flagged, liveSessionTranscripts membership, or the active session's isRunning): the newer state stands and the live flow reconciles from here. When no turn restarted, the settled read lands exactly as before. Regression tests cover both cases for pi-native and remote, alongside the existing failure and navigation cases.
…the settled-read guard The duplicate-compact review harness and native-pi-sessions tests build minimal runtime stubs that carry only the members the old code touched; the new ownership guard called liveSessionTranscripts.has unconditionally and crashed them. Optional chaining keeps the same semantics (no membership means no ownership) without requiring the member.
|
The red JS build was mine — found and fixed in The failing test ( |
|
The problem is real ( The Repro: in "the settled read still lands when no turn restarted", add Dropping that clause (keeping |
There was a problem hiding this comment.
AIUO CodePilot · Preliminary review
Diff-only preliminary review of the Stop settled-read guard and its tests. The guard skips transcript/cache reconciliation when a newer turn appears to own the session, and new tests cover restart and no-restart paths for pi-native and remote. No evidenced defect found in the added code; note that the guard's `liveSessionTranscripts`/`isRunning` reliance and mock-based test construction were not verified against the live runtime, and no tests were executed here.
No evidenced findings in the supplied diff.
Head: f4ff7b6
Base: 95df2e0
CI: success; mergeable: true.
Validation: code/tests NOT EXECUTED. Diff-only preliminary analysis; not approval. Human review and repository gates remain required.
…-repair Upstream's stop-path guard (vastsa#2409) asserts that a settled snapshot read during Stop must leave no trace when a new turn owns the transcript. The fork's bounded readSettledTail caches internally before the guard can run, so the guard now drops that premature cache entry; the live turn's projection re-caches its own messages immediately. Upstream's transcript changes also pulled lib/api.ts into the e2e-transcript-anchor-repair bundle graph for the first time, so its bare @pi-desktop/shared source alias needs the fork's /fork subpath alias beside it, as mode-run-elapsed.test.mjs already carries. Co-authored-by: dash0-app[bot] <270606358+dash0-app[bot]@users.noreply.github.com>
Fixes #2408. Sibling of #2385 — same late-read family, triggered by the native/remote Stop branch instead of delete.
What
After the #2383 confirmation, the native/remote Stop branch clears
isRunningimmediately (unlocking the composer) and then awaits a settled-stategetSession. A prompt submitted during that read starts a real turn, and the read's resolution then wholesale-replacedmessageswith its pre-turn snapshot, forcedisRunning: false, and wrote the stale transcript into the session cache and retained transcripts: the new turn's optimistic row vanished, the spinner muted mid-stream, and the session became double-sendable. Remote sessions widen the window to network latency. The reconciliation's only guard wasactiveSessionId === sessionId— it never asked whether a NEW turn owns the transcript.The fix
When the settled read resolves, skip the reconciliation entirely if a turn owns the transcript (
runningSessions[sessionId],liveSessionTranscriptsmembership, or the active session'sisRunning): the newer state stands and the live flow reconciles. No turn restarted → the settled read lands exactly as before, byte-identical behavior.Tests
native-stop-refresh-failure.test.mjsgains, for pi-native and remote:isRunning/runningSessionsstay true), and neither the session cache nor the retained transcripts receive the stale snapshot;Existing failure and navigation cases pass untouched. Full stop-family
node --test9/9; desktoptsc --noEmitclean. Branch contains latest main047c4eab1.