Skip to content

Commit 4bdec24

Browse files
FIX: Add Troubleshoot Button to Error Messages (#53)
* fix: add troubleshoot button to error messages Add a "Troubleshoot this" button inside error alerts that sends the error message to AI for troubleshooting assistance. The button only appears for actual errors (not warnings or credit errors). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * fix: add text guard to prevent undefined error in troubleshoot button Prevent button from rendering when socketError is a plain string, which would result in text being undefined. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * fix: move troubleshoot button inside message to keep alert layout consistent Embedding the button in the message prop instead of description prevents Ant Design Alert from switching to the expanded layout for errors only. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 1c6c829 commit 4bdec24

2 files changed

Lines changed: 26 additions & 2 deletions

File tree

frontend/src/ide/chat-ai/Conversation.jsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,15 @@ const Conversation = memo(function Conversation({
3232
setDetectedAction(actionType);
3333
}, []);
3434

35+
// Handle troubleshoot button click from error messages
36+
const handleTroubleshoot = useCallback(
37+
(errorMessage) => {
38+
const prompt = `There was an error encountered. We have the detailed error message below. Please see how we can fix this:\n\n${errorMessage}`;
39+
savePrompt(prompt, selectedChatIntent);
40+
},
41+
[savePrompt, selectedChatIntent]
42+
);
43+
3544
// Create UI action object based on detected action
3645
const uiAction = useMemo(() => {
3746
if (!detectedAction) return null;
@@ -168,7 +177,7 @@ const Conversation = memo(function Conversation({
168177
socketError={message?.error_msg}
169178
promptError={message?.prompt_error_message}
170179
transformError={message?.transformation_error_message}
171-
errorState={message?.error_state}
180+
onTroubleshoot={handleTroubleshoot}
172181
/>
173182
</Space>
174183
{isLastConversation ? <div className="pad-12" /> : <Divider />}

frontend/src/ide/chat-ai/DisplayErrorMessages.jsx

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { memo, useMemo } from "react";
22
import PropTypes from "prop-types";
3-
import { Alert, Space } from "antd";
3+
import { Alert, Button, Space } from "antd";
4+
import { ToolOutlined } from "@ant-design/icons";
45
import ReactMarkdown from "react-markdown";
56
import remarkGfm from "remark-gfm";
67

@@ -16,6 +17,7 @@ const DisplayErrorMessages = memo(function DisplayErrorMessages({
1617
socketError,
1718
promptError,
1819
transformError,
20+
onTroubleshoot,
1921
}) {
2022
const errors = useMemo(() => {
2123
const list = [];
@@ -49,6 +51,17 @@ const DisplayErrorMessages = memo(function DisplayErrorMessages({
4951
<ReactMarkdown remarkPlugins={[remarkGfm]}>
5052
{text}
5153
</ReactMarkdown>
54+
{!showAsWarning && onTroubleshoot && text && (
55+
<Button
56+
type="link"
57+
size="small"
58+
icon={<ToolOutlined />}
59+
onClick={() => onTroubleshoot(text)}
60+
style={{ padding: 0, marginTop: 8 }}
61+
>
62+
Troubleshoot this
63+
</Button>
64+
)}
5265
</div>
5366
}
5467
type={showAsWarning ? "warning" : "error"}
@@ -77,12 +90,14 @@ DisplayErrorMessages.propTypes = {
7790
transformError: PropTypes.shape({
7891
error_message: PropTypes.string,
7992
}),
93+
onTroubleshoot: PropTypes.func,
8094
};
8195

8296
DisplayErrorMessages.defaultProps = {
8397
socketError: null,
8498
promptError: null,
8599
transformError: null,
100+
onTroubleshoot: null,
86101
};
87102

88103
export { DisplayErrorMessages };

0 commit comments

Comments
 (0)