refactor(web): the command palette's thread items come from their own hook#22687

merged1
refactor/command-palette-theme-items
refactor/command-palette-thread-items
opened3d agobyJJulius Marminge
View on GitHubTwo-way sync enabledPR last imported 3d ago

CommandPalette.tsx is ~3,400 lines: one 2,600-line dialog component builds every item, runs every add-project flow, and renders the results. Layer 2 of a stack that splits it into focused files so each piece reads on its own and the React Compiler caches each piece on its own inputs.

Moves thread items into useCommandPaletteThreadItems in CommandPaletteThreadItems.tsx. It owns the thread search, the provider entry map and the thread row content. The environment, project and sorted-group lookup hooks move to CommandPaletteLookups.ts so both files can share them.

This is the layer with the render win. In the dialog, the compiler cached the thread items in a scope that typing invalidated, so every keystroke rebuilt them and re-rendered the visible thread rows. In the hook, they depend only on the deferred search query. ThreadCommandSubtitle, ThreadRowLeadingStatus, ThreadSearchPullRequestNumber and ThreadRowTrailingStatus drop from 80 renders each to 0.

beforeafter
CommandPalette.tsx lines32493055
Renders, open palette + type 10 chars (median of 3)26842352

Measured with the fiber render counter, same browser session and seeded dev DB, swapping only the palette files between this layer and the one below it. Behavior is unchanged.

Tests: vp test run src/reactCompilerCoverage.test.ts -t CommandPalette (0 bailouts, new files included), vp test run src/components/CommandPalette.logic.test.ts, tsc --noEmit for apps/web, vp lint on changed files.

🤖 Generated with Claude Code

Checks

All checks passed

Added 1 commit

  • refactor(web): the command palette's thread items come from their own hook0dd1a0a
Synced from GitHub

Approvability

Verdict: Approved at 0dd1a0a

Macroscope's review found this PR approvable — This is a contained command-palette refactor that moves existing thread, search, and lookup logic into focused hooks without adding user-facing capability or changing schemas, defaults, or deployment behavior. The intended runtime effect is a narrower render-cache boundary and reduced rerendering, while existing item behavior and navigation remain unchanged.

You can add or adjust custom eligibility rules. Learn more.

Synced from GitHub

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Path: .coderabbit.config.ts
  • Review profile: CHILL
  • Plan: Team
  • Run ID: cfd3766d-a8b4-49a9-85bd-1c468e53bf35
📥 Commits

Reviewing files that changed from the base of the PR and between 159fdb5320101963dad5015646ea3eb98b5b82c2 and 0dd1a0aff8312a8fa4bf0467e2bb2eae5aa9b3e3.

📒 Files selected for processing: 3
  • apps/web/src/components/CommandPalette.tsx
  • apps/web/src/components/CommandPaletteLookups.ts
  • apps/web/src/components/CommandPaletteThreadItems.tsx

Limit details: You’ve used all 10 included reviews currently available.

📝 Walkthrough

The command palette moves environment and project lookup logic and thread-item construction into dedicated modules. The dialog uses the extracted hooks for thread items and pending-search state.

Changes: Command Palette

Layer / File(s)Summary
Environment and project lookups
apps/web/src/components/CommandPaletteLookups.ts
Adds hooks and a settings selector for environment labels and classifications, project lookup maps, and sorted project groups.
Thread-item construction
apps/web/src/components/CommandPaletteThreadItems.tsx
Adds a hook that builds thread items with search matches, provider metadata, navigation, and pending-search state.
Dialog integration
apps/web/src/components/CommandPalette.tsx
Removes local lookup and thread-search implementations. The dialog uses the extracted modules and uses the hook’s pending-search state for its loading empty state.

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Refactor

Merge Risk: ⚪ Minimal · up to 0dd1a

No actionable regression was identified in the extracted command-palette behavior; the PR is mergeable after normal checks.

Pre-merge checks: Passed 4
Check nameStatusExplanation
Title checkPassedThe title clearly identifies the main change: moving command palette thread items into a dedicated hook.
Description checkPassedThe description clearly explains the problem, implementation, performance impact, unchanged behavior, and verification steps. It does not include an explicit linked issue or maintainer approval, but i…
Linked Issues checkPassedCheck skipped because no linked issues were found for this pull request.
Out of Scope Changes checkPassedCheck skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description clearly explains the problem, implementation, performance impact, unchanged behavior, and verification steps. It does not include an explicit linked issue or maintainer approval, but it provides the core information for this focused refactor.

✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Usage-based review receipt

Note

This review was completed with usage-based billing: files reviewed beyond your plan's included limits are billed at $0.25/file. View usage-based billing.

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