Optimize sidebar unseen completion subscriptions#2895
Draft
cursor[bot] wants to merge 2 commits into
Draft
Conversation
Co-authored-by: Julius Marminge <juliusmarminge@users.noreply.github.com>
Co-authored-by: Julius Marminge <juliusmarminge@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What Changed
SidebarProjectItem's per-threadlastVisitedAtarray subscription with a derivedhasUnseenCompletionselector.hasUnseenCompletionSinceVisitlogic so project status derivation and thread status logic use the same completion/visit semantics.artifacts/react-scan/sidebar-before.webmartifacts/react-scan/sidebar-after.webmWhy
React Doctor/manual review showed the sidebar project row subscribed to every visit timestamp for every thread in a project. Updating a hidden thread's visit timestamp could rerender the project group even when the visible project status did not change. The new selector only changes when the derived unseen-completion boolean changes, preserving status behavior while avoiding rerenders for timestamp churn that is not user-visible.
React Scan scenario used for both videos: seed one sidebar project with 24 completed threads, then repeatedly mark a hidden already-seen thread as visited with later timestamps. Before the fix, the sidebar project group highlights repeatedly; after the fix, the status selector remains stable for those updates.
React Doctor was run pre/post scan. The post-fix diff report still lists broader pre-existing Sidebar/ChatView/CommandPalette findings on the branch, but this PR intentionally addresses only the sidebar visit-status rerender hotspot.
UI Changes
Before/after react-scan recordings are committed in this PR:
artifacts/react-scan/sidebar-before.webmartifacts/react-scan/sidebar-after.webmChecklist
Verification:
bun fmtbun lintbun typecheckbun run --filter @t3tools/web test src/components/Sidebar.logic.test.tsbunx react-doctor ./apps/web --full --json --no-score --no-telemetrybunx react-doctor ./apps/web --diff main --json --no-score --no-telemetryNote
Optimize sidebar unseen completion subscriptions in
SidebarProjectItemhasUnseenCompletionSinceVisitfunction in Sidebar.logic.ts that compares rawcompletedAtandlastVisitedAttimestamps, and refactorshasUnseenCompletionto delegate to it.lastVisitedAtstate subscriptions with a pre-computed boolean arrayprojectThreadHasUnseenCompletions, reducing the number of reactive state reads.resolveThreadStatusPillnow receiveslastVisitedAt: undefinedwhen a thread has an unseen completion, andlastVisitedAtequal tolatestTurn.completedAtotherwise — previously it always received the persistedlastVisitedAtfrom state.Macroscope summarized 237ffdb.