mirror of
https://github.com/pacnpal/Roo-Code.git
synced 2025-12-20 04:11:10 -05:00
Refactor commands
This commit is contained in:
18
package.json
18
package.json
@@ -62,27 +62,27 @@
|
||||
},
|
||||
"commands": [
|
||||
{
|
||||
"command": "claude-dev.plusButtonTapped",
|
||||
"command": "cline.plusButtonClicked",
|
||||
"title": "New Task",
|
||||
"icon": "$(add)"
|
||||
},
|
||||
{
|
||||
"command": "claude-dev.historyButtonTapped",
|
||||
"command": "cline.historyButtonClicked",
|
||||
"title": "History",
|
||||
"icon": "$(history)"
|
||||
},
|
||||
{
|
||||
"command": "claude-dev.popoutButtonTapped",
|
||||
"command": "cline.popoutButtonClicked",
|
||||
"title": "Open in Editor",
|
||||
"icon": "$(link-external)"
|
||||
},
|
||||
{
|
||||
"command": "claude-dev.settingsButtonTapped",
|
||||
"command": "cline.settingsButtonClicked",
|
||||
"title": "Settings",
|
||||
"icon": "$(settings-gear)"
|
||||
},
|
||||
{
|
||||
"command": "claude-dev.openInNewTab",
|
||||
"command": "cline.openInNewTab",
|
||||
"title": "Open In New Tab",
|
||||
"category": "Cline"
|
||||
}
|
||||
@@ -90,22 +90,22 @@
|
||||
"menus": {
|
||||
"view/title": [
|
||||
{
|
||||
"command": "claude-dev.plusButtonTapped",
|
||||
"command": "cline.plusButtonClicked",
|
||||
"group": "navigation@1",
|
||||
"when": "view == claude-dev.SidebarProvider"
|
||||
},
|
||||
{
|
||||
"command": "claude-dev.historyButtonTapped",
|
||||
"command": "cline.historyButtonClicked",
|
||||
"group": "navigation@2",
|
||||
"when": "view == claude-dev.SidebarProvider"
|
||||
},
|
||||
{
|
||||
"command": "claude-dev.popoutButtonTapped",
|
||||
"command": "cline.popoutButtonClicked",
|
||||
"group": "navigation@3",
|
||||
"when": "view == claude-dev.SidebarProvider"
|
||||
},
|
||||
{
|
||||
"command": "claude-dev.settingsButtonTapped",
|
||||
"command": "cline.settingsButtonClicked",
|
||||
"group": "navigation@4",
|
||||
"when": "view == claude-dev.SidebarProvider"
|
||||
}
|
||||
|
||||
@@ -631,7 +631,7 @@ export class Cline {
|
||||
const sendCommandOutput = async (line: string): Promise<void> => {
|
||||
try {
|
||||
const { response, text, images } = await this.ask("command_output", line)
|
||||
if (response === "yesButtonTapped") {
|
||||
if (response === "yesButtonClicked") {
|
||||
// proceed while running
|
||||
} else {
|
||||
userFeedback = { text, images }
|
||||
@@ -737,8 +737,8 @@ export class Cline {
|
||||
"api_req_failed",
|
||||
error.message ?? JSON.stringify(serializeError(error), null, 2)
|
||||
)
|
||||
if (response !== "yesButtonTapped") {
|
||||
// this will never happen since if noButtonTapped, we will clear current task, aborting this instance
|
||||
if (response !== "yesButtonClicked") {
|
||||
// this will never happen since if noButtonClicked, we will clear current task, aborting this instance
|
||||
throw new Error("API request failed")
|
||||
}
|
||||
await this.say("api_req_retried")
|
||||
@@ -877,7 +877,7 @@ export class Cline {
|
||||
|
||||
const askApproval = async (type: ClineAsk, partialMessage?: string) => {
|
||||
const { response, text, images } = await this.ask(type, partialMessage, false)
|
||||
if (response !== "yesButtonTapped") {
|
||||
if (response !== "yesButtonClicked") {
|
||||
if (response === "messageResponse") {
|
||||
await this.say("user_feedback", text, images)
|
||||
pushToolResult(
|
||||
@@ -1404,8 +1404,8 @@ export class Cline {
|
||||
resultToSend = ""
|
||||
}
|
||||
const { response, text, images } = await this.ask("completion_result", resultToSend) // this prompts webview to show 'new task' button, and enable text input (which would be the 'text' here)
|
||||
if (response === "yesButtonTapped") {
|
||||
return [false, ""] // signals to recursive loop to stop (for now this never happens since yesButtonTapped will trigger a new task)
|
||||
if (response === "yesButtonClicked") {
|
||||
return [false, ""] // signals to recursive loop to stop (for now this never happens since yesButtonClicked will trigger a new task)
|
||||
}
|
||||
await this.say("user_feedback", text ?? "", images)
|
||||
return [
|
||||
@@ -1488,8 +1488,8 @@ export class Cline {
|
||||
|
||||
// we already sent completion_result says, an empty string asks relinquishes control over button and field
|
||||
const { response, text, images } = await this.ask("completion_result", "", false)
|
||||
if (response === "yesButtonTapped") {
|
||||
pushToolResult("") // signals to recursive loop to stop (for now this never happens since yesButtonTapped will trigger a new task)
|
||||
if (response === "yesButtonClicked") {
|
||||
pushToolResult("") // signals to recursive loop to stop (for now this never happens since yesButtonClicked will trigger a new task)
|
||||
break
|
||||
}
|
||||
await this.say("user_feedback", text ?? "", images)
|
||||
@@ -1809,7 +1809,7 @@ export class Cline {
|
||||
|
||||
return didEndLoop // will always be false for now
|
||||
} catch (error) {
|
||||
// this should never happen since the only thing that can throw an error is the attemptApiRequest, which is wrapped in a try catch that sends an ask where if noButtonTapped, will clear current task and destroy this instance. However to avoid unhandled promise rejection, we will end this loop which will end execution of this instance (see startTask)
|
||||
// this should never happen since the only thing that can throw an error is the attemptApiRequest, which is wrapped in a try catch that sends an ask where if noButtonClicked, will clear current task and destroy this instance. However to avoid unhandled promise rejection, we will end this loop which will end execution of this instance (see startTask)
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -509,7 +509,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
|
||||
if (this.cline) {
|
||||
this.cline.api = buildApiHandler({ apiProvider: openrouter, openRouterApiKey: apiKey })
|
||||
}
|
||||
// await this.postMessageToWebview({ type: "action", action: "settingsButtonTapped" }) // bad ux if user is on welcome
|
||||
// await this.postMessageToWebview({ type: "action", action: "settingsButtonClicked" }) // bad ux if user is on welcome
|
||||
}
|
||||
|
||||
private async ensureCacheDirectoryExists(): Promise<string> {
|
||||
@@ -659,7 +659,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
|
||||
const { historyItem } = await this.getTaskWithId(id)
|
||||
await this.initClineWithHistoryItem(historyItem) // clears existing task
|
||||
}
|
||||
await this.postMessageToWebview({ type: "action", action: "chatButtonTapped" })
|
||||
await this.postMessageToWebview({ type: "action", action: "chatButtonClicked" })
|
||||
}
|
||||
|
||||
async exportTaskWithId(id: string) {
|
||||
@@ -955,6 +955,6 @@ export class ClineProvider implements vscode.WebviewViewProvider {
|
||||
}
|
||||
vscode.window.showInformationMessage("State reset")
|
||||
await this.postStateToWebview()
|
||||
await this.postMessageToWebview({ type: "action", action: "chatButtonTapped" })
|
||||
await this.postMessageToWebview({ type: "action", action: "chatButtonClicked" })
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ export function createClineAPI(outputChannel: vscode.OutputChannel, sidebarProvi
|
||||
outputChannel.appendLine("Starting new task")
|
||||
await sidebarProvider.clearTask()
|
||||
await sidebarProvider.postStateToWebview()
|
||||
await sidebarProvider.postMessageToWebview({ type: "action", action: "chatButtonTapped" })
|
||||
await sidebarProvider.postMessageToWebview({ type: "action", action: "chatButtonClicked" })
|
||||
await sidebarProvider.postMessageToWebview({
|
||||
type: "invoke",
|
||||
invoke: "sendMessage",
|
||||
|
||||
@@ -34,11 +34,11 @@ export function activate(context: vscode.ExtensionContext) {
|
||||
)
|
||||
|
||||
context.subscriptions.push(
|
||||
vscode.commands.registerCommand("claude-dev.plusButtonTapped", async () => {
|
||||
outputChannel.appendLine("Plus button tapped")
|
||||
vscode.commands.registerCommand("cline.plusButtonClicked", async () => {
|
||||
outputChannel.appendLine("Plus button Clicked")
|
||||
await sidebarProvider.clearTask()
|
||||
await sidebarProvider.postStateToWebview()
|
||||
await sidebarProvider.postMessageToWebview({ type: "action", action: "chatButtonTapped" })
|
||||
await sidebarProvider.postMessageToWebview({ type: "action", action: "chatButtonClicked" })
|
||||
})
|
||||
)
|
||||
|
||||
@@ -75,19 +75,19 @@ export function activate(context: vscode.ExtensionContext) {
|
||||
await vscode.commands.executeCommand("workbench.action.lockEditorGroup")
|
||||
}
|
||||
|
||||
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("cline.popoutButtonClicked", openClineInNewTab))
|
||||
context.subscriptions.push(vscode.commands.registerCommand("cline.openInNewTab", openClineInNewTab))
|
||||
|
||||
context.subscriptions.push(
|
||||
vscode.commands.registerCommand("claude-dev.settingsButtonTapped", () => {
|
||||
vscode.commands.registerCommand("cline.settingsButtonClicked", () => {
|
||||
//vscode.window.showInformationMessage(message)
|
||||
sidebarProvider.postMessageToWebview({ type: "action", action: "settingsButtonTapped" })
|
||||
sidebarProvider.postMessageToWebview({ type: "action", action: "settingsButtonClicked" })
|
||||
})
|
||||
)
|
||||
|
||||
context.subscriptions.push(
|
||||
vscode.commands.registerCommand("claude-dev.historyButtonTapped", () => {
|
||||
sidebarProvider.postMessageToWebview({ type: "action", action: "historyButtonTapped" })
|
||||
vscode.commands.registerCommand("cline.historyButtonClicked", () => {
|
||||
sidebarProvider.postMessageToWebview({ type: "action", action: "historyButtonClicked" })
|
||||
})
|
||||
)
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// type that represents json data that is sent from extension to webview, called ExtensionMessage and has 'type' enum which can be 'plusButtonTapped' or 'settingsButtonTapped' or 'hello'
|
||||
// type that represents json data that is sent from extension to webview, called ExtensionMessage and has 'type' enum which can be 'plusButtonClicked' or 'settingsButtonClicked' or 'hello'
|
||||
|
||||
import { ApiConfiguration, ModelInfo } from "./api"
|
||||
import { HistoryItem } from "./HistoryItem"
|
||||
@@ -16,7 +16,7 @@ export interface ExtensionMessage {
|
||||
| "partialMessage"
|
||||
| "openRouterModels"
|
||||
text?: string
|
||||
action?: "chatButtonTapped" | "settingsButtonTapped" | "historyButtonTapped" | "didBecomeVisible"
|
||||
action?: "chatButtonClicked" | "settingsButtonClicked" | "historyButtonClicked" | "didBecomeVisible"
|
||||
invoke?: "sendMessage" | "primaryButtonClick" | "secondaryButtonClick"
|
||||
state?: ExtensionState
|
||||
images?: string[]
|
||||
|
||||
@@ -29,4 +29,4 @@ export interface WebviewMessage {
|
||||
bool?: boolean
|
||||
}
|
||||
|
||||
export type ClineAskResponse = "yesButtonTapped" | "noButtonTapped" | "messageResponse"
|
||||
export type ClineAskResponse = "yesButtonClicked" | "noButtonClicked" | "messageResponse"
|
||||
|
||||
@@ -19,15 +19,15 @@ const AppContent = () => {
|
||||
switch (message.type) {
|
||||
case "action":
|
||||
switch (message.action!) {
|
||||
case "settingsButtonTapped":
|
||||
case "settingsButtonClicked":
|
||||
setShowSettings(true)
|
||||
setShowHistory(false)
|
||||
break
|
||||
case "historyButtonTapped":
|
||||
case "historyButtonClicked":
|
||||
setShowSettings(false)
|
||||
setShowHistory(true)
|
||||
break
|
||||
case "chatButtonTapped":
|
||||
case "chatButtonClicked":
|
||||
setShowSettings(false)
|
||||
setShowHistory(false)
|
||||
break
|
||||
|
||||
@@ -269,7 +269,7 @@ const ChatView = ({ isHidden, showAnnouncement, hideAnnouncement, showHistoryVie
|
||||
case "tool":
|
||||
case "resume_task":
|
||||
case "mistake_limit_reached":
|
||||
vscode.postMessage({ type: "askResponse", askResponse: "yesButtonTapped" })
|
||||
vscode.postMessage({ type: "askResponse", askResponse: "yesButtonClicked" })
|
||||
break
|
||||
case "completion_result":
|
||||
case "resume_completed_task":
|
||||
@@ -299,7 +299,7 @@ const ChatView = ({ isHidden, showAnnouncement, hideAnnouncement, showHistoryVie
|
||||
case "command":
|
||||
case "tool":
|
||||
// responds to the API with a "This operation failed" and lets it try again
|
||||
vscode.postMessage({ type: "askResponse", askResponse: "noButtonTapped" })
|
||||
vscode.postMessage({ type: "askResponse", askResponse: "noButtonClicked" })
|
||||
break
|
||||
}
|
||||
setTextAreaDisabled(true)
|
||||
|
||||
Reference in New Issue
Block a user