Skip to content

fix(linux): stop CLI commands from falling through to Chromium startup - #15083

Merged
nwparker merged 8 commits into
nwparker/linux-cli-single-entrypointfrom
nwparker/linux-cli-launch-redirect
Sep 1, 2026
Merged

nwparker merged 8 commits into
nwparker/linux-cli-single-entrypointfrom
nwparker/linux-cli-launch-redirect

Conversation

@nwparker

@nwparker nwparker commented Aug 17, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 14 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​664 $\color{#cf222e}{\Huge{\mathbf{−}}}$​377 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​287
Prod 13 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​482 $\color{#cf222e}{\Huge{\mathbf{−}}}$​409 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​73

ELI5

Linux CLI commands are launched by an Electron binary. If Orca fails to recognize a command, the process continues into Chromium instead of running as Node; on a headless host that can crash before printing anything. This PR unifies the launch redirect, covers every current CLI command, and makes command-list drift fail CI.

What Changed

  • Replaces the separate AppImage and packaged-entry redirect modules with one cli-launch-redirect.
  • Handles both trusted launch shapes:
    • the computed unpacked CLI entry path on every platform;
    • a known first command positional for packaged Linux binaries.
  • Keeps direct serve in the Electron process so its signal handlers own the server, Xvfb, and daemon lifecycle; help still routes to the CLI.
  • Shares global value flags so values such as --environment status are not mistaken for commands.
  • Moves the import-free command-name list to main startup and adds a bidirectional, sorted parity test against COMMAND_SPECS.
  • Strips pre-command Chromium switches that Node mode rejects, fences redirect recursion, and reports missing entry/spawn failures with non-zero status.
  • Runs the supported Linux launcher with ELECTRON_RUN_AS_NODE=1 unconditionally.
  • Mirrors AppRun's sandbox fallback when the CLI launches an extracted AppImage tree, and forwards Linux SIGHUP through the serve supervisor.

The consolidation reduces net production code while retaining the Windows entry-path behavior.

Why

Ten top-level commands were missing from the previous hand-maintained list, including skills, diagnostics, project, and vm. The old redirect also required AppImage environment state, so extracted trees and deb/rpm installs could skip it. In either case a text command fell through to Chromium startup and could die during display initialization (#14229).

Chromium sandbox failures that occur before JavaScript remain outside an in-process redirect. The bundled resources/bin/orca-ide launcher is the supported boundary because Electron reads ELECTRON_RUN_AS_NODE before Chromium initializes; #15081 gives AppImage installs a stable path to that launcher.

Linked Issue

Fixes #14229
Fixes #13004
Refs #17412

Visual Proof

N/A — Linux CLI startup behavior only; no rendered UI changes.

Testing

  • 10 changed test files / 148 tests
  • pnpm tc:node
  • pnpm tc:cli
  • changed-code quality, full lint/readiness gates, and git diff --check

Stack readiness evidence on the published rebased stack (main@212c0e42): 56 changed test files, 785 tests passed, and 4 platform-gated skips. Typecheck, reliability/max-lines/runtime-Electron ratchets, changed-code quality/React Doctor, formatting, oxlint, shellcheck, and git diff --check passed. The full-suite control run had 7 failures in 3 untouched files: the zsh non-ASCII wrapper rename collision, the SSH host-key mock's missing ssh2.utils, and a renderer context-menu failure seen only in the full run (the isolated test passed). The zsh and SSH failures reproduce on pristine origin/main; fresh CI is running on the published heads.

Coverage includes both argv shapes, Linux/macOS/Windows gating, case-insensitive Windows paths, global flag values, help and direct serve, Chromium-switch placement, recursion, missing entrypoints, spawn failure, environment sanitation, extracted-tree sandbox fallback, signal forwarding, command-spec parity, command-named project selectors in both split and equals forms (--project project project setups and --project=project project setups), open-url redirection, and the AUR serve wrapper injected desktop flags.

The elegance pass removed a redundant command-membership check and uses the shared boundary result directly.

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

AI Disclosure

Review

PR 2 of 7, stacked on #15081.

  1. fix(linux): give the CLI one entrypoint by extracting the AppImage once #15081 — one stable AppImage CLI entrypoint
  2. fix(linux): stop CLI commands from falling through to Chromium startup #15083 — unified launch redirect
  3. fix(linux): report a missing display instead of dying in uv_close #15084 — missing-display diagnosis
  4. test(linux): add a packaged-artifact contract for the CLI launch paths #15085 — packaged-artifact launch contract and rpm parity
  5. fix(linux): require static AppImage runtimes #17319 — static AppImage runtime validation
  6. fix(linux): move deb/rpm update installation outside Orca #17318 — manual deb/rpm package installation handoff
  7. docs(linux): document orcad update restart safety #17320 — orcad restart-ownership safety documentation

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 wire, mobile, persistence, or provider contract changes; no mobile-facing RPC/protocol/pairing surface was touched.

  • Windows retains the trusted entry-path redirect; direct command matching remains Linux-only.

  • Folder workspaces and SSH targets are unaffected because redirection occurs in the local packaged process before workspace resolution.

  • Residual P2: an unknown split-token Chromium value flag whose value exactly matches a CLI command remains ambiguous; the equals form is unambiguous.

Checklist

  • Rebased onto fix(linux): give the CLI one entrypoint by extracting the AppImage once #15081
  • This PR is small and focused
  • I explained what changed and why (including ELI5)
  • 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)

User-facing regressions

None identified.

The redirect keeps its isPackaged gate but no longer requires !env.APPIMAGE && !env.APPDIR, so it now also covers extracted-AppRun launches. That broadening is deliberate and is required by the extraction work in #15081 — without it, a CLI command run through the extracted launcher would fall through to a GUI launch. Review looked specifically for a case where a launch that previously opened the GUI is now redirected to the CLI and did not find one.

Verified by the packaged-artifact contract in #15085: both direct-binary cases and both GUI cases pass on this stack and crash at status 133 against a stock release AppImage.

@greptile-apps

greptile-apps Bot commented Aug 30, 2026 •

Copy link
Copy Markdown

Greptile Summary

The PR consolidates packaged CLI launch redirection, shares command-boundary parsing, keeps direct serve launches in Electron, and adds Linux launcher and signal-handling support.

  • Replaces platform-specific redirect modules with a unified startup redirect.
  • Aligns command-name coverage with CLI command specifications.
  • Adds extracted-AppImage sandbox fallback and Linux SIGHUP forwarding.

Confidence Score: 4/5

The PR is not yet safe to merge because the previously reported command-named project selector can still be discarded and produce unfiltered results.

The new scanner still selects the value in --project project setups as the project setups command boundary, after which parsing stores --project as boolean true and the handler treats the selector as absent.

Files Needing Attention: src/shared/cli-argument-boundary.ts, src/cli/args.ts, src/cli/args.test.ts

Important Files Changed

Filename Overview
src/shared/cli-argument-boundary.ts Introduces shared command-boundary detection, but the previously reported command-named selector case remains reachable.
src/cli/args.ts Adopts the shared boundary helper; a selector immediately preceding a matching command can still be stored as boolean rather than as its string value.
src/main/startup/cli-launch-redirect.ts Consolidates packaged entry-path and Linux command-form redirection with recursion fencing and environment sanitation.
src/cli/runtime/launch.ts Adds extracted-AppImage sandbox fallback for open and serve child launches.
src/cli/args.test.ts Adds selector regression coverage, but the split-token fixture differs from the exact outstanding three-token invocation.
src/main/index.ts Installs the unified redirect before serve-mode argv normalization.
src/cli/runtime/serve-update-supervisor.ts Extends Linux foreground serve signal forwarding to SIGHUP.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[Packaged Electron invocation] --> B{CLI entry path or Linux command detected?}
  B -->|Non-serve CLI| C[Restart Electron with ELECTRON_RUN_AS_NODE]
  B -->|Direct serve| D[Normalize serve argv in main process]
  B -->|Desktop launch| E[Continue Chromium startup]
  C --> F[CLI parser and command handler]
  D --> G[Serve lifecycle and signal ownership]
Loading

Reviews (22): Last reviewed commit: "fix(linux): strip injected Chromium swit..." | Re-trigger Greptile

Comment thread src/main/startup/cli-launch-redirect.ts Resolved
@nwparker
nwparker force-pushed the nwparker/linux-cli-single-entrypoint branch from 25634e2 to 8152f54 Compare August 30, 2026 02:09
@nwparker
nwparker force-pushed the nwparker/linux-cli-launch-redirect branch from 6ef707d to 7e3a2ce Compare August 30, 2026 02:14
Comment thread src/shared/cli-argument-boundary.ts Resolved
@nwparker
nwparker force-pushed the nwparker/linux-cli-single-entrypoint branch from 8152f54 to 8f709a4 Compare August 30, 2026 03:42
@nwparker
nwparker force-pushed the nwparker/linux-cli-launch-redirect branch from 7e3a2ce to de05897 Compare August 30, 2026 03:42
@nwparker
nwparker force-pushed the nwparker/linux-cli-single-entrypoint branch from 8f709a4 to 5b57909 Compare August 30, 2026 04:22
@nwparker
nwparker force-pushed the nwparker/linux-cli-launch-redirect branch 2 times, most recently from 3d9f13c to ec38c08 Compare August 30, 2026 04:57
@nwparker
nwparker force-pushed the nwparker/linux-cli-single-entrypoint branch from ea9526a to 3b22569 Compare August 30, 2026 05:09
@nwparker
nwparker force-pushed the nwparker/linux-cli-launch-redirect branch 2 times, most recently from 3375af7 to 746490c Compare August 30, 2026 05:15
@nwparker
nwparker force-pushed the nwparker/linux-cli-single-entrypoint branch 2 times, most recently from 34926b9 to bdf2c36 Compare August 30, 2026 06:24
@nwparker
nwparker force-pushed the nwparker/linux-cli-launch-redirect branch from 746490c to a3d0e25 Compare August 30, 2026 06:26
@nwparker
nwparker force-pushed the nwparker/linux-cli-single-entrypoint branch from bdf2c36 to c60eb21 Compare August 30, 2026 08:28
@nwparker
nwparker force-pushed the nwparker/linux-cli-launch-redirect branch 2 times, most recently from 7350a97 to 6f3166e Compare August 30, 2026 08:35
@nwparker
nwparker force-pushed the nwparker/linux-cli-single-entrypoint branch from c60eb21 to e00978c Compare August 30, 2026 08:37
Comment thread src/shared/cli-argument-boundary.ts Resolved
@nwparker
nwparker force-pushed the nwparker/linux-cli-single-entrypoint branch from e00978c to 9c8586f Compare August 30, 2026 08:58
@nwparker
nwparker force-pushed the nwparker/linux-cli-launch-redirect branch from 6f3166e to 1e152b9 Compare August 30, 2026 08:58
@nwparker
nwparker force-pushed the nwparker/linux-cli-single-entrypoint branch from 9c8586f to 77671b3 Compare August 30, 2026 09:21
@nwparker
nwparker force-pushed the nwparker/linux-cli-launch-redirect branch from 1e152b9 to e40c806 Compare August 30, 2026 09:21
@nwparker
nwparker force-pushed the nwparker/linux-cli-single-entrypoint branch from 3279a24 to 1cd8794 Compare August 31, 2026 03:13
@nwparker
nwparker force-pushed the nwparker/linux-cli-launch-redirect branch from 3618edc to 1e37307 Compare August 31, 2026 03:13
@nwparker
nwparker force-pushed the nwparker/linux-cli-single-entrypoint branch from 1cd8794 to fd9f582 Compare August 31, 2026 03:27
@nwparker
nwparker force-pushed the nwparker/linux-cli-launch-redirect branch 2 times, most recently from 2bc13e6 to e7c373b Compare August 31, 2026 05:19
@nwparker
nwparker force-pushed the nwparker/linux-cli-single-entrypoint branch 2 times, most recently from 486d1a6 to a1318ea Compare August 31, 2026 11:59
@nwparker
nwparker force-pushed the nwparker/linux-cli-launch-redirect branch from e7c373b to aba62d5 Compare August 31, 2026 11:59
@nwparker
nwparker force-pushed the nwparker/linux-cli-single-entrypoint branch from a1318ea to 15e1388 Compare August 31, 2026 13:02
@nwparker
nwparker force-pushed the nwparker/linux-cli-launch-redirect branch from aba62d5 to 000f798 Compare August 31, 2026 13:03
@nwparker
nwparker force-pushed the nwparker/linux-cli-launch-redirect branch 2 times, most recently from d06b724 to 5435a61 Compare September 1, 2026 10:07
@nwparker
nwparker force-pushed the nwparker/linux-cli-launch-redirect branch from 5435a61 to 4f90ecf Compare September 1, 2026 10:28
@nwparker
nwparker merged commit b88f03f into nwparker/linux-cli-single-entrypoint Sep 1, 2026
32 checks passed
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