Skip to content
Source
Sign inSign up
pingdotgg/t3code

perf(client): a reconnect snapshot keeps unchanged skills and providers identical #20855

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

juliusmarmingecommented

Problem

The render audit (thread view timeline, idle 20s across an environment reconnect: 45 commits, 7554 renders) logged 248 SkillInlineText renders caused by props:skills, plus the 800 that follow from their MarkdownListItem parents. ChatView's timelineSkills is resolveProviderSkillsForCwd(activeProviderStatus, gitCwd), and it goes to every message's SkillInlineText.

providerStatuses pushes already keep unchanged skill arrays since #20392 (reuseUnchanged). The snapshot event that every reconnect sends did not. applyServerConfigProjection replaced the whole config, so each reconnect gave every provider, model, skill and workspace snapshot a new identity even when only checkedAt changed.

Fix

The snapshot case now runs the new config through reuseUnchanged against the current projection, the same way providerStatuses is handled. Unchanged providers[].skills and workspaceSnapshots[].skills keep their references, so timelineSkills keeps its identity. The fix sits at the source, so web and mobile both get it, along with every other reader of the config (models, slash commands, settings).

This doesn't overlap with #20821 (it splits providers out of the presentation atom) or #20851 (it compares providers while ignoring checkedAt). Both depend on nested values already being shared, and this makes that true after a reconnect too.

Why consumers now bail out

React Compiler output for SkillInlineText (oxc-transform-react, the same options as reactCompilerCoverage.test.ts):

function SkillInlineText(props) {
	const $ = _c(6);
	...
	if ($[0] !== props.skills || $[1] !== props.text) {
		// recompute matches and nodes

When props.skills keeps its reference, the cached element is returned and nothing under it renders. The ThreadFindCanvas findOptions.skills input also stays stable.

What still renders

  • ChatView itself still re-renders on each push and snapshot, because it reads the whole environment presentation. #20821 handles that.
  • A skill list that really changes, such as a skill added or a workspace snapshot that comes back with different skills, still produces a new array, as it should.
  • The MarkdownListItem context fan-out from ChatMarkdown's renderer context is a separate cause.

Test: serverConfigProjection.test.ts checks that a second snapshot keeps the previous skills array while it takes the new checkedAt.

After:

🤖 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 acaa63b

      Macroscope's review found this PR approvable — This is a focused client performance improvement that reuses unchanged nested configuration objects across reconnect snapshots while preserving updated values. It adds targeted unit coverage and does not change product defaults, schemas, or production infrastructure.

      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: 51750dcc-370e-4341-8d21-d18237a9dcec
      📥 Commits

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

      📒 Files selected for processing: 2
      • packages/client-runtime/src/state/serverConfigProjection.test.ts
      • packages/client-runtime/src/state/serverConfigProjection.ts

      Limit details: You’ve used all 10 included reviews currently available.

      📝 Walkthrough

      Snapshot projection now reuses deeply equal config objects and arrays from the current projection. A test checks that a later snapshot updates checkedAt while retaining the previous skills reference.

      Changes: Config Snapshot Projection

      Layer / File(s)Summary
      Merge snapshots and verify identity reuse
      packages/client-runtime/src/state/serverConfigProjection.ts, packages/client-runtime/src/state/serverConfigProjection.test.ts
      When a current projection exists, snapshot handling passes the merged config through reuseUnchanged. The test checks that the second snapshot has the updated checkedAt and retains the first snapshot’s skills reference.

      Priority: ⬇️ Low

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

      Change: Refactor

      Suggested reviewers: maria-rcks

      Merge Risk: ⚪ Minimal · up to acaa6

      No actionable merge-blocking risk was established for this change; it is ready for normal merge checks.

      Pre-merge checks: Passed 4
      Check nameStatusExplanation
      Title checkPassedThe title clearly identifies the client performance improvement: reconnect snapshots preserve unchanged skills and providers by identity.
      Description checkPassedThe description covers the problem, implementation, scope, affected consumers, limitations, and focused test. It is mostly complete, but it does not provide an issue or maintainer approval link, and t…
      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 covers the problem, implementation, scope, affected consumers, limitations, and focused test. It is mostly complete, but it does not provide an issue or maintainer approval link, and the post-change render measurement remains pending.

      ✨ 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

      Usage-based review receipt

      Note

      This review was completed with usage-based billing: files reviewed beyond your plan's included limits are billed at $0.25/file. View usage-based billing.

      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. Every window deliberately includes one reconnect: I restarted only my own server process group 2 s into the window, waited for welcome, and settled for 10 s. I counted only windows where the reconnect actually happened and the page didn't reload. Both sides saw 2 welcome/ready frames and 6 snapshots per window.

      scenariomainthis PR
      prose/links thread, idle across a reconnect: commits / renders52 / 542958 / 5377
      ↳ SkillInlineText props:skills20 (in 3 of 3 windows)0 (in 2 of 3 windows), 20 in the third
      list-heavy thread (200-line numbered reply), idle across a reconnect: commits / renders45 / 1271246 / 11410
      ↳ SkillInlineText props:skills7260
      ↳ MarkdownListItem / SkillInlineText4320 / 43563600 / 3636

      The targeted cause is gone. A reconnect snapshot no longer gives timelineSkills a new identity, so SkillInlineText stops getting new skills props. That held in 5 of 6 windows. In one window on the prose thread, 20 props:skills renders still appeared. All windows got the same frames, so my best guess is that a skill list really changed when the server restarted. I couldn't confirm that from the page.

      What still renders: the total only drops about 10%. The remaining fan-out is ChatMarkdown#18 (the presentation/server-config subscription) rebuilding the markdown context, which re-renders every MarkdownListItem/MarkdownParagraph and the SkillInlineText under them as parent-same-props. #20852 removes that, and these two PRs together are what make a reconnect cheap. This PR by itself isn't a big win, but it's correct and needed.

      Behaviour check (after a reconnect on this PR): typing $ in the composer still lists repo and personal skills. A message sent with the Agent Browser skill shows the "Agent Browser" chip in the timeline, and the chip is still there after a reconnect.

    6. juliusmarminge merged thisbc5f754

    7. juliusmarminge closed this

Sign in to join this conversation.