Repository navigation
fix(renderer): account switchers and CLI cards follow the focused repo's host - #27687
Conversation
49899ea to
afac382
Compare
📝 Walkthrough
Priority: ➖ Normal Merge Risk: 🟡 Moderate · up to While a remote repo is focused, desktop-owned task sources and automation providers may show as unavailable. Account lists in the status bar can also briefly show the previous host's data after a focus change. Resolve both before merging. Pre-merge checks |
|
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
b746d922-661c-462f-a31c-f91ecb326702
📥 Commits
Reviewing files that changed from the base of the PR and between cfb63dc and afac382fda4a68931322a4b93e242f653b9a2b04.
📒 Files selected for processing (18)
src/renderer/src/components/automations/use-automation-source-host-availability.tssrc/renderer/src/components/status-bar/ClaudeSwitcherMenu.tsxsrc/renderer/src/components/status-bar/status-bar-claude-accounts.tssrc/renderer/src/components/status-bar/status-bar-codex-accounts.tssrc/renderer/src/components/status-bar/status-bar-runtime-groups.test.tssrc/renderer/src/components/status-bar/use-codex-switcher-controller.tssrc/renderer/src/components/use-task-page-source-availability.tssrc/renderer/src/components/use-task-page-source-summary.tssrc/renderer/src/components/use-task-page-store-bindings.tssrc/renderer/src/lib/focused-scope-host.test.tssrc/renderer/src/lib/focused-scope-host.tssrc/renderer/src/lib/local-preflight-context.test.tssrc/renderer/src/lib/local-preflight-context.tssrc/renderer/src/lib/provider-runtime-context.tssrc/renderer/src/runtime/use-focused-scope-host.tssrc/renderer/src/store/always-mounted-selector-scan-cost.test.tssrc/renderer/src/store/slices/preflight.test.tssrc/renderer/src/store/slices/preflight.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 3 remain after this review.
| ? { kind: 'environment', environmentId: activeRuntimeEnvironmentId } | ||
| : { kind: 'local' } | ||
| ) | ||
| const snapshot = await fetchProviderAccountsSnapshot(runtimeTarget) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Reject account snapshots from a previous focused host. When focus changes from host A to host B, A’s pending request can finish after B’s request and replace B’s account roster. Both switchers check only whether the component is mounted. Keep a current-host or request-ID guard at each state update.
src/renderer/src/components/status-bar/use-codex-switcher-controller.ts#L93-L93: guard the Codex snapshot update against superseded requests.src/renderer/src/components/status-bar/ClaudeSwitcherMenu.tsx#L113-L113: guard the Claude snapshot update against superseded requests.
Based on learnings: guard retriggered async React effects against out-of-order responses.
📍 Affects 2 files
src/renderer/src/components/status-bar/use-codex-switcher-controller.ts#L93-L93(this comment)src/renderer/src/components/status-bar/ClaudeSwitcherMenu.tsx#L113-L113
Source: Learnings
… the focused workspace's owner The switchers and the shared gh/glab preflight resolve the focused workspace's owner row (getActiveWorkspaceOwnerTarget, which has no focus fallback) and fall back to the default scope host only when nothing proves an owner. The task page and Automations ignore a preflight whose context key names a paired server.
afac382 to
122cfcf
Compare
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to GitHub limitations.
🟡 Minor · Keep desktop preflight separate from… · use-automation-source-host-availability.ts:153
src/renderer/src/components/automations/use-automation-source-host-availability.ts:153
🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick winKeep desktop preflight separate from focused-host preflight.
When focus resolves to an environment,
getLocalPreflightContextreturns a runtime context and the shared preflight runs on that environment. Both availability paths then setpreflightReadytofalse.getRepoBackedProviderAvailabilityskips desktop-owned contexts, so their provider availability is omitted. Keep a separately keyed desktop preflight result for automation and task-page availability.
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
fb93f018-a916-4fc6-b614-37a572b763c9
📥 Commits
Reviewing files that changed from the base of the PR and between afac382fda4a68931322a4b93e242f653b9a2b04 and 122cfcf.
📒 Files selected for processing (11)
config/focus-setting-read-baseline.txtsrc/renderer/src/components/automations/use-automation-source-host-availability.tssrc/renderer/src/components/status-bar/ClaudeSwitcherMenu.tsxsrc/renderer/src/components/status-bar/use-codex-switcher-controller.tssrc/renderer/src/components/use-task-page-store-bindings.tssrc/renderer/src/lib/local-preflight-context.tssrc/renderer/src/lib/provider-runtime-context.tssrc/renderer/src/lib/resolved-worktree-execution-host.test.tssrc/renderer/src/lib/resolved-worktree-execution-host.tssrc/renderer/src/runtime/use-worktree-runtime-target.tssrc/renderer/src/store/slices/preflight.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.
ELI5
When one Orca window holds both projects on this computer and projects on a paired remote Orca server, the GitHub/GitLab CLI cards and the Claude/Codex account switchers in the status bar now describe the computer that runs the project you are looking at, not whichever computer new workspaces default to.
What Changed
Before: with the default creation host set to a remote server, focusing a local repo still showed the remote server's
gh/glabstatus and Claude/Codex accounts (and the reverse). Switching accounts could act on the wrong machine. Separately, the task page and Automations read a shared preflight result as "this computer's gh/glab" even when it described a remote server, which produced false "gh not authenticated" warnings for local repos.After: these surfaces follow the host that owns the focused workspace.
Mechanism:
getActiveWorkspaceOwnerTarget(src/renderer/src/lib/resolved-worktree-execution-host.ts) reads the focused workspace's own row through the existing proof-only owner resolver (getResolvedExecutionHostIdForWorktree, which never falls back to the "default host" setting). It returns nothing when nothing is focused, the row has not loaded, or the owner has no RPC route (direct SSH). Each caller then falls back explicitly to the existingdefaultScopeHost.useActiveWorkspaceOwnerTarget(fallback)is the memoized hook form (string selector, no effects). The preflight slice and its context key use the same owner-then-default rule. The task page and Automations ignore a preflight whose context key names a paired server.Known limits: direct SSH repos are unchanged; usage bars still come from this computer; switching focus between hosts refetches the preflight/account list, so the previous host's list stays visible until the new one arrives.
Why
The default creation host answers "where will a new workspace go", not "what am I looking at". The repo's focus-read ratchet requires routing by the resource's owner, so the owner lookup reads only rows and the one remaining read of the default host stays visible at each call site through the sanctioned
defaultScopeHost. An earlier version wrapped both in a new helper; that hid the default-host read inside a new module and was rejected by the ratchet. The ratchet baseline drops by 13 because the switchers and the preflight context no longer read the setting directly.Linked Issue
None. Possibly related: #17435, #10922 (partial)
Visual Proof
Captured from a dev build of this branch: a desktop paired to a second local Orca instance acting as the server ("A5 Server"), with one local repo and the server's repo in the same window. Hidden windows, isolated profiles.
Default host = this computer, server worktree focused: the switchers subscribe to the server's accounts (
runtimeEnvironments:subscribe accounts.subscribe <server>), not this computer's.Task page for the local GitHub repo. Server worktree focused: the shared preflight describes the server, so its verdict is not shown as this computer's. Local worktree focused: the local preflight's verdict (this isolated profile really has no
ghlogin) is shown.Testing
pnpm tc(node, cli, web) passes.Ran renderer
lib/, preflight slice, status-bar, settings, automations, feature-wall, sidebar, setup-guide, task-page tests and renderer tests importing changed modules: all pass.palette-match-performancetiming test failed once under full-suite load and passes alone (unrelated).Performance: with no paired server (once the server list has loaded), the focused-host lookup returns the default host without touching repo or worktree rows, so local-only windows pay nothing extra (
always-mounted-selector-scan-cost.test.tskeeps its original one-build budget). A window with a paired server builds the owner lookup table alongside the local runtime one, once per store snapshot, not on every store update; other always-mounted selectors already share that table. A new scan-cost case covers that window with a two-build budget.Real paired server (temporary Playwright spec, not committed): one Electron instance served as the server, a second paired to it. A main-process IPC probe recorded which host each request went to:
preflight.check/runtime:<id>accounts.subscribepreflight:check/hostclaudeAccounts:list,codexAccounts:listruntime:<id>hostruntime:<id>hostThe task page for the local GitHub repo showed no preflight-derived warning while the server's preflight was current, and showed the local verdict once the local worktree was focused. A window with no paired server had a loaded server list with 0 entries, so the owner lookup returns before building an index (the scan-cost test pins the read counts). Automations uses the same check as the task page and was covered by unit tests, not exercised live.
oxlint,pnpm run check:code-quality:changed, React Doctor, anti-slop, both code-quality audits, Zustand fan-out andpnpm check:focus-read-ratchet(1133 to 1120 reads) pass. Tested on macOS only.I manually tested these changes locally
Automated tests added/updated, or explained why not below
AI Disclosure
Review
Agent skill upstream boundary
Notes
Ensure no issues in: Security, Cross-platoform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
No wire changes; renderer only. Direct SSH routing is untouched.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)