Skip to content

fix(cli-peer): tighten terminal tracking and BTW turn watching - #3677

Merged
bobleer merged 1 commit into
openBitFun:mainfrom
bobleer:bob/cli-peer-followups
Nov 2, 2026
Merged

bobleer merged 1 commit into
openBitFun:mainfrom
bobleer:bob/cli-peer-followups

Conversation

@bobleer

@bobleer bobleer commented Nov 2, 2026

Copy link
Copy Markdown
Collaborator

Summary

Follow-ups from the re-review of #3669.

Refs #3417

  • BTW watcher (CLI and Desktop): read get_session_state() instead of cloning the whole session every 250 ms. A turn not yet running on the first check keeps its registration for up to 5 seconds, so btw_cancel still works. The decision lives in BtwTurnWatch in agent-runtime.
  • Terminal tracking: listSessions() no longer starts tracking, because terminal_list spans every workspace on the host. useTerminalSessions declares what it shows through setTrackedSessions(owner, ids), per owner, so concurrent tab lists don't overwrite each other.
  • Exit code on close: the local PTY path checks session_status once before publishing terminal-closed.
  • Capabilities: Desktop's list is now explicit, with a test that it covers everything in ALL except TerminalCursorReplayV1.

One addition beyond the review list: PeerTerminalReplay kept a single pending lifecycle event, so a close right behind an exit discarded the exit code on the controller. Fixing only the host would not have delivered it, so pending events are now queued in order.

Type and Areas

Type: bug fix

Areas: CLI peer host, Desktop, agent-runtime, Product Operation Registry, web UI (terminal)

Motivation / Impact

Lower polling cost and fewer host stream subscriptions on large hosts. /btw stays cancellable right after it starts, and terminals report their exit code when closed quickly.

Compatibility

No wire or persisted format changes. Desktop's advertised capabilities are unchanged. With an older CLI host, exit tracking for tabs without a mounted view still works, now only for the tabs shown.

Verification

Passed:

  • cargo test --locked -p openbitfun-agent-runtime --features agent-runtime --lib side_question (6 passed)
  • cargo test --locked -p openbitfun-cli --bin openbitfun peer_host:: (119 passed)
  • cargo test --locked -p openbitfun-product-domains --no-default-features remote_surface (20 passed)
  • cargo check --locked -p openbitfun-desktop (compiles; the Desktop watcher has no test of its own)
  • pnpm --dir src/web-ui run test:run src/tools/terminal/services src/app/scenes/shell/hooks src/app/hooks/sessionTerminalDirectoryWiring.test.ts; 49 passed before the new hook test was fixed, and that test then passed in its own run. The two were not re-run together.
  • pnpm --dir src/web-ui run type-check; eslint on the touched terminal services and useTerminalSessions.ts
  • pnpm run capabilities:check, pnpm run i18n:audit, pnpm run check:repo-hygiene
  • node scripts/check-core-boundaries.mjs from a temporary sibling checkout at this head (the agent-harness:check step of the pnpm script was not run)

Remote scenarios exercised: none in a real session. Peer Device Mode has unit coverage with mocked transport only. Remote workspace, remote control and Detached Dispatch were not exercised.

Reviewer Notes

  • useTerminalSessions re-declares its tracking after each refresh, and clears it when its effect re-runs. A savedSessionIds change can therefore briefly close and reopen the lifecycle streams.
  • editor_ai_api.rs was checked and has no matching watcher, so it is unchanged.

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. No user-facing strings changed.

The BTW watchers cloned the whole session every 250 ms and dropped the
registration if the turn was not running on the first check, which left it
uncancellable. Read only the session state and allow a short start grace.

Track only the terminals a tab list shows instead of every host terminal.
Publish a missed exit before terminal-closed, and deliver both on the
controller so the close no longer discards the exit code. List Desktop
capabilities explicitly instead of relying on the order of ALL.
@bobleer
bobleer merged commit 7e23bdb into openBitFun:main Nov 2, 2026
13 checks passed
bobleer added a commit to Raing5Days/OpenBitFun that referenced this pull request Nov 2, 2026
Regenerate the remote surface registry artifacts after openBitFun#3677 and openBitFun#3591.
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