Skip to content

Commit 0bc4f30

Browse files
qdaxbmrubens
andauthored
add new task command (#1648)
* add new task command * Internationalize * Revert README changes * More i18n * Fix tests * Fix i18n * Missing translations --------- Co-authored-by: Matt Rubens <[email protected]>
1 parent 22d01ce commit 0bc4f30

38 files changed

+163
-36
lines changed

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,11 @@
140140
"title": "Add To Context",
141141
"category": "Roo Code"
142142
},
143+
{
144+
"command": "roo-cline.newTask",
145+
"title": "New Task",
146+
"category": "Roo Code"
147+
},
143148
{
144149
"command": "roo-cline.terminalAddToContext",
145150
"title": "Add Terminal Content to Context",

src/activate/handleTask.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import * as vscode from "vscode"
2+
import { COMMAND_IDS } from "../core/CodeActionProvider"
3+
import { ClineProvider } from "../core/webview/ClineProvider"
4+
import { t } from "../i18n"
5+
6+
export const handleNewTask = async (params: { prompt?: string } | null | undefined) => {
7+
let prompt = params?.prompt
8+
if (!prompt) {
9+
prompt = await vscode.window.showInputBox({
10+
prompt: t("common:input.task_prompt"),
11+
placeHolder: t("common:input.task_placeholder"),
12+
})
13+
}
14+
if (!prompt) {
15+
await vscode.commands.executeCommand("roo-cline.SidebarProvider.focus")
16+
return
17+
}
18+
19+
await ClineProvider.handleCodeAction(COMMAND_IDS.NEW_TASK, "NEW_TASK", {
20+
userInput: prompt,
21+
})
22+
}

src/activate/registerCommands.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import delay from "delay"
44
import { ClineProvider } from "../core/webview/ClineProvider"
55

66
import { registerHumanRelayCallback, unregisterHumanRelayCallback, handleHumanRelayResponse } from "./humanRelay"
7+
import { handleNewTask } from "./handleTask"
78

89
// Store panel references in both modes
910
let sidebarPanel: vscode.WebviewView | undefined = undefined
@@ -85,6 +86,7 @@ const getCommandsMap = ({ context, outputChannel, provider }: RegisterCommandOpt
8586
"roo-cline.registerHumanRelayCallback": registerHumanRelayCallback,
8687
"roo-cline.unregisterHumanRelayCallback": unregisterHumanRelayCallback,
8788
"roo-cline.handleHumanRelayResponse": handleHumanRelayResponse,
89+
"roo-cline.newTask": handleNewTask,
8890
"roo-cline.setCustomStoragePath": async () => {
8991
const { promptForCustomStoragePath } = await import("../shared/storagePathManager")
9092
await promptForCustomStoragePath()

src/core/Cline.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2893,7 +2893,7 @@ export class Cline extends EventEmitter<ClineEvents> {
28932893
if (item.mimeType?.startsWith("image") && item.blob) {
28942894
images.push(item.blob)
28952895
}
2896-
});
2896+
})
28972897
await this.say("mcp_server_response", resourceResultPretty, images)
28982898
pushToolResult(formatResponse.toolResult(resourceResultPretty, images))
28992899
break

src/core/CodeActionProvider.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,15 @@ export const ACTION_NAMES = {
77
FIX_LOGIC: "Roo Code: Fix Logic",
88
IMPROVE: "Roo Code: Improve Code",
99
ADD_TO_CONTEXT: "Roo Code: Add to Context",
10+
NEW_TASK: "Roo Code: New Task",
1011
} as const
1112

1213
export const COMMAND_IDS = {
1314
EXPLAIN: "roo-cline.explainCode",
1415
FIX: "roo-cline.fixCode",
1516
IMPROVE: "roo-cline.improveCode",
1617
ADD_TO_CONTEXT: "roo-cline.addToContext",
18+
NEW_TASK: "roo-cline.newTask",
1719
} as const
1820

1921
export class CodeActionProvider implements vscode.CodeActionProvider {

src/core/__tests__/Cline.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,10 @@ jest.mock("vscode", () => {
139139
}
140140

141141
return {
142+
CodeActionKind: {
143+
QuickFix: { value: "quickfix" },
144+
RefactorRewrite: { value: "refactor.rewrite" },
145+
},
142146
window: {
143147
createTextEditorDecorationType: jest.fn().mockReturnValue({
144148
dispose: jest.fn(),

src/core/webview/__tests__/ClineProvider.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,10 @@ jest.mock("vscode", () => ({
167167
joinPath: jest.fn(),
168168
file: jest.fn(),
169169
},
170+
CodeActionKind: {
171+
QuickFix: { value: "quickfix" },
172+
RefactorRewrite: { value: "refactor.rewrite" },
173+
},
170174
window: {
171175
showInformationMessage: jest.fn(),
172176
showErrorMessage: jest.fn(),

src/i18n/locales/ca/common.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
{
2+
"input": {
3+
"task_prompt": "Què vols que faci Roo?",
4+
"task_placeholder": "Escriu la teva tasca aquí"
5+
},
26
"extension": {
37
"name": "Roo Code",
48
"description": "Tot un equip de desenvolupadors d'IA al teu editor."

src/i18n/locales/de/common.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,5 +83,9 @@
8383
"path_placeholder": "D:\\RooCodeStorage",
8484
"enter_absolute_path": "Bitte gib einen absoluten Pfad ein (z.B. D:\\RooCodeStorage oder /home/user/storage)",
8585
"enter_valid_path": "Bitte gib einen gültigen Pfad ein"
86+
},
87+
"input": {
88+
"task_prompt": "Was soll Roo tun?",
89+
"task_placeholder": "Gib deine Aufgabe hier ein"
8690
}
8791
}

src/i18n/locales/en/common.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,5 +83,9 @@
8383
"path_placeholder": "D:\\RooCodeStorage",
8484
"enter_absolute_path": "Please enter an absolute path (e.g. D:\\RooCodeStorage or /home/user/storage)",
8585
"enter_valid_path": "Please enter a valid path"
86+
},
87+
"input": {
88+
"task_prompt": "What should Roo do?",
89+
"task_placeholder": "Type your task here"
8690
}
8791
}

0 commit comments

Comments
 (0)