Repository navigation
refactor(floating-workspace): launch the default agent through the shared launcher - #21390
Conversation
…ared launcher The floating workspace titlebar agent button drove tab startup itself: it built its own `buildAgentStartupPlan`, created the tab, queued the startup command and rebuilt the tab-bar order by hand. That is a second copy of what `launchAgentInNewTab` already does for every other "start an agent here" button, so a launch-point change had two places to land. The button now calls `launchAgentInNewTab` and keeps only its own placement: selecting the tab inside the floating panel's unified group and focusing it. `launchAgentInNewTab` gains an optional `activate` so a caller that places the tab itself can keep the new terminal out of the global selection. The floating panel needs this — activating would move the main window's active tab to a tab it does not show — and it matches the other floating tab creators, which already pass `activate: false` to `createTab` and select via `activateTab`. Two behaviours change, both fixes: - tab-bar order now goes through `persistAgentLaunchTabOrder`, which reconciles editor and browser tabs. The hand-rolled loop rebuilt order from terminal tabs only, dropping the floating workspace's markdown and browser tabs. - the startup plan now carries the resolved Windows shell, so argument quoting matches the shell the PTY actually gets.
|
Understand this PR’s impact Explore downstream dependencies and potential security impact with Blast Radius. Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
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 (1)
Included review availability: Your plan provides up to 10 included reviews per hour; 5 remain after this review. 📝 WalkthroughWalkthroughFloating terminal controls now use Priority: ⬇️ Low 🚥 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.
Caution
Some comments are outside the diff and can’t be posted inline due to GitHub limitations.
🟠 Major · Suppress global activation when activate is false. · launch-agent-in-new-tab.ts:342
src/renderer/src/lib/launch-agent-in-new-tab.ts:342
🎯 Functional Correctness | 🟠 Major | ⚡ Quick winSuppress global activation when
activateis false.The floating caller passes
activate: false, butlaunchAgentInNewTabInternalstill reachesstore.setActiveTabType('terminal'). That store action updates the active worktree's surface, so a floating launch can switch the main window from an editor or browser to the terminal.- store.setActiveTabType('terminal') + if (activate !== false) { + store.setActiveTabType('terminal') + }Extend the placement test to assert that
setActiveTabTypeis not called whenactivate: false.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: b9ed3cad-29db-49c3-8255-9b142946d036
📒 Files selected for processing (4)
src/renderer/src/components/floating-terminal/FloatingTerminalWindowControls.test.tsxsrc/renderer/src/components/floating-terminal/FloatingTerminalWindowControls.tsxsrc/renderer/src/lib/launch-agent-in-new-tab-placement.test.tssrc/renderer/src/lib/launch-agent-in-new-tab.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review.
There was a problem hiding this comment.
Important
The migration introduces a main-window side effect the inline path did not have: the shared launcher flips the active worktree's activeTabType to terminal, so launching the floating default agent can switch the main window out of an open editor. Details inline.
Reviewed changes
- Floating default-agent button delegates to the shared launcher —
FloatingTerminalWindowControls.tsxnow callslaunchAgentInNewTab(...)withactivate: falseand keeps only its own selection and focus, dropping the inline startup plan,createTab,queueTabStartupCommand, and the hand-rolled tab-order loop. launchAgentInNewTabgains an optionalactivate— forwarded tocreateTabonly whenfalse; the terminal route honors it, the structured and host-published routes do not.- Test changes — the component test now mocks the shared launcher and pins the call shape; a new
launch-agent-in-new-tab-placement.test.tspins theactivatethreading and the floating-to-terminal route.
ℹ️ Floating launches now adopt the native-chat default view mode and session options
The shared launcher resolves initialViewModeProps and sessionOptions from settings and forwards both into createTab and the startup plan, where the inline path passed neither. With experimentalNativeChat and openAgentTabsInChatByDefault on, the floating button now creates a viewMode: 'chat' tab and applies model / effort flags; the removed test asserted no sessionOptions. This is plausibly the intended consistency with every other launch point, but it is not in the PR body, so please confirm the floating surface should follow the native-chat default.
Technical details
# Floating launch adopts native-chat view mode and session options
## Affected sites
- `src/renderer/src/lib/launch-agent-in-new-tab.ts:161-178` — resolves `initialViewModeProps` and `sessionOptions` from settings.
- `src/renderer/src/lib/launch-agent-in-new-tab.ts:268-274` — forwards `viewMode` to `createTab` and seeds the session-option cache.
- `src/renderer/src/components/floating-terminal/FloatingTerminalWindowControls.tsx:70` — the new call site.
## Open questions for the human
- Should the floating workspace follow `openAgentTabsInChatByDefault`, or stay terminal-only?DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
The census exists so a new launchAgentInNewTab caller is a deliberate act. This entry is a bypass converging, not a bypass appearing: the button previously hand-rolled the helper's terminal arm against queueTabStartupCommand.
Review status: clean after fixesThe review/fix loop found and fixed two in-scope regressions in the shared launch boundary:
Fix commit: Validation on the pushed head:
Visual proof: Before launch: After clicking “Open Claude in floating workspace”: No further in-scope issues remain. The change stays focused on converging the floating launch point onto the shared launcher. |
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Scoped the shared launcher's global tab-type write —
launchAgentInNewTabnow gatesstore.setActiveTabType('terminal')onactivate !== false, so a caller-placed floating launch no longer flips the main window's active worktree to the terminal view. - Made the floating workspace terminal-only end to end —
decideInitialAgentTabViewModereturnsundefinedforworkspaceKind === 'floating', andworkspaceKindis threaded throughinitialAgentTabViewModeProps,resolveInitialNativeChatSessionOptions, andresolveAgentLaunchRoute, so a floating launch no longer adopts native-chat view mode, session options, or thelegacy-native-chatroute under chat-default settings. - Tests updated to pin the boundaries — the placement suite now asserts the gated
setActiveTabType, terminal-only creation, and omitted session options for floating; routing, initial-view-mode, and session-option suites each add a floating case.
Both prior concerns are addressed. I verified no other launchAgentInNewTab caller passes activate: false, so the gate cannot change behavior for non-floating launches, and the new tests pass locally (46 tests across the five touched suites).
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
|
Additional Electron validation with native-chat settings enabled:
Clicking “Open Codex in floating workspace” rendered a terminal tab (expected floating-workspace behavior) rather than native chat, with no console errors. |
|
Corrected Electron visual proof (regular workspace, not floating): With experimentalNativeChat=true, experimentalStructuredNativeChat=true, openAgentTabsInChatByDefault=true, and defaultTuiAgent=codex, I opened the normal workspace New tab menu and selected Codex. The rendered UI shows the structured Codex Chat view ("Start a chat with Codex" and the "Send a message…" composer). The floating workspace remains intentionally terminal-only; its separate screenshot is not evidence for native-chat behavior. |
…pace The floating launch button now routes through the shared launcher, so it should inherit the same launch policy as every other caller. The previous review pass added a `workspaceKind === 'floating'` guard to `decideInitialAgentTabViewMode`, which silently dropped `openAgentTabsInChatByDefault` (and the user's model and effort preferences) for that one button. That guard was not justified. `canToggleNativeChat` has no workspace-kind gate, so a floating terminal can already be switched into the chat view by hand, and `TerminalPaneNativeChatPortal` mounts into the pane's own container — the panel already renders it. Refusing the setting at launch while the same view sits one click away in the same panel is an inconsistency, not an invariant. Structured sessions stay out of the floating workspace on the pre-existing blocker in `resolveStructuredNativeChatSupport`: those open an `agent-session` tab, and the floating panel renders no such surface.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Reverted the floating workspace's terminal-only gating —
decideInitialAgentTabViewMode,resolveInitialNativeChatSessionOptions, andresolveAgentLaunchRouteno longer readworkspaceKind, so a floating launch followsopenAgentTabsInChatByDefaultand resolves the terminal-backedlegacy-native-chatroute. It still cannot reach a structured session: thefloating-workspaceblocker refuses one before the view-mode decider runs. - Kept the
activategate from the prior commit —store.setActiveTabType('terminal')is still skipped whenactivate === false, andcreateTabstill receives{ activate: false }, so the button keeps its placement inside the floating group without moving the main window's selection. - Re-pinned the boundary tests — the routing suite now asserts floating resolves
legacy-native-chat, and the placement suite asserts the floating launch carriesviewMode: 'chat'and seeds the resolved session options.
ℹ️ The floating chat path is covered only at mocked/store level
The new commit turns on native-chat rendering for the floating workspace, but no test exercises that rendering: the component test mocks launchAgentInNewTab, and the placement test asserts the createTab args and the session-option seed rather than a rendered pane. The bridge NativeChatView is pane/PTY-keyed and needs no worktree row, so the path looks sound from source, but a render-level regression here would not be caught. The PR body already flags that no Electron run happened — worth confirming in the app that a floating launch under chat-default settings comes up as a working chat pane, especially since worktree-derived chat affordances resolve against the FLOATING_TERMINAL_WORKTREE_ID sentinel.
Technical details
# Floating native-chat rendering has no render-level coverage
## Affected sites
- `src/renderer/src/components/floating-terminal/FloatingTerminalWindowControls.test.tsx` — mocks `@/lib/launch-agent-in-new-tab`, so it never reaches the chat surface.
- `src/renderer/src/lib/launch-agent-in-new-tab-placement.test.ts` — asserts `createTab` args (`viewMode: 'chat'`) and `seedNativeChatAppliedSessionOptions`, not a rendered pane.
- `src/renderer/src/components/floating-terminal/FloatingTerminalPanelSurface.tsx:226` — renders `TerminalPane` for terminal tabs; chat takes over through `TerminalPaneNativeChatPortal`.
- `src/renderer/src/components/terminal-pane/use-terminal-pane-chat-state.ts` — `effectiveChatViewMode` derives from `unifiedTabsByWorktree[FLOATING_TERMINAL_WORKTREE_ID][tabId].viewMode === 'chat'`.
## Required outcome
- Confidence that a floating launch under chat-default settings produces a working chat pane rather than a blank or terminal-only tab.
## Open questions for the human
- Was the floating chat path exercised in a running app? The PR body notes no Electron/UI run.DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
Correction + visual proof: the floating workspace now honours the chat-view defaultMy earlier comments on this PR said the floating workspace "remains intentionally terminal-only." That was wrong, and the screenshot I attached alongside it (a regular workspace) was not evidence for the floating behaviour. Correcting both here. What was wrongDuring the review loop I added a That guard was not justified:
Refusing the setting at launch while the identical view sits one click away in the same panel is an inconsistency, not an invariant — and it put a second guard beside the one that already exists in Visual proofFloating workspace, with Verified in a dev instance attached to this exact worktree (
Still out of scope hereStructured sessions remain unavailable in the floating workspace, on the pre-existing blocker in Worth recording for that work: Orca currently has no fallback when a session's workspace has moved or is gone; Validation
|






What the button did before
The floating workspace titlebar has a default-agent icon button. It drove tab startup itself —
buildAgentStartupPlan→createTab(FLOATING_TERMINAL_WORKTREE_ID, …, { activate: false })→queueTabStartupCommand(…)→ activate + a hand-rolled tab-bar order loop → focus.That is a second copy of what
launchAgentInNewTabalready does for every other "start an agent here" button (use-terminal-create-actions.ts:98,QuickLaunchButton.tsx:137, the dashboard, source control, session fork, and six more). A change to the launch point had two places to land.What it does now
The button calls
launchAgentInNewTab({ agent, worktreeId: FLOATING_TERMINAL_WORKTREE_ID, launchSource: 'shortcut', activate: false })and keeps only its own placement — selecting the tab inside the floating panel's unified group and focusing it. The shared launcher owns the startup plan, the route, and the tab identity.launchAgentInNewTabgains an optionalactivate. The floating panel must not take the global selection: activating would move the main window's active tab to a tab it does not show. This matches the floating workspace's other tab creators, which already passactivate: falsetocreateTaband select viaactivateTab(use-floating-terminal-create-actions.ts:68-72).Does the renderer place a tab on the launch receipt?
Not on the receipt, and it does not need to. Two mechanisms exist; neither is receipt-driven.
orca-runtime-create-terminal.ts:256-271callsnotifier.revealTerminalSession(…)wheneverpresentation !== 'background', and the renderer'sterminal-presentation-ipc-bridge.ts:86-107answers by callingstore.createTab(worktreeId, undefined, undefined, { initialPtyId: ptyId, … }). The host creates the tab; the caller places nothing.reserveAgentBackgroundSessionIdentity+adoptAgentBackgroundSessionTab(adopt-agent-background-session-tab.ts:97-102, used atlaunch-agent-background-session.ts:226) mint the tab id before the spawn, bake it into the PTY env, and adopt afterwards.What the receipt itself carries is only
{ kind: 'terminal', handle }(agent-launch-intent.ts:61-63).agentLaunchSurfaceFactory.createTerminalAgent(agent-launch-surfaces.ts:92-95) drops thetabIdthatRuntimeTerminalCreatealready computed, and the renderer cannot resolve aterm_*handle itself —terminal-handle-links.ts:309-311says so outright ("main owns theterm_*mapping") and defers to aterminal.focusRPC. So placing on the receipt would require addingtabIdtoAgentLaunchOutcome, i.e. a wire change.No wire change was needed, because
agent.launchis not the shared launch point for a desktop button —launchAgentInNewTabis. It already routes the floating workspace correctly: it builds its route input withworkspaceKindForWorktreeId(worktreeId)(launch-agent-in-new-tab.ts:219, the same shared module #21193 added), andstructured-native-chat-launch-route.ts:86-87returns{ supported: false, blocker: 'floating-workspace' }. The launch resolves the terminal-backed lane, as required — a PTY, rendered as chat when the user's chat default is on (see the behaviour-change section below). No new target arm, no change toAgentLaunchIntent, no placement or focus on the wire.What crosses the shared command
Everything the button passed, verified field by field against
launch-agent-in-new-tab.ts:149-175:defaultAgentcmdOverridessettings.agentCmdOverridesagentArgsresolveTuiAgentLaunchArgs(...)agentEnvresolveTuiAgentLaunchEnv(...)allowEmptyPromptLaunchtruetrueviaplanLaunchAgentStartupPrompt(launch-agent-startup-prompt-plan.ts:72-77, empty prompt)platformCLIENT_PLATFORMCLIENT_PLATFORM— the floating sentinel has no worktree row, sorepois null and the helper falls back to the same constantlaunch_source'shortcut''shortcut'Prompt transport is untouched: this button passes no prompt.
Two behaviours change, both fixes:
persistAgentLaunchTabOrder, which reconciles editor and browser tabs. The hand-rolled loop rebuilt order from terminal tabs only, so a floating workspace holding markdown or browser tabs (both creatable from its+menu) would have had them dropped from the order.resolveLocalWindowsAgentStartupShell), so argument quoting matches the shell the PTY actually gets. The button passed no shell.Nothing was dropped.
Behaviour change: the floating launch now honours the chat-view default
Worth calling out separately, because it goes beyond "route through the shared launcher" and it reverses an assertion that was on
main.main'sFloatingTerminalWindowControls.test.tsxdeliberately seedednativeChatSessionOptionsand then assertednot.toHaveProperty('sessionOptions')— an intentional pin that the floating launch did not carry the user's model/effort preferences. That pin is gone, and this is why:experimentalNativeChat+openAgentTabsInChatByDefaulton, the floating launch now opens in the chat view and applies the user's model/effort, exactly as every other launch caller does. With the flags off (the default) nothing changes — it is still a plain terminal.main's ownagent-launch-routing.test.ts:115-116already assertedroute({ workspaceKind: 'floating' }) === 'legacy-native-chat'. The shared launcher always resolved the chat view for floating; the button simply was not using the shared launcher. Verified by ablation:main'slaunch-agent-in-new-tab.tsproducescreateTab(floating, …, { viewMode: 'chat' })unchanged.resolveInitialNativeChatSessionOptionsemits options only whenviewMode === 'chat', so they cannot diverge.Structured sessions remain unavailable in the floating workspace, on the pre-existing
floating-workspaceblocker. That is unchanged here and tracked separately.Ablation
Originally proved at
a7295c19f5. Re-proved at the final headde8fb41006: substitutingorigin/main'slaunch-agent-in-new-tab.tsmakes the floating placement test fail (it produces noactivate: falseand callssetActiveTabType), confirming the test is a real pin rather than a no-op. Each scripted substitution asserts it matched exactly once, so a silent no-op fails loudly.FloatingTerminalWindowControls.tsxto its pre-change content (rg -c launchAgentInNewTab→ 0, confirming the ablation landed):Test Files 1 failed (1),Tests 3 failed | 1 passed (4). The one that still passes is the route assertion, which pins the floating→terminal rule independently of the component — correct.activatethreading inlaunch-agent-in-new-tab.ts(ablated 1 occurrence):Test Files 1 failed (1),Tests 1 failed | 1 passed (2). The passing one is the default-behaviour control.Test Files 2 passed (2),Tests 6 passed (6).Verification
All observed on
a7295c19f5:pnpm tc— exit 0.pnpm testover the floating-terminal directory, everylaunch-agent-in-new-tab*suite and the shared route suite —Test Files 24 passed (24),Tests 210 passed (210).pnpm run check:code-quality:changed— 0 new findings across 4 changed files, all seven gates, baselined at71f3bdb70026. Re-run after committing, after the pre-commitoxfmt --write, and after the merge.pnpm-lock.yamlverified byte-identical toorigin/mainbefore the commit and absent from it. Local pnpm rewrote it three times (adding@pnpm/exe); restored each time.max-linesdisable. Adding theactivatetest pushedlaunch-agent-in-new-tab.test.tsto 811/800, so the test went into a newlaunch-agent-in-new-tab-placement.test.ts, following the split the repo already uses for the-cwd,-host-resolutionand-windows-quotingsuites.Verified in Electron
Dev instance attached to this worktree, driven through the real button with the chat flags on: the floating panel renders the chat view (
.native-chat-pane-shellcount inside[data-floating-terminal-panel]= 1), tab created ascontentType: terminal/viewMode: chat, 0 console errors. Screenshot in the comments.UNVERIFIED
tabBarOrderByWorktree, so this affects the mobile/web projections rather than the panel itself.activateis consumed only on the local-terminal route. The structured and host-published routes ignore it; the floating workspace cannot reach either, but another caller passingactivate: falsefor a structured launch would be silently ignored. Documented on the field.