Skip to content

fix(preflight): route landing banner through the runtime-aware preflight slice - #11390

Merged
OrcaWin merged 7 commits into
stablyai:mainfrom
croakingtoad:fix/landing-preflight-remote-runtime
Aug 1, 2026
Merged

OrcaWin merged 7 commits into
stablyai:mainfrom
croakingtoad:fix/landing-preflight-remote-runtime

Conversation

@croakingtoad

Copy link
Copy Markdown
Contributor

Summary

Landing.tsx calls window.api.preflight.check(...) directly on mount, on window focus/visibility, and on a 30s poll while a warning is visible. That IPC handler always probes the local client machine.

The preflight slice (store/slices/preflight.ts) is the only caller that consults getActiveRuntimeTarget(settings) and forwards to preflight.check on the active runtime environment. Because Landing bypasses it, a user connected to a remote Orca runtime sees a landing banner describing the client's git/gh state, not the server's — e.g. "Git is not installed" on a machine that isn't running anything.

This delegates Landing to refreshPreflightStatus() and derives the issue list from state.preflightStatus.

Why this instead of the main-process proxy in #6938

This supersedes the preflight half of #6938. In #6938 (comment) the ask was to reopen that half as its own PR against preflight:check / detectAgents / refreshAgents. That version was built and tested first — but checking the blast radius raised in that comment showed the main-side proxy is no longer the right fix:

  1. preflight.check is already runtime-aware. slices/preflight.ts routes to callRuntimeRpc when runtimeTarget.kind === 'environment'. Proxying in main would double-handle every caller that already routes correctly, and Landing is the only surface still bypassing it. Fixing Landing closes the actual gap.
  2. detectAgents / refreshAgents are also already runtime-aware, via the AgentDetectionTarget union (local | ssh | runtime) in useDetectedAgents and the runtime-detected-agents slice. Proxying them in main is exactly the wide blast radius flagged in that comment: it hijacks legitimately-local callers — OrchestrationSkillAgentCoverage.tsx hard-codes { kind: 'local' } — returning the remote host's agents whenever activeRuntimeEnvironmentId is set, and feeding the wrong PATH to locally-spawned terminals. That half is dropped entirely rather than reopened.
  3. Keeping the routing decision in one place (the slice) also avoids the activeRuntimeEnvironmentId-vs-getSingleFocusedRuntimeEnvironmentId mismatch raised in review — Landing now inherits whatever predicate the slice uses.

This matches the direction of #6887 for skills: fix it where the routing already lives.

Behavior notes

  • No change to the error path. Landing previously only called setPreflightIssues on success, so a failed check retained the last banner. The slice's .catch likewise leaves preflightStatus intact and only sets preflightStatusError. This is deliberately not the Landing.tsx change from fix: proxy skill discovery and preflight checks to remote runtime when connected #6938 (333900d4), which was asked to be split out — that one is not included here.
  • Removes a duplicate probe. The slice dedupes concurrent and forced checks, so Landing's mount/focus/poll paths now share one in-flight request with the rest of the app instead of issuing their own.

Testing

  • New landing-preflight-runtime-boundary.test.ts, following the existing *-boundary.test.ts pattern (e.g. file-explorer-runtime-owner-boundary.test.ts): asserts Landing routes through the slice and never touches the local preflight IPC directly.
  • preflight.test.ts already covers the remote path at the slice level (checks integrations through the active runtime environment), which Landing now inherits.
  • 30/30 pass across the boundary, landing-preflight, and preflight-slice suites; typecheck:web clean; oxlint + react-doctor clean.

Reproduction

Verified against a real remote runtime: Orca serve on Ubuntu 22.04 reached from a desktop client over Tailscale. Before this change the landing banner reported the client's git/gh state while an environment was active; after it, the banner reflects the server.

@coderabbitai

coderabbitai Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Landing now derives preflight issues from app-store status and refreshes that status on mount, window activation, and a 30-second interval while issues remain. Direct preflight IPC access was removed from the component. New source-boundary tests verify store-based ownership, prohibit direct landing IPC references, and check runtime-target routing in the preflight slice.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description covers the summary and testing, but it omits the required Screenshots, AI Review Report, Security Audit, and Notes sections. Add the missing template sections and include the required AI review, cross-platform compatibility check, security audit, screenshots or a no-visual-change note, and notes.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: routing the landing preflight banner through the runtime-aware slice.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.

🧹 Nitpick comments (1)
src/renderer/src/components/Landing.tsx (1)

241-245: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Condense the duplicated runtime-routing rationale. Keep the essential “remote runtime vs. client machine” reason, but reduce these implementation walkthroughs to one concise sentence each.

  • src/renderer/src/components/Landing.tsx#L241-L245: replace with a brief reason for using the slice rather than local IPC.
  • src/renderer/src/components/landing-preflight-runtime-boundary.test.ts#L19-L23: retain only the test-specific reason for forbidding direct local IPC.

As per coding guidelines, comments must be concise, limited to non-obvious information, and preferably one line.

Source: Coding guidelines


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 749541b0-a050-4a05-9fb4-f5dde9c7333d

📥 Commits

Reviewing files that changed from the base of the PR and between 4543bb6 and 6eeba5049e0fa7fc1b860a211e786ef9c299881e.

📒 Files selected for processing (2)
  • src/renderer/src/components/Landing.tsx
  • src/renderer/src/components/landing-preflight-runtime-boundary.test.ts

@greptile-apps

greptile-apps Bot commented Jul 29, 2026 •

Copy link
Copy Markdown

Greptile Summary

This PR fixes a runtime-routing bug in Landing.tsx: the component was calling window.api.preflight.check(...) directly, which always probes the local client machine. Users connected to a remote Orca runtime therefore saw the client's git/gh state (e.g., "Git is not installed" on their laptop) instead of the server's.

  • Introduces useLandingPreflightRuntime, a hook that reads preflightStatus from the Zustand store and dispatches refreshPreflightStatus / invalidatePreflightStatus so Landing inherits the slice's runtime-aware routing.
  • Adds invalidatePreflightStatus to the preflight slice — clears all in-flight request caches and resets the status atomically when the runtime session ends or switches.
  • Calls bumpProviderRuntimeSessionGeneration inside setRuntimeEnvironmentStatus when the active environment connects/disconnects, ensuring the deduplication contextKey changes and prevents stale results from a previous session from landing.

Confidence Score: 5/5

Safe to merge — the change narrows Landing's scope from a direct IPC caller to a pure store consumer with no new error paths.

The fix is surgical: ~60 lines of inline IPC calls removed, replaced by a well-tested hook that delegates to the existing runtime-aware slice. The deduplication key in the slice already encodes the remote environment ID (via getProviderRuntimeContextKey), so switching runtimes naturally creates a fresh request rather than reusing a stale one. The new invalidatePreflightStatus correctly bumps the in-flight request ID before clearing state, so any concurrent probe is discarded via the requestId guard. Both unit tests and an E2E journey (disconnect, reconnect, A→B switch) cover the new paths. No new IPC surface, no schema change, no new async error paths.

Files Needing Attention: No files require special attention.

Important Files Changed

Filename Overview
src/renderer/src/components/landing-preflight-runtime.ts New hook encapsulating the runtime-aware preflight refresh logic; correctly derives activeRuntimeState as a stable string key and handles local, unknown, unreachable, and reachable cases in mutually exclusive branches.
src/renderer/src/store/slices/preflight.ts Adds invalidatePreflightStatus: correctly bumps latestPreflightRequestId, nullifies both dedup caches, and resets all state fields so any in-flight result is discarded via the requestId guard.
src/renderer/src/store/slices/runtime-status.ts Calls bumpProviderRuntimeSessionGeneration when the active environment's session ends or changes identity, ensuring the contextKey used for preflight deduplication differs across sessions.
src/renderer/src/components/Landing.tsx Removes ~60 lines of direct window.api.preflight.check calls and delegates entirely to useLandingPreflightRuntime; change is minimal and clean.
src/renderer/src/components/landing-preflight-runtime-boundary.test.ts New unit tests cover runtime A→B switch, disconnect/reconnect invalidation, unknown-state banner suppression, and interval/listener lifecycle; well-structured and matches existing boundary test patterns.
src/renderer/src/store/slices/preflight.test.ts Adds two new integration tests for invalidation and cross-runtime result isolation; now imports createRuntimeStatusSlice and adds the necessary sonner/rpc-client mocks to satisfy the combined slice.
src/renderer/src/store/slices/runtime-status.test.ts Adds a test verifying that bumpProviderRuntimeSessionGeneration only fires when the active environment's session changes, not for unrelated environment updates.
tests/e2e/landing-preflight-runtime-routing.spec.ts End-to-end test using paired Electron clients validates the full runtime-routing journey: initial display, A→B switch, disconnect banner clear, reconnect re-check, and contextKey changes.

Sequence Diagram

sequenceDiagram
    participant L as Landing.tsx
    participant H as useLandingPreflightRuntime
    participant S as preflightSlice
    participant RPC as callRuntimeRpc / window.api

    Note over L,RPC: Before this PR (broken path)
    L->>RPC: window.api.preflight.check() [always local]
    RPC-->>L: local machine state

    Note over L,RPC: After this PR (correct path)
    L->>H: useLandingPreflightRuntime()
    H->>S: refreshPreflightStatus()
    S->>S: getActiveRuntimeTarget(settings)
    alt "kind === 'environment'"
        S->>RPC: "callRuntimeRpc(target, 'preflight.check', {})"
        RPC-->>S: remote server state
    else "kind === 'local'"
        S->>RPC: window.api.preflight.check(args)
        RPC-->>S: local machine state
    end
    S-->>H: preflightStatus updated in store
    H-->>L: "{ preflightIssues }"

    Note over H,S: On runtime disconnect
    H->>S: invalidatePreflightStatus()
    S->>S: bump requestId, clear caches, reset state
    Note over H: banner clears immediately

    Note over H,S: On runtime reconnect
    S->>S: setRuntimeEnvironmentStatus → bumpProviderRuntimeSessionGeneration
    H->>S: refreshPreflightStatus() (new contextKey)
    S->>RPC: "callRuntimeRpc(target, 'preflight.check', {})"
Loading

Reviews (4): Last reviewed commit: "test(preflight): isolate runtime status ..." | Re-trigger Greptile

Marty and others added 7 commits July 31, 2026 17:54
…ght slice

Landing called window.api.preflight.check directly, which always probes the
local client. The preflight slice is the only caller that consults
getActiveRuntimeTarget and forwards to preflight.check on the active runtime
environment, so while connected to a remote runtime the landing banner
reported the client machine's git/gh state instead of the server's.

Delegate to refreshPreflightStatus and derive the issue list from
state.preflightStatus. This also drops Landing's duplicate probe: the slice
dedupes concurrent and forced checks, so the mount/focus/poll paths now share
one in-flight request with the rest of the app.
@OrcaWin
OrcaWin force-pushed the fix/landing-preflight-remote-runtime branch from 1f7b9c9 to 7f2d8cb Compare August 1, 2026 00:57
@OrcaWin
OrcaWin merged commit 072133f into stablyai:main Aug 1, 2026
45 checks passed
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…ght slice (stablyai#11390)

* fix(preflight): route landing banner through the runtime-aware preflight slice

Landing called window.api.preflight.check directly, which always probes the
local client. The preflight slice is the only caller that consults
getActiveRuntimeTarget and forwards to preflight.check on the active runtime
environment, so while connected to a remote runtime the landing banner
reported the client machine's git/gh state instead of the server's.

Delegate to refreshPreflightStatus and derive the issue list from
state.preflightStatus. This also drops Landing's duplicate probe: the slice
dedupes concurrent and forced checks, so the mount/focus/poll paths now share
one in-flight request with the rest of the app.

* fix(preflight): refresh landing status across runtime sessions

* test(preflight): cover paired runtime session races

* test: make landing preflight oracle behavioral

* fix(preflight): scope runtime session invalidation

* test(preflight): cover headed runtime switching

* test(preflight): isolate runtime status toast

---------

Co-authored-by: Marty <marty@localhost>
Co-authored-by: OrcaWin <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants