Skip to content

Commit 8a578a9

Browse files
t3dotggclaude
andcommitted
fix(checkpoint): Git grouping falls back to the full diff when it cannot filter
The diff query now loads the complete diff when the numstat summary fails or the retained paths would not fit on a Windows command line. The mobile Git banner moves into the review list header so iOS insets apply to it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent c265359 commit 8a578a9

2 files changed

Lines changed: 36 additions & 24 deletions

File tree

‎apps/mobile/src/features/review/ReviewSheet.tsx‎

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -702,12 +702,31 @@ export function ReviewSheet(props: ReviewSheetProps) {
702702
children.push(<ReviewNotice key="review-notice" notice={parsedDiffNotice} />);
703703
}
704704

705+
if (gitFileCount > 0) {
706+
children.push(
707+
<View
708+
key="review-git-changes"
709+
className="flex-row flex-wrap items-center gap-2 border-b border-border px-4 py-2"
710+
>
711+
<Text className="text-xs text-muted-foreground">
712+
{gitFileCount} {gitFileCount === 1 ? "file" : "files"} updated via Git{" "}
713+
{includeGitChanges ? "shown" : "hidden"}.
714+
</Text>
715+
<Pressable accessibilityRole="button" onPress={toggleGitChanges}>
716+
<Text className="text-sm text-primary">
717+
{includeGitChanges ? "Hide Git changes" : "Show Git changes"}
718+
</Text>
719+
</Pressable>
720+
</View>,
721+
);
722+
}
723+
705724
if (children.length === 0) {
706725
return null;
707726
}
708727

709728
return <>{children}</>;
710-
}, [error, parsedDiffNotice]);
729+
}, [error, parsedDiffNotice, gitFileCount, includeGitChanges, toggleGitChanges]);
711730
const headerSubtitle = [
712731
headerDiffSummary.additions,
713732
headerDiffSummary.deletions,
@@ -740,19 +759,6 @@ export function ReviewSheet(props: ReviewSheetProps) {
740759

741760
<MaterialScreenContent>
742761
<View className="flex-1 bg-sheet android:bg-sheet-solid">
743-
{gitFileCount > 0 && (
744-
<View className="flex-row flex-wrap items-center gap-2 border-b border-border px-4 py-2">
745-
<Text className="text-xs text-muted-foreground">
746-
{gitFileCount} {gitFileCount === 1 ? "file" : "files"} updated via Git{" "}
747-
{includeGitChanges ? "shown" : "hidden"}.
748-
</Text>
749-
<Pressable accessibilityRole="button" onPress={toggleGitChanges}>
750-
<Text className="text-sm text-primary">
751-
{includeGitChanges ? "Hide Git changes" : "Show Git changes"}
752-
</Text>
753-
</Pressable>
754-
</View>
755-
)}
756762
{showConnectionNotice ? (
757763
<View className="flex-1" style={{ paddingTop: topContentInset }}>
758764
<EnvironmentConnectionNotice

‎apps/server/src/checkpointing/CheckpointDiffQuery.ts‎

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ import {
3333
import * as CheckpointStore from "./CheckpointStore.ts";
3434
import { isGitImport, parseTurnDiffFilesFromNumstat } from "./Diffs.ts";
3535

36+
// Windows limits a command line to 32,767 characters. Leave room for the rest of git's arguments.
37+
const MAX_PATHSPEC_CHARS = 24_000;
38+
3639
/** Service tag for checkpoint diff queries. */
3740
export class CheckpointDiffQuery extends Context.Service<
3841
CheckpointDiffQuery,
@@ -197,21 +200,24 @@ export const make = Effect.gen(function* () {
197200
: yield* checkpointStore
198201
.listAuthoredPaths(comparison)
199202
.pipe(Effect.orElseSucceed(() => null));
203+
// Grouping is optional. When the summary fails, the complete diff still loads.
200204
const files =
201205
authoredPaths === null
202206
? []
203-
: parseTurnDiffFilesFromNumstat(
204-
yield* checkpointStore.diffCheckpoints({ ...comparison, format: "numstat" }),
207+
: yield* checkpointStore.diffCheckpoints({ ...comparison, format: "numstat" }).pipe(
208+
Effect.map(parseTurnDiffFilesFromNumstat),
209+
Effect.orElseSucceed(() => []),
205210
);
206-
const gitFileCount = files.filter((file) => isGitImport(file, authoredPaths)).length;
211+
const retainedFiles = files.filter((file) => !isGitImport(file, authoredPaths));
212+
const retainedPaths = retainedFiles.flatMap((file) =>
213+
file.previousPath === undefined ? [file.path] : [file.previousPath, file.path],
214+
);
215+
// Retained paths become pathspecs. Skip grouping when they would not fit on a command line.
216+
const fitsCommandLine =
217+
retainedPaths.reduce((length, path) => length + path.length + 16, 0) <= MAX_PATHSPEC_CHARS;
218+
const gitFileCount = fitsCommandLine ? files.length - retainedFiles.length : 0;
207219
const filePaths =
208-
input.includeGitChanges === false && gitFileCount > 0
209-
? files
210-
.filter((file) => !isGitImport(file, authoredPaths))
211-
.flatMap((file) =>
212-
file.previousPath === undefined ? [file.path] : [file.previousPath, file.path],
213-
)
214-
: undefined;
220+
input.includeGitChanges === false && gitFileCount > 0 ? retainedPaths : undefined;
215221
// Select retained paths before generating a patch, so imported bulk cannot exhaust its output limit.
216222
const diff = yield* checkpointStore
217223
.diffCheckpoints({

0 commit comments

Comments
 (0)