Skip to content

feat(runtime): detect client/server app-version skew on status ingestion - #10234

Closed
tomdebres wants to merge 5 commits into
stablyai:mainfrom
tomdebres:feat/app-version-skew-detect
Closed

tomdebres wants to merge 5 commits into
stablyai:mainfrom
tomdebres:feat/app-version-skew-detect

Conversation

@tomdebres

@tomdebres tomdebres commented Jul 23, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds non-blocking client/server app-version skew detection. orca serve now reports its appVersion in status.get (read from ORCA_APP_VERSION, already stamped at startup in main/index.ts), and the renderer derives an AppVersionSkew verdict (server-older / server-newer) whenever it ingests a runtime status, via a new shared, dependency-free semver-ish evaluator (src/shared/app-version-skew.ts). A reachable server that reports no version is provably older than any client evaluating it and is flagged as such; an unparseable version (custom build) stays silent. Before, protocol-compat only blocked truly incompatible pairs and mere app-version skew was invisible — a client that auto-updated ahead of its server hit missing-RPC failures with misleading downstream errors.

The verdict is computed centrally in buildRuntimeEnvironmentStatusEntry (store slice) so every status-ingestion path gets it for free. This PR is detection + plumbing only; the UI surfacing (sidebar host-header warning, proactive toast nudge, i18n strings) stays in #9614, which will be rebased down to that layer once this and #10235 land.

Split out of #9614.

Tests: new app-version-skew.test.ts (14 cases: skew directions, rc ordering, missing/unparseable versions, build metadata). pnpm typecheck and the test file green locally.

Review starting point: evaluateAppVersionSkew in src/shared/app-version-skew.ts, then buildRuntimeEnvironmentStatusEntry in src/renderer/src/store/slices/runtime-status.ts.

cc @OrcaWin

ELI5

Detects when the desktop app version and orca serve version do not match and surfaces a non-blocking skew signal (server older or newer) so you know when to upgrade one side.

@coderabbitai

coderabbitai Bot commented Jul 23, 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 shared app-version parsing, SemVer comparison, skew evaluation, and user-facing descriptions. The server runtime payload now includes appVersion from ORCA_APP_VERSION, while the renderer retrieves and caches the client version. Runtime environment status entries now include computed version skew, timestamps, and connection-generation checks during refresh. Disconnected runtime toasts now support localized messaging, retry actions, dismissal, and stale-toast cleanup. Tests cover version semantics and asynchronous runtime refresh behavior.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the change and tests, but it omits the required Screenshots, AI Review Report, Security Audit, and Notes sections. Add all required template sections, state whether there is a visual change, document lint/typecheck/test/build results, and include AI review, security audit, and platform notes.
Docstring Coverage ⚠️ Warning Docstring coverage is 12.50% 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 summarizes the main change: detecting client/server app-version skew during runtime status ingestion.
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: 3

🧹 Nitpick comments (1)
src/shared/app-version-skew.test.ts (1)

93-98: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Add regression cases for malformed version components.

Extend the malformed-version test with cases such as 01.4.147, 1.4.147-rc..1, and 1.4.147-rc.01, asserting null. This locks down the “unparseable versions remain unflagged” behavior.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 94923ae1-1e4a-4f7b-a841-031dc164e104

📥 Commits

Reviewing files that changed from the base of the PR and between 94d3db4 and 1341408eaae76f4bd2dcbf028e8a15c38f66612e.

📒 Files selected for processing (6)
  • src/main/runtime/orca-runtime.ts
  • src/renderer/src/runtime/client-app-version.ts
  • src/renderer/src/store/slices/runtime-status.ts
  • src/shared/app-version-skew.test.ts
  • src/shared/app-version-skew.ts
  • src/shared/runtime-types.ts

Comment thread src/main/runtime/orca-runtime.ts Resolved
Comment thread src/shared/app-version-skew.ts Resolved

@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 Plus

Run ID: 01b3072e-856e-4256-8ef5-d2816297a931

📥 Commits

Reviewing files that changed from the base of the PR and between 1341408eaae76f4bd2dcbf028e8a15c38f66612e and fb64fe2719ab3435ce20e8ab2bdce45cb13e76b9.

📒 Files selected for processing (4)
  • src/main/runtime/orca-runtime.ts
  • src/renderer/src/runtime/client-app-version.ts
  • src/shared/app-version-skew.test.ts
  • src/shared/app-version-skew.ts
🚧 Files skipped from review as they are similar to previous changes (3)
  • src/main/runtime/orca-runtime.ts
  • src/renderer/src/runtime/client-app-version.ts
  • src/shared/app-version-skew.test.ts

Comment thread src/shared/app-version-skew.ts Resolved
@nwparker nwparker added the enhancement New feature or request label Jul 27, 2026
@tomdebres
tomdebres force-pushed the feat/app-version-skew-detect branch from 6922295 to 86d048b Compare July 30, 2026 06:15
Comment on lines +30 to +46
export async function buildRuntimeEnvironmentStatusEntry(
status: RuntimeStatus | null
): Promise<RuntimeEnvironmentStatus> {
if (!status) {
return { status: null, checkedAt: Date.now() }
}
const clientAppVersion = await getClientAppVersion()
return {
status,
appVersion: status.appVersion ?? null,
versionSkew: evaluateAppVersionSkew({
clientAppVersion,
serverAppVersion: status.appVersion ?? null
}),
checkedAt: Date.now()
}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 checkedAt captured after async gap

Date.now() is called after await getClientAppVersion(), so on the very first probe (before the IPC version is cached) the recorded timestamp lags behind when the server status was actually received. Subsequent probes are near-instant (resolved promise microtask), but the first one can be off by the full IPC round-trip. Capturing checkedAt before the await — or at the top of the function — would faithfully represent when the status was fetched.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 1bf320f — checkedAt is now stamped at the top of buildRuntimeEnvironmentStatusEntry, before the version lookup, with a fake-timer test pinning it.

Comment thread src/shared/app-version-skew.ts Outdated
Comment on lines +10 to +15
export type AppVersionSkew = {
direction: AppVersionSkewDirection
clientAppVersion: string
/** null when the server predates app-version reporting in status.get. */
serverAppVersion: string | null
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 serverAppVersion nullability not encoded in the type for server-newer

AppVersionSkew.serverAppVersion is string | null regardless of direction, but evaluateAppVersionSkew only produces direction: 'server-newer' when a parsed (non-null) server version string is available. describeAppVersionSkew relies on this invariant without a null check — if a caller constructs an AppVersionSkew with direction: 'server-newer' and serverAppVersion: null, the message will read "This Orca server (null) is newer…". A discriminated union makes the contract machine-checkable.

Suggested change
export type AppVersionSkew = {
direction: AppVersionSkewDirection
clientAppVersion: string
/** null when the server predates app-version reporting in status.get. */
serverAppVersion: string | null
}
export type AppVersionSkew =
| {
direction: 'server-older'
clientAppVersion: string
/** null when the server predates app-version reporting in status.get. */
serverAppVersion: string | null
}
| {
direction: 'server-newer'
clientAppVersion: string
serverAppVersion: string
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adopted in 1bf320f — AppVersionSkew is now a discriminated union; 'server-newer' requires a non-null serverAppVersion.

Comment thread src/shared/app-version-skew.ts Outdated
Comment on lines +128 to +132
return {
direction: diff < 0 ? 'server-older' : 'server-newer',
clientAppVersion: input.clientAppVersion!.trim(),
serverAppVersion: input.serverAppVersion!.trim()
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Minor: reportedServerVersion (already trimmed) is available in scope but the return statement re-trims input.serverAppVersion instead of reusing the local variable. These evaluate to the same string, but using reportedServerVersion removes the redundant operation and makes the relationship between the earlier guard and the returned value explicit.

Suggested change
return {
direction: diff < 0 ? 'server-older' : 'server-newer',
clientAppVersion: input.clientAppVersion!.trim(),
serverAppVersion: input.serverAppVersion!.trim()
}
return {
direction: diff < 0 ? 'server-older' : 'server-newer',
clientAppVersion: input.clientAppVersion!.trim(),
serverAppVersion: reportedServerVersion
}

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adopted in 1bf320f — both return arms reuse the trimmed locals.

@greptile-apps

greptile-apps Bot commented Jul 30, 2026

Copy link
Copy Markdown

Greptile Summary

Adds non-blocking client/server app-version skew detection to orca serve. The server now reports its appVersion in status.get, and the renderer derives an AppVersionSkew verdict (server-older / server-newer) on every status ingestion through the new buildRuntimeEnvironmentStatusEntry helper.

  • src/shared/app-version-skew.ts introduces a dependency-free semver-ish parser and comparator; a null server version is treated as "server predates this feature" (older), and an unparseable version (custom build) produces no verdict.
  • src/renderer/src/runtime/client-app-version.ts caches the IPC client-version lookup per session, clearing the cache on rejection so subsequent probes retry.
  • src/renderer/src/store/slices/runtime-status.ts centralises skew derivation in buildRuntimeEnvironmentStatusEntry so every ingestion path gets the verdict.

Confidence Score: 4/5

Safe to merge; the skew verdict is non-blocking and detection-only, so any edge-case misbehaviour is silent rather than user-facing.

The core semver logic is sound and well-tested. Two small gaps: the AppVersionSkew type does not discriminate serverAppVersion nullability by direction, so describeAppVersionSkew on server-newer relies on an invariant the type system does not enforce. And checkedAt is stamped after the getClientAppVersion await, slightly misrepresenting when the server status was fetched on the first probe. Neither affects the skew verdict itself.

Files Needing Attention: src/shared/app-version-skew.ts for the discriminated-union type gap and the redundant re-trim; src/renderer/src/store/slices/runtime-status.ts for the checkedAt timing.

Important Files Changed

Filename Overview
src/shared/app-version-skew.ts New hand-rolled semver evaluator: parsing, comparison, and skew detection logic are correct; two minor issues — the AppVersionSkew type lacks a discriminated union that would make the server-newer/serverAppVersion non-null invariant machine-checkable, and the return block re-trims a variable already held as reportedServerVersion.
src/renderer/src/store/slices/runtime-status.ts Adds buildRuntimeEnvironmentStatusEntry to centralize skew derivation on status ingestion; the one call site updated is refreshRuntimeEnvironmentStatus. Minor timing issue: checkedAt is stamped after await getClientAppVersion(), slightly overestimating the real check time on the first probe.
src/renderer/src/runtime/client-app-version.ts New IPC wrapper that caches the client app version promise and correctly clears the cache on rejection so the next probe retries rather than skipping skew detection for the entire session.
src/shared/app-version-skew.test.ts 14-case test suite covering skew directions, rc ordering, numeric prerelease magnitude, missing/unparseable versions, and build-metadata stripping. Comprehensive for the pure functions.
src/main/runtime/orca-runtime.ts Adds appVersion field to the status response, reading from ORCA_APP_VERSION env var. The
src/shared/runtime-types.ts Updates RuntimeStatus.appVersion from string

Sequence Diagram

sequenceDiagram
    participant Probe as refreshRuntimeEnvironmentStatus
    participant Server as orca serve (main)
    participant Builder as buildRuntimeEnvironmentStatusEntry
    participant IPC as getClientAppVersion (IPC cache)
    participant Eval as evaluateAppVersionSkew
    participant Store as setRuntimeEnvironmentStatus

    Probe->>Server: getStatus(environmentId)
    Server-->>Probe: "RuntimeStatus { appVersion: string | null }"

    Probe->>Builder: buildRuntimeEnvironmentStatusEntry(status)
    Builder->>IPC: getClientAppVersion()
    IPC-->>Builder: "clientAppVersion (string | null)"
    Builder->>Eval: "evaluateAppVersionSkew({ clientAppVersion, serverAppVersion })"
    Eval-->>Builder: "AppVersionSkew | null"
    Builder-->>Probe: "RuntimeEnvironmentStatus { status, versionSkew, checkedAt }"

    Probe->>Store: setRuntimeEnvironmentStatus(environmentId, entry)
Loading

Reviews (1): Last reviewed commit: "Reject unsafe-integer release segments a..." | Re-trigger Greptile

@tomdebres
tomdebres force-pushed the feat/app-version-skew-detect branch from 86d048b to fb917d5 Compare August 5, 2026 06:15
@coderabbitai

coderabbitai Bot commented Aug 5, 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: 1

🧹 Nitpick comments (2)
src/shared/app-version-skew.ts (1)

1-6: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Condense the implementation comments.

Several comments span multiple lines and restate adjacent code behavior. Keep only the non-obvious rationale, using one concise line per comment.

As per coding guidelines, comments must be concise, non-obvious, and brief.

Also applies to: 22-23, 29-30, 45-46, 57-58, 110-111, 120-121

Source: Coding guidelines

src/renderer/src/store/slices/runtime-status.ts (1)

23-25: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick win

Make the no-verdict value consistent.

The field comment documents versionSkew as null when the server is unreachable. buildRuntimeEnvironmentStatusEntry(null) omits the property at Line 37, and the refresh catch path does the same. This exposes undefined, not null, for the same state. Add versionSkew: null to failed-probe entries, or document undefined in the type and comment.

Also applies to: 36-37


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 9c18e373-7426-4136-a83b-bf79d9905cbb

📥 Commits

Reviewing files that changed from the base of the PR and between 1f86f98 and fb917d55e65f180c3e7ed369a49194350a4f2e3b.

📒 Files selected for processing (6)
  • src/main/runtime/orca-runtime.ts
  • src/renderer/src/runtime/client-app-version.ts
  • src/renderer/src/store/slices/runtime-status.ts
  • src/shared/app-version-skew.test.ts
  • src/shared/app-version-skew.ts
  • src/shared/runtime-types.ts
🚧 Files skipped from review as they are similar to previous changes (4)
  • src/shared/runtime-types.ts
  • src/main/runtime/orca-runtime.ts
  • src/renderer/src/runtime/client-app-version.ts
  • src/shared/app-version-skew.test.ts

tomdebres and others added 4 commits August 7, 2026 18:22
Servers report appVersion in status.get; the renderer derives a
non-blocking AppVersionSkew verdict when ingesting runtime status.
UI surfacing stays in stablyai#9614.

Split out of stablyai#9614.
…robe commits

- Stamp checkedAt before the client-version lookup so it reflects when the
  server answered (greptile)
- Bound the client-version IPC with a 2s race so a stalled preload can never
  delay or block publishing a live server status (coderabbit)
- Drop probe results whose environment was removed or re-paired while the
  probe was in flight, keyed on tombstones + connection generation (coderabbit)
- Make AppVersionSkew a discriminated union so 'server-newer' cannot carry a
  null serverAppVersion (greptile)
- Reuse the already-trimmed reportedServerVersion in the skew result (greptile)
- Split runtime-environment-status-entry.ts and runtime-disconnected-toast.ts
  out of runtime-status.ts to stay under the max-lines budget after the rebase

Co-Authored-By: Claude Fable 5 <[email protected]>
@tomdebres
tomdebres force-pushed the feat/app-version-skew-detect branch from fb917d5 to 1bf320f Compare August 7, 2026 17:28
@coderabbitai

coderabbitai Bot commented Aug 7, 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.

@tomdebres

Copy link
Copy Markdown
Contributor Author

Rebased onto current main and pushed review follow-ups: checkedAt stamped before the version lookup, the client-version IPC bounded by a 2s race so it can never delay publishing a live status, stale probe commits dropped via tombstone + connection-generation guards, AppVersionSkew converted to a discriminated union, and the trimmed locals reused. runtime-status.ts was split (status-entry construction and the disconnect toast moved to their own modules) to stay under the max-lines budget after the rebase. 47 focused tests pass; typecheck and lint clean.

@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 Plus

Run ID: 1c018493-c431-4ab7-a954-362bb140aeab

📥 Commits

Reviewing files that changed from the base of the PR and between bc1e049 and 1bf320f.

📒 Files selected for processing (9)
  • src/main/runtime/orca-runtime.ts
  • src/renderer/src/runtime/client-app-version.ts
  • src/renderer/src/store/slices/runtime-disconnected-toast.ts
  • src/renderer/src/store/slices/runtime-environment-status-entry.ts
  • src/renderer/src/store/slices/runtime-status.test.ts
  • src/renderer/src/store/slices/runtime-status.ts
  • src/shared/app-version-skew.test.ts
  • src/shared/app-version-skew.ts
  • src/shared/runtime-types.ts
🚧 Files skipped from review as they are similar to previous changes (4)
  • src/shared/runtime-types.ts
  • src/shared/app-version-skew.test.ts
  • src/main/runtime/orca-runtime.ts
  • src/renderer/src/runtime/client-app-version.ts

…tatus

A first probe can be in flight before any status entry exists; removal then
tombstoned the id without advancing the generation, so a same-id re-add
(which clears the tombstone) let the stale probe commit to the new pairing.

Co-Authored-By: Claude Fable 5 <[email protected]>
@tomdebres tomdebres closed this Aug 18, 2026
@tomdebres
tomdebres deleted the feat/app-version-skew-detect branch August 18, 2026 22:35
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