Fix edge case issues when running commands with long outputs or as completion command

This commit is contained in:
Saoud Rizwan
2024-08-04 19:32:45 -04:00
parent c823cdd4f8
commit 38d461b784
4 changed files with 31 additions and 4 deletions

16
package-lock.json generated
View File

@@ -1,18 +1,19 @@
{
"name": "claude-dev",
"version": "1.0.86",
"version": "1.0.91",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "claude-dev",
"version": "1.0.86",
"version": "1.0.91",
"license": "MIT",
"dependencies": {
"@anthropic-ai/bedrock-sdk": "^0.10.2",
"@anthropic-ai/sdk": "^0.24.3",
"@vscode/codicons": "^0.0.36",
"default-shell": "^2.2.0",
"delay": "^6.0.0",
"diff": "^5.2.0",
"execa": "^9.3.0",
"globby": "^14.0.2",
@@ -5549,6 +5550,17 @@
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/delay": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/delay/-/delay-6.0.0.tgz",
"integrity": "sha512-2NJozoOHQ4NuZuVIr5CWd0iiLVIRSDepakaovIN+9eIDHEhdCAEvSy2cuf1DCrPPQLvHmbqTHODlhHg8UCy4zw==",
"engines": {
"node": ">=16"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/delayed-stream": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",

View File

@@ -127,6 +127,7 @@
"@anthropic-ai/sdk": "^0.24.3",
"@vscode/codicons": "^0.0.36",
"default-shell": "^2.2.0",
"delay": "^6.0.0",
"diff": "^5.2.0",
"execa": "^9.3.0",
"globby": "^14.0.2",

View File

@@ -19,6 +19,7 @@ import { DEFAULT_MAX_REQUESTS_PER_TASK } from "./shared/Constants"
import { ClaudeAsk, ClaudeMessage, ClaudeSay, ClaudeSayTool } from "./shared/ExtensionMessage"
import { Tool, ToolName } from "./shared/Tool"
import { ClaudeAskResponse } from "./shared/WebviewMessage"
import delay from "delay"
const SYSTEM_PROMPT =
() => `You are Claude Dev, a highly skilled software developer with extensive knowledge in many programming languages, frameworks, design patterns, and best practices.
@@ -676,13 +677,19 @@ export class ClaudeDev {
}
} catch (e) {
if ((e as ExecaError).signal === "SIGINT") {
const line = `\nUser exited command...`
const line = `\nUser terminated process via SIGINT...`
await this.say("command_output", line)
result += line
} else {
throw e // if the command was not terminated by user, let outer catch handle it as a real error
}
}
// Wait for the next event loop tick to ensure all promises from the loop are created
// This is necessary because the non-awaited promises in the loop might not be
// created until the next Node.js event loop cycle. We want to make sure all
// promises are at least created before proceeding, to maintain the correct
// order of messages and avoid potential race conditions.
await delay(0)
// for attemptCompletion, we don't want to return the command output
if (returnEmptyStringOnSuccess) {
return ""

View File

@@ -132,6 +132,13 @@ const ChatView = ({ messages, isHidden, vscodeThemeName, showAnnouncement, hideA
case "error":
break
case "api_req_started":
if (claudeAsk === "command_output") {
// if the last ask is a command_output, and we receive an api_req_started, then that means the command has finished and we don't need input from the user anymore (in every other case, the user has to interact with input field or buttons to continue, which does the following automatically)
setInputValue("")
setTextAreaDisabled(true)
setClaudeAsk(undefined)
setEnableButtons(false)
}
break
case "api_req_finished":
break