You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
refactor(renderer): one default-host read; one catalog fan-out - #27613
The sidebar loads projects, project groups and folder workspaces from this computer and from every connected server. Three loaders each wrote out the same "list the servers, guard each one, then fetch it" loop, and the "default host for new projects" setting was turned into a host in two separate places. This PR keeps one copy of each. Nothing a user sees changes.
What Changed
One server fan-out.loadRuntimeHostCatalogs (in store/host-catalog-fencing.ts, next to the fence it claims) lists the configured servers, claims each server's catalog fence, and runs the caller's fetch for it. It also has an optional "is this load still current?" check that runs after listing and before any fence is claimed. store/runtime-catalog-hosts.ts (8 lines) moved into it.
Each loader still decides its own outcome. The helper only does the listing and the fence claiming. Each domain keeps its own rules:
Folder workspaces clear restored owner hints only when every host answered.
Repos settle the local startup waiter even when the local fetch fails. They keep both load-generation checks (after the local fetch, and after listing servers), fetch visibility defaults separately (these still apply when the repo fetch fails), and check saved filters only after a full successful load.
Project groups keep their simple local-then-remote load.
One apply per domain. Project groups and folder workspaces each had two identical "check the fence, merge, skip if unchanged" blocks: one for loading a single host and one for loading all hosts. Each domain now has one.
One read of the default-host setting.readDefaultHost in lib/default-creation-host.ts now projects the shared primitive getSettingsFocusedExecutionHostId instead of trimming the setting itself. The primitive stays in shared/ because the main-process registry uses it too, so shared/ does not import from the renderer. Ordinary environment ids (UUIDs from pairing and deployment) are encoded and decoded back to the same value. Two ids that cannot occur in practice now behave the way the sidebar already treats them: the reserved unresolved-owner sentinel id resolves to local, and an id with an unpaired UTF-16 surrogate throws.
Before and after for users: identical. Mechanism: the duplicated loops and apply blocks now share one helper and one apply per domain.
Net lines: production −31 (+142 / −173), tests +231 (new characterization suite).
Why
The duplicated loop is where #27116 and #27218 added the per-host catalog fences, and keeping three copies in step is how a fence gets missed. A fully general loader was considered and rejected. The three domains settle differently, and options that encode every settlement rule would cost more lines than they save. They would also risk clearing folder ownership or saved repo filters after a host was offline. So the helper covers only what is truly shared.
Linked Issue
Phase 3.99 cleanup (D3), no issue.
Visual Proof
N/A. This is an internal refactor with no change to UI or behaviour.
Testing
I manually tested these changes locally
Automated tests added/updated, or explained why not below
I committed the characterization tests first, and they passed on unmodified main: store/slices/all-host-catalog-settlement.test.ts covers:
local folder failure keeps the owner hints
remoteHosts: 'skip' lists no servers and keeps the hints
a folder-only catalog with no repos on any host
a server removed mid-load is skipped by every domain
a local repo failure rejects the startup waiter but still loads remote repos
Existing suites pass unchanged (226 tests): all-host, generation, connection fence, stale fetch, folder workspaces, project groups, default-creation-host, startup selector. Supersession during listing is already covered by repos-catalog-connection-fence.test.ts.
Dead-code proof: rg --hidden "runtime-catalog-hosts|listRuntimeEnvironmentsForAllHostLoad" src config scripts tests mobile packages returns only the new private function in host-catalog-fencing.ts. rg -w over all @ts-nocheck files finds no hits. pnpm run build:electron-vite passes.
pnpm tc, pnpm lint (focus-read ratchet still at 1133), oxlint and check:code-quality:changed all pass.
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
SSH and remote: no route changes. Servers are still listed from the same API, and each one is still fenced by pairing, connection generation and SSH-state generation.
Folder workspaces: covered by the folder-only test.
Cross-platform: renderer-only code with no platform branches.
Wire: nothing sent or received changed.
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)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 remain after this review.
📝 Walkthrough
📝 Walkthrough
Walkthrough
The change adds a shared loader for runtime-host catalogs and uses it in folder, project-group, and repository catalog actions. Folder and project-group actions share catalog application logic. New tests cover folder and repository settlement cases. Default host selection now maps the focused execution-host ID to a runtime target and falls back to local when no target is returned.
Priority: ⬇️ Low
Merge Risk:⚪ Minimal · up to b0cf3
This refactor is intended to keep user-visible behavior the same, and no concrete risk was found in the supplied changes. It looks safe to merge after normal checks.
Pre-merge checks | 4 | 1
❌ Failed checks (1 warning)
Check name
Status
Explanation
Resolution
Docstring Coverage
Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 10 functions across 6 files.
Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name
Status
Explanation
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Title check
The title clearly and concisely summarizes the two main refactoring changes: consolidating the default-host read and catalog fan-out.
Description check
The description is detailed and covers the change, rationale, testing, compatibility considerations, visual proof, and checklist. The Linked Issue section states that no issue exists instead of provid…
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ELI5
The sidebar loads projects, project groups and folder workspaces from this computer and from every connected server. Three loaders each wrote out the same "list the servers, guard each one, then fetch it" loop, and the "default host for new projects" setting was turned into a host in two separate places. This PR keeps one copy of each. Nothing a user sees changes.
What Changed
loadRuntimeHostCatalogs(instore/host-catalog-fencing.ts, next to the fence it claims) lists the configured servers, claims each server's catalog fence, and runs the caller's fetch for it. It also has an optional "is this load still current?" check that runs after listing and before any fence is claimed.store/runtime-catalog-hosts.ts(8 lines) moved into it.readDefaultHostinlib/default-creation-host.tsnow projects the shared primitivegetSettingsFocusedExecutionHostIdinstead of trimming the setting itself. The primitive stays inshared/because the main-process registry uses it too, soshared/does not import from the renderer. Ordinary environment ids (UUIDs from pairing and deployment) are encoded and decoded back to the same value. Two ids that cannot occur in practice now behave the way the sidebar already treats them: the reservedunresolved-ownersentinel id resolves to local, and an id with an unpaired UTF-16 surrogate throws.Before and after for users: identical. Mechanism: the duplicated loops and apply blocks now share one helper and one apply per domain.
Net lines: production −31 (+142 / −173), tests +231 (new characterization suite).
Why
The duplicated loop is where #27116 and #27218 added the per-host catalog fences, and keeping three copies in step is how a fence gets missed. A fully general loader was considered and rejected. The three domains settle differently, and options that encode every settlement rule would cost more lines than they save. They would also risk clearing folder ownership or saved repo filters after a host was offline. So the helper covers only what is truly shared.
Linked Issue
Phase 3.99 cleanup (D3), no issue.
Visual Proof
N/A. This is an internal refactor with no change to UI or behaviour.
Testing
I manually tested these changes locally
Automated tests added/updated, or explained why not below
I committed the characterization tests first, and they passed on unmodified main:
store/slices/all-host-catalog-settlement.test.tscovers:remoteHosts: 'skip'lists no servers and keeps the hintsExisting suites pass unchanged (226 tests): all-host, generation, connection fence, stale fetch, folder workspaces, project groups, default-creation-host, startup selector. Supersession during listing is already covered by
repos-catalog-connection-fence.test.ts.Dead-code proof:
rg --hidden "runtime-catalog-hosts|listRuntimeEnvironmentsForAllHostLoad" src config scripts tests mobile packagesreturns only the new private function inhost-catalog-fencing.ts.rg -wover all@ts-nocheckfiles finds no hits.pnpm run build:electron-vitepasses.pnpm tc,pnpm lint(focus-read ratchet still at 1133),oxlintandcheck:code-quality:changedall pass.AI Disclosure
Review
Agent skill upstream boundary
Notes
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)