Skip to content

Add remote server update advisor with detection and platform-specific guidance - #9602

Closed
AmethystLiang wants to merge 6 commits into
mainfrom
prompt-user-to-update-orca-remote-server
Closed

AmethystLiang wants to merge 6 commits into
mainfrom
prompt-user-to-update-orca-remote-server

Conversation

@AmethystLiang

Copy link
Copy Markdown
Contributor

Summary

Implements a remote server update advisor that activates when protocol compatibility blocks a paired Orca server. The advisor detects the server's install kind (Linux AppImage/deb/rpm, macOS app, Windows installer, or source build) and restart method (systemd service, foreground serve, or desktop app) at startup, then provides copyable, platform-specific update guidance. Never executes commands on the remote machine — all guidance is written for the user to paste into their own SSH session.

Covers both block directions from evaluateRuntimeCompat:

  • server-too-old: shows detection, versions, and copyable update steps
  • client-too-old: routes to the local update flow, never server commands

Implementation

Detection & Status

  • Startup-cached install detection in src/main/runtime/runtime-install-detection.ts (pure function core, caching wrapper)
    • Gathers installKind, restartKind, serviceName, and installPath from signals: app.isPackaged, APPIMAGE env, systemd cgroup, Windows install roots, optional startup package probe
    • Never runs subprocesses or reads /proc on the polled status.get path
  • Emits optional updateInfo in runtime status alongside existing runtimeProtocolVersion, capabilities, hostPlatform
  • Older servers omit it; all client handling is defensive

Trust Model

  • Every updateInfo field is untrusted; validated in src/shared/runtime-update-info-validation.ts before use
  • Command blocks rendered only from client-owned templates; server data selects templates or fills validated placeholders
  • serviceName matched to ^orca[A-Za-z0-9@:._-]{0,75}\.service$ (orca-prefixed to prevent steering at unrelated units)
  • installPath validated for absolute path, .AppImage suffix, no traversal, no shell metacharacters
  • Versions and URLs validated by regex; unrecognized enums mapped to unknown

Client-Side Guide Matrix

  • Pure module in src/shared/runtime-update-guide.ts mapping (hostPlatform, installKind, restartKind, hostArch) to structured steps + links
  • Dependency-free so mobile can mirror it
  • Platform guides:
    • Linux AppImage: download to sibling temp file, atomic mv, systemd restart or foreground prose
    • Debian/Ubuntu: apt install with optional asset URL from release metadata
    • RPM: dnf install with optional asset URL
    • macOS: in-app updater, dmg download, or Homebrew upgrade (no sudo)
    • Windows: installer download/run, no sudo
    • Source: pull and rebuild
    • Unknown: platform-generic hint, fall back to releases page

Release Metadata

  • Lazy fetch of electron-updater manifests (latest-*.yml) in main process via src/main/ipc/runtime-release-manifest.ts (avoids CORS on GitHub redirects)
  • Parsed in dependency-free src/shared/runtime-release-manifest.ts to extract version + asset filenames
  • Client-fetched manifest wins over server-supplied hints; exact asset URLs only from manifest
  • Best-effort with short timeout; missing manifest degrades to version-less guidance, never an error

Renderer UI

  • src/renderer/src/components/settings/RuntimeUpdateAdvisor.tsx: responsive card for blocked environments
  • Branches on verdict direction; server-too-old renders detection, versions, copyable command blocks, and docs links
  • "Check again" re-fetches status through raw (non-asserting) RPC, re-evaluates compatibility, shows inline "still out of date" note if block persists
  • Added to RuntimeEnvironmentsPane.tsx below blocked row; also deep-linkable from host menu and compat-block errors

Error Threading

  • src/renderer/src/runtime/runtime-protocol-compat.ts now carries verdict and status on block errors so advisor can render guidance without re-probing

Testing

  • ✅ pnpm typecheck: all new types verified
  • ✅ pnpm test: comprehensive unit tests for all new modules
    • Detection mapping per platform fixture (APPIMAGE env, systemd cgroup including user-slice non-orca units)
    • All validation regex reject shell metacharacter and traversal payloads; accept documented defaults
    • Guide matrix snapshot per (platform, arch, installKind, restartKind) combination plus cold-start
    • Verdict branching verified (client-too-old never renders server commands)
    • Release manifest parsing from real electron-updater YAML
    • Endpoint port hint extraction and fallback
  • High-quality tests: 1000+ lines of test coverage ensuring injection resistance and behavioral correctness

Security Audit

Input Handling & Command Construction:

  • ✅ Zero free-text command injection: all commands built from client-owned templates only
  • ✅ serviceName, installPath, currentVersion, latestVersion, docsUrl validated with regexes before use
  • ✅ Enum fields (installKind, restartKind) only accept known values, default to unknown
  • ✅ Line-break check (/[\r\n]/) prevents newline smuggling in validated strings

Network & IPC:

  • ✅ Manifest fetch runs in main (renderer fetch() would hit CORS on GitHub redirects)
  • ✅ URL built entirely from client-owned platform/arch mapping; server data never steers the fetch
  • ✅ Max 64KB cap prevents slurping large objects; 4s timeout prevents hangs

Authorization & Execution:

  • ✅ Advisor never executes commands: all guidance is user-copied text for their own SSH session
  • ✅ No sudo invocation by the app; user decides privilege escalation
  • ✅ No package manager, installer, or service restart invoked by app

Cross-Platform:

  • ✅ File paths in guides use platform-correct separators (templates cover Windows \, Unix /)
  • ✅ Tested for Linux, macOS, Windows install kinds
  • ✅ SSH use case verified (guidance written for user's own shell, not app-controlled)

Notes

  • Rollout: All 6 design steps implemented (detection → validation → guide matrix → UI → deep links → release metadata)
  • Compatibility: Works with servers lacking updateInfo (cold-start) via client-only guide matrix; future servers benefit from server-supplied detection
  • Platform: Tested Linux (AppImage, deb, rpm), macOS (app, homebrew), Windows, source builds; SSH compatible
  • Docs: Design doc at docs/reference/remote-server-update-advisor.md covers motivation, trust model, testing strategy, and deferred questions
  • Localization: Strings added for en/es/ja/ko/zh in 5 locale files

AmethystLiang and others added 6 commits July 20, 2026 11:41
- Fetch the server's electron-updater release manifest (latest-*.yml) via
  a main-process IPC handler, since renderer fetch() hits CORS on GitHub's
  release-asset redirect.
- Parse the manifest in a shared, dependency-free module to derive
  latestVersion, updateAvailable, and exact deb/rpm asset URLs, which
  override the server's startup-stale updateInfo hints.
- Wire a lazy React hook that only fetches while the advisor shows a
  server-too-old block, with a short in-memory cache per platform/arch.
@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Adds a remote runtime update advisor for protocol compatibility blocks. Runtime status now includes cached installation and restart metadata, which is validated before client use. Shared guide generation covers platform-specific update and restart instructions. Release manifests are parsed and fetched through bounded main-process IPC. Compatibility errors retain verdict and status details, while the renderer displays validated guidance, optional release metadata, copyable commands, localized text, and a direct status recheck flow.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description is detailed, but it misses the required Screenshots and AI Review Report sections from the template. Add a Screenshots section (or say No visual change) and an AI Review Report that summarizes review risks and cross-platform checks.
Docstring Coverage ⚠️ Warning Docstring coverage is 32.61% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly names the new remote server update advisor and its detection/guidance focus.
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.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

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: 6673ddd2-473c-42d4-8c0a-981f4c90a2eb

📥 Commits

Reviewing files that changed from the base of the PR and between aca7d50 and c044052.

📒 Files selected for processing (31)
  • docs/reference/remote-server-update-advisor.md
  • src/main/ipc/register-core-handlers.test.ts
  • src/main/ipc/register-core-handlers.ts
  • src/main/ipc/runtime-release-manifest.test.ts
  • src/main/ipc/runtime-release-manifest.ts
  • src/main/runtime/orca-runtime.test.ts
  • src/main/runtime/orca-runtime.ts
  • src/main/runtime/runtime-install-detection.test.ts
  • src/main/runtime/runtime-install-detection.ts
  • src/preload/api-types.ts
  • src/preload/index.ts
  • src/renderer/src/components/settings/RuntimeEnvironmentsPane.tsx
  • src/renderer/src/components/settings/RuntimeUpdateAdvisor.tsx
  • src/renderer/src/components/settings/runtime-update-advisor-model.test.ts
  • src/renderer/src/components/settings/runtime-update-advisor-model.ts
  • src/renderer/src/components/settings/use-runtime-release-metadata.ts
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/i18n/locales/es.json
  • src/renderer/src/i18n/locales/ja.json
  • src/renderer/src/i18n/locales/ko.json
  • src/renderer/src/i18n/locales/zh.json
  • src/renderer/src/runtime/runtime-protocol-compat.test.ts
  • src/renderer/src/runtime/runtime-protocol-compat.ts
  • src/shared/runtime-release-manifest.test.ts
  • src/shared/runtime-release-manifest.ts
  • src/shared/runtime-types.ts
  • src/shared/runtime-update-guide-templates.ts
  • src/shared/runtime-update-guide.test.ts
  • src/shared/runtime-update-guide.ts
  • src/shared/runtime-update-info-validation.test.ts
  • src/shared/runtime-update-info-validation.ts

Comment on lines +26 to +45
async function loadReleaseManifest(
platform: string | undefined,
arch: RuntimeUpdateGuideArch | undefined
): Promise<ParsedReleaseManifest | null> {
const key = `${platform ?? ''}:${arch ?? ''}`
const cached = manifestCache.get(key)
if (cached && Date.now() - cached.at < CACHE_TTL_MS) {
return cached.manifest
}
const result = await window.api.runtimeReleaseManifest.fetch({ platform, arch })
if (!result.ok) {
return null
}
const manifest = parseReleaseManifest(result.yaml)
if (!manifest) {
return null
}
manifestCache.set(key, { at: Date.now(), manifest })
return manifest
}

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.

🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check which preload entrypoints expose runtimeReleaseManifest
rg -nP --type=ts -C2 'runtimeReleaseManifest' src/preload
fd -e ts . src/preload --exec rg -l 'runtimeReleaseManifest' {} \; 2>/dev/null || true

Repository: stablyai/orca

Length of output: 1011


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Inspect the release-metadata helper and its caller contract
ast-grep outline src/renderer/src/components/settings/use-runtime-release-metadata.ts --view expanded || true
echo '--- file ---'
sed -n '1,220p' src/renderer/src/components/settings/use-runtime-release-metadata.ts | cat -n
echo '--- advisor usage ---'
rg -n "useRuntimeReleaseMetadata|runtimeReleaseManifest|check\(" src/renderer/src/components/settings src/renderer/src/components -g '!**/dist/**' -g '!**/build/**'

Repository: stablyai/orca

Length of output: 9567


🏁 Script executed:

#!/bin/bash
set -euo pipefail
sed -n '1,220p' src/renderer/src/components/settings/use-runtime-release-metadata.ts | cat -n

Repository: stablyai/orca

Length of output: 4131


🏁 Script executed:

#!/bin/bash
set -euo pipefail
rg -n "window\.api\.(updater|runtimeReleaseManifest)|runtimeReleaseManifest\.fetch|updater\?\.check" src/renderer src/preload src/mobile 2>/dev/null || true

Repository: stablyai/orca

Length of output: 2512


Catch rejected IPC calls here

window.api.runtimeReleaseManifest.fetch(...) can reject, and this effect has no .catch, so the helper can violate its “any failure yields undefined” contract. Wrap the call in try/catch or add a catch so IPC errors fall back cleanly.

Source: Learnings

@AmethystLiang
AmethystLiang requested a review from OrcaWin July 20, 2026 20:31
@AmethystLiang AmethystLiang added the orca-remote-server Remote Orca Server / orca serve / paired remote runtime label Jul 22, 2026
@OrcaWin
OrcaWin marked this pull request as draft October 27, 2026 09:47
@OrcaWin

OrcaWin commented Oct 27, 2026

Copy link
Copy Markdown
Collaborator

Moving this PR to draft because it has been untouched for more than 80 days (latest recorded PR activity or commit timestamp: 2026-07-22T17:40:01Z; checked on 2026-10-27). This keeps the review queue focused on active work while preserving the proposal. Please mark it ready for review when work resumes.

@AmethystLiang

Copy link
Copy Markdown
Contributor Author

Closing as stale: the code it changes no longer exists on main.

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

Labels

orca-remote-server Remote Orca Server / orca serve / paired remote runtime

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants