Skip to content

Commit 5ff5bc2

Browse files
exe.dev userclaude
andcommitted
fix(web): drop the second media gate that still skipped the folder read
useProjectFileQuery short-circuited image and video paths to the empty atom regardless of the enabled flag, so a folder named `assets.png` still never reached readFile. Enablement is the caller's decision now. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
1 parent d522363 commit 5ff5bc2

2 files changed

Lines changed: 34 additions & 11 deletions

File tree

‎apps/web/src/components/files/projectFilesQueryState.test.tsx‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,35 @@ describe("project query refresh", () => {
252252
}
253253
});
254254

255+
it("reports a directory named like an image as not a file", async () => {
256+
const readAtom = Atom.make(
257+
Effect.fail(
258+
new ProjectReadFileError({
259+
cwd: "/repo",
260+
relativePath: "assets.png",
261+
failure: "path_not_file",
262+
}),
263+
),
264+
);
265+
const registry = AtomRegistry.make();
266+
const unmount = registry.mount(readAtom);
267+
projectMocks.readFile.mockReturnValue(readAtom);
268+
projectMocks.optimisticFile.mockReturnValue(Atom.make(null));
269+
atomHooks.registry = registry;
270+
271+
try {
272+
await flushEffects();
273+
reactHooks.beginRender();
274+
const query = useProjectFileQuery(environmentId, "/repo", "assets.png");
275+
expect(query.isNotFile).toBe(true);
276+
expect(query.data).toBeNull();
277+
} finally {
278+
unmount();
279+
registry.dispose();
280+
atomHooks.registry = null;
281+
}
282+
});
283+
255284
it("reports a directory read as not a file", async () => {
256285
const readAtom = Atom.make(
257286
Effect.fail(

‎apps/web/src/components/files/projectFilesQueryState.ts‎

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@ import {
55
ProjectReadFileError,
66
type ProjectReadFileResult,
77
} from "@t3tools/contracts";
8-
import {
9-
isWorkspaceImagePreviewPath,
10-
isWorkspaceVideoPreviewPath,
11-
} from "@t3tools/shared/filePreview";
128
import * as Cause from "effect/Cause";
139
import * as Option from "effect/Option";
1410
import * as Schema from "effect/Schema";
@@ -194,13 +190,11 @@ export function useProjectFileQuery(
194190
relativePath: string | null,
195191
enabled = true,
196192
): ProjectFileQueryState {
197-
const isMedia =
198-
relativePath !== null &&
199-
(isWorkspaceImagePreviewPath(relativePath) || isWorkspaceVideoPreviewPath(relativePath));
200-
const atom =
201-
enabled && !isMedia
202-
? getProjectFileQueryAtom(environmentId, cwd, relativePath)
203-
: EMPTY_PROJECT_FILE_QUERY_ATOM;
193+
// The caller decides what to read. A media path is not skipped here: a folder
194+
// named `assets.png` is only knowable as a folder from the read failure.
195+
const atom = enabled
196+
? getProjectFileQueryAtom(environmentId, cwd, relativePath)
197+
: EMPTY_PROJECT_FILE_QUERY_ATOM;
204198
const result = useAtomValue(atom);
205199
const refreshAtom = useAtomRefresh(atom);
206200
const refresh = useCallback(() => refreshAtom(), [refreshAtom]);

0 commit comments

Comments
 (0)