@devries-cameron20 / t3code Mirror · read-only / commits / 5f69cac5c9
Fork 0

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

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 17:15 UTC

fix(web): turn diffs cut off at the size limit say changes are incomplete (#36079)

Julius Marminge committed Nov 13, 2026 at 00:47 UTC 5f69cac5c91c85860dd3d2c471bdac6efa70241e
4 files changed +54 -7
apps/server/src/checkpointing/CheckpointDiffQuery.ts
+4 -3
@@ -1,4 +1,5 @@
1 import {
2 + CHECKPOINT_DIFF_TRUNCATED_MARKER,
3 OrchestrationGetTurnDiffResult,
4 type OrchestrationGetFullThreadDiffInput,
5 type OrchestrationGetFullThreadDiffResult,
@@ -28,7 +29,6 @@ import { isGitImport, parseTurnDiffFilesFromNumstat, type TurnDiffFileSummary }
29
30 // Windows limits a command line to 32,767 characters. Leave room for the rest of git's arguments.
31 const MAX_PATHSPEC_CHARS = 24_000;
31 -const DIFF_TRUNCATED_MARKER = "\n\n[truncated]";
32
33 function batchFilePaths(files: ReadonlyArray<TurnDiffFileSummary>) {
34 const batches: string[][] = [];
@@ -243,10 +243,11 @@ export const make = Effect.gen(function* () {
243 new TextDecoder().decode(
244 Buffer.from(diff).subarray(
245 0,
246 - CHECKPOINT_DIFF_MAX_OUTPUT_BYTES - Buffer.byteLength(DIFF_TRUNCATED_MARKER),
246 + CHECKPOINT_DIFF_MAX_OUTPUT_BYTES -
247 + Buffer.byteLength(CHECKPOINT_DIFF_TRUNCATED_MARKER),
248 ),
249 { stream: true },
249 - ) + DIFF_TRUNCATED_MARKER;
250 + ) + CHECKPOINT_DIFF_TRUNCATED_MARKER;
251 break;
252 }
253 remainingBytes -= patchBytes;
apps/web/src/components/DiffPanel.browser.test.tsx
+37 -2
@@ -4,6 +4,7 @@ import {
4 DEFAULT_CLIENT_SETTINGS,
5 EnvironmentId,
6 ProjectId,
7 + RunId,
8 ThreadId,
9 type ClientSettings,
10 type ReviewBranchCommitsResult,
@@ -35,6 +36,8 @@ const state = vi.hoisted(() => ({
36 localRefs: null as unknown as ResultAtom<VcsListRefsResult>,
37 remoteRefs: null as unknown as ResultAtom<VcsListRefsResult>,
38 commits: null as unknown as ResultAtom<ReviewBranchCommitsResult>,
39 + checkpoints: [] as unknown[],
40 + checkpointDiff: null as { diff: string } | null,
41 }));
42
43 vi.mock("~/state/server", () => ({
@@ -59,7 +62,7 @@ vi.mock("~/state/vcs", () => ({
62 vi.mock("~/state/entities", () => ({
63 useQuietThreadShell: () => state.thread,
64 useProject: () => ({ workspaceRoot: "/project", repositoryIdentity: null }),
62 - useThreadCheckpointSummaries: () => [],
65 + useThreadCheckpointSummaries: () => state.checkpoints,
66 useQuietThreadVisibleTurnItems: () => [],
67 }));
68 vi.mock("~/state/filesystem", () => ({
@@ -77,7 +80,7 @@ vi.mock("~/hooks/useTheme", () => ({
80 subscribeRenderedAppearance: () => () => {},
81 }));
82 vi.mock("~/state/queries", () => ({
80 - useCheckpointDiff: () => ({ data: null, error: null, isPending: false }),
83 + useCheckpointDiff: () => ({ data: state.checkpointDiff, error: null, isPending: false }),
84 useTurnItemDetail: () => ({ data: null, error: null, isPending: false }),
85 useDebouncedValue: <A,>(value: A) => value,
86 }));
@@ -126,6 +129,8 @@ function setup(failedBaseRef: string | null) {
129 };
130 reset();
131 state.diffFilesCollapsed = false;
132 + state.checkpoints = [];
133 + state.checkpointDiff = null;
134 const patch = Atom.make<AsyncResult.AsyncResult<ReviewDiffPreviewSource, Error>>(
135 AsyncResult.initial(),
136 );
@@ -267,3 +272,33 @@ it.each([false, true])(
272 await expect.element(toggle).toHaveAttribute("aria-expanded", "false");
273 },
274 );
275 +
276 +it("says a turn diff cut off at the server's size limit is incomplete", async () => {
277 + using context = setup("origin/orphan");
278 + state.checkpoints = [
279 + {
280 + runId: "run",
281 + checkpointTurnCount: 1,
282 + checkpointRef: "ref",
283 + status: "ready",
284 + files: [],
285 + assistantMessageId: null,
286 + completedAt: "2026-01-01T00:00:00Z",
287 + },
288 + ];
289 + state.checkpointDiff = {
290 + diff: "diff --git a/first.txt b/first.txt\n--- a/first.txt\n+++ b/first.txt\n@@ -0,0 +1 @@\n+visible\n\n[truncated]",
291 + };
292 + useDiffPanelStore.getState().selectTurn(context.threadRef, RunId.make("run"));
293 + await using screen = await render(
294 + <RegistryContext.Provider value={context.registry}>
295 + <div style={{ height: 600, display: "flex", flexDirection: "column" }}>
296 + <DiffPanel composerDraftTarget={context.threadRef} workspaceMutationId={null} visible />
297 + </div>
298 + </RegistryContext.Provider>,
299 + );
300 + await expect.element(screen.getByText("first.txt", { exact: true }).first()).toBeVisible();
301 + await expect
302 + .element(screen.getByText("This preview exceeds the size limit. Changes shown are incomplete."))
303 + .toBeVisible();
304 +});
apps/web/src/components/DiffPanel.tsx
+10 -2
@@ -6,7 +6,12 @@ import {
6 squashAtomCommandFailure,
7 } from "@t3tools/client-runtime/state/runtime";
8 import { safeErrorLogAttributes } from "@t3tools/client-runtime/errors";
9 -import type { ReviewBranchCommitsResult, ScopedThreadRef, RunId } from "@t3tools/contracts";
9 +import {
10 + CHECKPOINT_DIFF_TRUNCATED_MARKER,
11 + type ReviewBranchCommitsResult,
12 + type ScopedThreadRef,
13 + type RunId,
14 +} from "@t3tools/contracts";
15 import {
16 ArrowRightIcon,
17 CheckIcon,
@@ -483,7 +488,10 @@ export default function DiffPanel({
488 : gitDiff;
489 const isSelectedPatchTruncated =
490 toolCallPreview?.truncated === true ||
486 - (isGitSelection && selectedGitSource?.truncated === true);
491 + (isGitSelection && selectedGitSource?.truncated === true) ||
492 + (!toolCallSelection &&
493 + selectedTurn !== undefined &&
494 + selectedPatch?.endsWith(CHECKPOINT_DIFF_TRUNCATED_MARKER) === true);
495 const selectedPatchQuery = toolCallSelection
496 ? toolCallDetail
497 : selectedTurn
packages/contracts/src/checkpointDiff.ts
+3
@@ -4,6 +4,9 @@ import * as Struct from "effect/Struct";
4
5 import { NonNegativeInt, ThreadId, TrimmedNonEmptyString } from "./baseSchemas.ts";
6
7 +/** Ends a checkpoint diff the server cut off at its output size limit. */
8 +export const CHECKPOINT_DIFF_TRUNCATED_MARKER = "\n\n[truncated]";
9 +
10 export const TurnCountRange = Schema.Struct({
11 fromTurnCount: NonNegativeInt,
12 toTurnCount: NonNegativeInt,