refactor(web): the command palette's thread items come from their own hook#22687
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.
| before | after | |
|---|---|---|
CommandPalette.tsx lines | 3249 | 3055 |
| Renders, open palette + type 10 chars (median of 3) | 2684 | 2352 |
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
- SuccessfulCodeRabbitGitHub
Review completed
- Successful
Skipped - Not affected
- Skipped
- Skipped
- Skipped
- SuccessfulRemove preview downloadGitHub
- Skipped
- SuccessfulLabel PR 22687GitHub
- SuccessfulLabel PR sizeGitHub
- Successful
- Successful
- Successful
- Successful
- SuccessfulPrepare PR size configGitHub
- SuccessfulCollect PR targetsGitHub
- SuccessfulCheckGitHub
- SkippedRustGitHub
- Skipped
- SkippedRelease SmokeGitHub
- SuccessfulTest WebGitHub
- SuccessfulTestGitHub
- SuccessfulBuild and TypecheckGitHub
- Skipped
- SuccessfulLabel PR sizeGitHub
- SuccessfulLabel PR 22687GitHub
- SuccessfulPrepare PR size configGitHub
- SuccessfulCollect PR targetsGitHub
- SkippedEAS PreviewGitHub
- SuccessfulTest Server 6GitHub
- SuccessfulTest Server 7GitHub
- SuccessfulTest Server 5GitHub
- SuccessfulTest Server 8GitHub
- SuccessfulTest Server 1GitHub
- SuccessfulTest Server 4GitHub
- SuccessfulTest Server 3GitHub
- SuccessfulTest Server 2GitHub
- SuccessfulChangesGitHub
- SuccessfulLintGitHub
- SuccessfulNative fingerprint diffGitHub
Added 1 commit
- refactor(web): the command palette's thread items come from their own hook0dd1a0a
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.
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.tsxapps/web/src/components/CommandPaletteLookups.tsapps/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.tsAdds 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.tsxAdds a hook that builds thread items with search matches, provider metadata, navigation, and pending-search state. Dialog integration
apps/web/src/components/CommandPalette.tsxRemoves 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 name Status Explanation Title check Passed The title clearly identifies the main change: moving command palette thread items into a dedicated hook. Description check Passed 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 i… 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. 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
- Mode: Continue automatically
- Reviewed files: 3
- Charged: $0.75
- View usage details
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.