Skip to content

refactor(renderer): one default-host read; one catalog fan-out - #27613

Merged
OrcaWin merged 2 commits into
mainfrom
OrcaWin/p399-D3
Oct 11, 2026
Merged

OrcaWin merged 2 commits into
mainfrom
OrcaWin/p399-D3

Conversation

@OrcaWin

@OrcaWin OrcaWin commented Oct 11, 2026 •

Copy link
Copy Markdown
Collaborator

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

  • 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
    • visibility succeeds and repo fetch fails: defaults apply, saved filters stay
  • 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)

@coderabbitai

coderabbitai Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: d4a5d9f3-e841-4072-8718-0eb62eb2c468


📥 Commits

Reviewing files that changed from the base of the PR and between df2f2a7 and b0cf3aa.



📒 Files selected for processing (7)
  • src/renderer/src/lib/default-creation-host.ts
  • src/renderer/src/store/folder-workspaces/folder-workspace-catalog-actions.ts
  • src/renderer/src/store/host-catalog-fencing.ts
  • src/renderer/src/store/project-groups/project-group-catalog-actions.ts
  • src/renderer/src/store/repos/all-host-repo-catalog-actions.ts
  • src/renderer/src/store/runtime-catalog-hosts.ts
  • src/renderer/src/store/slices/all-host-catalog-settlement.test.ts


💤 Files with no reviewable changes (1)
  • src/renderer/src/store/runtime-catalog-hosts.ts


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

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning 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 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 summarizes the two main refactoring changes: consolidating the default-host read and catalog fan-out.
Description check Passed 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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@OrcaWin
OrcaWin merged commit b022406 into main Oct 11, 2026
29 checks passed
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