Repository navigation
fix(serve): keep Chromium switches out of CLI redirect - #17633
Conversation
Greptile SummaryThis PR keeps direct AppImage
Confidence Score: 5/5The 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.
|
| 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]
Reviews (1): Last reviewed commit: "fix(serve): keep Chromium switches out o..." | Re-trigger Greptile
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Serve redirect exemption —
getAppImageCliArgsnow returnsnull(stay in Electron) when the resolved command isserveand a pre-command--disable-featuresis present, so Electron's ownnormalizeServeModeArgvrewritesserve --port N→--serve --serve-port Ninstead of the strict CLI parser rejecting the switch. - Value-aware command scan —
findFirstCommandCandidateis split into an index-returning helper with a sharedflagName, and--disable-featuresis added to bothCLI_FLAGS_WITH_VALUES(redirect) andVALUE_TAKING_FLAGS(serve-mode-argv) so equals- and space-separated forms both resolve theservesubcommand. - Regression coverage — new cases pin the pre-command switch (both forms), the post-command exclusion,
--helprouting, 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.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

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:
Changes
Validation
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.