Repository navigation
Route terminal-only launch customization to the terminal - #21103
brennanb2025 wants to merge 1 commit into
Conversation
📝 WalkthroughWalkthroughThe routing contract now uses Priority: ➖ Normal Merge Risk: 🔵 Low · up to Direct launches currently work, but a small future change could silently collapse empty or null argument overrides and route them incorrectly. Add the focused regression cases before merge. 🚥 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.
Important
The presence test on agentArgs reads the codebase's empty-string "unset" sentinel as an explicit choice, which makes structured chat unreachable from the source-control action dialogs. Worth confirming intent before merge.
Reviewed changes
- Blocker rename —
tui-launch-commandbecomestui-launch-customizationin the shared feasibility resolver, and the main-process reasontui_launch_commandbecomestui_launch_customizationwith reworded downgrade copy. - Route input reads per-launch
agentArgs—requiresTuiLaunchCustomizationis nowcwd || agentArgs !== undefined || command override(presence, not truthiness), while globalagentDefaultArgsstill do not demote. - Per-launch forwarding —
launchAgentInNewTabandprepareDirectWorkItemAgentLaunchnow pass the caller'sagentArgsintotuiCustomization. - Tests — empty/null argument cases added to the route-input and structured-guard suites, a new direct-route preparation test, and blocker/receipt fixtures updated for the rename.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
9865a7e to
7316078
Compare
Electron routing evidenceHidden Electron QA on this worktree (
Setup used the store only for experimental Chat UI flags, global Claude extra args ( 1. Plain launch with only global extra args stays structured chatUI: tab-bar New tab → Claude (no per-launch args, cwd, or command override). Visible: tab titled Claude Chat, empty structured composer (“Start a chat with Claude”). Backing: 2. Settings command override routes to a terminalUI: Settings → Agents → Claude Command set to Visible: new tab Terminal 2 (not Claude Chat). PTY ran: Backing: 3. Explicit empty per-launch CLI arguments route to a terminalCommand override was cleared first ( UI: Checks → failing static analysis → View full details → Choose agent to fix check → Customize launch… → CLI arguments left empty ( Visible: new terminal-backed tab (not Backing: Reachability note (empty
|
… terminal Per-launch arguments, working directories and command overrides are launch customization only a PTY can apply, so they route to the terminal. An explicitly empty `agentArgs: ''` is a request for no flags, not an absent value, and now routes there too rather than inheriting the global permission setting. Global Agent Settings arguments and environment still do not demote a launch.
7316078 to
07d6bfc
Compare
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes: incremental re-review of the commit pushed since the prior Pullfrog review — the receipt-token revert, the reworded downgrade copy, and a rebase onto current main.
- Receipt token restored — the internal
tui-launch-customizationblocker maps back to the shippedtui_launch_commandreason, so mixed-version clients continue to decode it. - Downgrade copy reworded — the terminal-only detail now names the custom command, per-launch arguments, and working directory.
- Branch rebased onto
main(de4dab93) with no other content changes.
The previously flagged empty-string agentArgs behavior is unchanged and now documented as intended: a blank per-launch argument field means "no flags" and deliberately routes to the terminal-backed surface (the PR's visual proof demonstrates the source-control Customize dialog doing exactly that). That answers the open question from the prior review, and that thread has been resolved.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 7d021e88-9c0d-48a5-84b0-511b324e6b05
📥 Commits
Reviewing files that changed from the base of the PR and between 73160781af029017297f2504fba6331cf37a5c3f and 07d6bfc.
📒 Files selected for processing (13)
src/main/agent-launch/agent-launch-mode.tssrc/main/runtime/rpc/methods/orchestration-worker-start-receipt-wording.test.tssrc/renderer/src/lib/agent-launch-route-input.test.tssrc/renderer/src/lib/agent-launch-route-input.tssrc/renderer/src/lib/agent-launch-routing.test.tssrc/renderer/src/lib/agent-launch-routing.tssrc/renderer/src/lib/launch-agent-in-new-tab.tssrc/renderer/src/lib/launch-agent-structured-chat-guard.test.tssrc/renderer/src/lib/launch-work-item-direct-route-preparation.test.tssrc/renderer/src/lib/launch-work-item-direct-route-preparation.tssrc/shared/structured-native-chat-launch-route.test.tssrc/shared/structured-native-chat-launch-route.tstests/e2e/structured-native-chat-routing-authority.unit.test.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review.
| import { beforeEach, describe, expect, it, vi } from 'vitest' | ||
| import type { AppState } from '@/store' | ||
| import { adoptAgentSessionLaunchVerdict } from './agent-session-launch-plan' | ||
|
|
||
| const mocks = vi.hoisted(() => ({ | ||
| buildDirectWorkItemStartup: vi.fn(), | ||
| getConnectionId: vi.fn(), | ||
| getLocalProjectExecutionRuntimeContext: vi.fn(), | ||
| markDirectWorkItemAgentTrusted: vi.fn(), | ||
| resolveDirectWorkItemAgent: vi.fn() | ||
| })) | ||
|
|
||
| vi.mock('@/lib/connection-context', () => ({ getConnectionId: mocks.getConnectionId })) | ||
| vi.mock('@/lib/new-workspace', () => ({ CLIENT_PLATFORM: 'darwin' })) | ||
| vi.mock('@/lib/local-preflight-context', () => ({ | ||
| getLocalProjectExecutionRuntimeContext: mocks.getLocalProjectExecutionRuntimeContext | ||
| })) | ||
| vi.mock('@/lib/launch-work-item-direct-agent-routing', () => ({ | ||
| buildDirectWorkItemStartup: mocks.buildDirectWorkItemStartup, | ||
| markDirectWorkItemAgentTrusted: mocks.markDirectWorkItemAgentTrusted, | ||
| resolveDirectWorkItemAgent: mocks.resolveDirectWorkItemAgent | ||
| })) | ||
|
|
||
| import { prepareDirectWorkItemAgentLaunch } from './launch-work-item-direct-route-preparation' | ||
|
|
||
| describe('prepareDirectWorkItemAgentLaunch', () => { | ||
| beforeEach(() => { | ||
| vi.clearAllMocks() | ||
| mocks.getConnectionId.mockReturnValue(null) | ||
| mocks.getLocalProjectExecutionRuntimeContext.mockReturnValue(null) | ||
| mocks.resolveDirectWorkItemAgent.mockResolvedValue({ unavailable: false, agent: 'codex' }) | ||
| mocks.buildDirectWorkItemStartup.mockReturnValue({ | ||
| startupPlan: null, | ||
| draftLaunchedNatively: false, | ||
| startupPlanFailed: false | ||
| }) | ||
| mocks.markDirectWorkItemAgentTrusted.mockResolvedValue(undefined) | ||
| }) | ||
|
|
||
| it.each(['--model gpt-5.6-sol', '--dangerously-bypass-approvals-and-sandbox'])( | ||
| 'passes explicit recipe arguments to the shared route planner: %s', | ||
| async (agentArgs) => { | ||
| const updateWorktreeMeta = vi.fn().mockResolvedValue(undefined) | ||
| // oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: Mocked collaborators only read updateWorktreeMeta and settings in this focused preparation test. | ||
| const store = { updateWorktreeMeta, settings: {} } as unknown as AppState | ||
| const planLaunch = vi.fn().mockReturnValue( | ||
| adoptAgentSessionLaunchVerdict({ | ||
| route: 'legacy-native-chat', | ||
| agent: 'codex', | ||
| worktreeId: 'worktree-1', | ||
| prompt: 'Fix the launch', | ||
| promptDelivery: 'submit-after-ready' | ||
| }) | ||
| ) | ||
|
|
||
| const result = await prepareDirectWorkItemAgentLaunch({ | ||
| worktreeId: 'worktree-1', | ||
| worktreePath: '/repo/worktree', | ||
| repoId: 'repo-1', | ||
| agentOverride: 'codex', | ||
| agentArgs, | ||
| repoConnectionId: null, | ||
| detectedAgentsPromise: null, | ||
| latestStore: store, | ||
| settings: store.settings, | ||
| draftContent: 'Fix the launch', | ||
| promptDelivery: 'submit-after-ready', | ||
| planLaunch | ||
| }) | ||
|
|
||
| expect(planLaunch).toHaveBeenCalledWith( | ||
| store, | ||
| expect.objectContaining({ tuiCustomization: { agentArgs } }) | ||
| ) | ||
| expect(result.structuredLaunch).toBe(false) | ||
| } | ||
| ) | ||
| }) |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
sed -n '1,145p' src/renderer/src/lib/launch-work-item-direct-route-preparation.ts
sed -n '1,140p' src/renderer/src/lib/launch-work-item-direct-route-preparation.test.ts
rg -n "prepareDirectWorkItemAgentLaunch|tuiCustomization.*agentArgs|agentArgs.*null|agentArgs.*''" src/renderer/src/lib --glob '*test.ts'Repository: stablyai/orca
Length of output: 13213
🏁 Script executed:
set -eu
printf '%s\n' '--- route input implementation/tests ---'
rg -n -C 8 "agentArgs|tuiCustomization|explicit empty|explicit null|normalize|route input" src/renderer/src/lib/agent-launch-route-input.ts src/renderer/src/lib/agent-launch-route-input.test.ts src/renderer/src/lib/agent-session-launch-plan.ts
printf '%s\n' '--- direct launch tests around relevant callers ---'
rg -n -C 12 "prepareDirectWorkItemAgentLaunch|planLaunch|agentArgs|tuiCustomization" src/renderer/src/lib/launch-work-item-direct.test.ts src/renderer/src/lib/launch-work-item-direct-agent.test.ts src/renderer/src/lib/launch-work-item-direct-route-preparation.test.ts
printf '%s\n' '--- same preparation caller references ---'
rg -n -C 10 "prepareDirectWorkItemAgentLaunch" src/renderer/src --glob '*.{ts,tsx}'Repository: stablyai/orca
Length of output: 45882
Cover explicit empty and null agentArgs values.
buildAgentLaunchRouteInput treats tuiCustomization.agentArgs !== undefined as requiring terminal customization. Therefore '' and null must be forwarded, while undefined must remain omitted. The direct preparation test covers only truthy strings, so a future truthiness-based forwarding regression could pass this test and route these launches through structured chat. Add '' and null cases that assert tuiCustomization.agentArgs is forwarded. The current structuredLaunch assertion is not sufficient because planLaunch always returns legacy-native-chat in this test.
Review status: ready to mergeFinal head: The review found and fixed one mixed-version compatibility issue during the rebase: the internal blocker is now Two independent code-review loops and the opening/final readiness audits are clean. The final post-rebase range diff has the same patch ID as the reviewed change. No actionable correctness, architecture, compatibility, security, scope, or performance findings remain. The launch checks are constant-time and add no polling, subprocesses, listeners, caches, or retained resources. Validation:
No mobile surface, Windows/WSL launch mechanism, SSH/remote boundary, or folder-workspace mechanism changed. Mobile emulator, remote Windows UI, and SSH-host UI runs were therefore out of scope; Windows packaging and the existing platform-boundary tests passed in CI. |
|
Closing: this goes the wrong direction. This PR made per-launch CLI arguments take effect by routing those launches to a terminal. The agreed model is that CLI arguments are a terminal concern and structured chat reads none of them — it uses its own settings. Honouring per-launch arguments pulls launches off structured chat to keep a free-text CLI field working, which entrenches the surface rather than removing it. Origin, for the record: the per-launch routing entered in this lane's original commit ( What stays: #20944 (structured chat ignores CLI arguments) and #20977 (the Agent Permissions toggle actually applies to Codex chat) are merged and unaffected. The real fix is removing the free-text CLI arguments input from the Source Control AI dialogs, since what a user types there provably does nothing in structured chat. Tracking that separately. The one case worth revisiting under the new model is a per-launch empty argument override inheriting the global permission setting — it needs a different answer than routing to a terminal. |







ELI5
Orca can open an agent in structured chat or in a terminal-backed tab. Global Agent Settings should not force every launch into a terminal, but options chosen for one launch must be honored by the surface that opens.
This change keeps ordinary launches in structured chat when only global arguments or environment are configured. A launch that explicitly supplies its own command, working directory, or CLI arguments opens in a terminal, including an explicit empty argument value that means “use no flags.”
What Changed
''andnullare explicit values rather than “unset.”tui-launch-customization. The externally visible receipt reason remainstui_launch_commandso mixed-version clients continue to understand it.Before, an empty per-launch argument override could enter structured chat and inherit global arguments, including a more permissive global permission mode. After, Orca opens the terminal-backed surface and launches with no flags, preserving the caller’s choice.
Why
Structured Claude and Codex sessions accept semantic session options; they do not accept arbitrary interactive CLI arguments, a replacement command, or a launch-specific working directory. Silently dropping those values changes what the user requested. Routing those launches through the existing terminal path applies the values directly while keeping the route decision centralized.
The planner checks whether the caller supplied an argument value, rather than whether the string is truthy. This matches the existing terminal launch contract and avoids storing a second routing policy in individual callers.
Linked Issue
Follow-up to #20944 and split from #20977.
Visual Proof
Fresh Electron routing evidence covers:
Testing
I manually tested these changes locally
Automated tests added/updated
pnpm tcpnpm run check:code-quality:changed— 0 findings across all six scans and 13 changed filesFocused launch-routing suite — 8 files, 130 tests passed
GitHub CI — all 8 test shards, typecheck, macOS package, and Windows package passed
Hidden macOS Electron QA with an isolated profile and branch identity verification
git diff --checkAI Disclosure
Review
The branch was rebased onto current
origin/main. Independent review found the final routing mechanism clean for functional behavior, architecture, performance, mixed-version compatibility, and platform boundaries. The only review fix was preserving the shipped external receipt reason after the internal blocker rename.Agent skill upstream boundary
docs/reference/agent-skill-sharing-upstream-boundary.mdand copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.Notes
No schema, migration, dependency, mobile UI, or user-owned data format changed. The receipt value sent across versions remains stable. Existing remote-host, SSH, WSL, and folder-workspace feasibility blockers are unchanged.
The route checks are constant-time property checks. They add no polling, subprocesses, listeners, caches, or retained resources.
Electron QA exercised macOS. CI packaged both macOS and Windows. Linux, SSH, WSL, mobile, folder workspaces, and per-launch cwd were reviewed but not exercised manually because this change does not alter their existing blockers or platform-specific execution code.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)