From b5422d23334a242a2da7b6849b54a3aa5bec7df5 Mon Sep 17 00:00:00 2001 From: Ben Weller Date: Mon, 17 Feb 2025 09:32:59 -0600 Subject: [PATCH 1/4] add missing deps [fzf, vscrui] --- package-lock.json | 49 +++++++++++++++++++++++++++++++++++++++++++++++ package.json | 2 ++ 2 files changed, 51 insertions(+) diff --git a/package-lock.json b/package-lock.json index f0d36579d68..8579831a58f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -31,6 +31,7 @@ "diff-match-patch": "^1.0.5", "fast-deep-equal": "^3.1.3", "fastest-levenshtein": "^1.0.16", + "fzf": "^0.5.2", "get-folder-size": "^5.0.0", "globby": "^14.0.2", "isbinaryfile": "^5.0.2", @@ -51,6 +52,7 @@ "tmp": "^0.2.3", "tree-sitter-wasms": "^0.1.11", "turndown": "^7.2.0", + "vscrui": "^0.2.1", "web-tree-sitter": "^0.22.6", "zod": "^3.23.8" }, @@ -6025,6 +6027,16 @@ "resolved": "https://registry.npmjs.org/@types/pdf-parse/-/pdf-parse-1.1.4.tgz", "integrity": "sha512-+gbBHbNCVGGYw1S9lAIIvrHW47UYOhMIFUsJcMkMrzy1Jf0vulBN3XQIjPgnoOXveMuHnF3b57fXROnY/Or7eg==" }, + "node_modules/@types/react": { + "version": "19.0.10", + "resolved": "https://registry.npmjs.org/@types/react/-/react-19.0.10.tgz", + "integrity": "sha512-JuRQ9KXLEjaUNjTWpzuR231Z2WpIwczOkBEIvbHNCzQefFIT0L8IqE6NV6ULLyC1SI/i234JnDoMkfg+RjQj2g==", + "license": "MIT", + "peer": true, + "dependencies": { + "csstype": "^3.0.2" + } + }, "node_modules/@types/stack-utils": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/@types/stack-utils/-/stack-utils-2.0.3.tgz", @@ -7830,6 +7842,13 @@ "url": "https://github.com/sponsors/fb55" } }, + "node_modules/csstype": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.3.tgz", + "integrity": "sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw==", + "license": "MIT", + "peer": true + }, "node_modules/data-uri-to-buffer": { "version": "6.0.2", "resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-6.0.2.tgz", @@ -9319,6 +9338,12 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/fzf": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/fzf/-/fzf-0.5.2.tgz", + "integrity": "sha512-Tt4kuxLXFKHy8KT40zwsUPUkg1CrsgY25FxA2U/j/0WgEDCk3ddc/zLTCCcbSHX9FcKtLuVaDGtGE/STWC+j3Q==", + "license": "BSD-3-Clause" + }, "node_modules/gauge": { "version": "5.0.2", "resolved": "https://registry.npmjs.org/gauge/-/gauge-5.0.2.tgz", @@ -13646,6 +13671,16 @@ "node": ">= 0.8" } }, + "node_modules/react": { + "version": "19.0.0", + "resolved": "https://registry.npmjs.org/react/-/react-19.0.0.tgz", + "integrity": "sha512-V8AVnmPIICiWpGfm6GLzCR/W5FXLchHop40W4nXBmdlEceh16rCN8O8LNWm5bh5XUX91fh7KpA+W0TgMKmgTpQ==", + "license": "MIT", + "peer": true, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/react-is": { "version": "18.3.1", "resolved": "https://registry.npmjs.org/react-is/-/react-is-18.3.1.tgz", @@ -15327,6 +15362,20 @@ "spdx-expression-parse": "^3.0.0" } }, + "node_modules/vscrui": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/vscrui/-/vscrui-0.2.1.tgz", + "integrity": "sha512-PiPCYoiiw2Z8ZmMwCIqjHWszaUruyTa345yh6mIOixQH9DLfeYUK040huAlwVL+yZ32xb8tB6zHcL6PUGdiXyQ==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/estruyf" + }, + "peerDependencies": { + "@types/react": "*", + "react": "^17 || ^18 || ^19" + } + }, "node_modules/walker": { "version": "1.0.8", "resolved": "https://registry.npmjs.org/walker/-/walker-1.0.8.tgz", diff --git a/package.json b/package.json index c43cf05b11e..4cf8265fdb2 100644 --- a/package.json +++ b/package.json @@ -326,6 +326,7 @@ "diff-match-patch": "^1.0.5", "fast-deep-equal": "^3.1.3", "fastest-levenshtein": "^1.0.16", + "fzf": "^0.5.2", "get-folder-size": "^5.0.0", "globby": "^14.0.2", "isbinaryfile": "^5.0.2", @@ -346,6 +347,7 @@ "tmp": "^0.2.3", "tree-sitter-wasms": "^0.1.11", "turndown": "^7.2.0", + "vscrui": "^0.2.1", "web-tree-sitter": "^0.22.6", "zod": "^3.23.8" }, From 3d3d58144f39178903dc2af19df7b994a160a84d Mon Sep 17 00:00:00 2001 From: Ben Weller Date: Mon, 17 Feb 2025 11:22:18 -0600 Subject: [PATCH 2/4] refactor: replace console.log with logger in abortStream Following logging guidelines to use the logger from utils/logging instead of console.log for better debugging control in test environments. --- src/core/Cline.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/core/Cline.ts b/src/core/Cline.ts index 9c2977a2669..453f755f288 100644 --- a/src/core/Cline.ts +++ b/src/core/Cline.ts @@ -64,6 +64,7 @@ import { McpHub } from "../services/mcp/McpHub" import crypto from "crypto" import { insertGroups } from "./diff/insert-groups" import { EXPERIMENT_IDS, experiments as Experiments } from "../shared/experiments" +import { logger } from "../utils/logging" const cwd = vscode.workspace.workspaceFolders?.map((folder) => folder.uri.fsPath).at(0) ?? path.join(os.homedir(), "Desktop") // may or may not exist but fs checking existence would immediately ask for permission which would be bad UX, need to come up with a better solution @@ -2836,7 +2837,7 @@ export class Cline { } const abortStream = async (cancelReason: ClineApiReqCancelReason, streamingFailedMessage?: string) => { - console.log(`[Cline#abortStream] cancelReason = ${cancelReason}`) + logger.debug(`[Cline#abortStream] cancelReason = ${cancelReason}`) if (this.diffViewProvider.isEditing) { await this.diffViewProvider.revertChanges() // closes diff view From f87774005ad0070d725fc353933455cea0045e57 Mon Sep 17 00:00:00 2001 From: Ben Weller Date: Tue, 18 Feb 2025 11:37:05 -0600 Subject: [PATCH 3/4] refactor: improve error handling for empty conversation history - Initialize empty arrays for modified user content and API conversation history - Change error throw to debug log when no conversation history exists --- src/core/Cline.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/core/Cline.ts b/src/core/Cline.ts index 453f755f288..9bb56b8eb1e 100644 --- a/src/core/Cline.ts +++ b/src/core/Cline.ts @@ -598,6 +598,8 @@ export class Cline { let modifiedOldUserContent: UserContent // either the last message if its user message, or the user message before the last (assistant) message let modifiedApiConversationHistory: Anthropic.Messages.MessageParam[] // need to remove the last user message to replace with new modified user message + modifiedOldUserContent = [] + modifiedApiConversationHistory = [] if (existingApiConversationHistory.length > 0) { const lastMessage = existingApiConversationHistory[existingApiConversationHistory.length - 1] @@ -667,7 +669,7 @@ export class Cline { throw new Error("Unexpected: Last message is not a user or assistant message") } } else { - throw new Error("Unexpected: No existing API conversation history") + console.debug(Error("Unexpected: No existing API conversation history")) } let newUserContent: UserContent = [...modifiedOldUserContent] From 0f12d04e258369c35805ec644927c4f8a91def87 Mon Sep 17 00:00:00 2001 From: Ben Weller Date: Tue, 18 Feb 2025 11:40:45 -0600 Subject: [PATCH 4/4] fix: use logger.debug instead of console.debug in resumeTaskFromHistory Replaces console.debug with logger.debug to prevent 'Cannot log after tests are done' error in Jest tests. This change follows project logging guidelines and ensures proper test lifecycle handling. --- src/core/Cline.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/Cline.ts b/src/core/Cline.ts index 9bb56b8eb1e..93553479e19 100644 --- a/src/core/Cline.ts +++ b/src/core/Cline.ts @@ -669,7 +669,7 @@ export class Cline { throw new Error("Unexpected: Last message is not a user or assistant message") } } else { - console.debug(Error("Unexpected: No existing API conversation history")) + logger.debug("Unexpected: No existing API conversation history") } let newUserContent: UserContent = [...modifiedOldUserContent]