Skip to content

perf(web): sidebar rows no longer re-render on unrelated server-config updates - #40019

Closed
only21mil wants to merge 1 commit into
pingdotgg:mainfrom
only21mil:perf/sidebar-server-config-boolean-atoms
Closed

only21mil wants to merge 1 commit into
pingdotgg:mainfrom
only21mil:perf/sidebar-server-config-boolean-atoms

Conversation

@only21mil

Copy link
Copy Markdown
Contributor

Problem

On load or reconnect, each sidebar thread row re-renders every time the server-config Map is replaced, which happens twice during startup. Each row only needs one boolean per environment (config loaded, issues capability), and those don't change. At 300 threads that is 600 wasted row renders per load.

Change

useSupportsMultiplePullRequests and useSidebarLinkedIssueState now read per-environment boolean atoms (useEnvironmentServerConfigLoaded, useEnvironmentSupportsIssues) derived from serverConfigsAtom, instead of subscribing to the whole Map. Rows still re-render when an environment's config presence or issues capability actually changes. Rows without linked issues don't subscribe to the issues atom at all.

Scope

Fixes #39934

The separate providerEntryByInstanceId row passes (#39933) are intentionally left out.

Verification

Setup: Linux x86_64, Node v26.13.1, production apps/web build served by apps/server, isolated home, T3CODE_DEV_SEED=0, TZ=UTC, 10 projects x 30 finished devReplay threads = 300 threads.

Steps: an AI agent ran the issue's probe script, 10 loads each on base 2770bf3c61 and candidate 08fd6f8d3f.

Base 2770bf3c61 Candidate 08fd6f8d3f
rowRenders 2113 (10/10 loads) 1513 (10/10 loads)
hook59:Map(1) 600 (10/10 loads) 0 (10/10 loads)
longTaskMs median 1613 (1528-2065) 1446 (1361-1852)

mount: 300, props:providerEntryByInstanceId: 600, props:sortable: 300, hook52:Array: 300 and hook76:Object: 13 are unchanged. One load from each log, unedited:

Base 2770bf3c61:

{"run":0,"longTaskMs":1601,"rowRenders":2113,"items":300,"why":{"mount":300,"props:providerEntryByInstanceId":600,"hook59:Map(1)":600,"hook76:Object":13,"props:sortable":300,"hook52:Array":300}}

Candidate 08fd6f8d3f:

{"run":6,"longTaskMs":1473,"rowRenders":1513,"items":300,"why":{"mount":300,"props:providerEntryByInstanceId":600,"hook76:Object":13,"props:sortable":300,"hook52:Array":300}}

Regression test: a new case in Sidebar.browser.test.tsx (sidebar render isolation) checks that unrelated config updates leave both hooks quiet and that real capability or config changes still re-render them. It fails on base (expected "vi.fn()" to be called 1 times, but got 2 times) and passes on the candidate. Test delta is quiet (+1 test, no new files).

Gates: an AI agent ran vp run check:changed 2770bf3c61 on Node v26.13.1: format, lint (0 warnings, 0 errors), knip, typecheck (2 packages), 5 test files / 25 tests and the React compiler check all passed.

Links: #39934

Not shown: Windows Server 2025 was not measured; only Linux x86_64 ran.

Generated with Claude Opus 5.5 in T3 Code Nightly

…ooleans

Subscribe sidebar thread row hooks to per-environment boolean atoms instead of the whole server-config map so unrelated server-config updates do not re-render every sidebar row.
@github-actions github-actions Bot added vouch:unvouched Author is not yet trusted in the VOUCHED list. size:M 30-99 changed lines (additions + deletions). labels Nov 21, 2026
@coderabbitai

coderabbitai Bot commented Nov 21, 2026

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The changes add per-environment server-config selectors and use them in the multiple-pull-request and linked-issue hooks. Browser tests cover selector updates, environment-specific configuration state, and rerender behavior.

Changes: Per-environment server-config subscriptions

Layer / File(s) Summary
Per-environment selectors
apps/web/src/state/entities.ts
Adds atoms and hooks that report whether an environment's server configuration is loaded and whether it supports issues. Both hooks return false for a null environment ID.
Hook subscriptions
apps/web/src/hooks/useSupportsMultiplePullRequests.ts, apps/web/src/state/issues.ts
The multiple-pull-request hook delegates to the configuration-loaded hook. The linked-issue state hook uses the issue-support hook when links are present.
Selector regression tests
apps/web/src/components/Sidebar.browser.test.tsx, apps/web/src/components/ThreadStatusIndicators.linkedPr.browser.test.tsx, apps/web/src/components/chat/ThreadDetailsPanel.browser.test.tsx, apps/web/src/components/chat/ThreadDetailsPrRow.browser.test.tsx
Tests verify that unrelated configuration updates do not rerender the tested hooks, that environment-specific configuration state is respected, and that removing configuration updates the relevant hook results.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Refactor · Severity of issue fixed: Medium

Suggested reviewers: juliusmarminge, bil0000

Merge Risk: Minimal · up to 08fd6

This change reduces unnecessary sidebar row re-renders by subscribing to per-environment values. Rows still update when an environment's config presence or issues capability changes. No actionable merge risk was identified.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title states the main change: sidebar rows stop re-rendering on unrelated server-config updates. It follows conventional commit form with a perf(web) scope. It matches the raw summary, which shows…
Description check Passed The description follows the template. It has Problem, Change, Scope, and Verification sections. The Problem section explains the re-render cause and the cost. The Change section names the hooks and at…
Linked Issues check Passed [#39934] requires sidebar thread rows to stop re-rendering when the whole server-config Map is replaced, while still re-rendering on real config presence or issues capability changes. The reviewed hea…
Out of Scope Changes check Passed All changed files relate to the #39934 objective. Source changes are apps/web/src/state/entities.ts (new per-environment atoms and hooks, per the summary), apps/web/src/state/issues.ts (verified in di…
Full details: Title check

Explanation

The title states the main change: sidebar rows stop re-rendering on unrelated server-config updates. It follows conventional commit form with a perf(web) scope. It matches the raw summary, which shows the hooks now read per-environment booleans instead of the whole server-config Map.

Full details: Description check

Explanation

The description follows the template. It has Problem, Change, Scope, and Verification sections. The Problem section explains the re-render cause and the cost. The Change section names the hooks and atoms. The Scope section links #39934 and explains the exclusion of #39933. The Verification section gives the setup, measured results, a regression test, gate results, and the untested Windows case. It does not include screenshots, but the change is not a UI visual change, so that omission is acceptable. The template's agent-model line is present. The Problem section gives a short reproduction setup in Verification.

Full details: Linked Issues check

Explanation

[#39934] requires sidebar thread rows to stop re-rendering when the whole server-config Map is replaced, while still re-rendering on real config presence or issues capability changes. The reviewed head meets this in the code I could read. In apps/web/src/state/issues.ts, useSidebarLinkedIssueState now calls useEnvironmentSupportsIssues(links?.length ? environmentId : null) instead of useServerConfigs(). Rows without links pass null, so they do not subscribe to the issues atom. The PR summary states that useSupportsMultiplePullRequests now returns useEnvironmentServerConfigLoaded(environmentId), and that entities.ts adds both per-environment atoms and hooks that return false for a null ID. The entities.ts diff blob was unavailable, so those atom and hook details rest on the summary, not on a direct read. The summary also reports a new regression test in Sidebar.browser.test.tsx (sidebar render isolation) that fails on base and passes on the candidate. Measurements on Windows, which the issue requests, are non-coding acceptance evidence and are not assessed here. The Linux measurements in the PR description show Map-attributed renders falling from 600 to 0.

Full details: Out of Scope Changes check

Explanation

All changed files relate to the #39934 objective. Source changes are apps/web/src/state/entities.ts (new per-environment atoms and hooks, per the summary), apps/web/src/state/issues.ts (verified in diff: linked-issue state reads the per-environment issues boolean), and apps/web/src/hooks/useSupportsMultiplePullRequests.ts (per the summary, switches to the per-environment loaded boolean). Test changes in Sidebar.browser.test.tsx, ThreadStatusIndicators.linkedPr.browser.test.tsx, ThreadDetailsPanel.browser.test.tsx, and ThreadDetailsPrRow.browser.test.tsx are supporting changes. Their mocks of useEnvironmentServerConfigLoaded were added or narrowed to match the new hook. The PR explicitly excludes the providerEntryByInstanceId passes (#39933), and no change in the summary touches that code. No unrelated change was identified.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between a04bca5 and 08fd6f8.

Files selected for processing: 7

  • apps/web/src/components/Sidebar.browser.test.tsx
  • apps/web/src/components/ThreadStatusIndicators.linkedPr.browser.test.tsx
  • apps/web/src/components/chat/ThreadDetailsPanel.browser.test.tsx
  • apps/web/src/components/chat/ThreadDetailsPrRow.browser.test.tsx
  • apps/web/src/hooks/useSupportsMultiplePullRequests.ts
  • apps/web/src/state/entities.ts
  • apps/web/src/state/issues.ts

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

@juliusmarminge

Copy link
Copy Markdown
Member

Thanks for this. #40048 makes the same change and is the one being kept.

#40048 makes the same per-environment boolean subscription change with a smaller patch and includes measurements on the Windows platform requested by the issue. That platform evidence is the deciding difference.

Your render-isolation regression test adds useful coverage for unrelated updates and real capability changes. It would be worth carrying that coverage into the kept change.

Closing as a duplicate.

@only21mil

Copy link
Copy Markdown
Contributor Author

That makes sense. I'll start on another issue you posted and get that one done.

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:unvouched Author is not yet trusted in the VOUCHED list.

Projects

None yet

2 participants