Skip to content

Optimize sidebar unseen completion subscriptions#2895

Draft
cursor[bot] wants to merge 2 commits into
mainfrom
cursor/component-performance-optimization-ada5
Draft

Optimize sidebar unseen completion subscriptions#2895
cursor[bot] wants to merge 2 commits into
mainfrom
cursor/component-performance-optimization-ada5

Conversation

@cursor
Copy link
Copy Markdown
Contributor

@cursor cursor Bot commented Jun 1, 2026

What Changed

  • Replaced SidebarProjectItem's per-thread lastVisitedAt array subscription with a derived hasUnseenCompletion selector.
  • Added shared hasUnseenCompletionSinceVisit logic so project status derivation and thread status logic use the same completion/visit semantics.
  • Added focused coverage for repeated post-completion visit updates and invalid visit timestamps.
  • Included react-scan before/after recordings:
    • artifacts/react-scan/sidebar-before.webm
    • artifacts/react-scan/sidebar-after.webm

Why

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:

  • Before: artifacts/react-scan/sidebar-before.webm
  • After: artifacts/react-scan/sidebar-after.webm

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I included before/after screenshots for any UI changes
  • I included a video for animation/interaction changes

Verification:

  • bun fmt
  • bun lint
  • bun typecheck
  • bun run --filter @t3tools/web test src/components/Sidebar.logic.test.ts
  • bunx react-doctor ./apps/web --full --json --no-score --no-telemetry
  • bunx react-doctor ./apps/web --diff main --json --no-score --no-telemetry
Open in Web View Automation 

Note

Optimize sidebar unseen completion subscriptions in SidebarProjectItem

  • Extracts a new hasUnseenCompletionSinceVisit function in Sidebar.logic.ts that compares raw completedAt and lastVisitedAt timestamps, and refactors hasUnseenCompletion to delegate to it.
  • In Sidebar.tsx, replaces per-thread lastVisitedAt state subscriptions with a pre-computed boolean array projectThreadHasUnseenCompletions, reducing the number of reactive state reads.
  • Behavioral Change: resolveThreadStatusPill now receives lastVisitedAt: undefined when a thread has an unseen completion, and lastVisitedAt equal to latestTurn.completedAt otherwise — previously it always received the persisted lastVisitedAt from state.

Macroscope summarized 237ffdb.

cursoragent and others added 2 commits June 1, 2026 16:12
Co-authored-by: Julius Marminge <juliusmarminge@users.noreply.github.com>
Co-authored-by: Julius Marminge <juliusmarminge@users.noreply.github.com>
@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:M 30-99 changed lines (additions + deletions). labels Jun 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30-99 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant