Skip to content

Commit 1263353

Browse files
committed
fix(web): treat binary literal chip paths as existing
readFile reports existing binary files with a distinct failure reason. Count binary_file (and path_not_file) as existing so a slashed chip path like docs/report.pdf keeps its literal file instead of resolving to an unrelated indexed suffix match.
1 parent 0e64571 commit 1263353

1 file changed

Lines changed: 14 additions & 3 deletions

File tree

‎apps/web/src/components/ChatMarkdown.tsx‎

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import type {
3434
ServerProviderSkill,
3535
ThreadPullRequestKey,
3636
} from "@t3tools/contracts";
37+
import { ProjectReadFileError } from "@t3tools/contracts";
3738
import { scopedThreadKey } from "@t3tools/client-runtime/environment";
3839
import { faviconUrlForOrigin } from "@t3tools/shared/favicon";
3940
import { githubMediaFetchUrl } from "@t3tools/shared/githubMedia";
@@ -55,6 +56,7 @@ import { inlineCodeFilePathCandidate } from "@t3tools/client-runtime/markdown-li
5556
import { mediaFileReference, mediaUrlReference } from "@t3tools/client-runtime/media-reference";
5657
import { mediaKindFromPath, mediaMimeTypeFromExtension } from "@t3tools/shared/filePreview";
5758
import * as Cause from "effect/Cause";
59+
import * as Schema from "effect/Schema";
5860
import { AsyncResult } from "effect/unstable/reactivity";
5961
import React, {
6062
Children,
@@ -279,6 +281,8 @@ export function shouldUseMarkdownFileBrowserPrimaryAction(input: {
279281
const EMPTY_MARKDOWN_SKILLS: ReadonlyArray<Pick<ServerProviderSkill, "name" | "displayName">> = [];
280282
const EMPTY_REMARK_PLUGINS: NonNullable<ReactMarkdownOptions["remarkPlugins"]> = [];
281283

284+
const isProjectReadFileError = Schema.is(ProjectReadFileError);
285+
282286
const ARTIFACT_TEMPLATE_ICON_BY_KIND = {
283287
document: FileTextIcon,
284288
presentation: PresentationIcon,
@@ -2569,10 +2573,17 @@ function useChatMarkdownState({
25692573
environmentId,
25702574
input: { cwd, relativePath: workspaceRelativePath },
25712575
});
2576+
if (result._tag === "Success") return true;
25722577
// readFile reads from disk rather than the search index, so gitignored
2573-
// files still report present. Binary files fail the read and count as
2574-
// missing here; a stat RPC would close that gap.
2575-
return result._tag === "Success";
2578+
// files still report present. Existing binary files (and directories)
2579+
// fail the read with a distinct reason but still prove the literal path
2580+
// exists, so the index must not hijack them. Only a genuinely missing
2581+
// file falls through to the indexed match.
2582+
const cause = squashAtomCommandFailure(result);
2583+
return (
2584+
isProjectReadFileError(cause) &&
2585+
(cause.failure === "binary_file" || cause.failure === "path_not_file")
2586+
);
25762587
},
25772588
[cwd, environmentId, readWorkspaceFile],
25782589
);

0 commit comments

Comments
 (0)