Repository navigation
fix(linux): give the CLI one entrypoint by extracting the AppImage once - #15081
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📥 CommitsReviewing files that changed from the base of the PR and between 8f709a4582b8ce5cd25fd8181371bf218fe551f2 and 3b22569b72c1419755bbf85065333e1eb1aa0c6d. 📒 Files selected for processing (8)
Included review availability: Your plan provides up to 10 included reviews per hour; 0 remain after this review. 📝 WalkthroughWalkthroughLinux AppImage handling now validates runtime identity, extracts payloads into metadata-keyed cache generations, and exposes stable launcher endpoints. CLI installation and removal use transactional filesystem operations with race detection, ownership checks, pruning, and serialized registration locks. Dispatchers and terminal shims resolve extracted or bundled launchers directly. IPC repairs stale AppImage registrations, and PTY setup refreshes the Linux CLI shim for packaged runs. Tests cover extraction, races, cleanup, launcher publication, runtime validation, and IPC repair. Merge Risk: 🟡 Moderate · up to The PR replaces repeated AppImage launches with a cached stable Linux CLI launcher, but fresh extraction can still fail before publication, the documented root-owned /opt/orca setup is not writable as written, and some tests may be unreliable or platform-dependent; the launcher also trusts mutable user-cache targets at execution time. These are actionable merge-readiness risks that should be fixed or explicitly accepted before merging. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Linked Issues checkExplanation The implementation addresses all linked objectives [ Full details: Out of Scope Changes checkExplanation The production and test changes support the linked AppImage CLI objectives. Extraction, stable launcher publication, registration repair, cleanup, race handling, legacy migration, and terminal refresh are related implementation details. No unrelated feature changes are evident. ✨ Finishing Touches 💡 1📝 Generate docstrings 💡
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (1)
src/main/cli/linux-bare-orca-dispatcher.ts (1)
49-58: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick winResolve the launcher after the ownership check.
resolveStableLauncherPathnow runs first, and for an AppImage it callsensureAppImageExtractedRoot, which extracts the full payload. If the user owns~/.local/bin/orca, the function then returnsskipped-foreignand discards that work.orca servestartup pays the first-run extraction cost even when it cannot write a dispatcher.Move the
isOwnedDispatchercheck before launcher resolution. Theskipped-foreignresult then reportstarget: null, so update the tests for that state if you take this change.♻️ Proposed reordering
- const launcher = await resolveStableLauncherPath(options) - if (!launcher) { - return { state: 'skipped-launcher-missing', dispatcherPath, target: null } - } - // Why: only (re)write a dispatcher we previously created; leave a user's own // `orca` untouched rather than silently clobbering it on every serve start. if (existsSync(dispatcherPath) && !(await isOwnedDispatcher(dispatcherPath))) { - return { state: 'skipped-foreign', dispatcherPath, target: launcher } + return { state: 'skipped-foreign', dispatcherPath, target: null } + } + + const launcher = await resolveStableLauncherPath(options) + if (!launcher) { + return { state: 'skipped-launcher-missing', dispatcherPath, target: null } }Run the following script to find every assertion on the
skipped-foreigntarget:#!/bin/bash # Description: Locate consumers and assertions that read `target` for the skipped-foreign state. rg -n -C6 "skipped-foreign" src
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 81c06878-30a7-4c9d-982b-99b39268479a
📒 Files selected for processing (14)
docs/reference/headless-linux-server.mdsrc/main/cli/appimage-cli-wrapper.tssrc/main/cli/appimage-extracted-root.test.tssrc/main/cli/appimage-extracted-root.tssrc/main/cli/cli-installer.test.tssrc/main/cli/cli-installer.tssrc/main/cli/linux-bare-orca-dispatcher.test.tssrc/main/cli/linux-bare-orca-dispatcher.tssrc/main/cli/linux-terminal-orca-cli-shim.test.tssrc/main/cli/linux-terminal-orca-cli-shim.tssrc/main/cli/packaged-cli-assets.test.tssrc/main/cli/posix-shell-quote.tssrc/main/cli/wsl-cli-installer.tssrc/main/cli/wsl-cli-scripts.ts
💤 Files with no reviewable changes (1)
- src/main/cli/appimage-cli-wrapper.ts
Included review availability: Your plan includes up to 10 reviews per rolling hour; 6 remain after this review.
ef067ef to
25634e2
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
Greptile SummaryThe PR replaces repeated AppImage re-entry with a stable Linux CLI launcher backed by transactionally extracted, generation-keyed payloads.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains.
|
| Filename | Overview |
|---|---|
| src/main/cli/appimage-extracted-root.ts | Implements staged AppImage extraction, validation, atomic generation publication, and bounded retry handling. |
| src/main/cli/appimage-extraction-pruning.ts | Prunes obsolete generation roots while retaining selected, installed, and actively extracted payloads; the previously reported stale-snapshot race is now fenced by callers’ shared registration lock. |
| src/main/cli/appimage-registration-lock.ts | Provides the cache-scoped cross-process serialization used by AppImage publication and pruning paths. |
| src/main/cli/appimage-stable-launcher.ts | Defines the stable launcher and atomically managed live and installed endpoints. |
| src/main/cli/cli-installer.ts | Coordinates extraction, CLI registration, pruning, ownership-aware removal, and the shared AppImage lock. |
| src/main/cli/linux-bare-orca-dispatcher.ts | Installs the bare Linux dispatcher against the stable launcher and performs AppImage extraction and pruning while holding the registration lock. |
Sequence Diagram
sequenceDiagram
participant App as Orca AppImage
participant Lock as Registration lock
participant Cache as Generation cache
participant Endpoint as Stable endpoint
participant CLI as Registered CLI
App->>Lock: Acquire cache-scoped lock
Lock->>Cache: Extract and validate generation
Cache->>Endpoint: Atomically publish installed target
Lock->>Cache: Prune unprotected generations
Lock-->>App: Release lock
CLI->>Endpoint: Resolve stable launcher
Endpoint->>Cache: Execute selected payload
Reviews (23): Last reviewed commit: "refactor(linux): import bundled launcher..." | Re-trigger Greptile
There was a problem hiding this comment.
Actionable comments posted: 5
🧹 Nitpick comments (1)
src/main/cli/cli-installer-appimage-removal.test.ts (1)
174-178: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winMake the serialization assertion decisive.
The hook awaits one microtask, then asserts
siblingStatusReadsis0. The siblinginstall()first awaitswithAppImageRegistrationLock, which performsmkdirand lock-file I/O, so it cannot reachgetStatus()within a single microtask even if the lock did not serialize anything. The assertion therefore passes whether or not the lock works, and a regression inrunAppImageRegistrationOperationwould not fail this test.Record when the first operation releases the lock, then assert the ordering against that marker.
♻️ Proposed direction
+ let firstRemoveFinished = false + let siblingReadBeforeRelease = false let siblingInstall: Promise<unknown> | null = null siblingStatusReads = 0 firstInstaller.afterNextStatus = async () => { siblingInstall = secondInstaller.install() - await Promise.resolve() - expect(siblingStatusReads).toBe(0) } await firstInstaller.remove() + firstRemoveFinished = true expect(siblingInstall).not.toBeNull() await siblingInstall + expect(siblingReadBeforeRelease).toBe(false)Set
siblingReadBeforeReleaseinsideTrackingInstaller.getStatus()whenfirstRemoveFinishedis stillfalse.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: a7aaa018-4da0-452c-8129-2005f5026cb7
📒 Files selected for processing (34)
docs/reference/headless-linux-server.mdsrc/main/appimage-runtime-identity.test.tssrc/main/appimage-runtime-identity.tssrc/main/cli/appimage-cache-layout.tssrc/main/cli/appimage-extracted-root.test.tssrc/main/cli/appimage-extracted-root.tssrc/main/cli/appimage-extraction-pruning.test.tssrc/main/cli/appimage-extraction-pruning.tssrc/main/cli/appimage-registration-lock.tssrc/main/cli/appimage-stable-launcher.test.tssrc/main/cli/appimage-stable-launcher.tssrc/main/cli/cli-command-filesystem-transaction.tssrc/main/cli/cli-command-inspection.tssrc/main/cli/cli-command-installation-races.test.tssrc/main/cli/cli-command-installation.tssrc/main/cli/cli-command-privileged-transaction.test.tssrc/main/cli/cli-install-location.tssrc/main/cli/cli-installer-appimage-ownership.test.tssrc/main/cli/cli-installer-appimage-removal.test.tssrc/main/cli/cli-installer-contracts.tssrc/main/cli/cli-installer.test.tssrc/main/cli/cli-installer.tssrc/main/cli/legacy-appimage-cli-wrapper.tssrc/main/cli/linux-bare-orca-dispatcher.test.tssrc/main/cli/linux-bare-orca-dispatcher.tssrc/main/cli/linux-terminal-orca-cli-shim.test.tssrc/main/cli/linux-terminal-orca-cli-shim.tssrc/main/cli/packaged-cli-assets.test.tssrc/main/ipc/cli-appimage-stale-registration.test.tssrc/main/ipc/cli.tssrc/main/ipc/pty-ipc-mock-registry.tssrc/main/ipc/pty-ipc-suite-environment.tssrc/main/ipc/pty-restored-appimage-cli-shim-refresh.test.tssrc/main/ipc/pty/register-handlers.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- src/main/cli/linux-terminal-orca-cli-shim.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 5 remain after this review.
8152f54 to
8f709a4
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
There was a problem hiding this comment.
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: c62bcd10-061a-4f82-a69b-3dd5ed1010e9
📥 Commits
Reviewing files that changed from the base of the PR and between 14d39bd and 8f709a4582b8ce5cd25fd8181371bf218fe551f2.
📒 Files selected for processing (34)
docs/reference/headless-linux-server.mdsrc/main/appimage-runtime-identity.test.tssrc/main/appimage-runtime-identity.tssrc/main/cli/appimage-cache-layout.tssrc/main/cli/appimage-extracted-root.test.tssrc/main/cli/appimage-extracted-root.tssrc/main/cli/appimage-extraction-pruning.test.tssrc/main/cli/appimage-extraction-pruning.tssrc/main/cli/appimage-registration-lock.tssrc/main/cli/appimage-stable-launcher.test.tssrc/main/cli/appimage-stable-launcher.tssrc/main/cli/cli-command-filesystem-transaction.tssrc/main/cli/cli-command-inspection.tssrc/main/cli/cli-command-installation-races.test.tssrc/main/cli/cli-command-installation.tssrc/main/cli/cli-command-privileged-transaction.test.tssrc/main/cli/cli-install-location.tssrc/main/cli/cli-installer-appimage-ownership.test.tssrc/main/cli/cli-installer-appimage-removal.test.tssrc/main/cli/cli-installer-contracts.tssrc/main/cli/cli-installer.test.tssrc/main/cli/cli-installer.tssrc/main/cli/legacy-appimage-cli-wrapper.tssrc/main/cli/linux-bare-orca-dispatcher.test.tssrc/main/cli/linux-bare-orca-dispatcher.tssrc/main/cli/linux-terminal-orca-cli-shim.test.tssrc/main/cli/linux-terminal-orca-cli-shim.tssrc/main/cli/packaged-cli-assets.test.tssrc/main/ipc/cli-appimage-stale-registration.test.tssrc/main/ipc/cli.tssrc/main/ipc/pty-ipc-mock-registry.tssrc/main/ipc/pty-ipc-suite-environment.tssrc/main/ipc/pty-restored-appimage-cli-shim-refresh.test.tssrc/main/ipc/pty/register-handlers.ts
🚧 Files skipped from review as they are similar to previous changes (31)
- src/main/cli/linux-bare-orca-dispatcher.ts
- docs/reference/headless-linux-server.md
- src/main/ipc/pty-restored-appimage-cli-shim-refresh.test.ts
- src/main/cli/appimage-registration-lock.ts
- src/main/ipc/pty-ipc-mock-registry.ts
- src/main/ipc/cli.ts
- src/main/cli/linux-bare-orca-dispatcher.test.ts
- src/main/cli/cli-installer-appimage-removal.test.ts
- src/main/ipc/pty/register-handlers.ts
- src/main/cli/linux-terminal-orca-cli-shim.test.ts
- src/main/appimage-runtime-identity.test.ts
- src/main/cli/cli-command-privileged-transaction.test.ts
- src/main/cli/cli-command-inspection.ts
- src/main/cli/appimage-extraction-pruning.ts
- src/main/ipc/cli-appimage-stale-registration.test.ts
- src/main/cli/cli-installer-appimage-ownership.test.ts
- src/main/ipc/pty-ipc-suite-environment.ts
- src/main/cli/appimage-extracted-root.test.ts
- src/main/appimage-runtime-identity.ts
- src/main/cli/appimage-stable-launcher.ts
- src/main/cli/cli-install-location.ts
- src/main/cli/appimage-extraction-pruning.test.ts
- src/main/cli/cli-installer-contracts.ts
- src/main/cli/cli-installer.test.ts
- src/main/cli/appimage-stable-launcher.test.ts
- src/main/cli/appimage-extracted-root.ts
- src/main/cli/cli-command-installation-races.test.ts
- src/main/cli/appimage-cache-layout.ts
- src/main/cli/cli-command-filesystem-transaction.ts
- src/main/cli/linux-terminal-orca-cli-shim.ts
- src/main/cli/cli-installer.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 2 remain after this review.
9c8586f to
77671b3
Compare
|
thanks for reporting. looking into it |
6635923 to
1315eb8
Compare
486d1a6 to
a1318ea
Compare
a1318ea to
15e1388
Compare
Pruning removed 3215 of 3216 files from a superseded generation and always
stranded resources/app.asar, leaking ~105 MB per version update. Electron's
asar shim reports a *.asar file as a directory, so the recursive remove tried
to rmdir a real file and failed with ENOTEMPTY; the .catch(() => {}) hid it.
Reproduced end to end on Ubuntu 24.04: 519M -> 623M across one update, and
519M again once the payload is actually reclaimed.
removeExtractedAppImagePayload holds process.noAsar for the removal, counted
so overlapping removals cannot hand the shim back early, and the prune site
now warns with the path instead of swallowing the rejection. All three
removal sites use it -- staging cleanup and displaced roots leaked the same
way.
Also reclaim symlinks left by a packaged deb/rpm install, which the
extracted-cache-only rule turned into a hard conflict on a deb -> AppImage
migration, and name the remedy in the conflict error.
`retries: 1000` caps the attempt count, not elapsed time, so at up to 1s per attempt an IPC-driven registration could hang ~16 minutes against a wedged holder with no feedback. A legitimate holder is bounded by the extraction timeout, so wait that plus slack and then fail with a message naming the lock file, rather than hanging. `maxRetryTime` is forwarded verbatim to the `retry` package by proper-lockfile.
The extracted-payload cache key hashed ctime alongside dev/ino/size/mtime. ctime moves on any inode metadata write -- `chmod +x`, which every AppImage user is told to run, plus `chown`, an ACL or SELinux relabel, and a backup restore -- none of which alter a byte of the payload. Measured on Ubuntu 24.04: `chmod +x` leaves dev, ino, size and mtime identical and moves ctime alone, so the key changed and the next launch paid a full ~519 MB re-extraction and a multi-second stall to rebuild a payload it already had, then pruned the old generation. Key on content identity instead. An in-place content change moves mtime and almost always size; a replacement moves the inode. The existing replace-in-place test still passes.
ELI5
The registered Linux CLI used to reopen the outer AppImage for every command. That path can require FUSE and can inject Chromium flags that Electron's Node mode rejects, so the CLI was broken on stock modern Ubuntu and in containers. Orca now extracts the payload once and installs one stable launcher whose target can move safely across app restarts and upgrades.
What Changed
One stable entrypoint
${XDG_CACHE_HOME:-~/.cache}/orca/appimage/<namespace>/<generation>.launcher/orca-ide, never to the outer AppImage or a transient mount.installedendpoint; legacylivelinks are ignored by the launcher and removed during migration.Extraction and publication are transactional
dev,ino, size, mtime, and ctime).Ownership, install, and removal are fenced
installedownership is namespace-scoped, so one AppImage path cannot unregister or prune another path's payload.Cleanup preserves live work
liveendpoint intact.livewithout performing extraction, so PTY creation does not block on AppImage I/O.Why
The old registered wrapper re-entered
AppRun. On Ubuntu 24.04, restricted user namespaces makeAppRunprepend--no-sandbox; Electron Node mode rejects that option before Orca runs (#11609). The same wrapper also depended on mounting the outer AppImage, so it failed where/dev/fusewas unavailable (#12530).Extracting once removes both dependencies while preserving normal CLI latency. The cache cost is bounded to active/installed generations and reclaimed on later registration or unregister.
Linked Issue
Fixes #11609
Fixes #12530
Fixes #16650
Visual Proof
N/A — Linux packaging and CLI entrypoint behavior only; no rendered UI changes.
Testing
pnpm tc:nodegit diff --checkStack 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 --checkpassed. 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 missingssh2.utils, and a renderer context-menu failure seen only in the full run (the isolated test passed). The zsh and SSH failures reproduce on pristineorigin/main; fresh CI is running on the published heads.The tests cover concurrent registration, AppImage replacement during extraction, partial/malformed destinations, endpoint publication races, namespace isolation, privileged and unprivileged command-path races, stale registrations, restored-terminal refresh, pruning grace, legacy migration, and rollback/preservation failures.
The concurrent-registration test now fails if the sibling reads status before the first operation releases the cache-scoped lock.
The headless AppImage instructions now download the artifact before extraction and run extraction with
sudofor the root-owned/opt/orcadirectory.The elegance pass removed the unnecessary
cli-installerre-export; the dispatcher imports the narrow bundled-launcher module directly.AI Disclosure
Review
PR 1 of 7; reviewable on its own. The complete stack is ordered as follows:
Agent skill upstream boundary
docs/reference/agent-skill-sharing-upstream-boundary.mdand copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.Notes
Residual follow-ups
fstat.Both are defense-in-depth P2 follow-ups; current publication and pruning behavior remains bounded and tested.
Checklist
mainN/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)Review fixes applied after review (2026-09-01)
Three defects found in review, all fixed in
c23953a5a00and verified on Ubuntu 24.04 hardware.Superseded generations leaked ~105 MB each. Pruning removed 3215 of 3216 files and always stranded
resources/app.asar. Electron's asar shim reports a*.asarfile as a directory, so the recursive remove tried tormdira real file, failed withENOTEMPTY, and.catch(() => {})hid it. Reproduced end to end twice with different cache hashes (519M → 623M across a single version change), then confirmed reclaimed in a packaged build: registration 2 leavesduat 519M with one generation, no manual step and no warning.removeExtractedAppImagePayloadnow holdsprocess.noAsarfor the removal, counted so overlapping removals cannot hand the shim back early. All three removal sites use it — staging cleanup (appimage-extracted-root.ts:182) and displaced roots (:230) leaked identically, not just the prune site. The prune site now warns with the path instead of swallowing the rejection.A deb → AppImage migration wedged on its own leftover symlink. The Linux reclaim rule recognised only extracted-cache launchers, so a symlink into
/opt/Orca/resources/bin/orca-idefrom a previous packaged install became a hard conflict. Packaged-install prefixes are reclaimable again; the existing refusal of arbitraryresources/binpaths is unchanged and still covered by its test.The conflict error named the offending path but not the remedy. It now says what to do.
Verification
pnpm tcclean. The packaged CLI launch contract passes 8/8 in a restricted Ubuntu container with no/dev/fuseand unprivileged user namespaces denied, and fails 4/8 against a stock release AppImage — three of those at status 133 (SIGTRAP) — so the harness has real detection power rather than rubber-stamping any binary.Known gaps, tracked rather than fixed
Registration lock has no acquisition deadline (~15 min worst case against a wedged holder); pruning protects only the current and
installedroots, so a root another running version is exec'ing from is eligible; a crash mid-unregister can leave a gutted root that reports complete.User-facing regressions
Not zero. Three, plus three known gaps.
cli-install-location.tsnow reportsinstallMethod: 'symlink'unconditionally on Linux, dropping the AppImage'wrapper'branch, so an older build finds a symlink where it expects a wrapper. Workaround: delete~/.local/bin/orca-ideand re-register. Only bites on downgrade.~~3. A wedged registration lock can hang an IPC-driven install for ~15 minutes.~~ Removed.
retriescaps the attempt count, not elapsed time; amaxRetryTimewall-clock deadline is now forwarded toproper-lockfile, and a wedged holder produces a message naming the lock file instead of a silent hang.Known gaps, tracked not fixed: pruning protects only the current and
installedroots, so a root a different running Orca version is exec'ing from is eligible for removal; and a crash mid-unregister can leave a gutted root that reports complete and then fails at exec.Found in review and fixed here: superseded generations leaked ~105 MB each (reproduced twice, verified reclaimed in a packaged build), and a deb → AppImage migration wedged on its own leftover
/opt/Orcasymlink.