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, 06:00 UTC
fix(client-runtime): file tooltips keep the size after workspace search (#39012)
Co-authored-by: Julius Marminge <julius0216@outlook.com>
Wout Stiens committed
Nov 19, 2026 at 09:06 UTC
94b54cfa9f0e148ac0e1bba13558526dbbe87374
3 files changed
+89
-4
packages/client-runtime/src/state/fileMetadata.test.ts
+40
-1
@@ -346,15 +346,54 @@ describe("file metadata", () => {
346
}),
347
);
348
349
- it.effect("uses search and tree kinds without another request", () =>
349
+ it.effect("uses search and tree kinds for directories but still stats found files", () =>
350
Effect.gen(function* () {
351
const h = yield* makeHarness();
352
yield* h.seed("folder.ts", "directory");
353
expect(yield* h.read("/workspace/folder.ts")).toEqual({ kind: "directory" });
354
expect(h.batches).toHaveLength(0);
355
+ h.values.set("/workspace/notes.md", { kind: "file", byteLength: 2048 });
356
+ yield* h.seed("notes.md", "file");
357
+ expect(yield* h.read("/workspace/notes.md")).toEqual({ kind: "file", byteLength: 2048 });
358
}),
359
);
360
361
+ it.effect(
362
+ "stats listed files that replace directories or misses and reuses known file sizes",
363
+ () =>
364
+ Effect.gen(function* () {
365
+ const h = yield* makeHarness();
366
+ const threadId = ThreadId.make("listed-file-thread");
367
+ h.registry.mount(h.atoms.retainThread({ environmentId: ENVIRONMENT_ID, threadId }));
368
+ const directory = "/workspace/was-directory";
369
+ const missing = "/workspace/was-missing";
370
+ const file = "/workspace/known-file";
371
+ yield* h.seed("was-directory", "directory");
372
+ expect(yield* h.read(missing, ENVIRONMENT_ID, threadId)).toBeNull();
373
+ h.values.set(file, { kind: "file", byteLength: 100 });
374
+ yield* h.read(file, ENVIRONMENT_ID, threadId);
375
+
376
+ h.values.set(directory, { kind: "file", byteLength: 2048 });
377
+ h.values.set(missing, { kind: "file", byteLength: 4096 });
378
+ yield* h.seed("was-directory", "file");
379
+ yield* h.seed("was-missing", "file");
380
+ yield* h.seed("known-file", "file");
381
+
382
+ expect(yield* h.read(directory)).toEqual({ kind: "file", byteLength: 2048 });
383
+ h.registry.refresh(h.atom(missing, ENVIRONMENT_ID, threadId));
384
+ expect(yield* h.read(missing, ENVIRONMENT_ID, threadId)).toEqual({
385
+ kind: "file",
386
+ byteLength: 4096,
387
+ });
388
+ h.registry.refresh(h.atom(file, ENVIRONMENT_ID, threadId));
389
+ expect(yield* h.read(file, ENVIRONMENT_ID, threadId)).toEqual({
390
+ kind: "file",
391
+ byteLength: 100,
392
+ });
393
+ expect(h.batches.flat()).toEqual([missing, file, directory, missing]);
394
+ }),
395
+ );
396
+
397
it.effect("splits large mounts into bounded batches and caches misses", () =>
398
Effect.gen(function* () {
399
const h = yield* makeHarness();
packages/client-runtime/src/state/fileMetadata.ts
+16
-3
@@ -264,9 +264,22 @@ export function createFileMetadataAtoms<R, E>(
264
if (isCurrent && !isCurrent(session.value)) return;
265
for (const entry of entries) {
266
const path = resolveWorkspaceFilePath(entry.path, cwd);
267
- const previous = knownEntry(session.value, path, now);
268
- if (previous?.value?.kind === entry.kind) continue;
269
- remember(session.value, path, { kind: entry.kind }, now, true);
267
+ if (entry.kind === "directory") {
268
+ if (knownEntry(session.value, path, now)?.value?.kind !== "directory")
269
+ remember(session.value, path, { kind: "directory" }, now, true);
270
+ continue;
271
+ }
272
+
273
+ // A file listing can invalidate the cached kind but only a stat supplies full metadata.
274
+ const key = normalizeProjectPathForComparison(path);
275
+ const cached = cache.get(session.value);
276
+ if (cached?.get(key)?.value?.kind === "file") continue;
277
+ cached?.delete(key);
278
+ for (const thread of retainedThreads.values()) {
279
+ const retained = thread.sessions.get(session.value);
280
+ const previous = retained?.get(key);
281
+ if (previous && previous.value?.kind !== "file") retained?.delete(key);
282
+ }
283
}
284
});
285
scripts/scenarios/cited-file-tooltip-keeps-size-after-search.e2e.ts
new
+33
@@ -0,0 +1,33 @@
1
+import { expect } from "e2e";
2
+
3
+import { test, WEB } from "./t3.ts";
4
+
5
+const FILE = "quarterly-figures.md";
6
+
7
+test(
8
+ "The file citation tooltip shows the size even after workspace search finds the file",
9
+ WEB,
10
+ async ({ t3, app, browser, screen }) => {
11
+ const project = await t3.project("demo", { [FILE]: "x".repeat(2048) });
12
+ const thread = await t3.thread({
13
+ project,
14
+ title: "Review figures",
15
+ messages: [`See :codex-file-citation{path="${FILE}" line_range_start="1"}`],
16
+ });
17
+ await t3.open(thread);
18
+
19
+ await screen.getByRole("textbox").pressSequentially(`@${FILE}`);
20
+ await screen.getByRole("option", FILE, { exact: false }).hover();
21
+ await browser.keyboard.press("Escape");
22
+ await screen.getByRole("button", /^Agent See/).tap();
23
+ await screen.getByRole("link", /^quarterly-figures\.md/).hover();
24
+
25
+ try {
26
+ await expect(
27
+ browser.locator('[data-slot="tooltip-viewport"]:has-text("quarterly-figures.md")'),
28
+ ).toContainText("2 KB");
29
+ } finally {
30
+ await app.screenshot("cited-file-tooltip");
31
+ }
32
+ },
33
+);