Repository navigation
fix: show Session rollback results when remote-controlling a CLI host - #3707
Merged
Merged
Conversation
When the host restarts a session stream (for example after a rollback rewrites a paged history), the new epoch replays its latest page under fresh revisions and sends no tombstones for dropped turns. Mark the controller-side `relay://session-gap` with `resync: true` so the Web UI can rebuild its records from that replay. Host-appended gaps stay inside one epoch and omit the flag. Co-Authored-By: Claude <noreply@anthropic.com>
In Peer Device Mode the controller renders a record replica that only grew. After a rollback on the CLI host, the rolled-back turns stayed on screen, and rolling back one of them again failed with "Session rollback target was not found". - Rebuild the replica from the replay after a restarted host stream and drop rendered turns the replay no longer carries once it is ready. - Drop the turns a completed rollback retired right away, so the view matches the host before its stream restarts. Co-Authored-By: Claude <noreply@anthropic.com>
Reloading a device-surface Session whose relay subscription is already open marked it hydrating, but the open subscription announces no second first page. After a rollback on a host whose stream answers with tombstones instead of restarting, the Session stayed hydrating and its composer refused the next message. Keep an open, ready subscription ready. Co-Authored-By: Claude <noreply@anthropic.com>
This was referenced Nov 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up to #3688. When Desktop remote-controls a CLI host (Peer Device Mode), a rollback succeeds on the host, but the rolled-back turns stay on screen. Rolling back one of them again then fails with
Not found: Session rollback target was not found.Desktop logs confirm the sequence: the first
rollback_session_to_turncompleted in 109 ms with no error, and the composer showed the restored prompt. The second request targeted a turn the host had already hidden.Root cause:
SessionHistoryChanged. For a paged relay stream,invalidate_paged_historyrestarts the stream under a new epoch. The new epoch sends no tombstones for dropped turns, and its replay numbers revisions again from the same range below 2^52.HostStreamSubscribersees the epoch change, emitsrelay://session-gap, and replays the latest page.reloadAuthoritativeSessiondoes nothing on a device surface, so the rollback service didn't correct the view either.Fix:
HostStreamSubscriberaddsresync: trueto the gaps it emits itself; a full replay always follows those. Host-appended gaps (report_source_gap, same epoch, no replay) don't carry the flag.RelaySessionHistoryreacts to aresyncgap. It renders the records already received, then the store reduces the replay into a fresh replica. When the replay's ready event arrives, rendered turns the replay no longer carries are removed. Optimistic turns, which have no storage index yet, are kept.SessionRollbackServiceremoves the retired turns right away (retireRelaySessionTurns), so the view matches the host before the stream restarts.historyStateback tohydrating, and nothing set it to ready again unless the stream restarted. On a host whose stream answers with tombstones instead of restarting, the composer then refused the next message (canSubmit: false). An open, ready subscription now stays ready.Type and Areas
Type: bug fix
Areas: web UI (flow_chat, relay history), remote connect (stream subscriber), Peer Device Mode
Motivation / Impact
Rollback in Peer Device Mode now visibly takes effect. Other host-side history rewrites (undo/redo, changes from another controller or the CLI TUI) also show up on the controller instead of leaving stale turns.
Verification
node scripts/run-vitest.mjs run src/flow_chat/services src/flow_chat/session-stream src/flow_chat/store/FlowChatStore.test.ts(web-ui): 986 passed. The same suite onmaingives 981, plus 5 new tests:RelaySessionHistoryresyncs only on a flagged gap for its own Sessionnode scripts/run-vitest.mjs run src/flow_chat src/app/components/NavPanel: 5119 passedtsc --noEmit(web-ui): cleancargo test --locked -p openbitfun-services-integrations --no-default-features --features remote-connect --lib remote_connect::host_stream_subscriber::tests: 9 passed. The restart test now asserts theresyncflag.Reviewer Notes
hasMore, the same as a fresh open. Older pages load on demand.Checklist
🤖 Generated with Claude Code