orca/src/cli
Wooseong Kim f057cbc85f
fix(serve): recognize CLI-form serve args on the Electron process (#12818)
* fix(serve): recognize CLI-form serve args on the Electron process

When the binary is launched as `… serve --port …` without the CLI rewrite
that injects `--serve`, normalize argv so isServeMode, headless GPU flags,
and serve option parsing all engage.

Preserves existing `--serve*` flag behavior for the CLI-spawned path.

Fixes #12677

* fix(serve): treat only CLI subcommand position as serve

Parse bare `serve` as the first positional token after flags/values so an
option value named `serve` cannot enable headless mode.

Addresses CodeRabbit on #12818.

* fix(serve): keep CLI redirects ahead of the serve argv rewrite

Rewriting argv before maybeRedirectAppImageCliLaunch replaced the `serve`
positional with `--serve`, so the redirect's command-name lookup saw a port
number and bailed — dropping AppImage serve launches out of the CLI path.

Also translate `--port=6768` (the CLI accepts it, getServeOptions only reads
the next token) and the mixed `--serve --port` form, so a security-shaped flag
like `--no-pairing` can no longer read as accepted while pairing stays on.
Map lookups replace `in` on object literals, which turned a stray `serve
toString` positional into a function spliced onto argv.

* fix(serve): close the CLI-form serve gaps found in review

second-instance: shouldActivateDesktopForSecondInstance matched only `--serve`,
so a duplicate `<binary> serve --port …` — the ExecStart shape documented in
docs/reference/headless-linux-server.md — promoted the live headless server to a
desktop window, un-fixing #11935 on exactly the launch shape this PR legitimizes.

findServeSubcommandIndex consumed a flag's value unconditionally while the
rewrite consumed it only when the next token was not flag-shaped. The two could
disagree and swallow the `serve` token, leaving `--serve` uninjected: #12677
again in a new shape (`--port --port serve`, `--port -- serve`). Both scans now
share one definition of value consumption.

`<binary> serve --help` / `serve help` bound a network-exposed runtime server
with pairing on and printed nothing; the AppImage redirect already routes those
three tokens to the CLI, so refuse them here too.

`--no-pairing=false` translated to `--serve-no-pairing` with the value dropped,
disabling pairing for an operator who asked for the opposite. The CLI reads its
serve booleans as `flags.get(name) === true`, so a boolean is now translated only
in its bare form and the `=` form rides through as the CLI treats it.

Tests: spec-derived parity between src/cli/specs/serve.ts and the rewrite,
covering both ends of the contract (serveOrcaApp and getServeOptions); a
source-text lock on the index.ts redirect/rewrite ordering, which reverted
silently green before; an exhaustive self-consistency property test; and the
real GUI launch argv shapes that must never enter serve mode.

---------

Co-authored-by: Jinwoo-H <Jinwoo-H@users.noreply.github.com>
2026-08-06 23:56:34 -07:00
..
handlers Add per-worker model and effort overrides (#12851) 2026-08-05 21:17:45 -07:00
runtime fix(agent-hooks): resumed Claude Code session gets its sidebar agent row at SessionStart (STA-3386) (#12859) 2026-08-05 22:06:36 -07:00
specs Add per-worker model and effort overrides (#12851) 2026-08-05 21:17:45 -07:00
agent-context.test.ts
agent-context.ts
args.test.ts feat(cli): add `orca account add` / `account list` for headless hosts (Claude + Codex) (#9177) 2026-07-30 12:50:07 -07:00
args.ts perf(runtime): gate terminal.list visual layouts (#12450) 2026-08-04 17:50:52 -07:00
base64-payload-byte-count.test.ts
base64-payload-byte-count.ts
browser-format.ts fix(browser): add native-UA session profiles (#12608) 2026-08-04 19:07:23 -07:00
browser-handler-groups.ts perf(cli): load only the handler group a command dispatches into (#10883) 2026-07-27 01:01:25 -07:00
browser.test.ts fix(browser): add native-UA session profiles (#12608) 2026-08-04 19:07:23 -07:00
bundled-skill-guides.ts Add per-worker model and effort overrides (#12851) 2026-08-05 21:17:45 -07:00
codex-command-classification.test.ts
codex-command-classification.ts
command-spec.ts fix(quality): enforce performance-safe lint baseline (#11074) 2026-07-27 20:54:02 -07:00
command-suggestion.test.ts
command-suggestion.ts fix(quality): enforce performance-safe lint baseline (#11074) 2026-07-27 20:54:02 -07:00
computer-format.ts Revert "fix(memory): bound OOM-prone accumulators (#10179)" (#10255) 2026-07-23 18:35:31 -07:00
dispatch.ts perf(cli): construct the runtime client only when a command needs it (#10919) 2026-07-27 17:16:01 -07:00
emulator-logcat-format.test.ts
emulator-logcat-format.ts
emulator-permissions-args.ts
flags.test.ts
flags.ts perf(cli): construct the runtime client only when a command needs it (#10919) 2026-07-27 17:16:01 -07:00
format-recovery.test.ts
format.test.ts Implement robust orchestration primitives and connected-server workers (#9925) 2026-07-27 12:31:37 -07:00
format.ts perf(cli): construct the runtime client only when a command needs it (#10919) 2026-07-27 17:16:01 -07:00
handler-group-manifest.test.ts perf(cli): load only the handler group a command dispatches into (#10883) 2026-07-27 01:01:25 -07:00
handler-group-manifest.ts feat(orchestration): coordinator-driven release of settled worker terminals (STA-905) (#12355) 2026-08-03 17:17:26 -07:00
help.ts Add per-worker model and effort overrides (#12851) 2026-08-05 21:17:45 -07:00
index.test.ts perf(runtime): gate terminal.list visual layouts (#12450) 2026-08-04 17:50:52 -07:00
index.ts feat(cli): add `orca account add` / `account list` for headless hosts (Claude + Codex) (#9177) 2026-07-30 12:50:07 -07:00
linear-format.test.ts feat(linear): add MCP-compatible issue listing (#9672) 2026-07-21 13:16:44 -07:00
linear-format.ts feat(linear): add MCP-style save issue (#9670) 2026-07-21 13:25:22 -07:00
linear-request-builders.ts Revert "fix(memory): bound OOM-prone accumulators (#10179)" (#10255) 2026-07-23 18:35:31 -07:00
linear-save-issue-request.ts feat(linear): add MCP-style save issue (#9670) 2026-07-21 13:25:22 -07:00
main-module-bundle-parity.test.ts Fix packaged skills CLI runtime ownership (#11627) 2026-07-30 18:27:16 -07:00
project-format.ts
registry-parity.test.ts
registry-parity.ts
repo-path-arguments.ts
runtime-client-deferral.test.ts perf(cli): construct the runtime client only when a command needs it (#10919) 2026-07-27 17:16:01 -07:00
runtime-client.test.ts fix(orchestration): preserve active workers across updates (#11271) 2026-07-29 11:31:35 -07:00
runtime-client.ts
selectors.ts chore: condense code comments (#12008) 2026-08-01 14:24:31 -07:00
serve-electron-flag-parity.test.ts fix(serve): recognize CLI-form serve args on the Electron process (#12818) 2026-08-06 23:56:34 -07:00
shell-command-quote.test.ts
shell-command-quote.ts
skills.test.ts fix(windows): stop rejecting .cmd spawns under Program Files (x86) (#11686) 2026-07-31 01:01:35 -07:00
terminal-format.test.ts fix(runtime): coalesce concurrent host terminal focus (#11841) 2026-08-03 02:18:05 -07:00
terminal-format.ts fix(runtime): coalesce concurrent host terminal focus (#11841) 2026-08-03 02:18:05 -07:00
test-fixtures.ts
vocabulary-policy.test.ts
vocabulary-policy.ts
workspace-format.ts fix(memory): clarify Resource Manager accounting (#10821) 2026-07-26 19:46:29 -07:00
worktree-project-target.ts