mirror of
https://github.com/pacnpal/Roo-Code.git
synced 2025-12-21 12:51:17 -05:00
Refactor ClaudeDev
This commit is contained in:
@@ -206,9 +206,9 @@ export class Cline {
|
||||
text?: string,
|
||||
partial?: boolean
|
||||
): Promise<{ response: ClaudeAskResponse; text?: string; images?: string[] }> {
|
||||
// If this ClaudeDev instance was aborted by the provider, then the only thing keeping us alive is a promise still running in the background, in which case we don't want to send its result to the webview as it is attached to a new instance of ClaudeDev now. So we can safely ignore the result of any active promises, and this class will be deallocated. (Although we set claudeDev = undefined in provider, that simply removes the reference to this instance, but the instance is still alive until this promise resolves or rejects.)
|
||||
// If this Cline instance was aborted by the provider, then the only thing keeping us alive is a promise still running in the background, in which case we don't want to send its result to the webview as it is attached to a new instance of Cline now. So we can safely ignore the result of any active promises, and this class will be deallocated. (Although we set Cline = undefined in provider, that simply removes the reference to this instance, but the instance is still alive until this promise resolves or rejects.)
|
||||
if (this.abort) {
|
||||
throw new Error("ClaudeDev instance aborted")
|
||||
throw new Error("Cline instance aborted")
|
||||
}
|
||||
let askTs: number
|
||||
if (partial !== undefined) {
|
||||
@@ -304,7 +304,7 @@ export class Cline {
|
||||
|
||||
async say(type: ClaudeSay, text?: string, images?: string[], partial?: boolean): Promise<undefined> {
|
||||
if (this.abort) {
|
||||
throw new Error("ClaudeDev instance aborted")
|
||||
throw new Error("Cline instance aborted")
|
||||
}
|
||||
|
||||
if (partial !== undefined) {
|
||||
@@ -374,7 +374,7 @@ export class Cline {
|
||||
|
||||
private async startTask(task?: string, images?: string[]): Promise<void> {
|
||||
// conversationHistory (for API) and claudeMessages (for webview) need to be in sync
|
||||
// if the extension process were killed, then on restart the claudeMessages might not be empty, so we need to set it to [] when we create a new ClaudeDev client (otherwise webview would show stale messages from previous session)
|
||||
// if the extension process were killed, then on restart the claudeMessages might not be empty, so we need to set it to [] when we create a new Cline client (otherwise webview would show stale messages from previous session)
|
||||
this.claudeMessages = []
|
||||
this.apiConversationHistory = []
|
||||
await this.providerRef.deref()?.postStateToWebview()
|
||||
@@ -743,7 +743,7 @@ export class Cline {
|
||||
|
||||
async presentAssistantMessage() {
|
||||
if (this.abort) {
|
||||
throw new Error("ClaudeDev instance aborted")
|
||||
throw new Error("Cline instance aborted")
|
||||
}
|
||||
|
||||
if (this.presentAssistantMessageLocked) {
|
||||
@@ -1554,7 +1554,7 @@ export class Cline {
|
||||
includeFileDetails: boolean = false
|
||||
): Promise<boolean> {
|
||||
if (this.abort) {
|
||||
throw new Error("ClaudeDev instance aborted")
|
||||
throw new Error("Cline instance aborted")
|
||||
}
|
||||
|
||||
if (this.consecutiveMistakeCount >= 3) {
|
||||
@@ -1738,7 +1738,7 @@ export class Cline {
|
||||
|
||||
// need to call here in case the stream was aborted
|
||||
if (this.abort) {
|
||||
throw new Error("ClaudeDev instance aborted")
|
||||
throw new Error("Cline instance aborted")
|
||||
}
|
||||
|
||||
this.didCompleteReadingStream = true
|
||||
|
||||
@@ -56,8 +56,8 @@ export function activate(context: vscode.ExtensionContext) {
|
||||
})
|
||||
)
|
||||
|
||||
const openClaudeDevInNewTab = async () => {
|
||||
outputChannel.appendLine("Opening Claude Dev in new tab")
|
||||
const openClineInNewTab = async () => {
|
||||
outputChannel.appendLine("Opening Cline in new tab")
|
||||
// (this example uses webviewProvider activation event which is necessary to deserialize cached webview, but since we use retainContextWhenHidden, we don't need to use that event)
|
||||
// https://github.com/microsoft/vscode-extension-samples/blob/main/webview-sample/src/extension.ts
|
||||
const tabProvider = new ClineProvider(context, outputChannel)
|
||||
@@ -89,8 +89,8 @@ export function activate(context: vscode.ExtensionContext) {
|
||||
await vscode.commands.executeCommand("workbench.action.lockEditorGroup")
|
||||
}
|
||||
|
||||
context.subscriptions.push(vscode.commands.registerCommand("claude-dev.popoutButtonTapped", openClaudeDevInNewTab))
|
||||
context.subscriptions.push(vscode.commands.registerCommand("claude-dev.openInNewTab", openClaudeDevInNewTab))
|
||||
context.subscriptions.push(vscode.commands.registerCommand("claude-dev.popoutButtonTapped", openClineInNewTab))
|
||||
context.subscriptions.push(vscode.commands.registerCommand("claude-dev.openInNewTab", openClineInNewTab))
|
||||
|
||||
context.subscriptions.push(
|
||||
vscode.commands.registerCommand("claude-dev.settingsButtonTapped", () => {
|
||||
|
||||
Reference in New Issue
Block a user