Skip to content

Commit 9fc95db

Browse files
committed
Improve subtasks UI
1 parent 270fd88 commit 9fc95db

File tree

23 files changed

+194
-29
lines changed

23 files changed

+194
-29
lines changed

src/core/Cline.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -612,22 +612,22 @@ export class Cline extends EventEmitter<ClineEvents> {
612612
])
613613
}
614614

615-
async resumePausedTask(lastMessage?: string) {
615+
async resumePausedTask(lastMessage: string) {
616616
// release this Cline instance from paused state
617617
this.isPaused = false
618618
this.emit("taskUnpaused")
619619

620620
// fake an answer from the subtask that it has completed running and this is the result of what it has done
621621
// add the message to the chat history and to the webview ui
622622
try {
623-
await this.say("text", `${lastMessage ?? "Please continue to the next task."}`)
623+
await this.say("subtask_result", lastMessage)
624624

625625
await this.addToApiConversationHistory({
626626
role: "user",
627627
content: [
628628
{
629629
type: "text",
630-
text: `[new_task completed] Result: ${lastMessage ?? "Please continue to the next task."}`,
630+
text: `[new_task completed] Result: ${lastMessage}`,
631631
},
632632
],
633633
})
@@ -1495,8 +1495,6 @@ export class Cline extends EventEmitter<ClineEvents> {
14951495
// and return control to the parent task to continue running the rest of the sub-tasks
14961496
const toolMessage = JSON.stringify({
14971497
tool: "finishTask",
1498-
content:
1499-
"Subtask completed! You can review the results and suggest any corrections or next steps. If everything looks good, confirm to return the result to the parent task.",
15001498
})
15011499

15021500
return await askApproval("tool", toolMessage)

src/core/tools/attemptCompletionTool.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ export async function attemptCompletionTool(
102102
}
103103

104104
// tell the provider to remove the current subtask and resume the previous task in the stack
105-
await cline.providerRef.deref()?.finishSubTask(`Task complete: ${lastMessage?.text}`)
105+
await cline.providerRef.deref()?.finishSubTask(lastMessage?.text ?? "")
106106
return
107107
}
108108

src/core/webview/ClineProvider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements
184184
// remove the current task/cline instance (at the top of the stack), ao this task is finished
185185
// and resume the previous task/cline instance (if it exists)
186186
// this is used when a sub task is finished and the parent task needs to be resumed
187-
async finishSubTask(lastMessage?: string) {
187+
async finishSubTask(lastMessage: string) {
188188
console.log(`[subtasks] finishing subtask ${lastMessage}`)
189189
// remove the last cline instance from the stack (this is the finished sub task)
190190
await this.removeClineFromStack()

src/exports/api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ export class API extends EventEmitter<RooCodeEvents> implements RooCodeAPI {
152152
}
153153

154154
public async clearCurrentTask(lastMessage?: string) {
155-
await this.sidebarProvider.finishSubTask(lastMessage)
155+
await this.sidebarProvider.finishSubTask(lastMessage ?? "")
156156
await this.sidebarProvider.postStateToWebview()
157157
}
158158

src/exports/roo-code.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,7 @@ type ClineMessage = {
384384
| "mcp_server_response"
385385
| "new_task_started"
386386
| "new_task"
387+
| "subtask_result"
387388
| "checkpoint_saved"
388389
| "rooignore_error"
389390
)
@@ -463,6 +464,7 @@ type RooCodeEvents = {
463464
| "mcp_server_response"
464465
| "new_task_started"
465466
| "new_task"
467+
| "subtask_result"
466468
| "checkpoint_saved"
467469
| "rooignore_error"
468470
)

src/exports/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,7 @@ type ClineMessage = {
389389
| "mcp_server_response"
390390
| "new_task_started"
391391
| "new_task"
392+
| "subtask_result"
392393
| "checkpoint_saved"
393394
| "rooignore_error"
394395
)
@@ -472,6 +473,7 @@ type RooCodeEvents = {
472473
| "mcp_server_response"
473474
| "new_task_started"
474475
| "new_task"
476+
| "subtask_result"
475477
| "checkpoint_saved"
476478
| "rooignore_error"
477479
)

src/schemas/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -739,6 +739,7 @@ export const clineSays = [
739739
"mcp_server_response",
740740
"new_task_started",
741741
"new_task",
742+
"subtask_result",
742743
"checkpoint_saved",
743744
"rooignore_error",
744745
] as const

webview-ui/src/components/chat/ChatRow.tsx

Lines changed: 93 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ export const ChatRowContent = ({
518518
return (
519519
<>
520520
<div style={headerStyle}>
521-
{toolIcon("new-file")}
521+
{toolIcon("tasklist")}
522522
<span style={{ fontWeight: "bold" }}>
523523
<Trans
524524
i18nKey="chat:subtasks.wantsToCreate"
@@ -527,20 +527,70 @@ export const ChatRowContent = ({
527527
/>
528528
</span>
529529
</div>
530-
<div style={{ paddingLeft: "26px", marginTop: "4px" }}>
531-
<code>{tool.content}</code>
530+
<div
531+
style={{
532+
marginTop: "4px",
533+
backgroundColor: "var(--vscode-badge-background)",
534+
border: "1px solid var(--vscode-badge-background)",
535+
borderRadius: "4px 4px 0 0",
536+
overflow: "hidden",
537+
marginBottom: "2px",
538+
}}>
539+
<div
540+
style={{
541+
padding: "9px 10px 9px 14px",
542+
backgroundColor: "var(--vscode-badge-background)",
543+
borderBottom: "1px solid var(--vscode-editorGroup-border)",
544+
fontWeight: "bold",
545+
fontSize: "var(--vscode-font-size)",
546+
color: "var(--vscode-badge-foreground)",
547+
display: "flex",
548+
alignItems: "center",
549+
gap: "6px",
550+
}}>
551+
<span className="codicon codicon-arrow-right"></span>
552+
{t("chat:subtasks.newTaskContent")}
553+
</div>
554+
<div style={{ padding: "12px 16px", backgroundColor: "var(--vscode-editor-background)" }}>
555+
<MarkdownBlock markdown={tool.content} />
556+
</div>
532557
</div>
533558
</>
534559
)
535560
case "finishTask":
536561
return (
537562
<>
538563
<div style={headerStyle}>
539-
{toolIcon("checklist")}
564+
{toolIcon("check-all")}
540565
<span style={{ fontWeight: "bold" }}>{t("chat:subtasks.wantsToFinish")}</span>
541566
</div>
542-
<div style={{ paddingLeft: "26px", marginTop: "4px" }}>
543-
<code>{tool.content}</code>
567+
<div
568+
style={{
569+
marginTop: "4px",
570+
backgroundColor: "var(--vscode-editor-background)",
571+
border: "1px solid var(--vscode-badge-background)",
572+
borderRadius: "4px",
573+
overflow: "hidden",
574+
marginBottom: "8px",
575+
}}>
576+
<div
577+
style={{
578+
padding: "9px 10px 9px 14px",
579+
backgroundColor: "var(--vscode-badge-background)",
580+
borderBottom: "1px solid var(--vscode-editorGroup-border)",
581+
fontWeight: "bold",
582+
fontSize: "var(--vscode-font-size)",
583+
color: "var(--vscode-badge-foreground)",
584+
display: "flex",
585+
alignItems: "center",
586+
gap: "6px",
587+
}}>
588+
<span className="codicon codicon-check"></span>
589+
{t("chat:subtasks.completionContent")}
590+
</div>
591+
<div style={{ padding: "12px 16px", backgroundColor: "var(--vscode-editor-background)" }}>
592+
<MarkdownBlock markdown={t("chat:subtasks.completionInstructions")} />
593+
</div>
544594
</div>
545595
</>
546596
)
@@ -552,6 +602,43 @@ export const ChatRowContent = ({
552602
switch (message.type) {
553603
case "say":
554604
switch (message.say) {
605+
case "subtask_result":
606+
return (
607+
<div>
608+
<div
609+
style={{
610+
marginTop: "0px",
611+
backgroundColor: "var(--vscode-badge-background)",
612+
border: "1px solid var(--vscode-badge-background)",
613+
borderRadius: "0 0 4px 4px",
614+
overflow: "hidden",
615+
marginBottom: "8px",
616+
}}>
617+
<div
618+
style={{
619+
padding: "9px 10px 9px 14px",
620+
backgroundColor: "var(--vscode-badge-background)",
621+
borderBottom: "1px solid var(--vscode-editorGroup-border)",
622+
fontWeight: "bold",
623+
fontSize: "var(--vscode-font-size)",
624+
color: "var(--vscode-badge-foreground)",
625+
display: "flex",
626+
alignItems: "center",
627+
gap: "6px",
628+
}}>
629+
<span className="codicon codicon-arrow-left"></span>
630+
{t("chat:subtasks.resultContent")}
631+
</div>
632+
<div
633+
style={{
634+
padding: "12px 16px",
635+
backgroundColor: "var(--vscode-editor-background)",
636+
}}>
637+
<MarkdownBlock markdown={message.text} />
638+
</div>
639+
</div>
640+
</div>
641+
)
555642
case "reasoning":
556643
return (
557644
<ReasoningBlock

webview-ui/src/i18n/locales/ca/chat.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,12 @@
144144
},
145145
"subtasks": {
146146
"wantsToCreate": "Roo vol crear una nova subtasca en mode <code>{{mode}}</code>:",
147-
"wantsToFinish": "Roo vol finalitzar aquesta subtasca"
147+
"wantsToFinish": "Roo vol finalitzar aquesta subtasca",
148+
"newTaskContent": "Instruccions de la subtasca",
149+
"completionContent": "Subtasca completada",
150+
"resultContent": "Resultats de la subtasca",
151+
"defaultResult": "Si us plau, continua amb la següent tasca.",
152+
"completionInstructions": "Subtasca completada! Pots revisar els resultats i suggerir correccions o següents passos. Si tot sembla correcte, confirma per tornar el resultat a la tasca principal."
148153
},
149154
"questions": {
150155
"hasQuestion": "Roo té una pregunta:"

webview-ui/src/i18n/locales/de/chat.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,12 @@
144144
},
145145
"subtasks": {
146146
"wantsToCreate": "Roo möchte eine neue Teilaufgabe im <code>{{mode}}</code>-Modus erstellen:",
147-
"wantsToFinish": "Roo möchte diese Teilaufgabe abschließen"
147+
"wantsToFinish": "Roo möchte diese Teilaufgabe abschließen",
148+
"newTaskContent": "Teilaufgabenanweisungen",
149+
"completionContent": "Teilaufgabe abgeschlossen",
150+
"resultContent": "Teilaufgabenergebnisse",
151+
"defaultResult": "Bitte fahre mit der nächsten Aufgabe fort.",
152+
"completionInstructions": "Teilaufgabe abgeschlossen! Du kannst die Ergebnisse überprüfen und Korrekturen oder nächste Schritte vorschlagen. Wenn alles gut aussieht, bestätige, um das Ergebnis an die übergeordnete Aufgabe zurückzugeben."
148153
},
149154
"questions": {
150155
"hasQuestion": "Roo hat eine Frage:"

0 commit comments

Comments
 (0)