Skip to content

Commit 27624a2

Browse files
author
ShayBC
committed
fixed the missing case of cmd execution at the end of a subyask and added auto aprove option for finish task (and continue to the next task)
1 parent 1456db9 commit 27624a2

File tree

7 files changed

+45
-27
lines changed

7 files changed

+45
-27
lines changed

src/core/Cline.ts

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2953,19 +2953,7 @@ export class Cline {
29532953
if (lastMessage && lastMessage.ask !== "command") {
29542954
// havent sent a command message yet so first send completion_result then command
29552955
await this.say("completion_result", result, undefined, false)
2956-
// telemetryService.captureTaskCompleted(this.taskId)
2957-
if (this.isSubTask) {
2958-
const didApprove = await askFinishSubTaskApproval()
2959-
if (!didApprove) {
2960-
break
2961-
}
2962-
2963-
// tell the provider to remove the current subtask and resume the previous task in the stack
2964-
await this.providerRef
2965-
.deref()
2966-
?.finishSubTask(`Task complete: ${lastMessage?.text}`)
2967-
break
2968-
}
2956+
telemetryService.captureTaskCompleted(this.taskId)
29692957
}
29702958

29712959
// complete command message
@@ -2983,19 +2971,18 @@ export class Cline {
29832971
commandResult = execCommandResult
29842972
} else {
29852973
await this.say("completion_result", result, undefined, false)
2986-
// telemetryService.captureTaskCompleted(this.taskId)
2987-
if (this.isSubTask) {
2988-
const didApprove = await askFinishSubTaskApproval()
2989-
if (!didApprove) {
2990-
break
2991-
}
2974+
telemetryService.captureTaskCompleted(this.taskId)
2975+
}
29922976

2993-
// tell the provider to remove the current subtask and resume the previous task in the stack
2994-
await this.providerRef
2995-
.deref()
2996-
?.finishSubTask(`Task complete: ${lastMessage?.text}`)
2977+
if (this.isSubTask) {
2978+
const didApprove = await askFinishSubTaskApproval()
2979+
if (!didApprove) {
29972980
break
29982981
}
2982+
2983+
// tell the provider to remove the current subtask and resume the previous task in the stack
2984+
await this.providerRef.deref()?.finishSubTask(`Task complete: ${lastMessage?.text}`)
2985+
break
29992986
}
30002987

30012988
// we already sent completion_result says, an empty string asks relinquishes control over button and field

src/core/webview/ClineProvider.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -984,6 +984,10 @@ export class ClineProvider implements vscode.WebviewViewProvider {
984984
await this.updateGlobalState("alwaysAllowModeSwitch", message.bool)
985985
await this.postStateToWebview()
986986
break
987+
case "alwaysAllowFinishTask":
988+
await this.updateGlobalState("alwaysAllowFinishTask", message.bool)
989+
await this.postStateToWebview()
990+
break
987991
case "askResponse":
988992
this.getCurrentCline()?.handleWebviewAskResponse(
989993
message.askResponse!,
@@ -2177,6 +2181,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
21772181
alwaysAllowBrowser,
21782182
alwaysAllowMcp,
21792183
alwaysAllowModeSwitch,
2184+
alwaysAllowFinishTask,
21802185
soundEnabled,
21812186
diffEnabled,
21822187
enableCheckpoints,
@@ -2224,6 +2229,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
22242229
alwaysAllowBrowser: alwaysAllowBrowser ?? false,
22252230
alwaysAllowMcp: alwaysAllowMcp ?? false,
22262231
alwaysAllowModeSwitch: alwaysAllowModeSwitch ?? false,
2232+
alwaysAllowFinishTask: alwaysAllowFinishTask ?? false,
22272233
uriScheme: vscode.env.uriScheme,
22282234
currentTaskItem: this.getCurrentCline()?.taskId
22292235
? (taskHistory || []).find((item: HistoryItem) => item.id === this.getCurrentCline()?.taskId)
@@ -2385,6 +2391,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
23852391
alwaysAllowBrowser: stateValues.alwaysAllowBrowser ?? false,
23862392
alwaysAllowMcp: stateValues.alwaysAllowMcp ?? false,
23872393
alwaysAllowModeSwitch: stateValues.alwaysAllowModeSwitch ?? false,
2394+
alwaysAllowFinishTask: stateValues.alwaysAllowFinishTask ?? false,
23882395
taskHistory: stateValues.taskHistory,
23892396
allowedCommands: stateValues.allowedCommands,
23902397
soundEnabled: stateValues.soundEnabled ?? false,

src/shared/globalState.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ export const GLOBAL_STATE_KEYS = [
4040
"alwaysAllowBrowser",
4141
"alwaysAllowMcp",
4242
"alwaysAllowModeSwitch",
43+
"alwaysAllowFinishTask",
4344
"taskHistory",
4445
"openAiBaseUrl",
4546
"openAiModelId",

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,10 @@ const AutoApproveMenu = ({ style }: AutoApproveMenuProps) => {
8585
},
8686
{
8787
id: "finishTask",
88-
label: "Finish subtasks tasks",
89-
shortName: "Finish",
88+
label: "Continue to next task",
89+
shortName: "Continue",
9090
enabled: alwaysAllowFinishTask ?? false,
91-
description: "Allows automatic completeing a sub-task without requiring user review or approval.",
91+
description: "Allow tasks to end execution and continue to the next task, without user review or approval.",
9292
},
9393
{
9494
id: "retryRequests",

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,10 @@ const ChatView = ({ isHidden, showAnnouncement, hideAnnouncement, showHistoryVie
149149
setPrimaryButtonText("Save")
150150
setSecondaryButtonText("Reject")
151151
break
152+
case "finishTask":
153+
setPrimaryButtonText("Approve & Continue to the next Task")
154+
setSecondaryButtonText(undefined)
155+
break
152156
default:
153157
setPrimaryButtonText("Approve")
154158
setSecondaryButtonText("Reject")
@@ -644,7 +648,9 @@ const ChatView = ({ isHidden, showAnnouncement, hideAnnouncement, showHistoryVie
644648
message.ask === "tool" &&
645649
(JSON.parse(message.text || "{}")?.tool === "switchMode" ||
646650
JSON.parse(message.text || "{}")?.tool === "newTask")) ||
647-
(alwaysAllowFinishTask && message.ask === "finishTask")
651+
(alwaysAllowFinishTask &&
652+
message.ask === "tool" &&
653+
JSON.parse(message.text || "{}")?.tool === "finishTask")
648654
)
649655
},
650656
[

webview-ui/src/components/settings/AutoApproveSettings.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ type AutoApproveSettingsProps = HTMLAttributes<HTMLDivElement> & {
1818
requestDelaySeconds: number
1919
alwaysAllowMcp?: boolean
2020
alwaysAllowModeSwitch?: boolean
21+
alwaysAllowFinishTask?: boolean
2122
alwaysAllowExecute?: boolean
2223
allowedCommands?: string[]
2324
setCachedStateField: SetCachedStateField<keyof ExtensionStateContextType>
@@ -32,6 +33,7 @@ export const AutoApproveSettings = ({
3233
requestDelaySeconds,
3334
alwaysAllowMcp,
3435
alwaysAllowModeSwitch,
36+
alwaysAllowFinishTask,
3537
alwaysAllowExecute,
3638
allowedCommands,
3739
setCachedStateField,
@@ -180,6 +182,18 @@ export const AutoApproveSettings = ({
180182
</p>
181183
</div>
182184

185+
<div>
186+
<VSCodeCheckbox
187+
checked={alwaysAllowFinishTask}
188+
onChange={(e: any) => setCachedStateField("alwaysAllowFinishTask", e.target.checked)}>
189+
<span className="font-medium">Always approve finish & continue to next task</span>
190+
</VSCodeCheckbox>
191+
<p className="text-vscode-descriptionForeground text-sm mt-0">
192+
Automatically approve tasks to finish execution and continue to the next task, without user
193+
review or approval
194+
</p>
195+
</div>
196+
183197
<div>
184198
<VSCodeCheckbox
185199
checked={alwaysAllowExecute}

webview-ui/src/components/settings/SettingsView.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ const SettingsView = forwardRef<SettingsViewRef, SettingsViewProps>(({ onDone },
6363
alwaysAllowExecute,
6464
alwaysAllowMcp,
6565
alwaysAllowModeSwitch,
66+
alwaysAllowFinishTask,
6667
alwaysAllowWrite,
6768
alwaysApproveResubmit,
6869
browserToolEnabled,
@@ -184,6 +185,7 @@ const SettingsView = forwardRef<SettingsViewRef, SettingsViewProps>(({ onDone },
184185
vscode.postMessage({ type: "currentApiConfigName", text: currentApiConfigName })
185186
vscode.postMessage({ type: "updateExperimental", values: experiments })
186187
vscode.postMessage({ type: "alwaysAllowModeSwitch", bool: alwaysAllowModeSwitch })
188+
vscode.postMessage({ type: "alwaysAllowFinishTask", bool: alwaysAllowFinishTask })
187189
vscode.postMessage({ type: "upsertApiConfiguration", text: currentApiConfigName, apiConfiguration })
188190
vscode.postMessage({ type: "telemetrySetting", text: telemetrySetting })
189191
setChangeDetected(false)
@@ -364,6 +366,7 @@ const SettingsView = forwardRef<SettingsViewRef, SettingsViewProps>(({ onDone },
364366
requestDelaySeconds={requestDelaySeconds}
365367
alwaysAllowMcp={alwaysAllowMcp}
366368
alwaysAllowModeSwitch={alwaysAllowModeSwitch}
369+
alwaysAllowFinishTask={alwaysAllowFinishTask}
367370
alwaysAllowExecute={alwaysAllowExecute}
368371
allowedCommands={allowedCommands}
369372
setCachedStateField={setCachedStateField}

0 commit comments

Comments
 (0)