Skip to content

fix(peer): Make /btw and session actions work when controlling a CLI host - #3994

Merged
bobleer merged 7 commits into
openBitFun:mainfrom
bobleer:fix/peer-btw-cli-parity
Nov 18, 2026
Merged

bobleer merged 7 commits into
openBitFun:mainfrom
bobleer:fix/peer-btw-cli-parity

Conversation

@bobleer

@bobleer bobleer commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Controlling another device behaved differently from local use, most visibly with /btw on a CLI peer host:

  1. /btw replies never appeared. A peer host streams a session's events only to a controller subscribed to it, and the surface subscribes only its active session. A side question renders beside that session, so the host ran the turn while the panel stayed empty, and each retry reused the request id and was refused as Processing.
  2. Closing a side question failed with "暂时无法关闭侧问": the CLI peer host had no cancel_session handler.

While fixing these, other CLI-host gaps in the same chat/session flows were closed, and the controller now negotiates the new behavior so older hosts keep a working path.

Controller (web-ui)

  • A host streams each session's events only to that session's subscribers, while peer session refresh subscribes only the active session. Any other mounted transcript (side question, review / deep review, or subagent pane, docked chat) now opens its own relay subscription on a peer surface. This also covers panes restored after a device switch, which closes every subscription. The active session, unsent side drafts, and metadata-only shells keep their existing owners.

  • Open the side question's relay subscription once btw_ask_stream is accepted. The host replays from its records, so earlier events are not lost.

  • Close a side question with btw_cancel when an older CLI host refuses cancel_session, then delete it as before.

  • Hide turn fork and side question "save as fork" on CLI hosts that do not advertise session_fork_v1.

  • Stop interrupts recoverably (resumable, as on the local surface) when the rendered host advertises recoverable_interruption_v1; otherwise it keeps hard cancellation.

  • Subscription accounts in model settings report "not available on that device" instead of a retry that cannot succeed.

  • When a Relay reconnect loses the btw_ask_stream reply, the controller reads the host's records for turn btw-turn-<requestId> before reporting failure, mirroring how a dialog turn with an unknown outcome is confirmed. Nothing is resubmitted.

  • The composer's run-target chip named "This computer" even on a peer surface, where the task runs on the controlled device. It now shows the executing device's name (account alias, or the host name when signed out), falling back to the generic label until a name is known.

These controller changes apply to every host kind; the missing /btw replies were observed against a Desktop (Windows) host.

Desktop / Windows host

  • wsl.exe --list fails both when WSL is not installed and when it has no distribution, with a localized message. A Chinese Windows host reported a failed discovery with a retry. The host now classifies by the unlocalized command the message suggests (wsl.exe --install → unsupported, wsl.exe --list --online → supported with no distributions).

CLI peer host

New handlers mirroring Desktop: cancel_session, fork_session, copy_session, load_persisted_session_metadata, interrupt_dialog_turn, recover_interrupted_dialog_turn, compact_session, unarchive_session, list_archived_sessions, delete_persisted_session, delete_all_archived_sessions, get_session_lineage, the thread goal mutations, and get_session_file_diff_stats (through a new LocalWorkspaceSnapshotPort method). The CLI now advertises whole_session_copy_v1, session_fork_v1, and recoverable_interruption_v1; Desktop also advertises the latter two.

Compatibility

  • New capabilities are additive. Missing keys keep today's behavior: hard-cancel Stop on any older host, fork hidden only on older CLI hosts (every Desktop host already forks).
  • The close fallback makes side questions closable against already-deployed CLI hosts.
  • Subscription account rows on the CLI now use a dedicated unsupported reason, so controllers say "unavailable" rather than "update the host".

Remote scenarios

Peer Device Mode (Desktop controller → CLI host and → Desktop host), from controller logs of both. Remote workspace, remote control, and detached dispatch paths are unchanged: recoverable interruption still excludes remote SSH, goal, and dispatch sessions on the controller.

Verification

AI-assisted; lightly tested (focused automated tests, not yet exercised on real devices).

  • node scripts/run-vitest.mjs run on the affected web-ui test files (FlowChatStore, btw/review panes, subagent projection, peer refresh, state machine, settings, peer transport): all passed
  • cargo test -p openbitfun-cli --bin openbitfun peer_host::: 134 passed
  • cargo test -p openbitfun-product-domains --lib remote_surface: 20 passed
  • cargo test -p openbitfun-runtime-ports --lib: 8 passed
  • pnpm run check:repo-hygiene passed; pnpm run capabilities:generate regenerated the registry outputs
  • check:core-boundaries and the Desktop crate build could not run locally (nested worktree and unbuilt extension host); left to CI

A peer host only streams a session's events to a controller that subscribed
to it, and the surface subscribes only its active session. A side question
renders beside that session, so the host ran the turn while the panel stayed
empty, and every retry reused the request id and was refused as Processing.

Open the child session's relay subscription once btw_ask_stream is accepted.
The host replays from its records, so earlier events are not lost.
Controllers saw these features fail only when driving a CLI host:

- cancel_session, so closing a /btw side question no longer errors
- fork_session and copy_session (session_fork_v1, whole_session_copy_v1)
- load_persisted_session_metadata, used after create and fork
- interrupt_dialog_turn and recover_interrupted_dialog_turn
  (recoverable_interruption_v1, also advertised by Desktop)
- compact_session, unarchive_session, list_archived_sessions,
  get_session_lineage, and the thread goal mutations
- get_session_file_diff_stats through LocalWorkspaceSnapshotPort

Subscription account commands now carry a reason that reports them as
unavailable on CLI hosts instead of asking the user to update.
- Hide turn fork and side question "save as fork" on CLI hosts that do not
  advertise session_fork_v1 instead of failing them.
- Interrupt recoverably on Stop when the rendered host advertises
  recoverable_interruption_v1; older hosts keep hard cancellation.
- Close a side question with btw_cancel when an older CLI host refuses
  cancel_session, then delete it as before.
- Show subscription accounts as unavailable on hosts that refuse them
  rather than offering a retry that cannot succeed.
…sion

Peer session refresh subscribes only the active session, and a host streams
each session's events only to its own subscribers. Review and deep review
panes launched on a peer, new MiniApp topic chats, and any pane restored
after a device switch therefore showed no live progress.

Open the relay subscription when a pane retains a materialized session on a
peer surface. The active session, unsent side drafts, and metadata-only
shells keep their existing owners.
The CLI host can now list and restore archived sessions, so its archived
sessions page must also delete them. Answer delete_persisted_session through
the existing session deletion, as Desktop does, and add
delete_all_archived_sessions.
wsl.exe --list fails both when WSL is not installed and when it has no
distribution, and Windows localizes that message. A Chinese Windows host, or
a peer controlled through it, showed a failed discovery with a retry instead
of the not-installed state. Classify by the command the message suggests,
which is not localized.
btw_ask_stream is not replayed, so a Relay reconnect that lost its reply
reported an error while the host was already answering, and a retry was
refused as Processing. On a lost reply, read the host's records for the
Turn the request id names before reporting failure; nothing is resubmitted.
@bobleer
bobleer merged commit 77cb775 into openBitFun:main Nov 18, 2026
13 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