Skip to content

feat(cli): add orca update and orca version commands - #9406

Open
scastanoh21 wants to merge 8 commits into
stablyai:mainfrom
scastanoh21:scastanoh21/cli-update-command
Open

scastanoh21 wants to merge 8 commits into
stablyai:mainfrom
scastanoh21:scastanoh21/cli-update-command

Conversation

@scastanoh21

@scastanoh21 scastanoh21 commented Jul 19, 2026 •

Copy link
Copy Markdown
Contributor

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 orca CLI.

The orca CLI 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-tested electron-updater flow over the runtime RPC the CLI already speaks:

  • orca version — reports the installed version.
  • orca update [--check] [--prerelease] [--json] — --check checks and reports without installing; plain update checks → downloads → installs (via the existing quitAndInstall) 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 existing src/main/updater.ts functions and app.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. --json output is a structured object per state.

Testing

Checks run in this worktree (see note on full-suite caveats below):

  • pnpm lint — changed-file oxlint + react-doctor + exhaustive-switch + max-lines ratchet pass. Full-repo pnpm lint is red on a pre-existing, unrelated error (skill-freshness-group.tsx exhaustive-switch) that exists on main and is not touched by this PR.
  • pnpm typecheck — pnpm tc:cli and pnpm tc:node both pass (exit 0).
  • Tests — scoped vitest over the changed/added specs passes (RPC methods, CLI handlers, typed client, formatters). Full pnpm test was not run green due to unrelated Node-26 localStorage/zero-test-worker failures independent of this change.
  • pnpm build — pnpm build:cli passes.
  • Added high-quality tests: RPC method params/handlers, CLI handler paths (app-unreachable, error, not-available, prerelease), bounded polling, TTY vs non-TTY progress, and a --json contract 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).

  • Correctness: traced the full path CLI handler → typed runtime client → RPC method → 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; --check does not install.
  • Cross-platform / SSH: RPC-driven (works over the SSH relay against the host's Orca); no hardcoded paths or platform assumptions; the brew upgrade --cask hint is correctly gated on process.platform === 'darwin'. The \r/isTTY progress handling behaves identically on macOS/Linux/Windows terminals.
  • App-not-running: handled gracefully with actionable next steps (no stack trace); covered by a dedicated test.
  • Result: final verdict SHIP / SHIP-WITH-NITS. The one actioned nit was the in-place progress line; remaining nits are cosmetic (untested timeout-close branch, no erase-to-EOL on \r, minor copy inconsistency).

Security Audit

  • The CLI only triggers the existing updater over RPC; install goes through quitAndInstall. No new remote download/exec path, and electron-updater signature verification is not weakened or bypassed.
  • IPC/exposure: the new updater.* methods are deliberately not added to the mobile RPC allowlist, so a paired mobile client cannot trigger updater.install; only the local CLI and the full-trust SSH relay can. Verified against the default-deny gate in runtime-rpc.ts.
  • Input handling: updater.check accepts only an optional { includePrerelease } boolean; invalid params are rejected (tested). No secrets, no command execution from user input.

Notes

  • CLI-only change; no UI. In a dev/unpackaged build the updater reports not-available (expected).
  • Behavior is identical local vs SSH/remote (acts on the Orca instance executing the CLI).

ELI5

New CLI commands: orca version prints the app version and orca update triggers the same app update flow as the desktop updater. You can check and update Orca from a terminal without hunting menus.

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.
@coderabbitai

coderabbitai Bot commented Jul 19, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It 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 reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds orca version and orca update commands with --check, --prerelease, and --json support. Adds updater RPC methods for status, waiting, checking, downloading, and installing updates. Tracks updater status revisions and supports bounded waits with cancellation. Adds runtime client methods, CLI handlers, progress rendering, result formatting, recovery guidance, help text, command registration, and comprehensive tests.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 56.52% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the primary change: adding the orca update and orca version CLI commands.
Description check ✅ Passed The description includes all required sections and provides clear summaries of behavior, testing, AI review, cross-platform checks, security, and notes.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai 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.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 8e8d6fc2-a300-4839-9d37-d903fdbf804e

📥 Commits

Reviewing files that changed from the base of the PR and between ae1c943 and 2f3566a.

📒 Files selected for processing (16)
  • src/cli/args.ts
  • src/cli/dispatch.ts
  • src/cli/format.test.ts
  • src/cli/format.ts
  • src/cli/handlers/updater.test.ts
  • src/cli/handlers/updater.ts
  • src/cli/help.ts
  • src/cli/runtime/client-updater.test.ts
  • src/cli/runtime/client.ts
  • src/cli/specs/index.ts
  • src/cli/specs/updater.ts
  • src/cli/update-format.test.ts
  • src/cli/update-format.ts
  • src/main/runtime/rpc/methods/index.ts
  • src/main/runtime/rpc/methods/updater.test.ts
  • src/main/runtime/rpc/methods/updater.ts

Comment thread src/cli/handlers/updater.ts Resolved
@brennanb2025

Copy link
Copy Markdown
Contributor

Taking a look!

scastanoh21 and others added 2 commits July 20, 2026 09:24
…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.
@brennanb2025

Copy link
Copy Markdown
Contributor

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.

@coderabbitai coderabbitai 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.

🧹 Nitpick comments (1)
src/main/runtime/rpc/methods/updater.ts (1)

8-11: 🗄️ Data Integrity & Integration | 🔵 Trivial | 💤 Low value

Document 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

📥 Commits

Reviewing files that changed from the base of the PR and between 9422d1a and 50fe22a.

📒 Files selected for processing (10)
  • src/cli/handlers/updater.test.ts
  • src/cli/handlers/updater.ts
  • src/cli/runtime/client-updater.test.ts
  • src/cli/runtime/client.ts
  • src/main/runtime/rpc/methods/updater.test.ts
  • src/main/runtime/rpc/methods/updater.ts
  • src/main/runtime/runtime-rpc.ts
  • src/main/updater.test.ts
  • src/main/updater.ts
  • src/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

@nwparker nwparker added the enhancement New feature or request label Jul 27, 2026
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]>
@scastanoh21

Copy link
Copy Markdown
Contributor Author

Merged main and resolved the updater conflicts (d0341bd69)

main shipped its own updater RPC in #9839 (remote-server-updater: snapshot with app version + install-mode support, wired for paired/remote runtimes) while this branch had two other takes on the same surface. Rather than pick one, I reconciled all three:

Base: main's remote-server-updater (kept as canonical — it has install-mode/SSH support and is production-wired).

Folded in @brennanb2025's 50fe22a7c (event-driven attachment):

  • RemoteServerUpdaterSnapshot now carries a monotonic revision; added RemoteServerUpdaterWaitResult + a wait adapter method and the updater.wait RPC (registered as a long-poll in runtime-rpc.ts, wired in index.ts).
  • src/main/updater.ts: status-revision tracking, waitForRemoteServerUpdate (revision long-poll with abort), and server-side attach-to-in-progress-download on check.
  • CLI is now event-driven over updater.wait (no high-frequency polling), efficient local and remote.

Kept the SSH-aware CLI: orca update/version read the snapshot first and gate on support.automatic, so dev / headless-serve / updater-unavailable hosts get actionable guidance instead of a thrown remote_update_manual_required. Version now comes from the snapshot's appVersion (dropped the redundant updater.getVersion + the superseded UpdateStatus{Snapshot,WaitResult} types).

Verified: tc:cli, tc:node, tc:web, build:cli, oxlint, and the scoped updater vitest suites all pass. The remaining src/main/updater.test.ts failures in this Node-26 sandbox are pre-existing on origin/main (reproduced there with the same files) and unrelated to this change.

cc @brennanb2025 — your updater.wait/revision work is preserved (first parent of the merge) and now sits on top of #9839's remote-server-updater; a second look at the reconciliation would be welcome.

scastanoh21 and others added 2 commits July 27, 2026 17:34
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]>
@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

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.

@coderabbitai coderabbitai 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.

Actionable comments posted: 2

🧹 Nitpick comments (2)
src/cli/runtime/client.ts (1)

182-182: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Remove redundant method comments.

The comments restate checkForUpdate and downloadUpdate. 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 win

Add coverage for the timeout and error branches.

formatUpdateResult has two untested paths: the timedOut branch, which produces a different message when the state is downloading, and the error state, which changes text based on operation. Both are user-visible outcomes of orca 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

📥 Commits

Reviewing files that changed from the base of the PR and between f713739 and faf549a.

📒 Files selected for processing (26)
  • src/cli/args.ts
  • src/cli/format.test.ts
  • src/cli/format.ts
  • src/cli/handler-group-manifest.ts
  • src/cli/handlers/updater.test.ts
  • src/cli/handlers/updater.ts
  • src/cli/help.ts
  • src/cli/runtime/client-updater.test.ts
  • src/cli/runtime/client.ts
  • src/cli/runtime/remote-cli-status.ts
  • src/cli/specs/index.ts
  • src/cli/specs/updater.ts
  • src/cli/update-format.test.ts
  • src/cli/update-format.ts
  • src/main/index.ts
  • src/main/runtime/remote-server-updater.ts
  • src/main/runtime/rpc/methods/updater.test.ts
  • src/main/runtime/rpc/methods/updater.ts
  • src/main/runtime/runtime-rpc.ts
  • src/main/updater.test.ts
  • src/main/updater.ts
  • src/renderer/src/runtime/remote-server-install-failure-probe.test.ts
  • src/renderer/src/runtime/remote-server-restart-wait.test.ts
  • src/renderer/src/runtime/remote-server-update-coordinator.test.ts
  • src/renderer/src/store/slices/remote-server-updates.integration.test.ts
  • src/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

Comment thread src/cli/handlers/updater.ts Resolved
Comment thread src/cli/update-format.ts Resolved
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]>
@scastanoh21

Copy link
Copy Markdown
Contributor Author

@brennanb2025 quick status update: the branch is caught up with main again and back to mergeable. Your revision-based long-poll + attach/readiness work is preserved and now sits on top of main's remote-server-updater (#9839). Also folded in a couple of small CodeRabbit fixes (long-poll slice clamp + a copy tweak). Whenever you have a moment, a quick re-review of the reconciliation would be great. 🙏

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]>
@scastanoh21

Copy link
Copy Markdown
Contributor Author

@brennanb2025 heads-up: re-merged main and the branch is mergeable again. Your revision-based long-poll + attach/readiness work is still intact on top of main's remote-server-updater. A quick re-review whenever you have a moment would be great — thanks! 🙏

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants