Skip to content

fix(renderer): account switchers and CLI cards follow the focused repo's host - #27687

Merged
nwparker merged 1 commit into
mainfrom
nwparker/wsl-a5-focused-host-surfaces
Oct 12, 2026
Merged

nwparker merged 1 commit into
mainfrom
nwparker/wsl-a5-focused-host-surfaces

Conversation

@nwparker

@nwparker nwparker commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 5 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​170 $\color{#cf222e}{\Huge{\mathbf{−}}}$​17 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​153
Prod 14 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​119 $\color{#cf222e}{\Huge{\mathbf{−}}}$​56 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​63

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/glab status 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 existing defaultScopeHost. 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.

Surface Host it describes
Status-bar Claude / Codex account switchers Focused workspace's owner, else default host
Forge (gh/glab) preflight cards Focused workspace's owner, else default host
Task page / Automations source availability This computer only (remote preflight ignored)
Settings panes Default host (unchanged)
Worktree-visibility default mirrors Default host (unchanged)
Linear key dialog Default host (unchanged)

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.

switcher-defaultLocal_serverFocused.png

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 gh login) is shown.

tasks-serverFocused.png
tasks-localFocused.png

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-performance timing 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.ts keeps 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:

    Default host Focus Preflight request / context key Account switchers
    Server none server preflight.check / runtime:<id> server accounts.subscribe
    Server local worktree local preflight:check / host local claudeAccounts:list, codexAccounts:list
    Server server worktree server / runtime:<id> server
    This computer none local / host local
    This computer server worktree server / runtime:<id> server
    This computer local worktree local / host local

    The 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 and pnpm 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

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

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

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

@nwparker
nwparker force-pushed the nwparker/wsl-a5-focused-host-surfaces branch 2 times, most recently from 49899ea to afac382 Compare October 12, 2026 00:10
@coderabbitai

coderabbitai Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

📝 Walkthrough
📝 Walkthrough
📝 Walkthrough

Walkthrough

Preflight selection now follows the focused worktree’s execution host, with the default scope host as fallback. Claude and Codex status switchers use the focused owner’s runtime target and environment ID for account snapshots and related state. Provider availability requires current, checked preflight status that describes desktop. New tests cover owner resolution, preflight routing, and selector scan counts.





Priority: ➖ Normal

Merge Risk: 🟡 Moderate · up to 122cf

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 | Passed 4 | Failed 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 55.56% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 27 functions across 21 files. (1 skipped:… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
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.
Title check Passed The title clearly and concisely describes the primary change: routing account switchers and CLI cards according to the focused repository's host.
Description check Passed The description is detailed and on-topic. It includes the user impact, implementation, rationale, linked-issue note, visual proof, testing results, known limits, and checklist. The manual-testing chec…

Full details: Docstring Coverage

Explanation

Docstring coverage is 55.56% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 27 functions across 21 files. (1 skipped: 1 unsupported.)


  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR







  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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: 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.ts
  • src/renderer/src/components/status-bar/ClaudeSwitcherMenu.tsx
  • src/renderer/src/components/status-bar/status-bar-claude-accounts.ts
  • src/renderer/src/components/status-bar/status-bar-codex-accounts.ts
  • src/renderer/src/components/status-bar/status-bar-runtime-groups.test.ts
  • src/renderer/src/components/status-bar/use-codex-switcher-controller.ts
  • src/renderer/src/components/use-task-page-source-availability.ts
  • src/renderer/src/components/use-task-page-source-summary.ts
  • src/renderer/src/components/use-task-page-store-bindings.ts
  • src/renderer/src/lib/focused-scope-host.test.ts
  • src/renderer/src/lib/focused-scope-host.ts
  • src/renderer/src/lib/local-preflight-context.test.ts
  • src/renderer/src/lib/local-preflight-context.ts
  • src/renderer/src/lib/provider-runtime-context.ts
  • src/renderer/src/runtime/use-focused-scope-host.ts
  • src/renderer/src/store/always-mounted-selector-scan-cost.test.ts
  • src/renderer/src/store/slices/preflight.test.ts
  • src/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)

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.

🎯 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.
@nwparker
nwparker force-pushed the nwparker/wsl-a5-focused-host-surfaces branch from afac382 to 122cfcf Compare October 12, 2026 01:55

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

Caution

Some comments are outside the diff and can’t be posted inline due to GitHub limitations.

⚠️ Outside diff range comments (1)

🟡 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 win

Keep desktop preflight separate from focused-host preflight.

When focus resolves to an environment, getLocalPreflightContext returns a runtime context and the shared preflight runs on that environment. Both availability paths then set preflightReady to false. getRepoBackedProviderAvailability skips 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.txt
  • src/renderer/src/components/automations/use-automation-source-host-availability.ts
  • src/renderer/src/components/status-bar/ClaudeSwitcherMenu.tsx
  • src/renderer/src/components/status-bar/use-codex-switcher-controller.ts
  • src/renderer/src/components/use-task-page-store-bindings.ts
  • src/renderer/src/lib/local-preflight-context.ts
  • src/renderer/src/lib/provider-runtime-context.ts
  • src/renderer/src/lib/resolved-worktree-execution-host.test.ts
  • src/renderer/src/lib/resolved-worktree-execution-host.ts
  • src/renderer/src/runtime/use-worktree-runtime-target.ts
  • src/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.

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.

1 participant