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 22, 05:45 UTC
fix(server): files tree labels ignored folders inside git submodules (#29650)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Alex Southwell committed
Nov 3, 2026 at 23:12 UTC
04aed8f3eab6b2c44ef3f93eabeaa54276379112
2 files changed
+44
-6
apps/server/src/workspace/WorkspaceEntries.test.ts
+19
@@ -108,6 +108,14 @@ it.layer(layerTest, { excludeTestServices: true })("WorkspaceEntries", (it) => {
108
yield* writeTextFile(cwd, "node_modules/pkg/index.js");
109
yield* writeTextFile(cwd, "src/index.ts");
110
yield* fileSystem.makeDirectory(path.join(cwd, "empty"));
111
+ yield* git(cwd, ["init", "sub"]);
112
+ yield* writeTextFile(cwd, "sub/.gitignore", "dist/\n");
113
+ yield* writeTextFile(cwd, "sub/dist/out.js");
114
+ const gitlink = yield* git(cwd, ["hash-object", "tracked.txt"]);
115
+ yield* git(cwd, ["update-index", "--add", "--cacheinfo", `160000,${gitlink},sub`]);
116
+ // A nested clone that isn't a submodule keeps the outer repository's ignore rules.
117
+ yield* git(cwd, ["init", "node_modules/pkg"]);
118
+ yield* git(cwd, ["init", "sub/dist"]);
119
120
const workspaceEntries = yield* WorkspaceEntries.WorkspaceEntries;
121
const root = yield* workspaceEntries.list({ cwd, directoryPath: "" });
@@ -127,6 +135,17 @@ it.layer(layerTest, { excludeTestServices: true })("WorkspaceEntries", (it) => {
135
entries: [{ path: "node_modules/pkg/index.js", kind: "file", ignored: true }],
136
truncated: false,
137
});
138
+ // Git refuses pathspecs inside a submodule from the outer repository.
139
+ expect((yield* workspaceEntries.list({ cwd, directoryPath: "sub" })).entries).toEqual(
140
+ expect.arrayContaining([
141
+ { path: "sub/.gitignore", kind: "file" },
142
+ { path: "sub/dist", kind: "directory", ignored: true },
143
+ ]),
144
+ );
145
+ expect(yield* workspaceEntries.list({ cwd, directoryPath: "sub/dist" })).toEqual({
146
+ entries: [{ path: "sub/dist/out.js", kind: "file", ignored: true }],
147
+ truncated: false,
148
+ });
149
expect(yield* workspaceEntries.list({ cwd, directoryPath: "empty" })).toEqual({
150
entries: [],
151
truncated: false,
apps/server/src/workspace/WorkspaceEntries.ts
+25
-6
@@ -306,7 +306,7 @@ export const make = Effect.gen(function* () {
306
relativePath: directoryPath,
307
})
308
.pipe(Effect.mapError(toError));
309
- const { entries, throughSymlink } = yield* Effect.tryPromise({
309
+ const { entries, throughSymlink, nestedGitRoots } = yield* Effect.tryPromise({
310
try: async () => {
311
const root = await NodeFSP.realpath(normalizedCwd);
312
const directory = await NodeFSP.realpath(target.absolutePath);
@@ -378,7 +378,17 @@ export const make = Effect.gen(function* () {
378
)),
379
);
380
}
381
+ const nestedGitRoots: Array<string> = [];
382
+ const segments = target.relativePath.split("/").filter(Boolean);
383
+ for (let index = 1; index <= segments.length; index += 1) {
384
+ const candidate = segments.slice(0, index).join("/");
385
+ const dotGit = await NodeFSP.lstat(path.join(normalizedCwd, candidate, ".git")).catch(
386
+ () => null,
387
+ );
388
+ if (dotGit) nestedGitRoots.push(candidate);
389
+ }
390
return {
391
+ nestedGitRoots,
392
entries: children.flatMap((child, index): ProjectEntry[] => {
393
const kind = kinds[index];
394
if (kind === undefined) return [];
@@ -395,6 +405,8 @@ export const make = Effect.gen(function* () {
405
},
406
catch: toError,
407
});
408
+ let gitRoot = "";
409
+ let gitPrefix = "";
410
// stdin avoids argument limits; ignore classification is optional without git/repositories.
411
const checkIgnore = (paths: ReadonlyArray<string>) =>
412
vcsProcess
@@ -402,20 +414,27 @@ export const make = Effect.gen(function* () {
414
operation: "WorkspaceEntries.list",
415
command: "git",
416
args: ["-c", "core.fsmonitor=false", "check-ignore", "-z", "--stdin"],
405
- cwd: normalizedCwd,
406
- stdin: `${paths.join("\0")}\0`,
417
+ cwd: path.join(normalizedCwd, gitRoot),
418
+ stdin: `${paths.map((entryPath) => entryPath.slice(gitPrefix.length)).join("\0")}\0`,
419
allowNonZeroExit: true,
420
timeoutMs: 10_000,
421
maxOutputBytes: 16 * 1024 * 1024,
422
})
423
.pipe(Effect.orElseSucceed(() => undefined));
424
+ // Git refuses paths inside a submodule (128) but still answers for nested clones.
425
+ for (const nestedGitRoot of nestedGitRoots) {
426
+ if ((yield* checkIgnore([`${nestedGitRoot}/.git`]))?.exitCode !== 128) continue;
427
+ gitRoot = nestedGitRoot;
428
+ gitPrefix = `${gitRoot}/`;
429
+ }
430
+ const directoryGitPath = target.relativePath.slice(gitPrefix.length);
431
// Check ignored folders once to avoid child index lookups; exit 0 guarantees no tracked descendants.
432
// Symlinks and pathspec magic still need per-child checks.
433
if (
434
entries.length > IGNORE_CHECK_CHUNK_SIZE &&
416
- target.relativePath !== "" &&
435
+ directoryGitPath !== "" &&
436
!throughSymlink &&
418
- !/^:|[*?[\\]/.test(target.relativePath) &&
437
+ !/^:|[*?[\\]/.test(directoryGitPath) &&
438
(yield* checkIgnore([target.relativePath]))?.exitCode === 0
439
) {
440
return {
@@ -429,7 +448,7 @@ export const make = Effect.gen(function* () {
448
entries.slice(offset, offset + IGNORE_CHECK_CHUNK_SIZE).map((entry) => entry.path),
449
);
450
if (!result || (result.exitCode !== 0 && result.exitCode !== 1)) break;
432
- for (const ignoredPath of result.stdout.split("\0")) ignored.add(ignoredPath);
451
+ for (const ignoredPath of result.stdout.split("\0")) ignored.add(gitPrefix + ignoredPath);
452
}
453
return {
454
entries: entries.map((entry) =>