Skip to content

Commit aeb1ea6

Browse files
author
Merge Resolver
committed
feat: extract and display error title from error messages
- Parse error messages to extract title before first colon - Display extracted title (e.g. 'File Not Found') instead of generic 'Error' - Remove redundant 'Error' prefix from extracted titles - Maintain full error message in expanded content for context
1 parent 0f47482 commit aeb1ea6

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

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

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1088,7 +1088,27 @@ export const ChatRowContent = ({
10881088
/>
10891089
</div>
10901090
)
1091-
case "error":
1091+
case "error": {
1092+
// Extract error title from the message text if it follows the pattern "Title: rest of message"
1093+
let errorTitle = t("chat:error")
1094+
const errorContent = message.text || ""
1095+
1096+
// Check if the error message starts with a title pattern (e.g., "File Not Found:", "Permission Denied:", etc.)
1097+
// Look for text before the first colon on the first line
1098+
const firstLineEnd = errorContent.indexOf("\n")
1099+
const firstLine = firstLineEnd > -1 ? errorContent.substring(0, firstLineEnd) : errorContent
1100+
const colonIndex = firstLine.indexOf(":")
1101+
1102+
if (colonIndex > 0 && colonIndex < 50) {
1103+
// Reasonable title length limit
1104+
// Extract the title part before the colon
1105+
const potentialTitle = firstLine.substring(0, colonIndex).trim()
1106+
// Use it as title if it's not too long and looks like a title
1107+
if (potentialTitle.length > 0) {
1108+
errorTitle = potentialTitle.replace(/^Error\s+/i, "").trim()
1109+
}
1110+
}
1111+
10921112
return (
10931113
<div>
10941114
<div
@@ -1101,7 +1121,7 @@ export const ChatRowContent = ({
11011121
contentId={`error-${message.ts}`}
11021122
iconClass="codicon-warning"
11031123
iconStyle={{ color: "var(--vscode-editorWarning-foreground)", opacity: 0.8 }}
1104-
title={<span style={{ fontWeight: "bold" }}>{t("chat:error")}</span>}
1124+
title={<span style={{ fontWeight: "bold" }}>{errorTitle}</span>}
11051125
expanded={isErrorExpanded}
11061126
onToggle={() => setIsErrorExpanded(!isErrorExpanded)}
11071127
onCopy={() => {
@@ -1126,13 +1146,14 @@ export const ChatRowContent = ({
11261146
borderTop: "none",
11271147
}}>
11281148
<p style={{ ...pStyle, color: "var(--vscode-errorForeground)" }}>
1129-
{message.text}
1149+
{errorContent}
11301150
</p>
11311151
</div>
11321152
)}
11331153
</div>
11341154
</div>
11351155
)
1156+
}
11361157
case "completion_result":
11371158
return (
11381159
<>

0 commit comments

Comments
 (0)