Skip to content

fix(web): sidebar rows no longer re-render when the server-config map is replaced - #40048

Open
juliusmarminge wants to merge 2 commits into
mainfrom
factory/issue-39934
Open

juliusmarminge wants to merge 2 commits into
mainfrom
factory/issue-39934

Conversation

@juliusmarminge

Copy link
Copy Markdown
Member

Each time the server config was refreshed while the app loaded, every sidebar thread row re-rendered, even when nothing a row shows had changed. At 300 threads on Windows that added hundreds of milliseconds of main-thread work per load. The rows now subscribe only to the one value per environment they use.

  • useSupportsMultiplePullRequests reads a new per-environment useHasServerConfig atom instead of the whole server-config map.
  • useSidebarLinkedIssueState reads a new per-environment useSupportsIssues atom.
  • Both atoms are Atom.family selectors over serverConfigsAtom in apps/web/src/state/entities.ts. Rows still update when an environment gains or loses its config or its issues support.

Fixes #39934

Reproduction on main

Commit f2ec853 (origin/main) on a pooled Windows Server 2025 machine. Steps: vp i; cd apps/web && vp build; from apps/server started T3CODE_DEV_SEED=0 node src/bin.ts serve --base-dir <home> --port 3799 --host 127.0.0.1 --dev-url http://localhost:5733; ran the issue's seed.cjs with 10 30 4 (DONE 300); restarted the server on the same home without --dev-url (production web); minted a pairing URL with node src/bin.ts pair --ttl 2h; ran the issue's probe.cjs unchanged for 16 loads. Main: 300 rows in every load; in 13/16 loads the rows got 600 extra renders attributed to hook59:Map(1) (the server-config map), median row renders 2113. Long-task total median over all loads 3965 ms (2599-4320); affected loads median 4041 ms (3685-4320); unaffected loads 2599/2664/2954 ms. Comparison on the same machine, seed and home: scratch build where useSupportsMultiplePullRequests and useSidebarLinkedIssueState read per-environment boolean atoms (Atom.family over serverConfigsAtom), 16 loads: Map(1)-attributed renders 0 in every load, median row renders 1513; long-task median over all loads 3298.5 ms (2423-3582); affected loads (13/16, still showing the separate 600 provider-entry renders) median 3301 ms (3193-3582). That is about 740 ms saved per affected load. Logs: https://gh-file-drop-api-prod-mi5fy3sowv63ufte.pinglabs.workers.dev/f/efd5195910e366b3/main-utf8.log (main), https://gh-file-drop-api-prod-mi5fy3sowv63ufte.pinglabs.workers.dev/f/f633091dd4385c98/fix-utf8.log (scratch), scratch patch https://gh-file-drop-api-prod-mi5fy3sowv63ufte.pinglabs.workers.dev/f/45fbe051ac3d3451/scratch-fix.diff

Evidence

Being captured: before and after in the real app. This section is filled in before the pull request can merge.

Tests

  • vp run check:changed: format, lint, knip, typecheck (2 packages), test (1 file) and react compiler (3 files) all pass.
  • node probe.cjs from the issue, 16 loads on main and 16 on the fix, on Windows Server 2025 with a 300-thread seed: Map-caused row renders went from 600-900 (7/16 loads) to 0 (16/16), and the affected-load long-task median from 3483 ms to 3233.5 ms.

Not in this change

  • The 600 separate providerEntryByInstanceId row renders during startup remain; the issue says they are filed separately.
  • Many other components still call useServerConfigs() for one field; they are not per-row, so they were left alone.

Who did the work

  • Written by Claude Opus 5.5, in Claude Code
  • Reviewed by GPT-6.1 Sol, in Codex, and by Claude Opus 5.5, each on its own
  • Proof captured by GPT-6.1 Sol and checked by Claude Opus 5.5

Run by the t3code factory in T3 Code.

… is replaced

useSupportsMultiplePullRequests and useSidebarLinkedIssueState subscribed
to the whole server-config map for one boolean per environment, so every
replacement of the map during startup re-rendered every sidebar row. They
now read per-environment boolean atoms that only notify when the boolean
changes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added vouch:trusted Author is trusted by repo permissions or the VOUCHED list. size:M 30-99 changed lines (additions + deletions). labels Nov 21, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thread transfer impact

⚠️ The latest CI run did not produce a thread transfer result for 4810e3b.

This comment will update automatically after the next completed run.

@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 change adds per-environment hooks for server-config presence and issue capability. The multiple-pull-request and linked-issue hooks now use these hooks instead of reading the full server-config map. Related test mocks provide the server-config presence hook.

Changes: Server-config boolean hooks

Layer / File(s) Summary
Per-environment boolean atoms
apps/web/src/state/entities.ts
Added atoms and hooks that report whether an environment has a server config and whether its issues capability is exactly true.
Sidebar hook subscriptions and test mocks
apps/web/src/hooks/useSupportsMultiplePullRequests.ts, apps/web/src/state/issues.ts, 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
The multiple-pull-request hook uses the server-config presence hook. The linked-issue hook uses the issue-capability hook to gate aggregate creation. Test mocks now provide the server-config presence hook.

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

Change: Refactor · Severity of issue fixed: Medium

Possibly related issues

  • Issue 39933 describes a separate source of sidebar row re-renders. This change does not implement a fix for that source.

Suggested reviewers: shivamhwp, t3dotgg, maria-rcks

Merge Risk: Minimal · up to 41a97

This change narrows sidebar subscriptions so rows re-render only when their own environment's config presence or issues support changes. Behavior is preserved, and no concrete merge risk was identified.

Pre-merge checks: Passed 3 · Inconclusive 1

Failed Failed checks: 1 inconclusive

Check name Status Explanation Resolution
Description check Inconclusive The description follows the repository template. It gives a clear problem statement, a change explanation, a scope that links issue #39934, a verification section with measured results, and a who-did-… Capture and attach the before/after evidence in the Evidence section before merge. The template requires before/after screenshots or a recording for UI changes, and the section currently says it is still being captured. Upload the files to …
Passed Passed checks: 3 passed

Check name Status Explanation
Title check Passed The title names the main change: sidebar rows stop re-rendering when the server-config map is replaced. The changeset adds per-environment atoms (useHasServerConfig, useSupportsIssues) so rows subscri…
Linked Issues check Passed Issue #39934 is the only active direct target. Its coding requirement: sidebar row hooks must stop subscribing to the whole server-config map for one boolean, and rows must still update when config pr…
Out of Scope Changes check Passed The change touches apps/web/src/state/entities.ts (new per-environment atoms and hooks), apps/web/src/state/issues.ts (useSidebarLinkedIssueState switches to useSupportsIssues), and `apps/web/…
Full details: Title check

Explanation

The title names the main change: sidebar rows stop re-rendering when the server-config map is replaced. The changeset adds per-environment atoms (useHasServerConfig, useSupportsIssues) so rows subscribe only to the values they use. The title is specific and follows the conventional commit format from the template. It is a fix, and the description and linked issue describe a render-reduction bug.

Full details: Linked Issues check

Explanation

Issue #39934 is the only active direct target. Its coding requirement: sidebar row hooks must stop subscribing to the whole server-config map for one boolean, and rows must still update when config presence or issues capability changes.

Evidence at head:

  • apps/web/src/state/entities.ts defines hasServerConfigAtom (Atom.family over environmentPresentations.serverConfigsAtom, returns environmentId !== null &amp;&amp; map.has(environmentId)) and supportsIssuesAtom (returns map.get(environmentId)?.environment.capabilities.issues === true). It exports useHasServerConfig and useSupportsIssues.
  • apps/web/src/hooks/useSupportsMultiplePullRequests.ts now returns useHasServerConfig(environmentId). Its null handling matches the previous behavior.
  • useSidebarLinkedIssueState in apps/web/src/state/issues.ts reads useSupportsIssues, per the PR summary. I did not re-read that file at head.

Each row hook now subscribes to a boolean per environment. Those booleans change only when config presence or the issues capability changes, so rows still re-render on those changes and no longer re-render on every map replacement.

Unresolved: the timing and probe results in the PR body are not verified here. The Evidence section is still marked as being captured. The commenter's failing test and CI reports refer to commit 4810e3b and were not re-checked at head. These are verification steps, not coding requirements of the issue. The ThreadDetailsIssueRows read of the map is outside the row objective named in the issue.

Full details: Out of Scope Changes check

Explanation

The change touches apps/web/src/state/entities.ts (new per-environment atoms and hooks), apps/web/src/state/issues.ts (useSidebarLinkedIssueState switches to useSupportsIssues), and apps/web/src/hooks/useSupportsMultiplePullRequests.ts (switches to useHasServerConfig). Each change directly supports the row-subscription objective of #39934. The changed browser test mocks (ThreadStatusIndicators.linkedPr.browser.test.tsx, ThreadDetailsPanel.browser.test.tsx, ThreadDetailsPrRow.browser.test.tsx) add useHasServerConfig to existing mocks. This supports the renamed hook dependency and is not unrelated work. The PR leaves the provider-entry passes and other useServerConfigs() callers unchanged, which matches the issue scope. I found no unrelated change.

Full details: Description check

Explanation

The description follows the repository template. It gives a clear problem statement, a change explanation, a scope that links issue #39934, a verification section with measured results, and a who-did-the-work section. The Evidence section is explicitly marked as pending, which is a gap. The UI change requires before/after screenshots or a recording under the template, and those are not yet attached. The Scope section also refers to an issue that is linked, so scope is satisfied.

Resolution

Capture and attach the before/after evidence in the Evidence section before merge. The template requires before/after screenshots or a recording for UI changes, and the section currently says it is still being captured. Upload the files to GitHub and embed or link them. Also consider reconciling the verification results with the linked issue's acceptance criteria (for example, the Linux reproduction in the comments reported a long-task improvement was not reliable), and confirm that the failing test noted in the comments (state/presentation.test.ts) and the failing CI jobs are addressed.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • 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 4810e3b and 41a9797.

Files selected for processing: 3

  • 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

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

@shivamhwp

Copy link
Copy Markdown
Collaborator

Findings from the agent that worked on #39934 before Julius took it over (my PR was #40049; this PR now supersedes it).

Reproduced: on the web client, using the production build served from source with the issue's 300-thread seed. Headless Chromium on a Linux VM, base commit d984b71. Not Windows, so the Windows numbers in this PR's body are not reproduced here.

Result on base: 600 Map-attributed row renders (hook…:Map(1)) in 6 of 12 loads in one run and 5 of 12 in another. With the same atom change as this PR, the probe showed 0 of 12 loads in both runs. The separate 600 providerEntryByInstanceId renders stay in every load, as the PR says.

Timing: not claimed. Long-task medians were noisy on that VM: base 2144 ms and 3934 ms across two runs; with the change, 2519 ms and 1830 ms. I don't have a timing comparison I'd stand behind on that machine.

Tests: vp run check:changed passed on the working tree (format, lint, knip, typecheck, 3 test files, React compiler). The unit test state/presentation.test.ts ("notifies a row only when its own environment's flag changes") fails when the subscription is to the whole Map.

Checks on 4810e3b: Check, Test Web 1 and Test Web 2 are failing. I haven't looked into them.

Not run: the integrated pass in T3's browser tools against the web client. Also, ThreadDetailsIssueRows still reads the Map while the issue tooltip is open.

Posted by the agent working for Shivam, via T3 Code.

juliusmarminge added a commit that referenced this pull request Nov 21, 2026
The useSupportsMultiplePullRequests change and its test mocks fix #39934,
which #40048 covers with its own evidence. Keep this PR to the provider
model comparison.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

This branch has not been deployed

No deployments
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:trusted Author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

2 participants