Skip to content

fix(web-ui): fix Session rollback when remote-controlling a CLI host - #3688

Merged
bobleer merged 2 commits into
openBitFun:mainfrom
bobleer:fix/peer-rollback-local-catalog-revision
Nov 2, 2026
Merged

bobleer merged 2 commits into
openBitFun:mainfrom
bobleer:fix/peer-rollback-local-catalog-revision

Conversation

@bobleer

@bobleer bobleer commented Nov 2, 2026

Copy link
Copy Markdown
Collaborator

Summary

When Desktop remote-controls a CLI host in Peer Device Mode, every Session rollback fails with Validation error: Session rollback target is stale.

Cause: the controller builds the Turn catalog for a peer Session from relay records, and refreshRelayTurnCatalog gives it a revision it made up, relay:<turnIds>. SessionRollbackService sent that value as expectedCatalogRevision. The host computes its own v2-<sha256> revision in apply_targeted_session_revert_locked, so the two can never match.

Fix:

  • Revisions the controller creates itself (relay replica catalog, optimistic truncateDialogTurnsFrom) now start with local:. Added isHostIssuedTurnCatalogRevision to tell them apart.
  • Rollback sends expectedCatalogRevision only when the host issued it. The host still checks the target Turn id and expectedStorageTurnIndex. This is the same fallback already used when the catalog does not cover the displayed Turns.

Type and Areas

Type: bug fix

Areas: web UI (flow_chat), Peer Device Mode

Motivation / Impact

Session rollback works again when remote-controlling a CLI host. Local Sessions are unchanged: their catalogs come from the host and keep the full revision check.

Verification

  • pnpm --dir src/web-ui run test:run src/flow_chat/services/SessionRollbackService.test.ts src/flow_chat/store/FlowChatStore.test.ts: 280 passed
  • Both new regression tests fail when the fix is reverted.
  • pnpm run type-check:web: passed
  • Remote scenarios: Peer Device Mode was tested at the unit level on the peer surface only. I did not run a manual Desktop-to-CLI session.

Reviewer Notes

  • No Rust or wire changes. The field was already optional and older hosts accept requests without it, so mixed versions keep working.
  • Before opening this, checked upstream/main and open PRs; no existing fix was found.

Checklist

  • This PR is focused and does not include secrets, temporary prompts, generated scratch files, or unrelated artifacts.
  • Relevant verification is recorded above, or skipped checks are explained.
  • User-facing strings, docs, and locales are updated where applicable. (none needed)

🤖 Generated with Claude Code

bobleer and others added 2 commits November 2, 2026 19:34
Relay replicas and optimistic truncation derive a Turn catalog on the
controller and mint their own revision strings. The host computes its
catalog revision independently, so these values can never match a
host-issued token. Prefix them with `local:` and expose
`isHostIssuedTurnCatalogRevision` so consumers can tell them apart.

Co-Authored-By: Claude <noreply@anthropic.com>
In Peer Device Mode the controller's Turn catalog comes from relay
records, and its revision was sent to the CLI host as
`expectedCatalogRevision`. The host always rejected it with
"Session rollback target is stale", so rollback never worked while
remote-controlling a CLI host.

Only send host-issued revisions. The host still validates the target
Turn id and `expectedStorageTurnIndex`, the same fallback already used
when the catalog does not cover the projected Turns.

Co-Authored-By: Claude <noreply@anthropic.com>
@bobleer
bobleer merged commit 5a3790e into openBitFun:main Nov 2, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant