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 23, 01:45 UTC
fix(server): checkpoints work in Windows workspaces with paths over 260 characters (#13538)
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Co-authored-by: Julius Marminge <julius0216@outlook.com>
Keirara committed
Oct 19, 2026 at 16:26 UTC
ac871e6f1b1383183b33e43868596b1cc980decd
2 files changed
+75
-4
apps/server/src/vcs/GitVcsDriver.test.ts
+48
@@ -15,6 +15,7 @@ import { ChildProcessSpawner } from "effect/process";
15
import { assert, it } from "@effect/vitest";
16
17
import { CheckpointRef, GitCommandError, VcsProcessExitError } from "@t3tools/contracts";
18
+import * as HostProcess from "@t3tools/shared/HostProcess";
19
import * as ServerConfig from "../config.ts";
20
import * as CheckpointStore from "../checkpointing/CheckpointStore.ts";
21
import * as ProcessRunner from "../processRunner.ts";
@@ -1212,3 +1213,50 @@ it.effect("GitVcsDriver flushes checkpoint objects and refs to disk before publi
1213
),
1214
);
1215
});
1216
+
1217
+it.effect.each(["win32", "linux"] as const)(
1218
+ "checkpoint working-tree commands enable Git long paths only on Windows (%s)",
1219
+ (platform) =>
1220
+ Effect.gen(function* () {
1221
+ const fs = yield* FileSystem.FileSystem;
1222
+ const path = yield* Path.Path;
1223
+ const liveProcess = yield* VcsProcess.VcsProcess;
1224
+ const driver = yield* GitVcsDriver.makeVcsDriverShape();
1225
+ const cwd = yield* fs.makeTempDirectoryScoped({ prefix: "t3-checkpoint-long-paths-" });
1226
+ const { git, checkpointRef } = yield* makeCheckpointFixture(driver, cwd);
1227
+ // An unborn nested repository fails the first `add`, so recovery's listing runs too.
1228
+ yield* git(["init", "empty"]);
1229
+ const observedArgs: ReadonlyArray<string>[] = [];
1230
+ const platformDriver = yield* GitVcsDriver.makeVcsDriverShape().pipe(
1231
+ Effect.provideService(HostProcess.Platform, platform),
1232
+ Effect.provideService(VcsProcess.VcsProcess, {
1233
+ run: (input) => {
1234
+ observedArgs.push(input.args);
1235
+ return liveProcess.run(input);
1236
+ },
1237
+ }),
1238
+ );
1239
+
1240
+ yield* platformDriver.checkpoints.captureCheckpoint({ cwd, checkpointRef });
1241
+ yield* fs.writeFileString(path.join(cwd, "file.txt"), "changed\n");
1242
+ assert.isTrue(yield* platformDriver.checkpoints.restoreCheckpoint({ cwd, checkpointRef }));
1243
+
1244
+ assert.strictEqual(yield* fs.readFileString(path.join(cwd, "file.txt")), "unstaged\n");
1245
+ assert.strictEqual((yield* git(["ls-tree", checkpointRef, "--", "empty"])).stdout, "");
1246
+ for (const command of ["add", "ls-files", "restore", "clean", "reset"]) {
1247
+ const calls = observedArgs.filter(
1248
+ (args) => args.includes(command) && (command !== "ls-files" || args.includes("--others")),
1249
+ );
1250
+ assert.isNotEmpty(calls, `Expected checkpoint command: ${command}`);
1251
+ for (const args of calls) {
1252
+ const setting = args.indexOf("core.longpaths=true");
1253
+ if (platform === "win32") {
1254
+ assert.strictEqual(args[setting - 1], "-c", args.join(" "));
1255
+ assert.isBelow(setting, args.indexOf(command), args.join(" "));
1256
+ } else {
1257
+ assert.strictEqual(setting, -1, args.join(" "));
1258
+ }
1259
+ }
1260
+ }
1261
+ }).pipe(Effect.scoped, Effect.provide(layerGitContract)),
1262
+);
apps/server/src/vcs/GitVcsDriver.ts
+27
-4
@@ -32,6 +32,7 @@ import {
32
type VcsStatusResult,
33
type WorktreeSubmodules,
34
} from "@t3tools/contracts";
35
+import * as HostProcess from "@t3tools/shared/HostProcess";
36
import {
37
makeGitVcsDriverCore,
38
PATCH_RENDER_PREFIX_ARGS,
@@ -792,6 +793,10 @@ export const makeVcsDriverShape = Effect.fn("makeGitVcsDriverShape")(function* (
793
"core.fsyncMethod=fsync",
794
] as const;
795
796
+ // Checkpoints must handle existing paths beyond Windows MAX_PATH, even when
797
+ // core.longpaths is disabled in the user's Git configuration.
798
+ const longPaths = (yield* HostProcess.Platform) === "win32" ? ["-c", "core.longpaths=true"] : [];
799
+
800
const checkpoints: VcsDriver.VcsCheckpointOps = {
801
captureCheckpoint: Effect.fn("GitVcsDriver.checkpoints.captureCheckpoint")(function* (input) {
802
const operation = VcsProcess.CHECKPOINT_CAPTURE_OPERATION;
@@ -954,6 +959,7 @@ export const makeVcsDriverShape = Effect.fn("makeGitVcsDriverShape")(function* (
959
args: [
960
...indexConfig,
961
...durableWrite,
962
+ ...longPaths,
963
"add",
964
...(sparseCheckout ? ["--sparse"] : []),
965
"-A",
@@ -972,7 +978,15 @@ export const makeVcsDriverShape = Effect.fn("makeGitVcsDriverShape")(function* (
978
const untracked = yield* execute({
979
operation,
980
cwd: input.cwd,
975
- args: ["ls-files", "--others", "--exclude-standard", "-z", "--", "."],
981
+ args: [
982
+ ...longPaths,
983
+ "ls-files",
984
+ "--others",
985
+ "--exclude-standard",
986
+ "-z",
987
+ "--",
988
+ ".",
989
+ ],
990
env: commitEnv,
991
maxOutputBytes: WORKSPACE_FILES_MAX_OUTPUT_BYTES,
992
});
@@ -1092,7 +1106,16 @@ export const makeVcsDriverShape = Effect.fn("makeGitVcsDriverShape")(function* (
1106
yield* execute({
1107
operation,
1108
cwd: input.cwd,
1095
- args: ["restore", "--source", commitOid, "--worktree", "--staged", "--", "."],
1109
+ args: [
1110
+ ...longPaths,
1111
+ "restore",
1112
+ "--source",
1113
+ commitOid,
1114
+ "--worktree",
1115
+ "--staged",
1116
+ "--",
1117
+ ".",
1118
+ ],
1119
});
1120
}
1121
// Restoring away the last tracked file can remove a nested workspace directory.
@@ -1112,7 +1135,7 @@ export const makeVcsDriverShape = Effect.fn("makeGitVcsDriverShape")(function* (
1135
const cleaned = yield* execute({
1136
operation,
1137
cwd: input.cwd,
1115
- args: ["clean", "-fd", "--", "."],
1138
+ args: [...longPaths, "clean", "-fd", "--", "."],
1139
allowNonZeroExit: true,
1140
});
1141
if (cleaned.exitCode !== 0) {
@@ -1141,7 +1164,7 @@ export const makeVcsDriverShape = Effect.fn("makeGitVcsDriverShape")(function* (
1164
yield* execute({
1165
operation,
1166
cwd: input.cwd,
1144
- args: ["reset", "--quiet", "--", "."],
1167
+ args: [...longPaths, "reset", "--quiet", "--", "."],
1168
});
1169
}
1170