@devries-cameron20 / t3code Mirror · read-only / commits / f62fa296f0
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): Add to another machine can find ignored files past the first 200 (#36228)

Julius Marminge committed Nov 13, 2026 at 09:01 UTC f62fa296f065b6399fb68edf1863e6f4c831641b
7 files changed +108 -36
apps/server/src/environment/ServerEnvironment.ts
+1
@@ -274,6 +274,7 @@ export const make = Effect.gen(function* () {
274 projectCloneTracking: true,
275 projectOrganization: true,
276 ignoredFileListing: true,
277 + ignoredFileSearch: true,
278 triage: true,
279 oneTimeSchedules: true,
280 freshContext: true,
apps/server/src/workspace/WorkspaceEntries.test.ts
+14
@@ -433,6 +433,20 @@ it.layer(layerTest, { excludeTestServices: true })("WorkspaceEntries", (it) => {
433 });
434 }),
435 );
436 +
437 + it.effect("finds ignored files that sort past the listing limit", () =>
438 + Effect.gen(function* () {
439 + const cwd = yield* makeTempDir({ git: true });
440 + yield* writeTextFile(cwd, ".gitignore", "*.secret\n");
441 + for (let index = 1; index <= 205; index += 1) {
442 + yield* writeTextFile(cwd, `file-${String(index).padStart(3, "0")}.secret`, "s");
443 + }
444 +
445 + const workspaceEntries = yield* WorkspaceEntries.WorkspaceEntries;
446 + const listed = yield* workspaceEntries.listIgnoredFiles({ cwd, query: "file-205" });
447 + expect(listed.files).toContainEqual({ path: "file-205.secret", byteLength: 1 });
448 + }),
449 + );
450 });
451
452 describe("search", () => {
apps/server/src/workspace/WorkspaceEntries.ts
+5 -1
@@ -576,9 +576,13 @@ export const make = Effect.gen(function* () {
576 })
577 .pipe(Effect.orElseSucceed(() => undefined));
578 if (!result || result.exitCode !== 0) return { files: [], truncated: false };
579 + // Filter before the cap so files sorting past it stay reachable by search.
580 + const query = input.query?.toLowerCase() ?? "";
581 const paths = result.stdout
582 .split("\0")
581 - .filter((entry) => entry.length > 0 && !entry.endsWith("/"))
583 + .filter(
584 + (entry) => entry.length > 0 && !entry.endsWith("/") && entry.toLowerCase().includes(query),
585 + )
586 .toSorted();
587 const files = yield* Effect.promise(() =>
588 Promise.all(
apps/web/src/components/AddProjectToMachineDialog.tsx
+81 -35
@@ -26,6 +26,7 @@ import { useAddProjectTargets } from "../hooks/useAddProjectTargets";
26 import { useNewThreadHandler } from "../hooks/useHandleNewThread";
27 import { useLogicalProjectEnvironments } from "../hooks/useLogicalProjectEnvironments";
28 import {
29 + COPIED_FILES_MAX_COUNT,
30 COPYABLE_FILE_MAX_BYTES,
31 addProjectToMachine,
32 isDefaultCopiedFile,
@@ -35,6 +36,7 @@ import { newProjectId } from "../lib/utils";
36 import { readProject, subscribeProject, useProject } from "../state/entities";
37 import { useEnvironments } from "../state/environments";
38 import { projectEnvironment } from "../state/projects";
39 +import { useDebouncedValue } from "../state/queries";
40 import { useEnvironmentQuery } from "../state/query";
41 import { EnvironmentMachineIcon } from "./EnvironmentMachineIcon";
42 import { Button } from "./ui/button";
@@ -121,8 +123,10 @@ function AddProjectToMachineDialog({ request }: { request: AddProjectToMachineRe
123 const [pathOverride, setPathOverride] = useState<string | null>(null);
124 const destinationPath = pathOverride ?? defaultPath;
125
124 - const canListFiles = source?.serverConfig?.environment.capabilities.ignoredFileListing === true;
125 - const ignoredFiles = useEnvironmentQuery(
126 + const capabilities = source?.serverConfig?.environment.capabilities;
127 + const canListFiles = capabilities?.ignoredFileListing === true;
128 + const canSearchFiles = canListFiles && capabilities?.ignoredFileSearch === true;
129 + const allIgnoredFiles = useEnvironmentQuery(
130 project && canListFiles
131 ? projectEnvironment.listIgnoredFiles({
132 environmentId: project.environmentId,
@@ -130,13 +134,29 @@ function AddProjectToMachineDialog({ request }: { request: AddProjectToMachineRe
134 })
135 : null,
136 );
137 + const [fileQuery, setFileQuery] = useState("");
138 + const sentFileQuery = useDebouncedValue(fileQuery.trim(), 120);
139 + const searching = canSearchFiles && sentFileQuery.length > 0;
140 + const searchedFiles = useEnvironmentQuery(
141 + project && searching
142 + ? projectEnvironment.listIgnoredFiles({
143 + environmentId: project.environmentId,
144 + input: { cwd: project.workspaceRoot, query: sentFileQuery },
145 + })
146 + : null,
147 + );
148 + const ignoredFiles = searching ? searchedFiles : allIgnoredFiles;
149 const files = ignoredFiles.data?.files ?? [];
134 - const [selected, setSelected] = useState<ReadonlySet<string> | null>(null);
135 - const selectedFiles = selected ?? defaultSelection(files);
150 + // Keyed by path with the file kept, so picks made under one search survive the next.
151 + const [selected, setSelected] = useState<ReadonlyMap<string, ProjectIgnoredFile> | null>(null);
152 + const selectedFiles = selected ?? defaultSelection(allIgnoredFiles.data?.files ?? []);
153 const copyable = files.filter((file) => file.byteLength <= COPYABLE_FILE_MAX_BYTES);
137 - const selectedBytes = files
138 - .filter((file) => selectedFiles.has(file.path))
139 - .reduce((total, file) => total + file.byteLength, 0);
154 + const allCopyableSelected = copyable.every((file) => selectedFiles.has(file.path));
155 + const atSelectionLimit = selectedFiles.size >= COPIED_FILES_MAX_COUNT;
156 + const selectedBytes = [...selectedFiles.values()].reduce(
157 + (total, file) => total + file.byteLength,
158 + 0,
159 + );
160
161 const [submitting, setSubmitting] = useState(false);
162 const [error, setError] = useState<string | null>(null);
@@ -146,11 +166,19 @@ function AddProjectToMachineDialog({ request }: { request: AddProjectToMachineRe
166 const unavailable =
167 project === null ||
168 target === null ||
149 - (canListFiles && ignoredFiles.data === null && ignoredFiles.error === null);
150 - const toggleFile = (path: string, checked: boolean) => {
151 - const next = new Set(selectedFiles);
152 - if (checked) next.add(path);
153 - else next.delete(path);
169 + (canListFiles && allIgnoredFiles.data === null && allIgnoredFiles.error === null);
170 + const toggleFile = (file: ProjectIgnoredFile, checked: boolean) => {
171 + const next = new Map(selectedFiles);
172 + if (!checked) next.delete(file.path);
173 + else if (!atSelectionLimit) next.set(file.path, file);
174 + setSelected(next);
175 + };
176 + const toggleShownFiles = () => {
177 + const next = new Map(selectedFiles);
178 + for (const file of copyable) {
179 + if (allCopyableSelected) next.delete(file.path);
180 + else if (next.size < COPIED_FILES_MAX_COUNT) next.set(file.path, file);
181 + }
182 setSelected(next);
183 };
184
@@ -198,7 +226,7 @@ function AddProjectToMachineDialog({ request }: { request: AddProjectToMachineRe
226 title: project.title,
227 remoteUrl,
228 destinationPath: destinationPath.trim(),
201 - files: files.filter((file) => selectedFiles.has(file.path)).map((file) => file.path),
229 + files: [...selectedFiles.keys()],
230 });
231 close();
232 openClonedProject(scopeProjectRef(target.environmentId, projectId));
@@ -334,33 +362,41 @@ function AddProjectToMachineDialog({ request }: { request: AddProjectToMachineRe
362 {copyable.length > 0 ? (
363 <>
364 <span className="text-muted-foreground text-xs">
337 - {selectedFiles.size} of {files.length}
365 + {selectedFiles.size} of {allIgnoredFiles.data?.files.length ?? 0}
366 {selectedBytes > 0 ? ` · ${formatBytes(selectedBytes)}` : ""}
367 </span>
340 - <Button
341 - type="button"
342 - variant="ghost"
343 - size="xs"
344 - onClick={() =>
345 - setSelected(
346 - selectedFiles.size === copyable.length
347 - ? new Set()
348 - : new Set(copyable.map((file) => file.path)),
349 - )
350 - }
351 - >
352 - {selectedFiles.size === copyable.length ? "None" : "All"}
368 + <Button type="button" variant="ghost" size="xs" onClick={toggleShownFiles}>
369 + {allCopyableSelected ? "None" : "All"}
370 </Button>
371 </>
372 ) : null}
373 </div>
374 + {canSearchFiles && (allIgnoredFiles.data?.truncated || fileQuery.length > 0) ? (
375 + <Input
376 + size="sm"
377 + type="search"
378 + aria-label="Search ignored files"
379 + placeholder="Search ignored files"
380 + value={fileQuery}
381 + maxLength={256}
382 + onChange={(event) => setFileQuery(event.target.value)}
383 + // Enter would otherwise submit the clone.
384 + onKeyDown={(event) => {
385 + if (event.key === "Enter") event.preventDefault();
386 + }}
387 + spellCheck={false}
388 + autoComplete="off"
389 + />
390 + ) : null}
391 {ignoredFiles.error ? (
392 <p className="text-destructive-foreground text-xs">{ignoredFiles.error}</p>
393 ) : files.length === 0 ? (
394 <p className="text-muted-foreground text-xs">
361 - {ignoredFiles.isSuccess
362 - ? "No ignored files to copy."
363 - : "Finding ignored files…"}
395 + {!ignoredFiles.isSuccess
396 + ? "Finding ignored files…"
397 + : searching
398 + ? "No ignored files match."
399 + : "No ignored files to copy."}
400 </p>
401 ) : (
402 <div className="max-h-52 overflow-y-auto rounded-md border">
@@ -369,7 +405,8 @@ function AddProjectToMachineDialog({ request }: { request: AddProjectToMachineRe
405 key={file.path}
406 file={file}
407 checked={selectedFiles.has(file.path)}
372 - onCheckedChange={(checked) => toggleFile(file.path, checked)}
408 + disabled={atSelectionLimit && !selectedFiles.has(file.path)}
409 + onCheckedChange={(checked) => toggleFile(file, checked)}
410 />
411 ))}
412 </div>
@@ -377,6 +414,7 @@ function AddProjectToMachineDialog({ request }: { request: AddProjectToMachineRe
414 {ignoredFiles.data?.truncated ? (
415 <p className="text-muted-foreground text-xs">
416 Showing the first {files.length} files.
417 + {canSearchFiles ? " Search to find the rest." : ""}
418 </p>
419 ) : null}
420 <p className="text-muted-foreground text-xs">
@@ -415,29 +453,37 @@ function projectSubdirectory(repositoryRoot: string | undefined, workspaceRoot:
453 : "";
454 }
455
418 -function defaultSelection(files: readonly ProjectIgnoredFile[]): ReadonlySet<string> {
419 - return new Set(
456 +function defaultSelection(
457 + files: readonly ProjectIgnoredFile[],
458 +): ReadonlyMap<string, ProjectIgnoredFile> {
459 + return new Map(
460 files
461 .filter(
462 (file) => file.byteLength <= COPYABLE_FILE_MAX_BYTES && isDefaultCopiedFile(file.path),
463 )
424 - .map((file) => file.path),
464 + .map((file) => [file.path, file]),
465 );
466 }
467
468 function IgnoredFileRow({
469 file,
470 checked,
471 + disabled,
472 onCheckedChange,
473 }: {
474 file: ProjectIgnoredFile;
475 checked: boolean;
476 + disabled: boolean;
477 onCheckedChange: (checked: boolean) => void;
478 }) {
479 const tooLarge = file.byteLength > COPYABLE_FILE_MAX_BYTES;
480 return (
481 <label className="flex cursor-pointer items-center gap-2 px-2.5 py-1.5 text-sm not-last:border-b has-disabled:cursor-not-allowed has-disabled:opacity-64">
440 - <Checkbox checked={checked} disabled={tooLarge} onCheckedChange={onCheckedChange} />
482 + <Checkbox
483 + checked={checked}
484 + disabled={tooLarge || disabled}
485 + onCheckedChange={onCheckedChange}
486 + />
487 <span className="min-w-0 flex-1 truncate font-mono text-xs">{file.path}</span>
488 <span className="shrink-0 text-muted-foreground text-xs tabular-nums">
489 {tooLarge ? "Over 1 MB" : formatBytes(file.byteLength)}
apps/web/src/lib/addProjectToMachine.ts
+3
@@ -21,6 +21,9 @@ import { sourceControlEnvironment } from "../state/sourceControl";
21 /** Matches the server's read cap: a larger file would arrive truncated. */
22 export const COPYABLE_FILE_MAX_BYTES = 1024 * 1024;
23
24 +/** The server lists at most this many ignored files, so one pick never exceeded it. */
25 +export const COPIED_FILES_MAX_COUNT = 200;
26 +
27 const DEFAULT_COPIED_FILE_NAME = /^(?:\.env(?:\..+)?|\.envrc|\.dev\.vars)$/;
28
29 /** Env files are the ignored files people almost always want on a new machine. */
packages/contracts/src/environment.ts
+2
@@ -160,6 +160,8 @@ export const ExecutionEnvironmentCapabilities = Schema.Struct({
160 projectOrganization: Schema.optionalKey(Schema.Boolean),
161 /** Server answers projects.listIgnoredFiles. */
162 ignoredFileListing: Schema.optionalKey(Schema.Boolean),
163 + /** projects.listIgnoredFiles honors `query`. Older servers ignore it. */
164 + ignoredFileSearch: Schema.optionalKey(Schema.Boolean),
165 environmentIcon: Schema.optionalKey(Schema.Boolean),
166 desktopAppUpdate: Schema.optionalKey(Schema.Boolean),
167 /** The desktop app switches update tracks when a server update request names one. */
packages/contracts/src/project.ts
+2
@@ -311,6 +311,8 @@ export type ProjectListEntriesResult = typeof ProjectListEntriesResult.Type;
311 // are left out, so the list stays small enough to pick from.
312 export const ProjectListIgnoredFilesInput = Schema.Struct({
313 cwd: TrimmedNonEmptyString,
314 + /** Case-insensitive path substring, applied before the listing cap. */
315 + query: Schema.optionalKey(TrimmedString.check(Schema.isMaxLength(256))),
316 });
317 export type ProjectListIgnoredFilesInput = typeof ProjectListIgnoredFilesInput.Type;
318