perf(desktop): use granular selector in WorkspaceListItem to prevent rerenders#672
perf(desktop): use granular selector in WorkspaceListItem to prevent rerenders#672
Conversation
…rerenders Replace full `tabs` and `panes` store subscriptions with a single granular selector that computes workspace status directly and returns a primitive. Before: Each WorkspaceListItem subscribed to entire tabs/panes objects, causing ALL workspace items to rerender when ANY pane status changed. After: Selector filters tabs by workspace ID, extracts pane IDs, and computes highest priority status inside the selector. Returns primitive string/null so Zustand's Object.is equality check prevents rerenders unless the computed status actually changes. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
📝 WalkthroughWalkthroughThis change refactors workspace status derivation in the WorkspaceListItem component by replacing broad tabs/panes state usage with a granular, memoized selector. A useCallback-based selector now computes workspace status by filtering tabs and aggregating pane statuses. Previous useMemo-based memoization blocks are removed. The component's public API and UI behavior remain unchanged. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
📜 Recent review detailsConfiguration used: defaults Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🧰 Additional context used📓 Path-based instructions (6)apps/desktop/**/*.{ts,tsx}📄 CodeRabbit inference engine (apps/desktop/AGENTS.md)
Files:
**/*.{ts,tsx}📄 CodeRabbit inference engine (AGENTS.md)
Files:
apps/desktop/src/renderer/**/*.{ts,tsx}📄 CodeRabbit inference engine (AGENTS.md)
Files:
**/*.tsx📄 CodeRabbit inference engine (AGENTS.md)
Files:
apps/**/*.{ts,tsx}📄 CodeRabbit inference engine (AGENTS.md)
Files:
**/*.{ts,tsx,js,jsx}📄 CodeRabbit inference engine (AGENTS.md)
Files:
🧠 Learnings (1)📚 Learning: 2025-12-21T04:39:28.543ZApplied to files:
🧬 Code graph analysis (1)apps/desktop/src/renderer/screens/main/components/WorkspaceSidebar/WorkspaceListItem/WorkspaceListItem.tsx (4)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
🔇 Additional comments (1)
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 |
🧹 Preview Cleanup CompleteThe following preview resources have been cleaned up:
Thank you for your contribution! 🎉 |
Summary
tabsandpanesstore subscriptions with a single granular selector inWorkspaceListItemBefore: Each
WorkspaceListItemsubscribed to entiretabs/panesobjects, causing ALL workspace items to rerender when ANY pane status changed anywhere in the app.After: Single selector filters tabs by workspace ID, extracts pane IDs, computes highest priority status, and returns a primitive. Zustand's
Object.isequality check prevents rerenders unless the computed status actually changes.Test plan
🤖 Generated with Claude Code
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.