Uh oh!
There was an error while loading. Please reload this page.
fix(web): make the diff layout toggle a persisted setting - #9326
Conversation
The stacked/split diff toggle lived in two places with two lifetimes: a zustand store for the thread diff panel and plain component state in the pull request Code tab, which reset on every mount. Word wrap, whitespace handling, and the rest of the diff preferences already live in client settings. Diff layout is now a client setting (diffLayout, default stacked). Both toolbars read and write it, so one flip applies everywhere and survives reloads, and it gets a row under Settings > General with reset, search, and restore-defaults wiring like the neighbouring rows. Co-Authored-By: Claude Code <noreply@anthropic.com>
| const next = value[0]; | ||
| if (next === "stacked" || next === "split") { | ||
| setDiffRenderMode(next); | ||
| updateClientSettings({ diffLayout: next }); |
There was a problem hiding this comment.
🟡 MediumpullRequest/PullRequestCodeTab.tsx:1122
updateClientSettings({ diffLayout: next }) can be overwritten during initial settings hydration, causing the toggle and diff to revert to the user's selection. hydrateClientSettings() later replaces the snapshot with its stale persistedSettings because persistClientSettings does not invalidate the in-flight read; guard hydration against newer writes so the latest client setting wins.
Also found in 1 other location(s)
apps/web/src/components/DiffPanel.tsx:775
updateClientSettings({ diffLayout: next })can be overwritten by the initial asynchronous settings hydration. On a newly mounted panel,useClientSettingsinitially returns defaults whilehydrateClientSettings()is still awaitinggetClientSettings(); if the user changes the layout in that interval,persistClientSettingsupdates the snapshot but does not advance the hydration generation. When the pending read returns an older persisted layout, line 129 ofuseSettings.tsreplaces the snapshot with it, so the toggle and diff revert to the stale value (and the concurrent persistence operations can leave storage stale as well).
🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
In file @apps/web/src/components/pullRequest/PullRequestCodeTab.tsx around line 1122:
`updateClientSettings({ diffLayout: next })` can be overwritten during initial settings hydration, causing the toggle and diff to revert to the user's selection. `hydrateClientSettings()` later replaces the snapshot with its stale `persistedSettings` because `persistClientSettings` does not invalidate the in-flight read; guard hydration against newer writes so the latest client setting wins.
Also found in 1 other location(s):
- apps/web/src/components/DiffPanel.tsx:775 -- `updateClientSettings({ diffLayout: next })` can be overwritten by the initial asynchronous settings hydration. On a newly mounted panel, `useClientSettings` initially returns defaults while `hydrateClientSettings()` is still awaiting `getClientSettings()`; if the user changes the layout in that interval, `persistClientSettings` updates the snapshot but does not advance the hydration generation. When the pending read returns an older persisted layout, line 129 of `useSettings.ts` replaces the snapshot with it, so the toggle and diff revert to the stale value (and the concurrent persistence operations can leave storage stale as well).
There was a problem hiding this comment.
Pre-existing and out of scope here. hydrateClientSettings has never invalidated its in-flight read against later writes, and the same window applies to every other client-settings write (word wrap, whitespace, and the six existing useUpdateClientSettings callers). The window is a single localStorage read or desktop IPC round-trip at app boot, which resolves before a user can reach a diff toolbar. If we want to close it, that is a change to useSettings.ts on its own, not part of moving this one key.
Thread transfer impact✅ Thread transfer remains within every enforced ceiling.
Baseline: Scenario and decoded snapshot size10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed. |
ApprovabilityVerdict: Would Approve Macroscope's review found this PR approvable — This is a localized client-preference persistence change: existing diff layout controls now share a backward-compatible setting and retain the existing stacked default, with no production, security, billing, or deployment impact. An unresolved Medium-severity hydration race could briefly revert a newly selected layout and leave persistence stale. Not approved because:
Adjust the Minimum Blocking Severity for this repo — including turning it Off — in Settings. You can add or adjust custom eligibility rules. Learn more. |
Uh oh!
There was an error while loading. Please reload this page.
## What's Changed * chore(ci): only run check-run agents on vouched contributors by @juliusmarminge in pingdotgg/t3code#9298 * fix(web): stop remounting markdown on every activity delta by @juliusmarminge in pingdotgg/t3code#9306 * fix(pull-requests): keep cached PR chrome on reopen by @maria-rcks in pingdotgg/t3code#9294 * feat(environments): draw each environment as the machine it runs on by @juliusmarminge in pingdotgg/t3code#9299 * feat(web): apply and remove labels from the pull request tab by @juliusmarminge in pingdotgg/t3code#9313 * fix(sidebar): collapse settled and snoozed shelves by default by @maria-rcks in pingdotgg/t3code#9314 * refactor(media): unify file and media previews across clients by @juliusmarminge in pingdotgg/t3code#9253 * fix(chat): keep live tool labels in present tense by @maria-rcks in pingdotgg/t3code#9316 * chore: audit lint directives and move plugin allowlists into config by @juliusmarminge in pingdotgg/t3code#9300 * chore(ci): narrow the Effect conventions check-run agent by @juliusmarminge in pingdotgg/t3code#9321 * refactor(mobile): style plain views with Uniwind classes instead of the theme bridge by @juliusmarminge in pingdotgg/t3code#9322 * fix(dev): share dev servers on the loopback Vite actually binds by @juliusmarminge in pingdotgg/t3code#9324 * fix(web): line up the titlebar wordmark label and version pill by @tristanmanchester in pingdotgg/t3code#9255 * fix(web): make the diff layout toggle a persisted setting by @juliusmarminge in pingdotgg/t3code#9326 * chore: dedupe lightningcss and tailwind node bindings by @juliusmarminge in pingdotgg/t3code#9331 * chore: upgrade vite-plus to 0.3.0 by @juliusmarminge in pingdotgg/t3code#9327 * feat(web): add a file tree to the diff panel and pull request code tab by @juliusmarminge in pingdotgg/t3code#9330 * feat(web): add PageUp/PageDown chat navigation by @Yash-Singh1 in pingdotgg/t3code#9315 * fix(web): collapse PR header actions to icons when narrow by @maria-rcks in pingdotgg/t3code#9334 * fix(web): resolve Vite sourcemap and supports warnings by @juliusmarminge in pingdotgg/t3code#9343 * feat(web): choose whether links open in the default browser or in T3 Code by @juliusmarminge in pingdotgg/t3code#9339 * fix(web): add press feedback to buttons by @maria-rcks in pingdotgg/t3code#9349 * feat(web): add customizable project icons by @saphid in pingdotgg/t3code#9137 * fix(mobile): stop indented code overflowing Android chat bubbles by @Adamulek123 in pingdotgg/t3code#9347 * fix(web): let the pull request list use wide screens by @juliusmarminge in pingdotgg/t3code#9351 * feat: display native app and browser icons in work logs by @Yash-Singh1 in pingdotgg/t3code#9093 ## New Contributors * @tristanmanchester made their first contribution in pingdotgg/t3code#9255 **Full Changelog**: pingdotgg/t3code@v0.0.39-nightly.20260903.1262...v0.0.39-nightly.20260903.1265 Upstream release: https://github.com/pingdotgg/t3code/releases/tag/v0.0.39-nightly.20260903.1265
Problem
The stacked/split diff toggle was ephemeral. The thread diff panel kept it in a zustand store, and the pull request Code tab kept it in plain component state that reset on every mount, so the two toggles disagreed and the PR one forgot its value constantly. Word wrap, whitespace handling, and the rest of the diff preferences already live in client settings.
Fix
Diff layout is now a client setting (
diffLayout, defaultstacked, inpackages/contracts). Both diff toolbars read it and write throughuseUpdateClientSettings, so one flip applies everywhere and survives reloads (on desktop it persists to disk through the same bridge as every other client setting). The olddiffRenderModefield is removed fromdiffPanelStore, which is back to only per-thread scope selection.It also gets a Diff layout select under Settings → General next to "Hide whitespace changes", wired into reset, customized tracking, restore-defaults, and settings search (
split,side by side,unified, …).Not migrated: a
splitvalue in the oldt3code:diff-panel-state:v1localStorage entry. Anyone who had it set there flips the toggle once more.Verification
vp test runonclientPersistenceStorage.test.ts(new round-trip test),diffPanelStore.test.ts,settingsSearch.test.ts,SettingsPanels.logic.test.ts, and desktopDesktopClientSettings.test.tstsc --noEmitforpackages/contractsandapps/web, lint on changed filesClaude Fable 5 via Claude Code.
🤖 Generated with Claude Code
Note
Low Risk
UI preference persistence with schema defaults; no auth, security, or server data-path changes. Minor UX regression for unmigrated old localStorage layout only.
Overview
Diff layout (stacked vs split) is now a shared client setting (
diffLayout, defaultstacked) instead of ephemeral UI state.The thread Diff panel and pull request Code tab both read and update it through
useClientSettings/useUpdateClientSettings, so one toggle stays in sync everywhere and survives reloads (including desktop via the existing client-settings bridge).diffRenderModeis removed fromdiffPanelStore, which again only tracks per-thread diff scope.Settings → General adds a Diff layout control (plus reset, customized tracking, restore defaults, and search). Tests cover browser persistence defaults and desktop settings fixtures.
Not migrated: a prior
splitchoice stored only int3code:diff-panel-state:v1localStorage; users may need to pick split once more.Reviewed by Cursor Bugbot for commit 3627b1e. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Persist diff layout toggle in client settings instead of component state
DiffLayoutcontract (stacked/split, defaultstacked) to settings.ts and wires it into the client settings schema and patch typeDiffRenderModefrom diffPanelStore.ts; DiffPanel.tsx and PullRequestCodeTab.tsx now read and write the layout through client settingsuseSettingsRestorereports a non-default diff layout as changed and resets itdiffLayoutfield decode tostacked; any out-of-tree readers expectingdiffPanelStoreto hold render-mode state will break since that field is removed📊 Macroscope summarized 3627b1e. 6 files reviewed, 2 issues evaluated, 1 issue filtered, 1 comment posted
🗂️ Filtered Issues
apps/web/src/components/DiffPanel.tsx — 0 comments posted, 1 evaluated, 1 filtered
updateClientSettings({ diffLayout: next })can be overwritten by the initial asynchronous settings hydration. On a newly mounted panel,useClientSettingsinitially returns defaults whilehydrateClientSettings()is still awaitinggetClientSettings(); if the user changes the layout in that interval,persistClientSettingsupdates the snapshot but does not advance the hydration generation. When the pending read returns an older persisted layout, line 129 ofuseSettings.tsreplaces the snapshot with it, so the toggle and diff revert to the stale value (and the concurrent persistence operations can leave storage stale as well). [ Cross-file consolidated ]