Skip to content

Commit d522363

Browse files
exe.dev userclaude
andcommitted
fix(web): detect a folder whose name looks like a media file or a PDF
The read was skipped for media and PDF paths because their contents are never shown, so a folder named `assets.png` never produced the path_not_file failure and rendered as a broken media preview. The server stats before reading, so the read costs an open and a stat for a folder and returns no body. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
1 parent a08b6bf commit d522363

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

‎apps/web/src/components/files/FilePreviewPanel.tsx‎

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -989,12 +989,11 @@ export default function FilePreviewPanel({
989989
// A file outside the workspace (an absolute path) is shown, never edited.
990990
const isHostFile =
991991
attachment !== undefined || (relativePath !== null && isAbsolutePath(relativePath));
992-
const file = useProjectFileQuery(
993-
environmentId,
994-
cwd,
995-
relativePath,
996-
attachment === undefined && !isMedia && !isPdf,
997-
);
992+
// Media and PDFs render from their absolute path, so their contents are never
993+
// shown. The read still runs: a folder named `assets.png` is only knowable as a
994+
// folder from the read failure, and the server stats before reading, so a folder
995+
// costs an open and a stat and returns no body.
996+
const file = useProjectFileQuery(environmentId, cwd, relativePath, attachment === undefined);
998997
// A chat link cannot tell a folder from a file, so a folder arrives here as
999998
// a file surface and the read fails. Keep the breadcrumbs, drop the preview
1000999
// pane, and let the tree fill the surface with the folder revealed. Mutation
@@ -1053,8 +1052,10 @@ export default function FilePreviewPanel({
10531052
enabled:
10541053
attachment === undefined &&
10551054
relativePath !== null &&
1056-
!isMedia &&
1057-
!isPdf &&
1055+
// Media and PDFs never show their contents, so re-reading them on every
1056+
// workspace mutation is waste. A folder named like one still re-reads, so
1057+
// it notices when the path becomes a file.
1058+
(isDirectory || (!isMedia && !isPdf)) &&
10581059
!selectedFilePending,
10591060
mutationId: workspaceMutationId,
10601061
refresh: file.refresh,

0 commit comments

Comments
 (0)