@devries-cameron20 / t3code-1 / commits / e6fa2e35c3
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix(web): expanding hidden diff context works after a diff refresh (#33629)

Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com>

Julius Marminge committed Nov 9, 2026 at 17:08 UTC e6fa2e35c34c6b1af2cef4eaf444f1b88804933e
3 files changed +77 -8
apps/web/src/components/diffs/codeViewContextExpansion.browser.test.ts new
+59
@@ -0,0 +1,59 @@
1 +import { CodeView, DEFAULT_THEMES, parsePatchFiles, preloadHighlighter } from "@pierre/diffs";
2 +import { expect, it, vi } from "vite-plus/test";
3 +
4 +const OLD_LINES = Array.from({ length: 60 }, (_, index) => `line ${index + 1}`);
5 +const NEW_LINES = OLD_LINES.with(0, "changed 1").with(59, "changed 60");
6 +const PATCH = `diff --git a/notes.txt b/notes.txt
7 +--- a/notes.txt
8 ++++ b/notes.txt
9 +@@ -1,4 +1,4 @@
10 +-line 1
11 ++changed 1
12 + line 2
13 + line 3
14 + line 4
15 +@@ -57,4 +57,4 @@
16 + line 57
17 + line 58
18 + line 59
19 +-line 60
20 ++changed 60
21 +`;
22 +
23 +function parsePartialDiff() {
24 + return parsePatchFiles(PATCH, { cacheKeyPrefix: "notes" })[0]!.files[0]!;
25 +}
26 +
27 +// A diff refresh re-parses an unchanged patch into a new object with the same cacheKey.
28 +// Upstream keeps rendering the old object and then discards the file contents loaded for it.
29 +it("expands hidden context after the host re-supplies an unchanged partial diff", async () => {
30 + await preloadHighlighter({ themes: Object.values(DEFAULT_THEMES), langs: ["text"] });
31 + const root = document.createElement("div");
32 + root.style.cssText = "width: 800px; height: 600px; overflow: auto;";
33 + document.body.append(root);
34 + const view = new CodeView<undefined>({
35 + diffStyle: "unified",
36 + loadDiffFiles: async () => ({
37 + oldFile: { name: "notes.txt", contents: `${OLD_LINES.join("\n")}\n` },
38 + newFile: { name: "notes.txt", contents: `${NEW_LINES.join("\n")}\n` },
39 + }),
40 + });
41 + using _view = {
42 + [Symbol.dispose]: () => {
43 + view.cleanUp();
44 + root.remove();
45 + },
46 + };
47 + view.setup(root);
48 + const shadowRoot = () => root.querySelector("diffs-container")?.shadowRoot;
49 + const lines = () =>
50 + Array.from(shadowRoot()?.querySelectorAll("[data-line]") ?? [], (line) => line.textContent);
51 +
52 + view.setItems([{ id: "notes", type: "diff", fileDiff: parsePartialDiff(), version: 1 }]);
53 + await vi.waitFor(() => expect(lines()).toContain("line 57"));
54 + view.setItems([{ id: "notes", type: "diff", fileDiff: parsePartialDiff(), version: 2 }]);
55 +
56 + shadowRoot()!.querySelector<HTMLElement>("[data-expand-button]")!.click();
57 +
58 + await vi.waitFor(() => expect(lines()).toContain("line 30"));
59 +});
patches/@pierre__diffs@1.7.0-beta.3.patch
+13 -3
@@ -218,10 +218,20 @@ index 734ff9862cdfe65b8082599c6c221c4886436e01..f18798a3d56dd0749550b5aff62a06fb
218 } catch (error) {
219 if (disableErrorHandling) throw error;
220 diff --git a/dist/components/VirtualizedFileDiff.js b/dist/components/VirtualizedFileDiff.js
221 -index 984f049ff3694dd353fa6637b0f09fc7dce74992..8f659c06b70ba603f725cccdcaebe89c21b00f6b 100644
221 +index 984f049ff3694dd353fa6637b0f09fc7dce74992..4d6599905be0fe7b5b5c1a225c0b3ff8d810c72a 100644
222 --- a/dist/components/VirtualizedFileDiff.js
223 +++ b/dist/components/VirtualizedFileDiff.js
224 -@@ -626,7 +626,7 @@ var VirtualizedFileDiff = class extends FileDiff {
224 +@@ -264,7 +264,8 @@ var VirtualizedFileDiff = class extends FileDiff {
225 + const { pendingExpansions, pendingHydratedDiff, options: { collapsed = false } } = this;
226 + if (pendingHydratedDiff != null) {
227 + this.pendingHydratedDiff = void 0;
228 +- if (pendingHydratedDiff.expectedDiff === fileDiff) {
229 ++ // T3 patch: a host may re-supply an unchanged diff as a new object; it is still this diff.
230 ++ if (areDiffTargetsEqual(pendingHydratedDiff.expectedDiff, fileDiff)) {
231 + Object.assign(fileDiff, pendingHydratedDiff.nextDiff);
232 + this.setHydratedState(pendingHydratedDiff.files);
233 + this.installHydratedDiff(fileDiff);
234 +@@ -626,7 +627,7 @@ var VirtualizedFileDiff = class extends FileDiff {
235 rerender() {
236 if (!this.enabled || this.getInputDiff() == null && this.additionFile == null && this.deletionFile == null) return;
237 const workingDiff = this.getWorkingDiff();
@@ -230,7 +240,7 @@ index 984f049ff3694dd353fa6637b0f09fc7dce74992..8f659c06b70ba603f725cccdcaebe89c
240 if (this.isSimpleMode()) this.pendingRender = void 0;
241 this.forceRenderOverride = true;
242 if (this.isSimpleMode() && this.requestRender()) return;
233 -@@ -790,7 +790,7 @@ var VirtualizedFileDiff = class extends FileDiff {
243 +@@ -790,7 +791,7 @@ var VirtualizedFileDiff = class extends FileDiff {
244 const previousRenderedDiff = this.getRenderedDiff();
245 const { pendingRender } = this;
246 const previousLayoutDiff = pendingRender?.diff ?? previousRenderedDiff;
pnpm-lock.yaml
+5 -5
@@ -361,7 +361,7 @@ patchedDependencies:
361 '@ff-labs/fff-node@0.11.0': cc71fcec015f4d39bc96ae2e2bf6b0ca678124c722c66a7841efce9d34b5983c
362 '@legendapp/list@3.7.2': 3c68607b8bb7a531873bcbe0b197d163ef1fdb4d4cf52a4ddf9d2b3804671658
363 '@muse-code/sdk@1.4.6': 7b495b607fc5d76b444c7c4d58821e839726a30e6f3c53564f0d59f2d5b42101
364 - '@pierre/diffs@1.7.0-beta.3': b927b5049250ce93163cd44b03d9d22d16b484a8aae74ae1664973c6aa8060e4
364 + '@pierre/diffs@1.7.0-beta.3': aea143f4a2e59744371219c4e7ae675ec739c9ba16f1732e2f11748b496ea05e
365 '@react-native-ai/apple@0.12.0': 2d09870c2848d185cb05b53ed823a46e12dba519324d8dd8e584e28731990f9d
366 '@react-native-menu/menu@2.0.0': 6872ba71b9847c5a0210b1b896923dadc3860faedfe28d9f062bcedfe786ef1d
367 '@react-navigation/native-stack@7.21.0': 990d575444c4af2ce8218b3b7a8280fe244c03abbdb32b822a2e862f791dbf42
@@ -549,7 +549,7 @@ importers:
549 version: 0.3.0
550 '@pierre/diffs':
551 specifier: 1.7.0-beta.3
552 - version: 1.7.0-beta.3(patch_hash=b927b5049250ce93163cd44b03d9d22d16b484a8aae74ae1664973c6aa8060e4)(@shikijs/themes@4.2.0)(react-dom@19.3.0(react@19.3.0))(react@19.3.0)
552 + version: 1.7.0-beta.3(patch_hash=aea143f4a2e59744371219c4e7ae675ec739c9ba16f1732e2f11748b496ea05e)(@shikijs/themes@4.2.0)(react-dom@19.3.0(react@19.3.0))(react@19.3.0)
553 '@pierre/highlights':
554 specifier: 'catalog:'
555 version: 0.5.0
@@ -1061,7 +1061,7 @@ importers:
1061 version: 1.8.0
1062 '@pierre/diffs':
1063 specifier: 1.7.0-beta.3
1064 - version: 1.7.0-beta.3(patch_hash=b927b5049250ce93163cd44b03d9d22d16b484a8aae74ae1664973c6aa8060e4)(@shikijs/themes@4.2.0)(react-dom@19.3.0(react@19.3.0))(react@19.3.0)
1064 + version: 1.7.0-beta.3(patch_hash=aea143f4a2e59744371219c4e7ae675ec739c9ba16f1732e2f11748b496ea05e)(@shikijs/themes@4.2.0)(react-dom@19.3.0(react@19.3.0))(react@19.3.0)
1065 '@pierre/trees':
1066 specifier: 1.0.0-beta.6
1067 version: 1.0.0-beta.6(@pierre/theme@2.0.0)(@shikijs/themes@4.2.0)(react-dom@19.3.0(react@19.3.0))(react@19.3.0)(shiki@4.2.0)
@@ -1480,7 +1480,7 @@ importers:
1480 dependencies:
1481 '@pierre/diffs':
1482 specifier: 1.7.0-beta.3
1483 - version: 1.7.0-beta.3(patch_hash=b927b5049250ce93163cd44b03d9d22d16b484a8aae74ae1664973c6aa8060e4)(@shikijs/themes@4.2.0)(react-dom@19.3.0(react@19.3.0))(react@19.3.0)
1483 + version: 1.7.0-beta.3(patch_hash=aea143f4a2e59744371219c4e7ae675ec739c9ba16f1732e2f11748b496ea05e)(@shikijs/themes@4.2.0)(react-dom@19.3.0(react@19.3.0))(react@19.3.0)
1484 '@t3tools/contracts':
1485 specifier: workspace:*
1486 version: link:../contracts
@@ -15392,7 +15392,7 @@ snapshots:
15392 tslib: 2.8.1
15393 webcrypto-core: 1.9.2
15394
15395 - '@pierre/diffs@1.7.0-beta.3(patch_hash=b927b5049250ce93163cd44b03d9d22d16b484a8aae74ae1664973c6aa8060e4)(@shikijs/themes@4.2.0)(react-dom@19.3.0(react@19.3.0))(react@19.3.0)':
15395 + '@pierre/diffs@1.7.0-beta.3(patch_hash=aea143f4a2e59744371219c4e7ae675ec739c9ba16f1732e2f11748b496ea05e)(@shikijs/themes@4.2.0)(react-dom@19.3.0(react@19.3.0))(react@19.3.0)':
15396 dependencies:
15397 '@pierre/highlights': 0.5.0
15398 '@pierre/patches': 0.0.1