Repository navigation
fix(agent-launch): move only the requesting client's view to a launched tab - #22914
Conversation
…ed tab A launch into an existing workspace from a paired client (a phone, or a desktop client of a remote server) activated a new chat for every client and the host, and recorded no selection for the caller's terminal. It now publishes the chat without activating it for everyone and records the new tab as the caller's own selection, the way that client's own tab tap does (session.tabs.activate with caller navigation). In-process callers and workspace-creating launches are unchanged. Selecting the tab is bookkeeping: a failure there never fails the launch.
…ate does The launch recorded the caller's selection through the tab-tap path, which refreshes the PTY inventory (twice for a chat) on the reply path and treats a non-ready pane as a wake gesture that respawns its agent. Record it through the same caller-navigation step session.tabs.createTerminal uses after its own create: no host focus, no refresh, no materialize.
…d clients and never respawns
…vates a launched chat The desktop renderer reaches agent.launch as a runtime client with no paired device, so it must keep the host-wide activation rather than be treated as a paired caller.
Review status: ready for review (head
|
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (6)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughThe runtime adds a method to select a created mobile-session tab for a specific client. Agent launches derive a caller navigation ID for eligible existing-target launches and select the resulting tab when available. The changes also add tests for runtime selection, launch behavior, and replay. Priority: ⬇️ Low Merge Risk: ⚪ Minimal · up to No confirmed issue currently prevents merging. Structured-chat selection timing remains unverified. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to The reviewed paired-client path limits the new selection to the requesting device and workspace, and no introduced security vulnerability was established. Some alternate dispatch and failure paths remain insufficiently verified. Retained concerns Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
ℹ️ No critical issues — one comment-accuracy nit inline.
Reviewed changes
Read the complete diff plus the surrounding runtime/executor/navigation code it touches.
- Caller-scoped launch selection (new) —
agent-launch-caller-selection.tsresolves the requesting paired device id (existing-workspace targets only) and, after the launch, selects the tab the host just published bypaneKey(terminal) orsessionId(chat); failures warn, never fail the launch. runAgentLaunchbecomes async — computes the caller id, publishes a chat withactivate: falsefor paired callers, then records the caller's selection; replays return from the ledger before selection so nothing re-moves.- Surface factory gains
activateChat—agentLaunchSurfaceFactorythreads a new 4th param into the structured create'sactivate(defaultstrue, so in-process callers and the host window are unchanged). - Runtime selection helper (new) —
selectCreatedMobileSessionTabForClientfinds the tab ingetMobileSessionTabsForWorktreeand reuses the existingapplyMobileSessionTabNavigation(..., 'caller', id), deliberately skipping the tap path (no PTY refresh / respawn). - Tests — a real-runtime two-device test (caller moves, bystander and shared list do not, no respawn) and RPC-boundary coverage for paired/in-process/host-window/create-worktree/replay/failure arms.
I verified the design against existing conventions: the clientKind === undefined gate mirrors terminal.create's pairedViewer boundary, publishStructuredAgentSessionTab(activate:false) still publishes a selectable tab, the stored selection survives later coalesced broadcasts, and mobile's resolveActiveSessionTab reads the projected isActive — so no wire or client change is needed. Covering the chat arm by sessionId rather than a predicted tab id is the right call.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
| ...(tabId ? { tabId } : {}), | ||
| // The user asked for this chat, so it takes the surface — unlike a dispatched worker. | ||
| activate: true | ||
| activate: activateChat |
There was a problem hiding this comment.
The comment one line above — "The user asked for this chat, so it takes the surface" — no longer describes every case: with activateChat false, the chat is published without taking the host surface (it is selected for the paired caller instead). Worth restating as "a chat the user asked for takes the surface for host/in-process callers; a paired caller gets it as its own selection", so the code and comment do not drift.
When a paired phone created a workspace with a chat agent, the host briefly activated the chat, then the desktop window republished its own active tab (Setup) and the phone followed it about half a second later. agentLaunchCallerNavigationId skipped create-worktree targets, so these launches recorded no per-phone tab selection. It now returns the paired device for every target, so the creating phone keeps its own selection on the agent tab, the same as existing-workspace launches (stablyai#22914). Worktree creation still passes callerPresentsSurface=false, so host-wide chat activation is unchanged and a windowless host's other clients still open the new worktree on the chat. Fixes stablyai#47688 Co-authored-by: Neil <4138956+nwparker@users.noreply.github.com>
…tab (#47687) When a paired phone created a workspace with a chat agent, the host briefly activated the chat, then the desktop window republished its own active tab (Setup) and the phone followed it about half a second later. agentLaunchCallerNavigationId skipped create-worktree targets, so these launches recorded no per-phone tab selection. It now returns the paired device for every target, so the creating phone keeps its own selection on the agent tab, the same as existing-workspace launches (#22914). Worktree creation still passes callerPresentsSurface=false, so host-wide chat activation is unchanged and a windowless host's other clients still open the new worktree on the chat. Fixes #47688 Co-authored-by: Neil <4138956+nwparker@users.noreply.github.com>

ELI5
When you start an agent from your phone, your phone should open on the new tab the next time you look at that workspace, and nobody else's view should move. Before, a new chat from the phone was made the active tab in the list the computer shares with every device, and a new terminal wasn't remembered as the tab the phone wanted, so the phone came back to whatever it showed before. Now the phone that asked gets the new tab as its own choice, and the shared list isn't touched.
What Changed
Before:
agent.launchinto an existing workspace, from a paired client (a phone, or a desktop client connected to a remote Orca server):activate: true, making it the active tab in the host's shared tab list (what every client without its own selection follows);session.tabs.createTerminalpath did record it).After: for those launches the host publishes the chat without activating it for everyone, then records the new tab as the calling client's own selection through the same caller-navigation step
session.tabs.createTerminalruns after its own create (exposed asselectCreatedMobileSessionTabForClient). The terminal is found by the pane the launch created (paneKey), the chat by its session id (never a predicted tab id). It is deliberately not the tab-tap path (activateMobileSessionTab): a tap refreshes the PTY inventory and treats a pane that isn't ready as a wake gesture that respawns its agent, which a launch must never do.Unchanged:
worktree.create's navigation, whose host activation is what runs the new workspace's setup.This applies to paired desktop clients of a remote server as well as phones, intentionally: a view change belongs to the connection that asked for it, as it already does for
worktree.createandsession.tabs.activate.Why
The host already owns each paired client's tab selection —
session.tabs.createTerminaland caller-scoped browser tab creation already record the tab they create as the caller's selection — so a launch records the caller's selection the same way rather than broadcasting an activation. Two alternatives were considered:Deviation recorded: selection here is applied by the host at launch, from the requesting connection, rather than by the client after the reply.
Linked Issue
No linked issue.
Visual Proof
Android phone running the mobile client that sends this launch (the commit-failure Fix button, from the follow-up mobile PR), paired to an isolated desktop host built without this change (before) or with it at
7d944aa8aa(after). Both arms started from the same seeded state: one workspace with Terminal 1 active. Fix is tapped from Source Control opened outside the session, then the workspace is opened on the phone.back on Terminal 1
opens on the new Claude terminal (at Claude's folder-trust prompt)
back on Terminal 1
opens on the new chat
Desktop window after the phone's chat launch (after): still on Terminal 1, the new chat present but not selected.
A launch from the desktop window itself still moves the desktop to the new tab (after):
A phone that is already showing the workspace does not switch live; it opens on the new tab the next time the workspace is opened (after):
Testing
created-mobile-session-tab-caller-selection.test.ts(a real runtime, two subscribed devices): a launched terminal and a launched chat become the caller's selection while the shared tab list and a second subscribed device stay put; a tab that isn't published is reported, not substituted; selecting a pane that isn't ready never spawns (the tap path does).agent-launch-caller-selection.test.ts(through the realagent.launch/agent.launchReplayhandlers):navigation: 'caller', its device id);activate: false, then selects the chat, found by session id, for the caller;activate: trueand selects nothing;pnpm tc;src/main/runtime/rpc/methods+src/main/agent-launch— 216 files / 2,184 tests pass; oxlint on changed files;check:code-quality:changed0 findings.7d944aa8aa(Android emulator driven only throughorca emulator; isolated desktop host built with and without this change, identical seeded state per arm, desktop window hidden and checked over CDP):'all')Notes
agent-launch-surfaces.tschanges are one parameter and one argument; the runtime gains one public method,selectCreatedMobileSessionTabForClient, a thin wrapper over the existing caller-navigation step.