perf(client): a reconnect snapshot keeps unchanged skills and providers identical #20855
main fromrefs/pull/20855/head·merged by juliusmarminge View on GitHubProblem#
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
MarkdownListItemcontext fan-out fromChatMarkdown'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
juliusmarminge added labelsmacroscope-review
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:XS
Approvability#
Verdict: Approved at
acaa63bMacroscope'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).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.tspackages/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
checkedAtwhile retaining the previousskillsreference.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.tsWhen a current projection exists, snapshot handling passes the merged config through reuseUnchanged. The test checks that the second snapshot has the updatedcheckedAtand retains the first snapshot’sskillsreference.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:
4-
Check name Status Explanation Title check The title clearly identifies the client performance improvement: reconnect snapshots preserve unchanged skills and providers by identity. Description check 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 t… Linked Issues check Check skipped because no linked issues were found for this pull request. Out of Scope Changes check Check 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#
- Mode: Continue automatically
- Reviewed files: 2
- Charged: $0.50
- View usage details
Comment `@coderabbitai help` to get the list of available commands.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.
-
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 forwelcome, 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.scenario main this PR prose/links thread, idle across a reconnect: commits / renders 52 / 5429 58 / 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 / renders 45 / 12712 46 / 11410 ↳ SkillInlineText props:skills726 0 ↳ MarkdownListItem/SkillInlineText4320 / 4356 3600 / 3636 The targeted cause is gone. A reconnect snapshot no longer gives
timelineSkillsa new identity, soSkillInlineTextstops getting newskillsprops. That held in 5 of 6 windows. In one window on the prose thread, 20props:skillsrenders 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 everyMarkdownListItem/MarkdownParagraphand theSkillInlineTextunder them asparent-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.juliusmarminge merged thisbc5f754
juliusmarminge closed this
Sign in to join this conversation.
macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes