diff --git a/webview-ui/src/components/ChatRow.tsx b/webview-ui/src/components/ChatRow.tsx index 5f1070a..362bd92 100644 --- a/webview-ui/src/components/ChatRow.tsx +++ b/webview-ui/src/components/ChatRow.tsx @@ -4,11 +4,11 @@ import React, { memo, useMemo } from "react" import ReactMarkdown from "react-markdown" import { ClaudeMessage, ClaudeSayTool } from "../../../src/shared/ExtensionMessage" import { COMMAND_OUTPUT_STRING } from "../../../src/shared/combineCommandSequences" -import CodeAccordian, { formatFilePathForTruncation } from "./CodeAccordian" -import CodeBlock, { CODE_BLOCK_BG_COLOR } from "./CodeBlock" -import Thumbnails from "./Thumbnails" import { vscode } from "../utils/vscode" +import CodeAccordian, { removeLeadingNonAlphanumeric } from "./CodeAccordian" +import CodeBlock, { CODE_BLOCK_BG_COLOR } from "./CodeBlock" import { highlightMentions } from "./TaskHeader" +import Thumbnails from "./Thumbnails" interface ChatRowProps { message: ClaudeMessage @@ -209,7 +209,6 @@ const ChatRowContent = ({ message, isExpanded, onToggleExpand, lastModifiedMessa style={{ color: "var(--vscode-descriptionForeground)", display: "flex", - justifyContent: "space-between", alignItems: "center", padding: "9px 10px", cursor: "pointer", @@ -221,6 +220,7 @@ const ChatRowContent = ({ message, isExpanded, onToggleExpand, lastModifiedMessa onClick={() => { vscode.postMessage({ type: "openFile", text: tool.content }) }}> + {tool.path?.startsWith(".") && .} - {formatFilePathForTruncation(tool.path ?? "") + "\u200E"} + {removeLeadingNonAlphanumeric(tool.path ?? "") + "\u200E"} +
diff --git a/webview-ui/src/components/CodeAccordian.tsx b/webview-ui/src/components/CodeAccordian.tsx index 6ea22c7..6c894fd 100644 --- a/webview-ui/src/components/CodeAccordian.tsx +++ b/webview-ui/src/components/CodeAccordian.tsx @@ -13,12 +13,12 @@ interface CodeAccordianProps { } /* -We need to remove leading non-alphanumeric/period characters from the path in order for our leading ellipses trick to work. +We need to remove leading non-alphanumeric characters from the path in order for our leading ellipses trick to work. ^: Anchors the match to the start of the string. -[^a-zA-Z0-9.]+: Matches one or more characters that are not alphanumeric or a dot. -The replace method removes these matched characters, effectively trimming the string up to the first alphanumeric/period character. +[^a-zA-Z0-9]+: Matches one or more characters that are not alphanumeric. +The replace method removes these matched characters, effectively trimming the string up to the first alphanumeric character. */ -export const formatFilePathForTruncation = (path: string): string => path.replace(/^[^a-zA-Z0-9.]+/, "") +export const removeLeadingNonAlphanumeric = (path: string): string => path.replace(/^[^a-zA-Z0-9]+/, "") const CodeAccordian = ({ code, diff, language, path, isFeedback, isExpanded, onToggleExpand }: CodeAccordianProps) => { const inferredLanguage = useMemo( @@ -39,7 +39,6 @@ const CodeAccordian = ({ code, diff, language, path, isFeedback, isExpanded, onT style={{ color: "var(--vscode-descriptionForeground)", display: "flex", - justifyContent: "space-between", alignItems: "center", padding: "9px 10px", cursor: "pointer", @@ -64,6 +63,7 @@ const CodeAccordian = ({ code, diff, language, path, isFeedback, isExpanded, onT ) : ( <> + {path?.startsWith(".") && .} - {formatFilePathForTruncation(path ?? "") + "\u200E"} + {removeLeadingNonAlphanumeric(path ?? "") + "\u200E"} +
)} diff --git a/webview-ui/src/components/ContextMenu.tsx b/webview-ui/src/components/ContextMenu.tsx index 8a2638e..4ea10a0 100644 --- a/webview-ui/src/components/ContextMenu.tsx +++ b/webview-ui/src/components/ContextMenu.tsx @@ -1,6 +1,6 @@ import React, { useEffect, useMemo, useRef } from "react" import { ContextMenuOptionType, ContextMenuQueryItem, getContextMenuOptions } from "../utils/context-mentions" -import { formatFilePathForTruncation } from "./CodeAccordian" +import { removeLeadingNonAlphanumeric } from "./CodeAccordian" interface ContextMenuProps { onSelect: (type: ContextMenuOptionType, value?: string) => void @@ -56,17 +56,20 @@ const ContextMenu: React.FC = ({ case ContextMenuOptionType.Folder: if (option.value) { return ( - - {formatFilePathForTruncation(option.value || "") + "\u200E"} - + <> + / + {option.value?.startsWith("/.") && .} + + {removeLeadingNonAlphanumeric(option.value || "") + "\u200E"} + + ) } else { return Add {option.type === ContextMenuOptionType.File ? "File" : "Folder"}