Skip to content

Route terminal-only launch customization to the terminal - #21103

Closed
brennanb2025 wants to merge 1 commit into
mainfrom
brennanb2025/structured-chat-launch-routing
Closed

brennanb2025 wants to merge 1 commit into
mainfrom
brennanb2025/structured-chat-launch-routing

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 7 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​166 $\color{#cf222e}{\Huge{\mathbf{−}}}$​10 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​156
Prod 6 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​26 $\color{#cf222e}{\Huge{\mathbf{−}}}$​17 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​9

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

  • The shared launch planner now treats the presence of per-launch arguments as terminal-only customization. '' and null are explicit values rather than “unset.”
  • Global agent arguments and environment remain outside the routing decision, so they do not demote an otherwise structured launch.
  • Command, working-directory, and argument customization use one internal blocker, tui-launch-customization. The externally visible receipt reason remains tui_launch_command so mixed-version clients continue to understand it.
  • Both new-tab and direct work-item launches feed their per-launch values into the same route planner.

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:

  1. A plain launch with global extra arguments remaining in structured Claude Chat.
  2. A command override opening a terminal-backed tab and PTY.
  3. The source-control Customize launch dialog sending an explicit empty CLI-argument value to a terminal-backed tab and PTY.

Testing

  • I manually tested these changes locally

  • Automated tests added/updated

  • pnpm tc

  • pnpm run check:code-quality:changed — 0 findings across all six scans and 13 changed files

  • Focused 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 --check

AI 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

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and 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

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

@coderabbitai

coderabbitai Bot commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

📝 Walkthrough

Walkthrough

The routing contract now uses requiresTuiLaunchCustomization and tui-launch-customization for custom commands, per-launch arguments, and working directories. Per-launch agentArgs now flow through route planning and force terminal launches, including empty and null overrides. Downgrade wording and RPC receipt mappings were updated. Tests cover routing, direct launches, terminal fallback, and renamed blocker values.

Priority: ➖ Normal

Merge Risk: 🔵 Low · up to 07d6b

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)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 14 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly describes the primary change: routing terminal-only launch customization to the terminal-backed UI.
Description check ✅ Passed The description is complete and relevant. It covers the user-facing behavior, implementation, rationale, linked issues, visual proof, testing, compatibility, platform considerations, and checklist ite…
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-command becomes tui-launch-customization in the shared feasibility resolver, and the main-process reason tui_launch_command becomes tui_launch_customization with reworded downgrade copy.
  • Route input reads per-launch agentArgs — requiresTuiLaunchCustomization is now cwd || agentArgs !== undefined || command override (presence, not truthiness), while global agentDefaultArgs still do not demote.
  • Per-launch forwarding — launchAgentInNewTab and prepareDirectWorkItemAgentLaunch now pass the caller's agentArgs into tuiCustomization.
  • 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.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@brennanb2025
brennanb2025 force-pushed the brennanb2025/structured-chat-launch-routing branch from 9865a7e to 7316078 Compare September 17, 2026 00:01
@brennanb2025

Copy link
Copy Markdown
Contributor Author

Electron routing evidence

Hidden Electron QA on this worktree (ORCA_BACKGROUND_LAUNCH=1, CDP 9342, renderer 5183, isolated user-data profile). Identity from window.api.app.getIdentity():

  • name: Orca: brennanb2025/structured-chat-launch-routing
  • devBranch: brennanb2025/structured-chat-launch-routing
  • devWorktreeName: pr-21103-launch-routing
  • devRepoRoot: /Users/brennanbenson/orca/workspaces/orca/pr-21103-launch-routing
  • HEAD: 73160781af029017297f2504fba6331cf37a5c3f

Setup used the store only for experimental Chat UI flags, global Claude extra args (--dangerously-skip-permissions --model Opus), and env ORCA_QA=1. Launches were clicked in the UI.

1. Plain launch with only global extra args stays structured chat

UI: 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: contentType: "agent-session", agentSessionAgent: "claude", activeTabType: "agent-session", no queued PTY startup. Global extra args were still present and did not demote the route.

Plain launch remains structured native chat

2. Settings command override routes to a terminal

UI: Settings → Agents → Claude Command set to claude-qa-override → Back to app → New tab → Claude.

Visible: new tab Terminal 2 (not Claude Chat). PTY ran:

$ claude-qa-override '--dangerously-skip-permissions' '--model' 'Opus'
zsh: command not found: claude-qa-override

Backing: contentType: "terminal", activeTabType: "terminal", launchAgent: "claude", launchConfig.agentCommand starts with claude-qa-override.

Command override in Agent settings
PTY after command-override launch

3. Explicit empty per-launch CLI arguments route to a terminal

Command override was cleared first (agentCmdOverrides: {}) so this launch is not the previous blocker.

UI: Checks → failing static analysis → View full details → Choose agent to fix check → Customize launch… → CLI arguments left empty (value === "") → Start agent.

Visible: new terminal-backed tab (not agent-session / Claude Chat). After toggling to the PTY, Claude Code is running in the terminal.

Backing: contentType: "terminal", launchConfig.agentCommand: "claude", launchConfig.agentArgs: "". Global extra args were still --dangerously-skip-permissions --model Opus and were not applied to this launch.

Customize launch dialog with empty CLI arguments
Empty CLI-args launch as terminal-backed chat
Empty CLI-args launch as Claude TUI in a PTY

Reachability note (empty agentArgs)

Empty CLI arguments are reachable, but only through Customize launch…. The Checks strip Fix primary button does not open that dialog; it launches with recipe.agentArgs omitted (undefined), which stayed on the structured route in this session. Presence ('') and omission are different, and only the customize dialog exercises the empty-string case.

Remaining gaps

  • Per-launch cwd was not exercised; no cwd field was on the customize-launch dialog used here.
  • Folder workspaces, SSH, and WSL were not exercised.
  • QA-created agent tabs were closed after capture so they would not keep working on the unrelated static-analysis failure.

No product files were changed. Temporary Electron profile and process were created only for this validation.

… 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.
@brennanb2025
brennanb2025 force-pushed the brennanb2025/structured-chat-launch-routing branch from 7316078 to 07d6bfc Compare September 17, 2026 00:53

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ 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-customization blocker maps back to the shipped tui_launch_command reason, 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.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.ts
  • src/main/runtime/rpc/methods/orchestration-worker-start-receipt-wording.test.ts
  • src/renderer/src/lib/agent-launch-route-input.test.ts
  • src/renderer/src/lib/agent-launch-route-input.ts
  • src/renderer/src/lib/agent-launch-routing.test.ts
  • src/renderer/src/lib/agent-launch-routing.ts
  • src/renderer/src/lib/launch-agent-in-new-tab.ts
  • src/renderer/src/lib/launch-agent-structured-chat-guard.test.ts
  • src/renderer/src/lib/launch-work-item-direct-route-preparation.test.ts
  • src/renderer/src/lib/launch-work-item-direct-route-preparation.ts
  • src/shared/structured-native-chat-launch-route.test.ts
  • src/shared/structured-native-chat-launch-route.ts
  • tests/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.

Comment on lines +1 to +78
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)
}
)
})

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 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.

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Review status: ready to merge

Final head: 07d6bfc96678201fc5048b2d0cd5a91660a60416 — mergeable, clean worktree, current with origin/main.

The review found and fixed one mixed-version compatibility issue during the rebase: the internal blocker is now tui-launch-customization, while the shipped receipt value remains tui_launch_command. The final routing mechanism is centralized and preserves the caller’s intent: omitted per-launch arguments can use structured chat, while explicit values including '' and null use the terminal path that can honor them. Global arguments and environment do not demote an ordinary launch.

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:

  • GitHub CI is green: static analysis, typecheck, 8/8 test shards, Linux package, Windows package, aggregate verify, and Pullfrog.
  • Focused launch-routing validation: 8 files, 130 tests.
  • Changed-file code-quality gate: 0 findings across all six scans.
  • Hidden macOS Electron QA verified branch identity and the real UI flows for global arguments, command override, and explicit empty per-launch CLI arguments.
  • Electron screenshots and backing-state evidence. These were captured before the final ancestry-only rebase; the post-rebase patch ID is identical.

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.

@brennanb2025

Copy link
Copy Markdown
Contributor Author

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 (7819605f71); its parent, merged #20944, had no reference to it. Subsequent work extended and preserved it without re-checking it against the model, and the reviews assessed whether the implementation was correct rather than whether the behaviour was wanted.

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.

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