Compare commits

...

2 Commits

4 changed files with 36 additions and 16 deletions
+5
View File
@@ -0,0 +1,5 @@
---
"claude-dev": patch
---
Fixes issue where deleting tasks wasn't clearing the task metadata or context history files; let model recording fail gracefully
+2 -2
View File
@@ -1,12 +1,12 @@
{
"name": "claude-dev",
"version": "3.10.0",
"version": "3.10.1",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "claude-dev",
"version": "3.10.0",
"version": "3.10.1",
"license": "Apache-2.0",
"dependencies": {
"@anthropic-ai/bedrock-sdk": "^0.12.4",
+25 -13
View File
@@ -1704,6 +1704,8 @@ Here is the project's README to help you get started:\n\n${mcpDetails.readmeCont
taskDirPath: string
apiConversationHistoryFilePath: string
uiMessagesFilePath: string
contextHistoryFilePath: string
taskMetadataFilePath: string
apiConversationHistory: Anthropic.MessageParam[]
}> {
const history = ((await getGlobalState(this.context, "taskHistory")) as HistoryItem[] | undefined) || []
@@ -1712,6 +1714,8 @@ Here is the project's README to help you get started:\n\n${mcpDetails.readmeCont
const taskDirPath = path.join(this.context.globalStorageUri.fsPath, "tasks", id)
const apiConversationHistoryFilePath = path.join(taskDirPath, GlobalFileNames.apiConversationHistory)
const uiMessagesFilePath = path.join(taskDirPath, GlobalFileNames.uiMessages)
const contextHistoryFilePath = path.join(taskDirPath, GlobalFileNames.contextHistory)
const taskMetadataFilePath = path.join(taskDirPath, GlobalFileNames.taskMetadata)
const fileExists = await fileExistsAtPath(apiConversationHistoryFilePath)
if (fileExists) {
const apiConversationHistory = JSON.parse(await fs.readFile(apiConversationHistoryFilePath, "utf8"))
@@ -1720,6 +1724,8 @@ Here is the project's README to help you get started:\n\n${mcpDetails.readmeCont
taskDirPath,
apiConversationHistoryFilePath,
uiMessagesFilePath,
contextHistoryFilePath,
taskMetadataFilePath,
apiConversationHistory,
}
}
@@ -1791,22 +1797,28 @@ Here is the project's README to help you get started:\n\n${mcpDetails.readmeCont
console.debug("cleared task")
}
const { taskDirPath, apiConversationHistoryFilePath, uiMessagesFilePath } = await this.getTaskWithId(id)
const {
taskDirPath,
apiConversationHistoryFilePath,
uiMessagesFilePath,
contextHistoryFilePath,
taskMetadataFilePath,
} = await this.getTaskWithId(id)
const legacyMessagesFilePath = path.join(taskDirPath, "claude_messages.json")
const updatedTaskHistory = await this.deleteTaskFromState(id)
// Delete the task files
const apiConversationHistoryFileExists = await fileExistsAtPath(apiConversationHistoryFilePath)
if (apiConversationHistoryFileExists) {
await fs.unlink(apiConversationHistoryFilePath)
}
const uiMessagesFileExists = await fileExistsAtPath(uiMessagesFilePath)
if (uiMessagesFileExists) {
await fs.unlink(uiMessagesFilePath)
}
const legacyMessagesFilePath = path.join(taskDirPath, "claude_messages.json")
if (await fileExistsAtPath(legacyMessagesFilePath)) {
await fs.unlink(legacyMessagesFilePath)
for (const filePath of [
apiConversationHistoryFilePath,
uiMessagesFilePath,
contextHistoryFilePath,
taskMetadataFilePath,
legacyMessagesFilePath,
]) {
const fileExists = await fileExistsAtPath(filePath)
if (fileExists) {
await fs.unlink(filePath)
}
}
await fs.rmdir(taskDirPath) // succeeds if the dir is empty
+4 -1
View File
@@ -3087,8 +3087,11 @@ export class Task {
throw new Error("Cline instance aborted")
}
// Used to know what models were used in the task if user wants to export metadata for error reporting purposes
if (this.apiProvider && this.api.getModel().id) {
await this.modelContextTracker.recordModelUsage(this.apiProvider, this.api.getModel().id, this.chatSettings.mode)
try {
await this.modelContextTracker.recordModelUsage(this.apiProvider, this.api.getModel().id, this.chatSettings.mode)
} catch {}
}
if (this.consecutiveMistakeCount >= 3) {