diff --git a/apps/web/app/components/chain-of-thought.tsx b/apps/web/app/components/chain-of-thought.tsx index 10007cd0739..af9ad676f18 100644 --- a/apps/web/app/components/chain-of-thought.tsx +++ b/apps/web/app/components/chain-of-thought.tsx @@ -782,18 +782,10 @@ function ReasoningBlock({ return (
{text} - {isStreaming && ( - - )}
); diff --git a/apps/web/app/components/chat-message.tsx b/apps/web/app/components/chat-message.tsx index 80a85205b46..24778a6d023 100644 --- a/apps/web/app/components/chat-message.tsx +++ b/apps/web/app/components/chat-message.tsx @@ -424,20 +424,27 @@ function AttachedFilesCard({ paths }: { paths: string[] }) { /** * Detect whether an inline code string looks like a local file/directory path. - * Matches patterns like: - * ~/Downloads/file.pdf - * /Users/name/Documents/file.txt - * /home/user/file.py - * ./relative/path - * ../parent/path - * /etc/config + * Matches anything starting with: + * ~/ (home-relative) + * / (absolute) + * ./ (current-dir-relative) + * ../ (parent-dir-relative) + * Must contain at least one `/` separator to distinguish from plain commands. */ -const FILE_PATH_RE = - /^(?:~\/|\.\.?\/|\/(?:Users|home|tmp|var|etc|opt|usr|Library|Applications|Downloads|Documents|Desktop)\b)[^\s]*$/; - function looksLikeFilePath(text: string): boolean { - if (!text || text.length < 2 || text.length > 500) {return false;} - return FILE_PATH_RE.test(text.trim()); + const t = text.trim(); + if (!t || t.length < 3 || t.length > 500) {return false;} + // Must start with a path prefix + if (!(t.startsWith("~/") || t.startsWith("/") || t.startsWith("./") || t.startsWith("../"))) { + return false; + } + // Must have at least one path separator beyond the prefix + // (avoids matching bare `/` or standalone commands like `/bin`) + const afterPrefix = t.startsWith("~/") ? t.slice(2) : + t.startsWith("../") ? t.slice(3) : + t.startsWith("./") ? t.slice(2) : + t.slice(1); + return afterPrefix.includes("/") || afterPrefix.includes("."); } /** Open a file path using the system default application. */ @@ -496,14 +503,10 @@ function FilePathCode({ return ( {status === "error" ? ( <> @@ -650,7 +653,7 @@ export const ChatMessage = memo(function ChatMessage({ message, isStreaming }: { return (