Add mistake tracking to prevent indefinitely running loops

This commit is contained in:
Saoud Rizwan
2024-09-03 06:12:30 -04:00
parent ce71ed7cba
commit 7801f02d97
4 changed files with 61 additions and 0 deletions

View File

@@ -64,6 +64,13 @@ const ChatRow: React.FC<ChatRowProps> = ({
style={{ color: errorColor, marginBottom: "-1.5px" }}></span>,
<span style={{ color: errorColor, fontWeight: "bold" }}>Error</span>,
]
case "mistake_limit_reached":
return [
<span
className="codicon codicon-error"
style={{ color: errorColor, marginBottom: "-1.5px" }}></span>,
<span style={{ color: errorColor, fontWeight: "bold" }}>Claude is having trouble...</span>,
]
case "command":
return [
isCommandExecuting ? (
@@ -403,6 +410,16 @@ const ChatRow: React.FC<ChatRowProps> = ({
switch (message.ask) {
case "tool":
return renderTool(message, headerStyle)
case "mistake_limit_reached":
return (
<>
<div style={headerStyle}>
{icon}
{title}
</div>
<p style={{ ...pStyle, color: "var(--vscode-errorForeground)" }}>{message.text}</p>
</>
)
case "command":
const splitMessage = (text: string) => {
const outputIndex = text.indexOf(COMMAND_OUTPUT_STRING)

View File

@@ -102,6 +102,13 @@ const ChatView = ({
setPrimaryButtonText("Retry")
setSecondaryButtonText("Start New Task")
break
case "mistake_limit_reached":
setTextAreaDisabled(false)
setClaudeAsk("mistake_limit_reached")
setEnableButtons(true)
setPrimaryButtonText("Proceed Anyways")
setSecondaryButtonText("Start New Task")
break
case "followup":
setTextAreaDisabled(false)
setClaudeAsk("followup")
@@ -225,6 +232,7 @@ const ChatView = ({
case "completion_result": // if this happens then the user has feedback for the completion result
case "resume_task":
case "resume_completed_task":
case "mistake_limit_reached":
vscode.postMessage({
type: "askResponse",
askResponse: "messageResponse",
@@ -269,6 +277,7 @@ const ChatView = ({
case "command_output":
case "tool":
case "resume_task":
case "mistake_limit_reached":
vscode.postMessage({ type: "askResponse", askResponse: "yesButtonTapped" })
break
case "completion_result":
@@ -287,6 +296,7 @@ const ChatView = ({
const handleSecondaryButtonClick = () => {
switch (claudeAsk) {
case "api_req_failed":
case "mistake_limit_reached":
startNewTask()
break
case "command":