Skip to content

Optimize provider update pill renders#3811

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

Optimize provider update pill renders#3811
cursor[bot] wants to merge 2 commits into
mainfrom
cursor/component-performance-optimization-8b08

Conversation

@cursor

@cursor cursor Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

What Changed

  • Removed the provider update pill's effect-driven timestamp mirroring and replaced it with a mount-time baseline.
  • Seeded the rendered pill view from the first computed view so initial/remount renders do not need an extra post-commit state update.
  • Moved transition-only bookkeeping (pendingView, dismiss-after-exit key) into refs so it does not schedule additional renders.
  • Kept remaining synchronization/timer effects inside named hooks rather than directly in the component body.

Why

react-doctor flagged SidebarProviderUpdatePill for redundant effect-driven state and state used only in handlers. The old mount path did extra commits to mirror provider timestamps and seed rendered state. After the fix, the targeted SidebarProviderUpdatePill findings are gone: react-doctor issue count dropped from 162 to 158 overall, and State only used in handlers dropped from 6 to 4 with no remaining hit in this component.

React Scan proof:

  • Before recording: react_scan_provider_pill_before.mp4 — 5 identical remounts ended at 10 Profiler commits.
  • After recording: react_scan_provider_pill_after.mp4 — the same 5 remounts ended at 5 Profiler commits.

UI Changes

No intended visual UI change. The recordings demonstrate the render behavior change with React Scan enabled.

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

Validation:

  • corepack pnpm --filter @t3tools/web exec tsgo --noEmit
  • corepack pnpm dlx react-doctor@latest . --verbose --category performance --no-telemetry (expected non-zero due to remaining unrelated findings)
  • NODE_OPTIONS="--experimental-strip-types" corepack pnpm exec vp check
  • corepack pnpm exec vp run typecheck
Open in Web View Automation 

Note

Optimize SidebarProviderUpdatePill renders by replacing state with refs and a mount-time timestamp

  • Replaces visibleAfterIso state (derived from providers' checkedAt values) with a useMountedIsoTimestamp hook that captures a stable ISO timestamp at mount time, so getProviderUpdateSidebarPillView is called with a fixed reference point.
  • Replaces pendingView and dismissAfterExitKey state variables with useRef-backed equivalents, avoiding intermediate re-renders during exit transitions.
  • Extracts synchronization and auto-dismiss effects into useProviderUpdateRenderedViewSynchronization and useProviderUpdateAutoDismiss custom hooks in SidebarProviderUpdatePill.tsx.
  • Behavioral Change: the pill now evaluates provider updates relative to component mount time rather than the latest provider checkedAt timestamp.
📊 Macroscope summarized bd8657a. 1 file reviewed, 0 issues evaluated, 0 issues filtered, 0 comments posted

🗂️ Filtered Issues

No issues evaluated.

cursoragent and others added 2 commits July 8, 2026 16:15
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:L 100-499 changed lines (additions + deletions). labels Jul 8, 2026
const navigate = useNavigate();
const providers = useAtomValue(primaryServerProvidersAtom);
const [dismissedKeys, setDismissedKeys] = useState<ReadonlySet<string>>(() => new Set());
const visibleAfterIso = useMountedIsoTimestamp();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Medium sidebar/SidebarProviderUpdatePill.tsx:95

On sidebar remount or page reload, recently completed provider updates (succeeded/failed/unchanged) are silently filtered out and never shown to the user. visibleAfterIso is captured at component mount time via useMountedIsoTimestamp, and isRecentTerminalProvider only keeps terminal updates whose finishedAt is after that timestamp. But the providers in the server snapshot may have a finishedAt that is already in the past relative to mount — yet still represents a newly completed update the user hasn't been notified about. The result is the pill never appears for those updates after a remount. Consider deriving the cutoff from the providers' own timestamps (e.g. the latest prior checkedAt) rather than from the component mount clock, so updates that completed before mount are still shown.

🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
In file @apps/web/src/components/sidebar/SidebarProviderUpdatePill.tsx around line 95:

On sidebar remount or page reload, recently completed provider updates (succeeded/failed/unchanged) are silently filtered out and never shown to the user. `visibleAfterIso` is captured at component mount time via `useMountedIsoTimestamp`, and `isRecentTerminalProvider` only keeps terminal updates whose `finishedAt` is after that timestamp. But the providers in the server snapshot may have a `finishedAt` that is already in the past relative to mount — yet still represents a newly completed update the user hasn't been notified about. The result is the pill never appears for those updates after a remount. Consider deriving the cutoff from the providers' own timestamps (e.g. the latest prior `checkedAt`) rather than from the component mount clock, so updates that completed before mount are still shown.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100-499 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