Repository navigation
Speed up startup with deferred remote catalogs - #7087
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughChangesThis PR reworks renderer startup hydration to be runtime-host-aware. Local catalogs now load first while skipping remote hosts, worktree purge can be deferred, and persisted workspace sessions are read with runtime-host ownership data used to hydrate terminal state. A later background pass refreshes remote catalogs and worktrees. Repo, project-group, and folder-workspace fetch paths now use catalog helpers and optional all-host fetch options. Runtime RPC compatibility checks now use a TTL-based cache after failures. Persisted UI hydration and setup-script prompt dismissal handling were also tightened. Related tests were updated across these paths. Sequence Diagram(s)See hidden artifact diagram for startup hydration flow. Related PRs: None identified Suggested labels: renderer, startup, refactor Suggested reviewers: none identified 🚥 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.
Actionable comments posted: 3
🧹 Nitpick comments (1)
src/renderer/src/store/slices/repos-all-hosts.test.ts (1)
703-742: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winBounded polling loop risks flakiness.
The fixed
for (let attempt = 0; attempt < 10 ...)loop withsetTimeout(0)waits for both probes to be captured, but under CI load 10 microtask/macrotask ticks may not be enough before the subsequent assertion runs, causing intermittent failures. Considervi.waitFor(() => expect(firstStatusResolvers.size).toBe(2))for a more robust, self-adjusting wait.♻️ Suggested refactor using vi.waitFor
- const load = store.getState().fetchReposForAllHosts() - for (let attempt = 0; attempt < 10 && firstStatusResolvers.size < 2; attempt += 1) { - await new Promise((resolve) => setTimeout(resolve, 0)) - } + const load = store.getState().fetchReposForAllHosts() + await vi.waitFor(() => { + expect(firstStatusResolvers.size).toBe(2) + })
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 6d7970fb-cb2a-4394-83db-d27b7e53a4c3
📥 Commits
Reviewing files that changed from the base of the PR and between 6dafe8c and 6e003fa54e70aad6251eadc802562a93b5672136.
📒 Files selected for processing (13)
src/renderer/src/App.tsxsrc/renderer/src/app-startup-routing.test.tssrc/renderer/src/lib/workspace-session-host-persistence.test.tssrc/renderer/src/lib/workspace-session-host-persistence.tssrc/renderer/src/runtime/runtime-rpc-client.test.tssrc/renderer/src/runtime/runtime-rpc-client.tssrc/renderer/src/store/slices/repos-all-hosts.test.tssrc/renderer/src/store/slices/repos.tssrc/renderer/src/store/slices/terminals-hydration.test.tssrc/renderer/src/store/slices/terminals.tssrc/renderer/src/store/slices/worktree-helpers.tssrc/renderer/src/store/slices/worktrees.test.tssrc/renderer/src/store/slices/worktrees.ts
| function collectWorktreeIdsFromHostSession(session: WorkspaceSessionState): string[] { | ||
| const ids = new Set<string>() | ||
| for (const field of WORKTREE_KEYED_SESSION_FIELDS) { | ||
| const value = session[field] | ||
| if (isPlainRecord(value)) { | ||
| for (const id of Object.keys(value)) { | ||
| ids.add(id) | ||
| } | ||
| } | ||
| } | ||
| for (const id of session.activeWorktreeIdsOnShutdown ?? []) { | ||
| ids.add(id) | ||
| } | ||
| return [...ids] |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
Normalize workspace keys before adding owner-map IDs.
Line 62 adds record keys directly, but persisted session keys can be canonical WorkspaceKey values as well as raw worktree IDs. A key like worktree:repo::/path will later be treated as a raw worktree ID, causing runtime placeholders to be synthesized for the wrong repo/worktree and dropping or misrouting restored runtime tabs. Normalize worktree:* keys to their raw worktree ID and ignore folder:* keys before adding them to ids.
6e003fa to
8eaffa0
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/renderer/src/lib/workspace-session-host-persistence.ts (1)
207-210: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd a short
Why:comment for the extra runtime host set.
additionalRuntimeHostIdsexists for the startup path where saved runtime session hosts are known before their repo catalogs hydrate; that constraint is non-obvious from the code alone. As per coding guidelines,**/*.{ts,tsx,js,jsx}code driven by a non-obvious constraint should include a short comment explaining why.Suggested comment
+ // Why: startup can know saved runtime session hosts before their repo + // catalogs hydrate, so include those partitions in the first read. const runtimeHostIds = new Set<ExecutionHostId>([ ...listKnownRuntimeHostIds(repos), ...additionalRuntimeHostIds ])Source: Coding guidelines
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: d51fdaac-2830-4c1c-b5ba-8cfeea6a4904
📥 Commits
Reviewing files that changed from the base of the PR and between 6e003fa54e70aad6251eadc802562a93b5672136 and 8eaffa0284a53d13f7d1955294721a16a38034cb.
📒 Files selected for processing (13)
src/renderer/src/App.tsxsrc/renderer/src/app-startup-routing.test.tssrc/renderer/src/lib/workspace-session-host-persistence.test.tssrc/renderer/src/lib/workspace-session-host-persistence.tssrc/renderer/src/runtime/runtime-rpc-client.test.tssrc/renderer/src/runtime/runtime-rpc-client.tssrc/renderer/src/store/slices/repos-all-hosts.test.tssrc/renderer/src/store/slices/repos.tssrc/renderer/src/store/slices/terminals-hydration.test.tssrc/renderer/src/store/slices/terminals.tssrc/renderer/src/store/slices/worktree-helpers.tssrc/renderer/src/store/slices/worktrees.test.tssrc/renderer/src/store/slices/worktrees.ts
🚧 Files skipped from review as they are similar to previous changes (11)
- src/renderer/src/store/slices/worktree-helpers.ts
- src/renderer/src/store/slices/terminals-hydration.test.ts
- src/renderer/src/runtime/runtime-rpc-client.test.ts
- src/renderer/src/store/slices/worktrees.ts
- src/renderer/src/app-startup-routing.test.ts
- src/renderer/src/store/slices/repos-all-hosts.test.ts
- src/renderer/src/store/slices/worktrees.test.ts
- src/renderer/src/runtime/runtime-rpc-client.ts
- src/renderer/src/store/slices/repos.ts
- src/renderer/src/App.tsx
- src/renderer/src/store/slices/terminals.ts
8eaffa0 to
8a1ac37
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (2)
src/renderer/src/runtime/runtime-rpc-client.test.ts (1)
139-209: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winConsider adding a TTL-expiry test.
These tests cover failure reuse and post-recovery retry, but not the TTL eviction path (
RECENT_RUNTIME_COMPATIBILITY_FAILURE_TTL_MS) called out in the cache implementation — i.e., a cached failure older than the TTL should be discarded and re-checked even withreuseRecentCompatibilityFailure: true. Adding a fake-timers test would round out coverage of the new cache contract.src/renderer/src/store/slices/repos-all-hosts.test.ts (1)
752-755: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick winReplace the fixed scheduler loop with a deterministic probe barrier.
The 10-iteration
setTimeout(0)polling can make this concurrency test flaky on slow CI. Resolve a promise from the mock when both selectors have been observed, with an explicit timeout for a clear failure.Proposed refactor
const firstStatusResolvers = new Map<string, (value: unknown) => void>() + let resolveBothStatusProbes = (): void => {} + const bothStatusProbesStarted = new Promise<void>((resolve, reject) => { + const timeout = setTimeout( + () => reject(new Error('Timed out waiting for both runtime probes')), + 1_000 + ) + resolveBothStatusProbes = () => { + clearTimeout(timeout) + resolve() + } + }) runtimeEnvironmentTransportCall.mockImplementation( (args: RuntimeEnvironmentCallRequest & { selector?: string }) => { if ( args.method === 'status.get' && args.selector && @@ ) { return new Promise((resolve) => { firstStatusResolvers.set(args.selector!, resolve) + if (firstStatusResolvers.size === 2) { + resolveBothStatusProbes() + } }) } return createCompatibleRuntimeStatusResponseIfNeeded(args) ?? runtimeEnvironmentCall(args) } ) @@ const load = store.getState().fetchReposForAllHosts() - for (let attempt = 0; attempt < 10 && firstStatusResolvers.size < 2; attempt += 1) { - await new Promise((resolve) => setTimeout(resolve, 0)) - } + await bothStatusProbesStarted expect([...firstStatusResolvers.keys()].sort()).toEqual(['env-1', 'env-2'])
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 4b9bdd63-46cd-4cfb-a885-31bf0a435963
📥 Commits
Reviewing files that changed from the base of the PR and between 8eaffa0284a53d13f7d1955294721a16a38034cb and 8a1ac37.
📒 Files selected for processing (16)
src/renderer/src/App.tsxsrc/renderer/src/app-startup-routing.test.tssrc/renderer/src/lib/setup-script-prompt.tssrc/renderer/src/lib/workspace-session-host-persistence.test.tssrc/renderer/src/lib/workspace-session-host-persistence.tssrc/renderer/src/runtime/runtime-rpc-client.test.tssrc/renderer/src/runtime/runtime-rpc-client.tssrc/renderer/src/store/slices/repos-all-hosts.test.tssrc/renderer/src/store/slices/repos.tssrc/renderer/src/store/slices/terminals-hydration.test.tssrc/renderer/src/store/slices/terminals.tssrc/renderer/src/store/slices/ui.test.tssrc/renderer/src/store/slices/ui.tssrc/renderer/src/store/slices/worktree-helpers.tssrc/renderer/src/store/slices/worktrees.test.tssrc/renderer/src/store/slices/worktrees.ts
🚧 Files skipped from review as they are similar to previous changes (10)
- src/renderer/src/store/slices/terminals-hydration.test.ts
- src/renderer/src/store/slices/worktrees.test.ts
- src/renderer/src/lib/workspace-session-host-persistence.test.ts
- src/renderer/src/store/slices/worktrees.ts
- src/renderer/src/runtime/runtime-rpc-client.ts
- src/renderer/src/app-startup-routing.test.ts
- src/renderer/src/store/slices/worktree-helpers.ts
- src/renderer/src/lib/workspace-session-host-persistence.ts
- src/renderer/src/store/slices/repos.ts
- src/renderer/src/store/slices/terminals.ts
8a1ac37 to
8a52b41
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
♻️ Duplicate comments (1)
src/renderer/src/lib/workspace-session-host-persistence.ts (1)
61-92: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick winCanonical
worktree:*session keys still aren't normalized before use.
collectWorkspaceSessionKeysFromHostSessionadds dict keys fromtabsByWorktree/etc. directly toids(Lines 66-68) without stripping aworktree:prefix, andbuildHostIdByWorktreeId's returned lookup (Lines 169-186) explicitly parsesworktreeIdviaparseWorkspaceKeybut only special-casestype === 'folder'— fortype === 'worktree'it falls straight through, still using the prefixed string againstruntimeHostIdByWorktreeId/repoIdByWorktreeId(keyed by raw ids) andgetRepoIdFromWorktreeId(which would sliceworktree:repoId::pathintoworktree:repoId, matching no real repo). A canonicalworktree:repo::/pathsession key would therefore be misrouted toLOCAL_EXECUTION_HOST_ID, dropping/misrouting restored runtime tabs — exactly the scenario called out in a prior review on this file.🛠️ Proposed fix
function collectWorkspaceSessionKeysFromHostSession(session: WorkspaceSessionState): string[] { const ids = new Set<string>() for (const field of WORKSPACE_SESSION_KEYED_FIELDS) { const value = session[field] if (isPlainRecord(value)) { for (const id of Object.keys(value)) { - ids.add(id) + const scope = parseWorkspaceKey(id) + ids.add(scope?.type === 'worktree' ? scope.worktreeId : id) } } }return (worktreeId: string): ExecutionHostId => { const workspaceScope = parseWorkspaceKey(worktreeId) if (workspaceScope?.type === 'folder') { return getFolderWorkspaceRuntimeHostId(state, worktreeId) } - const worktreeHostId = runtimeHostIdByWorktreeId.get(worktreeId) + const rawWorktreeId = + workspaceScope?.type === 'worktree' ? workspaceScope.worktreeId : worktreeId + const worktreeHostId = runtimeHostIdByWorktreeId.get(rawWorktreeId) if (worktreeHostId) { return worktreeHostId } - const repoId = repoIdByWorktreeId.get(worktreeId) ?? getRepoIdFromWorktreeId(worktreeId) + const repoId = repoIdByWorktreeId.get(rawWorktreeId) ?? getRepoIdFromWorktreeId(rawWorktreeId)Based on a prior review comment: "A key like
worktree:repo::/pathwill later be treated as a raw worktree ID, causing runtime placeholders to be synthesized for the wrong repo/worktree and dropping or misrouting restored runtime tabs."Also applies to: 169-186
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 067cb23d-7684-45e3-b466-9e16fc9d095d
📥 Commits
Reviewing files that changed from the base of the PR and between 8a1ac37 and 8a52b41125136a8643e84482543b8c2381d18309.
📒 Files selected for processing (24)
src/renderer/src/App.tsxsrc/renderer/src/app-startup-routing.test.tssrc/renderer/src/lib/setup-script-prompt.tssrc/renderer/src/lib/workspace-session-host-persistence.test.tssrc/renderer/src/lib/workspace-session-host-persistence.tssrc/renderer/src/lib/workspace-session-hydration-keys.tssrc/renderer/src/lib/worktree-runtime-owner.test.tssrc/renderer/src/lib/worktree-runtime-owner.tssrc/renderer/src/runtime/runtime-rpc-client.test.tssrc/renderer/src/runtime/runtime-rpc-client.tssrc/renderer/src/store/slices/browser.tssrc/renderer/src/store/slices/editor.tssrc/renderer/src/store/slices/repos-all-hosts-folder-workspaces.test.tssrc/renderer/src/store/slices/repos-all-hosts.test.tssrc/renderer/src/store/slices/repos.tssrc/renderer/src/store/slices/store-session-cascades.test.tssrc/renderer/src/store/slices/tabs.tssrc/renderer/src/store/slices/terminals-hydration.test.tssrc/renderer/src/store/slices/terminals.tssrc/renderer/src/store/slices/ui.test.tssrc/renderer/src/store/slices/ui.tssrc/renderer/src/store/slices/worktree-helpers.tssrc/renderer/src/store/slices/worktrees.test.tssrc/renderer/src/store/slices/worktrees.ts
🚧 Files skipped from review as they are similar to previous changes (10)
- src/renderer/src/store/slices/worktree-helpers.ts
- src/renderer/src/store/slices/terminals-hydration.test.ts
- src/renderer/src/runtime/runtime-rpc-client.test.ts
- src/renderer/src/store/slices/ui.test.ts
- src/renderer/src/app-startup-routing.test.ts
- src/renderer/src/App.tsx
- src/renderer/src/lib/setup-script-prompt.ts
- src/renderer/src/runtime/runtime-rpc-client.ts
- src/renderer/src/store/slices/repos.ts
- src/renderer/src/store/slices/ui.ts
Co-authored-by: Orca <[email protected]>
8a52b41 to
3730b4a
Compare
Resolve conflicts from deferred-remote-catalog startup optimization: - App.tsx: combine main's parallel keybindings/onboarding promises with the PR's local-first ui-get -> hydrate -> local catalog -> deferred remote flow - browser.ts: keep both hydrateBrowserSession(options) and switchBrowserTabProfile(sessionPartition) signature changes - app-startup-routing.test.ts: point the startup-block end at session-get and drop the obsolete all-hosts scope-overlap test the PR's design replaces - terminals.ts: use findLast(Boolean) for basename to satisfy main's newly added unicorn/prefer-array-find lint rule Co-authored-by: Orca <[email protected]>
Brings in 9 commits: deferred remote catalogs at startup (#7087), owner-aware pane title decision gating the Gemini GPU fallback (#7458), incremental transcript parsing for JSONL agents (#7593), gh rate-limit and git-status spawn-churn fixes (#7595), WSL Codex session bridging (#7477), jump-palette subscription gating (#7558), and the IDE font dropdown fix. Conflict resolutions (our structure, main's semantics): - pty-connection.ts onTitleChange: kept this branch's third parameter and stale-derived-title guard (staleWorkingTitleClear must never feed completion tracking), grafted main's resolvePaneTitleDecision so the display label, GPU policy, and observeTitle all ride the owner-aware decision (#7428/#7447). - App.tsx startup: kept this branch's publishTerminalViewAttributesAtAppStart (hidden-at-launch OSC 10/11 replies) ahead of main's restructured local-first startup; dropped this branch's early ui.get() overlap — main's #7087 now awaits ui.get at effectively the same point, making it redundant. Gates: typecheck clean; 4298 tests across src/main/ipc, src/main/daemon, terminal-pane, pane-manager. The delivery path (ipc/pty.ts, dispatcher, scheduler, snapshots) had no conflicts and no incoming changes. Co-authored-by: Orca <[email protected]>
|
looking into it |
|
thanks for reporting. looking into it |
Co-authored-by: Orca <[email protected]>
Summary
Verification
Note: typecheck:web passed with the local Node-version warning: repo wants Node 24, shell is Node 26.
Review
Made with Orca 🐋