Compare commits

...

9 Commits

Author SHA1 Message Date
celestial-vault 083465210e merge conflicts 2025-06-19 14:03:04 -07:00
celestial-vault 55666522f8 integrate ToolExecutor into task class 2025-06-19 13:51:44 -07:00
celestial-vault 5e849beab4 extract tool logic into tool executor class 2025-06-19 13:31:23 -07:00
celestial-vault cb57340773 move task ephemeral state to state class 2025-06-17 18:23:22 -07:00
celestial-vault 5b08398eaf reorganize task class state variables and refactor out utility functions in recursivelyMakeClineRequests 2025-06-17 11:31:55 -07:00
celestial-vault 005576ba73 merge conflicts 2025-06-15 11:17:28 -07:00
celestial-vault 978b61df84 remove unused imports 2025-06-15 11:02:11 -07:00
celestial-vault f61bbe84eb move clineMessages state to MessageStateManager class 2025-06-14 23:11:48 -07:00
celestial-vault 5a34c78aa3 move apiConversationHistory to MessageStateHandler 2025-06-13 16:51:46 -07:00
4 changed files with 2426 additions and 2378 deletions
+3
View File
@@ -34,6 +34,9 @@ export class TaskState {
isAwaitingPlanResponse = false
didRespondToPlanAskBySwitchingMode = false
// Context and history
conversationHistoryDeletedRange?: [number, number]
// Tool execution flags
didRejectTool = false
didAlreadyUseTool = false
File diff suppressed because it is too large Load Diff
+52 -2373
View File
File diff suppressed because it is too large Load Diff
+6 -5
View File
@@ -11,13 +11,14 @@ import * as path from "path"
import CheckpointTracker from "@integrations/checkpoints/CheckpointTracker"
import { HistoryItem } from "@/shared/HistoryItem"
import Anthropic from "@anthropic-ai/sdk"
import { TaskState } from "./TaskState"
interface MessageStateHandlerParams {
context: vscode.ExtensionContext
taskId: string
conversationHistoryDeletedRange?: [number, number]
taskIsFavorited?: boolean
updateTaskHistory: (historyItem: HistoryItem) => Promise<HistoryItem[]>
taskState: TaskState
}
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
@@ -25,17 +26,17 @@ const cwd = vscode.workspace.workspaceFolders?.map((folder) => folder.uri.fsPath
export class MessageStateHandler {
private apiConversationHistory: Anthropic.MessageParam[] = []
private clineMessages: ClineMessage[] = []
private conversationHistoryDeletedRange: [number, number] | undefined
private taskIsFavorited: boolean
private checkpointTracker: CheckpointTracker | undefined
private updateTaskHistory: (historyItem: HistoryItem) => Promise<HistoryItem[]>
private context: vscode.ExtensionContext
private taskId: string
private taskState: TaskState
constructor(params: MessageStateHandlerParams) {
this.context = params.context
this.taskId = params.taskId
this.conversationHistoryDeletedRange = params.conversationHistoryDeletedRange
this.taskState = params.taskState
this.taskIsFavorited = params.taskIsFavorited ?? false
this.updateTaskHistory = params.updateTaskHistory
}
@@ -95,7 +96,7 @@ export class MessageStateHandler {
size: taskDirSize,
shadowGitConfigWorkTree: await this.checkpointTracker?.getShadowGitConfigWorkTree(),
cwdOnTaskInitialization: cwd,
conversationHistoryDeletedRange: this.conversationHistoryDeletedRange,
conversationHistoryDeletedRange: this.taskState.conversationHistoryDeletedRange,
isFavorited: this.taskIsFavorited,
})
} catch (error) {
@@ -117,7 +118,7 @@ export class MessageStateHandler {
// these values allow us to reconstruct the conversation history at the time this cline message was created
// it's important that apiConversationHistory is initialized before we add cline messages
message.conversationHistoryIndex = this.apiConversationHistory.length - 1 // NOTE: this is the index of the last added message which is the user message, and once the clinemessages have been presented we update the apiconversationhistory with the completed assistant message. This means when resetting to a message, we need to +1 this index to get the correct assistant message that this tool use corresponds to
message.conversationHistoryDeletedRange = this.conversationHistoryDeletedRange
message.conversationHistoryDeletedRange = this.taskState.conversationHistoryDeletedRange
this.clineMessages.push(message)
await this.saveClineMessagesAndUpdateHistory()
}