Repository navigation
feat(cli): add orca update and orca version commands - #9406
scastanoh21 wants to merge 8 commits into
Conversation
The `orca` CLI ships inside the Electron app bundle (its version is the
app version), so it cannot self-update independently. Instead these
commands drive the app's existing electron-updater over the runtime RPC
the CLI already speaks.
- New RPC methods `updater.{getVersion,getStatus,check,download,install}`
(src/main/runtime/rpc/methods/updater.ts, registered in the method
index). They delegate to the existing src/main/updater.ts functions and
app.getVersion(); no hand-rolled installer, and signature verification
is untouched. Not added to the mobile RPC allowlist, so paired mobile
clients cannot trigger an install (local CLI and full-trust SSH relay
can).
- `orca version` reports the installed version.
- `orca update [--check] [--prerelease] [--json]`: bounded polling until a
terminal updater state; `--check` never installs; plain `update` checks
then downloads then installs only when an update is available. Human
download progress renders on a single in-place TTY line and falls back
to newline output when stdout is not a TTY; the --json contract is
unchanged.
- Graceful handling when the app is not running: actionable next steps
instead of a stack trace (brew upgrade --cask on macOS, download link).
- Unit/integration tests for the RPC methods, CLI handlers (app
unreachable, error, not-available, TTY vs non-TTY), the typed runtime
client, and output formatting.
|
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:
📝 WalkthroughWalkthroughAdds 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
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: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 8e8d6fc2-a300-4839-9d37-d903fdbf804e
📒 Files selected for processing (16)
src/cli/args.tssrc/cli/dispatch.tssrc/cli/format.test.tssrc/cli/format.tssrc/cli/handlers/updater.test.tssrc/cli/handlers/updater.tssrc/cli/help.tssrc/cli/runtime/client-updater.test.tssrc/cli/runtime/client.tssrc/cli/specs/index.tssrc/cli/specs/updater.tssrc/cli/update-format.test.tssrc/cli/update-format.tssrc/main/runtime/rpc/methods/index.tssrc/main/runtime/rpc/methods/updater.test.tssrc/main/runtime/rpc/methods/updater.ts
|
Taking a look! |
…ings Address CodeRabbit review on stablyai#9406: - Treat `downloading`/`downloaded` as terminal in the update check phase so `orca update` attaches to a download already in flight (e.g. started from the desktop UI) instead of polling until the check-phase timeout and erroring. It now skips the redundant `downloadUpdate` and proceeds straight to install, and `orca update --check` reports an in-progress download immediately. - Add TSDoc docstrings across the new/changed updater CLI and RPC symbols to satisfy the docstring-coverage threshold. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Preserve active download states before starting a new update check, reject install requests until the updater is ready, and replace high-frequency status polling with revision-based long-polls that work efficiently over local and remote runtimes.
|
Thanks for the solid foundation! I pushed a maintainer follow-up that moves the attach guard to the updater RPC boundary so an active or completed download cannot be overwritten by a fresh check, rejects install requests until the update is actually ready, and replaces 500 ms polling with revision-based long-polls for efficient local and SSH/remote operation. I added coverage for attachment, readiness guards, revision waits, timeout/cancellation cleanup, and transport behavior; the scoped suite (188 tests), CLI/node/web typechecks, touched-file lint, max-lines ratchet, CLI build, and a current-main merge validation all pass. The only lint exception remains the pre-existing unrelated switch-exhaustiveness failure already noted in the PR description. |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/main/runtime/rpc/methods/updater.ts (1)
8-11: 🗄️ Data Integrity & Integration | 🔵 Trivial | 💤 Low valueDocument the 30s cap
Add a brief why-comment for
timeoutMs.max(30_000)so the limit reads as an intentional polling ceiling, not an arbitrary magic number.Source: Path instructions
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: b4a0ce9f-a93d-412b-83fb-95ea50a798fe
📒 Files selected for processing (10)
src/cli/handlers/updater.test.tssrc/cli/handlers/updater.tssrc/cli/runtime/client-updater.test.tssrc/cli/runtime/client.tssrc/main/runtime/rpc/methods/updater.test.tssrc/main/runtime/rpc/methods/updater.tssrc/main/runtime/runtime-rpc.tssrc/main/updater.test.tssrc/main/updater.tssrc/shared/types.ts
🚧 Files skipped from review as they are similar to previous changes (2)
- src/cli/runtime/client-updater.test.ts
- src/cli/handlers/updater.test.ts
Reconcile three independent takes on the updater RPC: - main (PR stablyai#9839) shipped `remote-server-updater` (snapshot with app version + install-mode support, wired for paired/remote runtimes). - this branch (Brennan) added revision-based long-polling (`updater.wait`) plus server-side attach-to-in-progress-download and an install-readiness guard. - earlier work added the SSH-aware `orca update`/`version` CLI. Resolution keeps main's remote-server-updater as the base and folds Brennan's efficiency + attach work onto it: - `RemoteServerUpdaterSnapshot` gains a monotonic `revision`; add `RemoteServerUpdaterWaitResult` and a `wait` adapter method. - `src/main/updater.ts`: track a status revision, add `waitForRemoteServerUpdate` (revision long-poll with abort), and attach to an in-flight download on check. - `updater.wait` RPC method (registered as a long-poll) + adapter wiring in `index.ts`; drop the now-superseded `UpdateStatus{Snapshot,WaitResult}` types. - CLI: event-driven `waitForStatus` over `updater.wait`, reading the snapshot first to gate on `support.automatic` (dev/headless-serve/unavailable get guidance instead of a thrown RPC), version from the snapshot's appVersion. Verified: tc:cli, tc:node, tc:web, build:cli, oxlint, and the scoped updater vitest suites pass. Pre-existing (main) updater.test.ts failures in this Node-26 sandbox are unrelated and reproduce on origin/main. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Merged
|
Resolve conflicts from main's lazy CLI dispatch refactor (#? handler-group manifest) and orchestration-envelope client changes (stablyai#9925): - dispatch.ts: adopt main's manifest-driven routing; register the updater commands by adding a `{ name: 'updater', keys: ['version','update'] }` group to handler-group-manifest.ts (verified by handler-group-manifest.test.ts). - client.ts: keep both the remote-server-update imports and main's new orchestration-envelope imports. Extract the remote status→CliStatus mapping to remote-cli-status.ts to stay under the max-lines budget (no baseline/disable). Updater reconciliation (revision long-poll + install-mode/SSH gate) is intact. Verified: tc:cli, tc:node, oxlint, and the scoped CLI/updater/manifest vitest suites pass (312 CLI tests green). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Resolve conflicts from main's CLI changes (account command + RuntimeClient RemoteRuntimeCompatGate refactor): - handler-group-manifest.ts / specs/index.ts: keep both the new `account` group and this branch's `updater` group (version/update) registrations. - client.ts: adopt main's RemoteRuntimeCompatGate flow (noteVerifiedStatus, drop the removed ensureRemoteRuntimeCompatible), keep the updater RPC methods, and reuse the extracted buildRemoteCliStatusResult helper to stay under max-lines (no baseline/disable). - Add the required `revision` field to RemoteServerUpdaterSnapshot literals in main's new renderer tests (restart-wait, install-failure-probe). - pnpm install for main's new emojibase-data dependency. Updater reconciliation (revision long-poll + install-mode/SSH gate) intact. Verified: tc:cli, tc:node, tc:web, oxlint, and the updater/manifest/renderer vitest suites pass (39 CLI/RPC + 26 renderer tests green). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
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
🧹 Nitpick comments (2)
src/cli/runtime/client.ts (1)
182-182: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueRemove redundant method comments.
The comments restate
checkForUpdateanddownloadUpdate. Remove them.As per coding guidelines, “Comments must be concise, limited to non-obvious information” and must not “describe how it works.”
Also applies to: 189-189
Source: Coding guidelines
src/cli/update-format.test.ts (1)
36-66: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd coverage for the timeout and error branches.
formatUpdateResulthas two untested paths: thetimedOutbranch, which produces a different message when the state isdownloading, and theerrorstate, which changes text based onoperation. Both are user-visible outcomes oforca update.💚 Suggested tests
it('reports a download timeout with the last known percent', () => { expect( formatUpdateResult({ operation: 'update', status: { state: 'downloading', version: '1.5.0', percent: 42 }, installRequested: false, timedOut: true }) ).toBe('Timed out waiting for Orca 1.5.0 to download (42%).') }) it('labels a failure by operation', () => { expect( formatUpdateResult({ operation: 'check', status: { state: 'error', message: 'network down' }, installRequested: false }) ).toBe('Update check failed: network down') })
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 8e771d8f-609f-4b81-afb8-12358142ffea
📒 Files selected for processing (26)
src/cli/args.tssrc/cli/format.test.tssrc/cli/format.tssrc/cli/handler-group-manifest.tssrc/cli/handlers/updater.test.tssrc/cli/handlers/updater.tssrc/cli/help.tssrc/cli/runtime/client-updater.test.tssrc/cli/runtime/client.tssrc/cli/runtime/remote-cli-status.tssrc/cli/specs/index.tssrc/cli/specs/updater.tssrc/cli/update-format.test.tssrc/cli/update-format.tssrc/main/index.tssrc/main/runtime/remote-server-updater.tssrc/main/runtime/rpc/methods/updater.test.tssrc/main/runtime/rpc/methods/updater.tssrc/main/runtime/runtime-rpc.tssrc/main/updater.test.tssrc/main/updater.tssrc/renderer/src/runtime/remote-server-install-failure-probe.test.tssrc/renderer/src/runtime/remote-server-restart-wait.test.tssrc/renderer/src/runtime/remote-server-update-coordinator.test.tssrc/renderer/src/store/slices/remote-server-updates.integration.test.tssrc/shared/remote-server-update.ts
🚧 Files skipped from review as they are similar to previous changes (8)
- src/cli/specs/index.ts
- src/cli/format.ts
- src/main/updater.test.ts
- src/main/runtime/runtime-rpc.ts
- src/cli/help.ts
- src/cli/format.test.ts
- src/cli/args.ts
- src/cli/runtime/client-updater.test.ts
Address CodeRabbit review on stablyai#9406: - waitForStatus read Date.now() twice per iteration; between the condition check and the slice computation the remaining time could reach 0/negative and updater.wait's `min(1)` param validation would reject it as an RPC error instead of a clean timeout. Read the clock once and break on non-positive remaining time. - Fix the run-on sentence in the manual-service-update guidance. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
@brennanb2025 quick status update: the branch is caught up with |
Resolve conflicts from main's CLI/shared refactors: - shared/types.ts was split; repoint updater CLI imports of UpdateStatus to shared/update-status-types. - specs/index.ts + handler-group-manifest.ts: keep the updater command group alongside main's new account/artifacts groups. - client.ts: adopt main's getCliStatus (target + projectRemoteAppStatus), drop the now-stale remote-cli-status extraction, keep the updater RPC methods. - format.ts: keep the actionable next-steps rendering for runtime_unavailable and main's orchestrationRequestId handling. - remote-server-updater.test.ts: add the required `wait`/`revision` to the adapter snapshot/config. - main split updater.test.ts into focused files; move the revision/abort wait coverage to updater.remote-server-wait.test.ts using the shared harness. Updater reconciliation (revision long-poll + install-mode/SSH gate) intact. Verified: tc:cli, tc:node, tc:web, oxlint, and the updater vitest suites pass (41 CLI/RPC/main tests green). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
@brennanb2025 heads-up: re-merged |
Summary
Adds two CLI commands so users (and agents) can update Orca and check its version from the terminal — there was previously no way to do either from the
orcaCLI.The
orcaCLI ships bundled inside the Electron app (its version is the app version), so it cannot self-update as an independent binary. Instead these commands drive the app's existing, battle-testedelectron-updaterflow over the runtime RPC the CLI already speaks:orca version— reports the installed version.orca update [--check] [--prerelease] [--json]—--checkchecks and reports without installing; plainupdatechecks → downloads → installs (via the existingquitAndInstall) only when an update is available.New RPC methods
updater.{getVersion,getStatus,check,download,install}(src/main/runtime/rpc/methods/updater.ts, registered in the method index) delegate to the existingsrc/main/updater.tsfunctions andapp.getVersion(). No hand-rolled installer; signature verification is untouched.Screenshots
No visual change (CLI only). Terminal behavior: human download progress renders on a single in-place line on a TTY (
Downloading Orca <version>… NN%), and falls back to newline output when stdout is not a TTY.--jsonoutput is a structured object per state.Testing
Checks run in this worktree (see note on full-suite caveats below):
pnpm lint— changed-fileoxlint+ react-doctor + exhaustive-switch + max-lines ratchet pass. Full-repopnpm lintis red on a pre-existing, unrelated error (skill-freshness-group.tsxexhaustive-switch) that exists onmainand is not touched by this PR.pnpm typecheck—pnpm tc:cliandpnpm tc:nodeboth pass (exit 0).vitestover the changed/added specs passes (RPC methods, CLI handlers, typed client, formatters). Fullpnpm testwas not run green due to unrelated Node-26localStorage/zero-test-worker failures independent of this change.pnpm build—pnpm build:clipasses.--jsoncontract test.AI Review Report
Reviewed across two rounds with an AI reviewer (Fable 5), each independently re-running typecheck, the scoped test files, and
oxlint(not trusting the implementer's claims).src/main/updater.ts; method names/param/return shapes match on both sides. Polling is genuinely bounded (60×500ms check / 1200×500ms download) with all terminal states handled;--checkdoes not install.brew upgrade --caskhint is correctly gated onprocess.platform === 'darwin'. The\r/isTTYprogress handling behaves identically on macOS/Linux/Windows terminals.\r, minor copy inconsistency).Security Audit
quitAndInstall. No new remote download/exec path, and electron-updater signature verification is not weakened or bypassed.updater.*methods are deliberately not added to the mobile RPC allowlist, so a paired mobile client cannot triggerupdater.install; only the local CLI and the full-trust SSH relay can. Verified against the default-deny gate inruntime-rpc.ts.updater.checkaccepts only an optional{ includePrerelease }boolean; invalid params are rejected (tested). No secrets, no command execution from user input.Notes
not-available(expected).ELI5
New CLI commands:
orca versionprints the app version andorca updatetriggers the same app update flow as the desktop updater. You can check and update Orca from a terminal without hunting menus.