Repository navigation
fix(preflight): route landing banner through the runtime-aware preflight slice - #11390
Conversation
📝 WalkthroughWalkthroughLanding 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)
✅ 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.
🧹 Nitpick comments (1)
src/renderer/src/components/Landing.tsx (1)
241-245: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winCondense 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.tsxsrc/renderer/src/components/landing-preflight-runtime-boundary.test.ts
Greptile SummaryThis PR fixes a runtime-routing bug in
Confidence Score: 5/5Safe 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.
|
| 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', {})"
Reviews (4): Last reviewed commit: "test(preflight): isolate runtime status ..." | Re-trigger Greptile
b4fb300 to
1f7b9c9
Compare
…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.
1f7b9c9 to
7f2d8cb
Compare
…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]>
Summary
Landing.tsxcallswindow.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 consultsgetActiveRuntimeTarget(settings)and forwards topreflight.checkon 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 fromstate.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:preflight.checkis already runtime-aware.slices/preflight.tsroutes tocallRuntimeRpcwhenruntimeTarget.kind === 'environment'. Proxying in main would double-handle every caller that already routes correctly, andLandingis the only surface still bypassing it. FixingLandingcloses the actual gap.detectAgents/refreshAgentsare also already runtime-aware, via theAgentDetectionTargetunion (local | ssh | runtime) inuseDetectedAgentsand theruntime-detected-agentsslice. Proxying them in main is exactly the wide blast radius flagged in that comment: it hijacks legitimately-local callers —OrchestrationSkillAgentCoverage.tsxhard-codes{ kind: 'local' }— returning the remote host's agents wheneveractiveRuntimeEnvironmentIdis set, and feeding the wrong PATH to locally-spawned terminals. That half is dropped entirely rather than reopened.activeRuntimeEnvironmentId-vs-getSingleFocusedRuntimeEnvironmentIdmismatch 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
setPreflightIssueson success, so a failed check retained the last banner. The slice's.catchlikewise leavespreflightStatusintact and only setspreflightStatusError. This is deliberately not theLanding.tsxchange 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.Testing
landing-preflight-runtime-boundary.test.ts, following the existing*-boundary.test.tspattern (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.tsalready covers the remote path at the slice level (checks integrations through the active runtime environment), which Landing now inherits.typecheck:webclean; oxlint + react-doctor clean.Reproduction
Verified against a real remote runtime: Orca
serveon 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.