Skip to content

fix(serve): keep Chromium switches out of CLI redirect - #17633

Merged
Jinwoo-H merged 1 commit into
mainfrom
aug30-sta6020-serve-flag-regression
Aug 31, 2026
Merged

Jinwoo-H merged 1 commit into
mainfrom
aug30-sta6020-serve-flag-regression

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​94 $\color{#cf222e}{\Huge{\mathbf{−}}}$​8 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​86
Prod 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​32 $\color{#cf222e}{\Huge{\mathbf{−}}}$​7 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​25

Summary

Refs STA-6020 and GitHub #17412.

Linux AppImage launches receive Electron Chromium switches such as --disable-features=... before the serve subcommand. The AppImage CLI redirect was forwarding that switch into the strict Node CLI parser, so an otherwise valid serve launch failed with Unknown flag --disable-features for command: serve.

This change keeps affected direct serve launches in Electron, where the switch belongs, while preserving the existing validating CLI redirect for clean serve invocations.

Deterministic reproduction

Baseline:
LIBGL_ALWAYS_SOFTWARE=1 stably-orca serve
or:
AppRun --disable-features=FedCm,DirectSockets serve --port 6768

The baseline redirect forwarded the Chromium switch to the CLI and exited 1 with the unknown-flag error.

Candidate:

  • pre-command --disable-features makes the AppImage redirect return null;
  • Electron normalizes serve --port 6768 to --serve --serve-port 6768;
  • clean serve still goes through CLI validation.

Changes

  • Detect --disable-features in both equals and separate-value argv forms while locating the command.
  • Keep only direct serve launches with that pre-command Chromium switch in Electron.
  • Leave help handling and post-command flag validation unchanged.
  • Add focused regression coverage for direct serve, help, clean CLI routing, launch ordering, and argv normalization.

Validation

  • Focused startup suites: 31 passed.
  • Full src/main/startup: 304 passed, 6 skipped; two unrelated environment-sensitive timeout tests failed (secure-dns-census and the macOS-only Electron rebuild test).
  • pnpm tc:node
  • pnpm tc:cli
  • pnpm run check:code-quality:changed
  • pnpm run build:cli
  • pnpm run build:electron-vite

All touched-code gates passed.

Tradeoff

A user-supplied pre-command --disable-features is indistinguishable from Electron injection and therefore takes the Electron path, where unknown non-serve flags are permissive. Port and project-root validation remain active. This avoids globally weakening the CLI parser or changing remote/wire behavior.

@greptile-apps

greptile-apps Bot commented Aug 31, 2026

Copy link
Copy Markdown

Greptile Summary

This PR keeps direct AppImage serve launches containing a pre-command Chromium --disable-features switch in Electron while preserving strict CLI routing for clean invocations.

  • Recognizes both equals and space-separated forms of the Chromium switch.
  • Reuses value-taking argument classification during serve-mode normalization.
  • Adds regression coverage for routing, help behavior, ordering, and normalization.

Confidence Score: 5/5

The PR appears safe to merge with no concrete changed-code failure identified.

The revised routing distinguishes Chromium-injected direct serve launches from clean CLI invocations, and the normalization logic consistently preserves the switch while translating serve arguments.

Important Files Changed

Filename Overview
src/main/startup/appimage-cli-redirect.ts Adds Chromium-switch-aware command scanning and keeps affected direct serve launches in Electron without weakening clean CLI validation.
src/main/startup/serve-mode-argv.ts Classifies the space-separated Chromium switch as value-taking so its value cannot be mistaken for the serve subcommand.
src/main/startup/appimage-cli-redirect.test.ts Covers clean and Chromium-injected serve routing, separate-value switches, help handling, and child-process redirection.
src/main/startup/serve-mode-argv.test.ts Verifies that Chromium switches survive direct serve argument normalization.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[AppImage argv] --> B{Recognized CLI command?}
    B -->|No| E[Continue in Electron]
    B -->|Yes| C{Direct serve with pre-command disable-features?}
    C -->|Yes| E
    C -->|No| D[Redirect to strict Node CLI]
    E --> F[Normalize serve argv]
    F --> G[Electron serve mode]
Loading

Reviews (1): Last reviewed commit: "fix(serve): keep Chromium switches out o..." | Re-trigger Greptile

@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

  • Serve redirect exemption — getAppImageCliArgs now returns null (stay in Electron) when the resolved command is serve and a pre-command --disable-features is present, so Electron's own normalizeServeModeArgv rewrites serve --port N → --serve --serve-port N instead of the strict CLI parser rejecting the switch.
  • Value-aware command scan — findFirstCommandCandidate is split into an index-returning helper with a shared flagName, and --disable-features is added to both CLI_FLAGS_WITH_VALUES (redirect) and VALUE_TAKING_FLAGS (serve-mode-argv) so equals- and space-separated forms both resolve the serve subcommand.
  • Regression coverage — new cases pin the pre-command switch (both forms), the post-command exclusion, --help routing, redirect-before-rewrite ordering, and argv normalization preserving the injected switch.

ℹ️ Single-switch sentinel is load-bearing but currently safe

The ELECTRON_LAUNCH_SWITCHES set contains only --disable-features. This is correct today because disableUnsupportedChromiumFeatures() and optOutOfHiddenPageWakeUpThrottling() both append disable-features unconditionally on every packaged Linux launch, so any Electron relaunch that injects Chromium switches will always carry it. If that unconditional append is ever removed or made conditional while another injected switch (e.g. --enable-features, --max-active-webgl-contexts) still forces a relaunch, this sentinel would silently stop matching and the regression would return. No change needed now, but worth a comment on ELECTRON_LAUNCH_SWITCHES noting that invariant.

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

@Jinwoo-H
Jinwoo-H merged commit 3cb9b5d into main Aug 31, 2026
30 checks passed
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
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