Skip to content

Commit d5a8049

Browse files
committed
feat: Improve stdout message handling in McpErrorRow
Enhanced stdout message handling with: - Comprehensive pattern detection for various formats - Clean [STDOUT] prefix handling - Consistent color coding - Improved code organization
1 parent 3f3825a commit d5a8049

File tree

1 file changed

+36
-2
lines changed

1 file changed

+36
-2
lines changed

webview-ui/src/components/mcp/McpErrorRow.tsx

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,54 @@ type McpErrorRowProps = {
99

1010
export const McpErrorRow = ({ error }: McpErrorRowProps) => {
1111
const color = useMemo(() => {
12+
// Add debugging to log what level is coming in
13+
14+
// First check for explicitly prefixed stdout messages
15+
if (error.level === "info" && error.message.startsWith("[STDOUT]")) {
16+
// Use regular foreground color for stdout messages
17+
return "var(--vscode-foreground)"
18+
}
19+
20+
// Check if this is a stdout message (mapped to info in backend)
21+
// Common patterns for stdout messages
22+
const isStdoutMessage =
23+
error.level === "info" &&
24+
(/Server .* stdout:/.test(error.message) ||
25+
/MCP Server .* running on stdio/.test(error.message) ||
26+
/INFO/i.test(error.message) ||
27+
/Server running/i.test(error.message) ||
28+
/Documentation MCP Server/i.test(error.message) ||
29+
/running on stdio/i.test(error.message))
30+
31+
if (isStdoutMessage) {
32+
// Use regular foreground color for stdout messages
33+
return "var(--vscode-foreground)"
34+
}
35+
1236
switch (error.level) {
1337
case "error":
1438
return "var(--vscode-testing-iconFailed)"
1539
case "warn":
1640
return "var(--vscode-charts-yellow)"
1741
case "info":
42+
// Note: stdout messages are handled above via prefix detection
1843
return "var(--vscode-testing-iconPassed)"
44+
default:
45+
// For any unexpected value, default to error color
46+
console.warn(`Unknown error level: ${error.level}`)
47+
return "var(--vscode-testing-iconFailed)"
1948
}
20-
}, [error.level])
49+
}, [error.level, error.message])
50+
51+
// Strip [STDOUT] prefix from the message for cleaner display
52+
const displayMessage = error.message.startsWith("[STDOUT]")
53+
? error.message.substring("[STDOUT]".length).trim()
54+
: error.message
2155

2256
return (
2357
<div className="text-sm bg-vscode-textCodeBlock-background border-l-2 p-2" style={{ borderColor: color }}>
2458
<div className="mb-1" style={{ color }}>
25-
{error.message}
59+
{displayMessage}
2660
</div>
2761
<div className="text-xs text-vscode-descriptionForeground">
2862
{formatRelative(error.timestamp, new Date())}

0 commit comments

Comments
 (0)