Repository navigation
perf(renderer): mount jump palette content only while open - #7617
brennanb2025 wants to merge 1 commit into
Conversation
#7558 gated the two hottest status-map subscriptions behind visible-or-lingering, but ~30 other store slices (prCache, issueCache, retainedAgentsByPaneKey, unifiedTabsByWorktree, browserPagesByWorkspace, ...) stayed subscribed while the palette was closed, re-rendering the whole always-mounted component on ordinary agent/terminal churn. Generalize the gate structurally: a tiny always-mounted shell subscribes only to activeModal (one boolean selector) and mounts WorktreeJumpPaletteContent only while visible or lingering through the close animation. The linger window and the selectPaletteStatusInputs gate keep #7558's close-animation freshness exactly; the create-lookup guard moves to the shell so a reopen still invalidates a pending GH work-item lookup across content unmounts. Cmd+J lives above the component (menu accelerator -> IPC -> openModal), so opening from the unmounted state is unchanged. Closed-render-count tests pin the seam: zero content renders on store churn while closed, fresh data on open, live maps during the linger window, and unmount after it. Co-authored-by: Orca <[email protected]>
📝 WalkthroughWalkthroughChangesWorktreeJumpPalette is refactored into a shell component and a newly exported WorktreeJumpPaletteContent component. The shell introduces a Sequence Diagram(s)sequenceDiagram
participant Store
participant WorktreeJumpPalette
participant WorktreeJumpPaletteContent
Store->>WorktreeJumpPalette: closeModal (visible=false)
WorktreeJumpPalette->>WorktreeJumpPalette: start lingering timeout
WorktreeJumpPalette->>WorktreeJumpPaletteContent: render while visible || lingering
WorktreeJumpPaletteContent->>Store: subscribe status inputs (visible || lingering)
WorktreeJumpPalette-->>WorktreeJumpPalette: timeout elapses, lingering=false
WorktreeJumpPalette--xWorktreeJumpPaletteContent: unmount content
Related PRs: None identified. Suggested labels: renderer, tests, refactor Suggested reviewers: None identified. 🐰 A palette that lingers just a beat, 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
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.
🧹 Nitpick comments (4)
src/renderer/src/components/WorktreeJumpPalette.tsx (2)
329-343: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueTrim "Why" comments to 1-2 lines per guideline.
Several new comment blocks (Lines 329-336, 339-343, 395-398) run 4-8 lines each. As per coding guidelines,
**/*.{ts,tsx,js,jsx}comments explaining non-obvious behavior should be "Keep comments short — one or two lines, capturing only the non-obvious reason."Also applies to: 395-398
Source: Coding guidelines
337-377: 📐 Maintainability & Code Quality | 🔵 Trivial | 🏗️ Heavy liftConsider extracting
WorktreeJumpPaletteContentinto its own module.This file is ~2355 lines. As per coding guidelines,
**/*.{ts,tsx,js,jsx}files should be split rather than accumulate further: "Split the file, extract focused modules, move fixtures/builders into named files, or otherwise reduce the counted lines instead." This PR already carves out a clean shell/content boundary at Line 369 — movingWorktreeJumpPaletteContent(and its ~2000 lines of hooks/handlers/JSX) to a dedicated file would be a natural, low-risk follow-up.Source: Coding guidelines
src/renderer/src/components/worktree-jump-palette-status-inputs.ts (1)
17-23: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueComment exceeds the 1-2 line guideline.
The rewritten rationale spans 7 lines. As per coding guidelines,
**/*.{ts,tsx,js,jsx}"Why" comments should be "one or two lines, capturing only the non-obvious reason." Consider trimming to the core point (frozen fallback + shallow-equal reference stability) and dropping the historical narrative.Source: Coding guidelines
src/renderer/src/components/WorktreeJumpPalette.closed-render-gating.test.tsx (1)
217-254: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick winGood linger-unmount coverage; consider adding a guard-persistence regression test.
This test correctly verifies the linger window and post-linger unmount. One architectural invariant introduced by this PR isn't directly exercised here:
createLookupGuardmust now survive full content unmount/remount (previously content never unmounted after first open, so the guard's lifetime was never at risk). A regression test that opens the palette, triggers a create-lookup, closes past the linger window (full unmount), reopens, and asserts the guard was invalidated exactly once (or that stale lookups are rejected) would protect this newly-fragile contract against future refactors that accidentally recreate the guard per content mount.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 930e60fd-abfb-4622-9a3a-b4ec653fd40b
📒 Files selected for processing (3)
src/renderer/src/components/WorktreeJumpPalette.closed-render-gating.test.tsxsrc/renderer/src/components/WorktreeJumpPalette.tsxsrc/renderer/src/components/worktree-jump-palette-status-inputs.ts
|
Closing as done: main's |
Problem
WorktreeJumpPalettestays mounted for the whole session once opened (App.tsx lazy-mounts it and never unmounts).#7558gated the two hottest status-map subscriptions (selectPaletteStatusInputs) behindvisible || lingering, but ~30 other store subscriptions in the component stayed live unconditionally —prCache,issueCache,retainedAgentsByPaneKey,sleepingAgentSessionsByPaneKey,unifiedTabsByWorktree,browserPagesByWorkspace, and more. Every moderate-frequency write to any of them re-rendered the closed palette (and re-ran its ~30useMemos) during ordinary agent/terminal use.Fix
Finish
#7558's approach structurally instead of slice-by-slice:WorktreeJumpPalette, always mounted): subscribes to a single boolean (activeModal === 'worktree-palette'), owns the existing 300ms close-animation linger timer and the create-lookup request guard, and mounts the content only whilevisible || lingering. Closed cost collapses to one boolean selector.WorktreeJumpPaletteContent, same file — it's grandfathered in the max-lines baseline): all previous subscriptions, memos, and dialog rendering, unchanged. TheselectPaletteStatusInputs(s, visible || lingering)gate is kept verbatim so#7558's close-animation freshness semantics are preserved exactly.Behavior preserved:
useIpcEvents→openModal), so it opens the palette from the fully unmounted state.visibleflips true and subscribes live immediately; open-time compute is the same work the open palette already did after#7558(status inputs change identity on open, so downstream memos recomputed anyway).Tests
New
WorktreeJumpPalette.closed-render-gating.test.tsx(render-count pattern, extends#7558's selector tests which still pass unchanged):prCache/issueCache/retainedAgentsByPaneKey/unifiedTabsByWorktree/agentStatusByPaneKey/runtimePaneTitlesByTabId→ zero content rendersviteston all 6 palette-related suites: 48/48 green. Fullpnpm typecheckclean.check:max-lines-ratchetOK (no new suppressions).Made with Orca 🐋