Skip to content
Source
Sign inSign up
pingdotgg/t3code

perf(web): provider status pushes no longer re-render every timeline row #20854

Mergedjuliusmarmingemerged 1 commit intomain fromrefs/pull/20854/headmerged by juliusmarminge View on GitHub

juliusmarmingecommented

Problem

Render audit, lane 4, thread view on a 5.5k-item thread, idle across one providerStatuses push where only providers[].checkedAt, usageLimits.checkedAt and versionAdvisory.checkedAt change: 818 renders in 2 commits. The audit found two causes:

  1. ChatView passed the environment's serverConfig.providers to MessagesTimeline as providerStatuses, and MessagesTimeline put it in the TimelineRowCtx shared state. Each push builds a new providers array, so sharedState was rebuilt and every row that reads the context re-rendered: about 14 AssistantTimelineRow/AssistantMessageMeta/AssistantForkButton, 12 TurnFoldTimelineRow, and about 300 tooltips under them. Only subagent rows, subagent notification links and handoff rows use providers.
  2. Every ChatMarkdown subscribed to the whole server-config map through usePullRequestLinking. #20852 already fixes this with a per-environment linkModeAtom, so this PR does not touch it.

Fix

  • providerStatuses is gone from TimelineRowCtx, the MessagesTimeline props, and ChatView, which also drops timelineProviders.
  • The leaves that need providers read serverEnvironment.providersValueAtom(environmentId) themselves:
    • EnvironmentSubagentAvatar (subagent group header and SubagentTimelineLink) uses two useAtomValue selectors that return only displayName and iconUrl. Those are strings, so a checkedAt-only push gives Object.is-equal results and the avatar does not re-render.
    • SubagentTimelineTooltip reads the full list. It mounts only while its hover popup is open.
    • Handoff rows go through EnvironmentHandoffRow, which reads the list and renders the existing HandoffRow. ChatView's pending-handoff HandoffRow is unchanged.

No useMemo, useCallback, memo or "use memo" was added.

Why consumers now bail out (compiled output, oxc-transform-react)

These files were compiled with reactCompiler: { reportDiagnostics: true }, the same call reactCompilerCoverage.test.ts makes: MessagesTimeline.tsx, V2LifecycleRow.tsx and ChatView.tsx. All three report 0 diagnostics.

ConversationTimeline builds sharedState (t88) under one guard. That guard used to include $[…] !== providerStatuses. It now reads:

if ($[178] !== activeThreadEnvironmentId || $[179] !== citationThreadRef || … || $[202] !== runs || $[203] !== skills || … || $[211] !== workspaceRoot) {
  t88 = { citationRequest: readyCitationRequest, … };

Nothing in that guard changes on a provider push, so TimelineRowCtx keeps its value and the use(TimelineRowCtx) readers do not re-render.

EnvironmentSubagentAvatar compiles to:

t2 = (providers) => providers?.find((provider) => provider.instanceId === providerInstanceId)?.displayName; // cached on providerInstanceId
const displayName = useAtomValue(providersAtom, t2);

The selector is stable and returns a string. useSyncExternalStore compares that string, so the avatar only re-renders when the name or icon actually changes.

What still renders on a provider push

  • ChatView itself, which reads providers for the composer, the model picker and the pending-handoff row.
  • Visible handoff rows and open subagent tooltips, which use model names and display names from the full list.
  • ChatMarkdown blocks, until #20852 lands.

After:

Checks run: MessagesTimeline.test.tsx (88 passed; the handoff test now supplies providers through the atom with RegistryProvider initialValues), the apps/web typecheck, and scoped lint on the changed files.

🤖 Generated with Claude Code

    1. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted

    2. juliusmarminge added labelsmacroscope-review

    3. Approvability

      Verdict: Approved at d5c5684

      Macroscope's review found this PR approvable — This is a contained web performance refactor that removes provider-status updates from the shared timeline context while preserving provider data access where the UI needs it. It introduces no new capability, schema or default change, deployment change, or static-analysis suppression.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    4. Review in Change Stack →

      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: 2d7a501f-1ca3-4335-9c1a-223edf88295b
      📥 Commits

      Reviewing files that changed from the base of the PR and between 2fbd4318fc5b610c3e7fcfcbd5bbd80b73521d8f and d5c568455d8b1576b41d443bae6882546a4b2892.

      📒 Files selected for processing: 4
      • apps/web/src/components/ChatView.tsx
      • apps/web/src/components/chat/MessagesTimeline.test.tsx
      • apps/web/src/components/chat/MessagesTimeline.tsx
      • apps/web/src/components/chat/V2LifecycleRow.tsx
      💤 Files with no reviewable changes: 1
      • apps/web/src/components/ChatView.tsx

      Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.

      📝 Walkthrough

      Chat timelines no longer receive provider status lists through props. Handoff rows, subagent avatars, and tooltips read provider data from the relevant environment. The timeline props also support optional skills data.

      Changes: Chat timeline provider data

      Layer / File(s)Summary
      Timeline provider contract and wiring
      apps/web/src/components/ChatView.tsx, apps/web/src/components/chat/MessagesTimeline.tsx, apps/web/src/components/chat/V2LifecycleRow.tsx
      Timeline props and row state no longer carry provider statuses. ChatView and timeline call sites stop passing those statuses.
      Environment-scoped handoff and subagent rendering
      apps/web/src/components/chat/V2LifecycleRow.tsx, apps/web/src/components/chat/MessagesTimeline.tsx, apps/web/src/components/chat/MessagesTimeline.test.tsx
      Handoff rows, subagent avatars, and tooltips read provider data from the relevant environment. Handoff tests provide provider data through the environment atom.

      Priority: ⬇️ Low

      Estimated code review effort: 2 (Simple) | ~10 minutes

      Change: Refactor

      Suggested reviewers: maria-rcks

      Merge Risk: ⚪ Minimal · up to d5c56

      This change stops provider-status pushes from re-rendering every timeline row. Provider data is now read at the components that use it. No concrete merge-blocking risk was identified.

      Pre-merge checks: Passed 3 · Failed 1
      Failed Failed checks: 1 warning
      Check nameStatusExplanationResolution
      Description checkWarningThe description clearly explains the problem, root causes, implementation, remaining renders, and checks performed. However, it omits the required Scope and approval section, does not provide issue or…Add the required Scope and approval section with the triaged issue or explicit maintainer approval, or explain why this focused fix qualifies for an exemption. Add a Verification section with the observed post-change render result and state…
      Passed Passed checks: 3 passed
      Check nameStatusExplanation
      Title checkPassedThe title clearly and concisely describes the primary performance change: provider-status pushes no longer re-render timeline rows.
      Linked Issues checkPassedCheck skipped because no linked issues were found for this pull request.
      Out of Scope Changes checkPassedCheck skipped because no linked issues were found for this pull request.
      Full details: Description check

      Explanation

      The description clearly explains the problem, root causes, implementation, remaining renders, and checks performed. However, it omits the required Scope and approval section, does not provide issue or maintainer-approval information, and does not report the post-change render measurement. It also uses ## Fix and Checks run instead of the template headings.

      Resolution

      Add the required Scope and approval section with the triaged issue or explicit maintainer approval, or explain why this focused fix qualifies for an exemption. Add a Verification section with the observed post-change render result and state any checks that remain incomplete. Use the template headings, and include UI evidence if the changed behavior requires it.

      • Fix all pre-merge checks with AI
      ✨ 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
      Comment `@coderabbitai help` to get the list of available commands.
    5. Re-measured in the app (seeded data, same scenario, median of 3):

      Measured against main at 489d08a054, with this PR's commit cherry-picked onto that same commit (it applies cleanly). The server ran without --watch, and no window had a reconnect.

      Scenario: the large thread (Evaluate Markdown Renderer Replacement, 713 messages) sits idle. A second browser session clicks Settings > Providers > Refresh provider status, and I measure a 15 s window. Each refresh delivers 3 to 4 providerStatuses pushes, and both sides got the same number.

      scenariomainthis PR
      large thread idle across a provider refresh: commits / renders4 / 16264 / 1254
      ↳ timeline renders58041
      ↳ AssistantTimelineRow / TurnFoldTimelineRow28 / 240 / 0
      ↳ TooltipTrigger230134

      The timeline fan-out from props:providerStatuses → TimelineRowCtx is gone. On main every push re-rendered every visible assistant row, its meta, its fork button and every turn fold. With this PR, the only timeline renders left are ChatMarkdown state#8 (one per message) and MessagesTimeline itself.

      What still renders:

      • In one of the three PR windows, 20 SkillInlineText props:skills renders and a handful of row context renders showed up. That's the first refresh after a server restart, when skills actually change. #20855 handles skill identity separately.
      • Outside the timeline (~1050 per window, same on both sides): sidebar rows (~570), the thread details panel (~220) and the composer (~115) all re-render on each provider push. Those read the provider list or the presentation for other reasons, so they're out of scope here.

      Behaviour check: in the "Take Over PR 6315" thread, subagent rows in the timeline still show the provider avatar ("Build layer 1: issue tracker core · Finished"). Hovering it still opens the subagent tooltip with the model and status ("Claude Fable 5.1 · medium · completed 24m 34s"). The lineage panel still lists all six previous agents with their icons.

    6. juliusmarminge merged thisecb938d

    7. juliusmarminge closed this

Sign in to join this conversation.