Skip to content

Commit ae8e4d8

Browse files
committed
fix: make error display less jarring by matching diff_error style
- Added collapsible UI for error messages similar to diff_error display - Added copy button for error text - Added expand/collapse chevron indicator - Error text now appears in a subtle background container when expanded - Maintains error icon and color but in a less jarring presentation
1 parent c99ccf0 commit ae8e4d8

File tree

1 file changed

+91
-8
lines changed

1 file changed

+91
-8
lines changed

webview-ui/src/components/chat/ChatRow.tsx

Lines changed: 91 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@ export const ChatRowContent = ({
118118
const [reasoningCollapsed, setReasoningCollapsed] = useState(true)
119119
const [isDiffErrorExpanded, setIsDiffErrorExpanded] = useState(false)
120120
const [showCopySuccess, setShowCopySuccess] = useState(false)
121+
const [isErrorExpanded, setIsErrorExpanded] = useState(false)
122+
const [showErrorCopySuccess, setShowErrorCopySuccess] = useState(false)
121123
const [isEditing, setIsEditing] = useState(false)
122124
const [editedContent, setEditedContent] = useState("")
123125
const [editMode, setEditMode] = useState<Mode>(mode || "code")
@@ -1132,15 +1134,96 @@ export const ChatRowContent = ({
11321134
)
11331135
case "error":
11341136
return (
1135-
<>
1136-
{title && (
1137-
<div style={headerStyle}>
1138-
{icon}
1139-
{title}
1137+
<div>
1138+
<div
1139+
style={{
1140+
marginTop: "0px",
1141+
overflow: "hidden",
1142+
marginBottom: "8px",
1143+
}}>
1144+
<div
1145+
style={{
1146+
borderBottom: isErrorExpanded
1147+
? "1px solid var(--vscode-editorGroup-border)"
1148+
: "none",
1149+
fontWeight: "normal",
1150+
fontSize: "var(--vscode-font-size)",
1151+
color: "var(--vscode-editor-foreground)",
1152+
display: "flex",
1153+
alignItems: "center",
1154+
justifyContent: "space-between",
1155+
cursor: "pointer",
1156+
}}
1157+
onClick={() => setIsErrorExpanded(!isErrorExpanded)}>
1158+
<div
1159+
style={{
1160+
display: "flex",
1161+
alignItems: "center",
1162+
gap: "10px",
1163+
flexGrow: 1,
1164+
}}>
1165+
<span
1166+
className="codicon codicon-error"
1167+
style={{
1168+
color: "var(--vscode-errorForeground)",
1169+
opacity: 0.8,
1170+
fontSize: 16,
1171+
marginBottom: "-1.5px",
1172+
}}></span>
1173+
<span style={{ fontWeight: "bold", color: "var(--vscode-errorForeground)" }}>
1174+
{t("chat:error")}
1175+
</span>
1176+
</div>
1177+
<div style={{ display: "flex", alignItems: "center" }}>
1178+
<VSCodeButton
1179+
appearance="icon"
1180+
style={{
1181+
padding: "3px",
1182+
height: "24px",
1183+
marginRight: "4px",
1184+
color: "var(--vscode-editor-foreground)",
1185+
display: "flex",
1186+
alignItems: "center",
1187+
justifyContent: "center",
1188+
background: "transparent",
1189+
}}
1190+
onClick={(e) => {
1191+
e.stopPropagation()
1192+
1193+
// Call copyWithFeedback and handle the Promise
1194+
copyWithFeedback(message.text || "").then((success) => {
1195+
if (success) {
1196+
// Show checkmark
1197+
setShowErrorCopySuccess(true)
1198+
1199+
// Reset after a brief delay
1200+
setTimeout(() => {
1201+
setShowErrorCopySuccess(false)
1202+
}, 1000)
1203+
}
1204+
})
1205+
}}>
1206+
<span
1207+
className={`codicon codicon-${showErrorCopySuccess ? "check" : "copy"}`}></span>
1208+
</VSCodeButton>
1209+
<span
1210+
className={`codicon codicon-chevron-${isErrorExpanded ? "up" : "down"}`}></span>
1211+
</div>
11401212
</div>
1141-
)}
1142-
<p style={{ ...pStyle, color: "var(--vscode-errorForeground)" }}>{message.text}</p>
1143-
</>
1213+
{isErrorExpanded && (
1214+
<div
1215+
style={{
1216+
padding: "8px",
1217+
backgroundColor: "var(--vscode-editor-background)",
1218+
borderTop: "none",
1219+
}}>
1220+
<p style={{ ...pStyle, color: "var(--vscode-errorForeground)" }}>
1221+
{message.text}
1222+
</p>
1223+
</div>
1224+
)}
1225+
</div>
1226+
</div>
11441227
)
11451228
case "completion_result":
11461229
return (

0 commit comments

Comments
 (0)