@devries-cameron20 / t3code Mirror · read-only / commits / 88bf393b30
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, 19:45 UTC

fix(server): @ file search finds filenames containing literal braces (#35239)

Co-authored-by: sidhartha1s <sidhartha1s@users.noreply.github.com> Co-authored-by: Julius Marminge <julius0216@outlook.com>

Sidhartha S committed Nov 12, 2026 at 22:51 UTC 88bf393b30d031ad998651eb66f4df804442399c
2 files changed +42 -17
apps/server/src/workspace/WorkspaceEntries.test.ts
+19 -5
@@ -457,17 +457,31 @@ it.layer(layerTest, { excludeTestServices: true })("WorkspaceEntries", (it) => {
457 }),
458 );
459
460 - it.effect("matches square brackets in the query literally", () =>
460 + it.effect("matches glob metacharacters in the query literally", () =>
461 Effect.gen(function* () {
462 const cwd = yield* makeTempDir({ prefix: "t3code-workspace-brackets-" });
463 yield* writeTextFile(cwd, "src/app/game/[id]/index.tsx");
464 + yield* writeTextFile(cwd, "src/foo{bar}.ts");
465 + yield* writeTextFile(cwd, "src/main.ts");
466 + yield* writeTextFile(cwd, "src/notes.md");
467
465 - for (const query of ["game/[i", "game/[id]"]) {
466 - const result = yield* searchWorkspaceEntries({ cwd, query, limit: 10 });
467 - expect(result.entries.map((entry) => entry.path)).toContain(
468 - "src/app/game/[id]/index.tsx",
468 + const search = (query: string) =>
469 + searchWorkspaceEntries({ cwd, query, limit: 10 }).pipe(
470 + Effect.map((result) => result.entries.map((entry) => entry.path)),
471 );
472 +
473 + for (const query of ["game/[i", "game/[id]"]) {
474 + expect(yield* search(query)).toContain("src/app/game/[id]/index.tsx");
475 }
476 + expect(yield* search("foo{bar}.ts")).toContain("src/foo{bar}.ts");
477 + expect((yield* search("*.{ts,tsx}")).toSorted()).toEqual([
478 + "src/app/game/[id]/index.tsx",
479 + "src/foo{bar}.ts",
480 + "src/main.ts",
481 + ]);
482 + expect((yield* search("*.{ts}")).toSorted()).toEqual(["src/foo{bar}.ts", "src/main.ts"]);
483 + expect(yield* search("src/{main}.ts")).toEqual(["src/main.ts"]);
484 + expect(yield* search("src/{foo{bar},notes}.md")).toEqual(["src/notes.md"]);
485 }),
486 );
487
apps/server/src/workspace/WorkspaceSearchIndex.ts
+23 -12
@@ -447,32 +447,43 @@ export const make = Effect.fn("WorkspaceSearchIndex.make")(function* (
447 },
448 );
449
450 - const search: WorkspaceSearchIndex["Service"]["search"] = Effect.fn(
451 - "WorkspaceSearchIndex.search",
452 - )(function* (rawQuery, limit, kind, imageOnly) {
453 - // fff parses any word containing "[" as a glob and has no escape for it; fuzzy
454 - // matching is subsequence-based, so dropping "[" still matches "[id]" folders.
455 - const query = rawQuery.replaceAll("[", "");
450 + const searchNames = Effect.fn("WorkspaceSearchIndex.searchNames")(function* (
451 + query: string,
452 + limit: number,
453 + kind: ProjectEntryKind | undefined,
454 + imageOnly: boolean | undefined,
455 + ) {
456 const pageSize = imageOnly ? WORKSPACE_INDEX_PAGE_SIZE : Math.max(1, limit + 1);
457 - const incompleteBeforeQuery = hasIncompleteInitialScan();
457 if (kind === "file" || imageOnly) {
458 const result = yield* runSearch(query, pageSize, "fileSearch", () =>
459 finder.fileSearch(query, { pageSize }),
460 );
462 - const mapped = mapFileSearchResult(result, limit, imageOnly);
463 - return { ...mapped, truncated: incompleteBeforeQuery || mapped.truncated };
461 + return mapFileSearchResult(result, limit, imageOnly);
462 }
463 if (kind === "directory") {
464 const result = yield* runSearch(query, pageSize, "directorySearch", () =>
465 finder.directorySearch(query, { pageSize }),
466 );
469 - const mapped = mapDirectorySearchResult(result, limit);
470 - return { ...mapped, truncated: incompleteBeforeQuery || mapped.truncated };
467 + return mapDirectorySearchResult(result, limit);
468 }
469 const result = yield* runSearch(query, pageSize, "mixedSearch", () =>
470 finder.mixedSearch(query, { pageSize }),
471 );
475 - const mapped = mapMixedSearchResult(result, limit);
472 + return mapMixedSearchResult(result, limit);
473 + });
474 +
475 + const search: WorkspaceSearchIndex["Service"]["search"] = Effect.fn(
476 + "WorkspaceSearchIndex.search",
477 + )(function* (rawQuery, limit, kind, imageOnly) {
478 + // fff parses any word containing "[" or "{" as a glob and has no escape for them; fuzzy
479 + // matching is subsequence-based, so dropping them still matches "[id]" and "a{b}" paths.
480 + // "{" is dropped only when the query finds nothing as a glob, so "*.{ts,tsx}" keeps working.
481 + const query = rawQuery.replaceAll("[", "");
482 + const incompleteBeforeQuery = hasIncompleteInitialScan();
483 + let mapped = yield* searchNames(query, limit, kind, imageOnly);
484 + if (mapped.entries.length === 0 && query.includes("{")) {
485 + mapped = yield* searchNames(query.replaceAll("{", ""), limit, kind, imageOnly);
486 + }
487 return { ...mapped, truncated: incompleteBeforeQuery || mapped.truncated };
488 });
489