diff --git a/webview-ui/src/components/chat/ChatRow.tsx b/webview-ui/src/components/chat/ChatRow.tsx index 919530749c..32b61be08d 100644 --- a/webview-ui/src/components/chat/ChatRow.tsx +++ b/webview-ui/src/components/chat/ChatRow.tsx @@ -33,7 +33,8 @@ import MarkdownBlock from "../common/MarkdownBlock" import { ReasoningBlock } from "./ReasoningBlock" import Thumbnails from "../common/Thumbnails" import McpResourceRow from "../mcp/McpResourceRow" -import { IconButton } from "./IconButton" + +import { DisclosureHeader } from "./DisclosureHeader" import { Mention } from "./Mention" import { CheckpointSaved } from "./checkpoints/CheckpointSaved" @@ -864,60 +865,29 @@ export const ChatRowContent = ({ overflow: "hidden", marginBottom: "8px", }}> -
{t("chat:diffError.title")}} + expanded={isDiffErrorExpanded} + onToggle={() => setIsDiffErrorExpanded(!isDiffErrorExpanded)} + onCopy={() => { + copyWithFeedback(message.text || "").then((success) => { + if (success) { + setShowCopySuccess(true) + setTimeout(() => { + setShowCopySuccess(false) + }, 1000) + } + }) }} - onClick={() => setIsDiffErrorExpanded(!isDiffErrorExpanded)}> -
- - {t("chat:diffError.title")} -
-
- { - e.stopPropagation() - copyWithFeedback(message.text || "").then((success) => { - if (success) { - setShowCopySuccess(true) - setTimeout(() => { - setShowCopySuccess(false) - }, 1000) - } - }) - }} - style={{ marginRight: "4px" }} - /> - -
-
+ copyTitle={t("chat:codeblock.tooltips.copy_code")} + copyIconClass={showCopySuccess ? "codicon-check" : "codicon-copy"} + /> {isDiffErrorExpanded && (
-
{t("chat:error")}} + expanded={isErrorExpanded} + onToggle={() => setIsErrorExpanded(!isErrorExpanded)} + onCopy={() => { + copyWithFeedback(message.text || "").then((success) => { + if (success) { + setShowErrorCopySuccess(true) + setTimeout(() => { + setShowErrorCopySuccess(false) + }, 1000) + } + }) }} - onClick={() => setIsErrorExpanded(!isErrorExpanded)}> -
- - - {t("chat:error")} - -
-
- { - e.stopPropagation() - copyWithFeedback(message.text || "").then((success) => { - if (success) { - setShowErrorCopySuccess(true) - setTimeout(() => { - setShowErrorCopySuccess(false) - }, 1000) - } - }) - }} - style={{ marginRight: "4px" }} - /> - -
-
+ copyTitle={t("chat:codeblock.tooltips.copy_code")} + copyIconClass={showErrorCopySuccess ? "codicon-check" : "codicon-copy"} + /> {isErrorExpanded && (
void + onCopy?: (e: React.MouseEvent) => void + copyTitle?: string + copyIconClass?: string // e.g. "codicon-copy" | "codicon-check" + className?: string +} + +export const DisclosureHeader: React.FC = ({ + contentId, + iconClass, + iconStyle, + title, + expanded, + onToggle, + onCopy, + copyTitle, + copyIconClass, + className, +}) => { + return ( +
+ + + {onCopy && ( + { + e.stopPropagation() + onCopy(e) + }} + style={{ marginLeft: 4 }} + /> + )} +
+ ) +}