Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion e2e/src/suite/subtasks.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ suite("Roo Code Subtasks", () => {
await api.setConfiguration({
mode: "ask",
alwaysAllowModeSwitch: true,
alwaysAllowSubtasks: true,
alwaysAllowSubtaskCreation: true,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My only feedback on this - I wonder if we should stick to the alwaysAllowSubtasks key for the creation, and preserve their current setting. Otherwise the settings are going to get cleared out for everyone right?

I guess we could also add migration logic that sets the value of both new keys to the value of the old key - that might not be so bad. What do you think?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initially I didn't change it for the same reason, but as I was working on it I thought it would be important to maintain clarity in the code going forward (already too many references to "subtasks".)

Adding some migration logic I suppose would be easy, just have no idea where exactly to put it. Even easier would be to just put a notice in the changelog that this setting will now be reset to defaults and people should double check their config after the update. People do read changelogs, right? That way there's no need to leave some migration code hanging around.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think people read in general :)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do have a migrateSettings method called from extension.ts

alwaysAllowSubtaskCompletion: true,
autoApprovalEnabled: true,
enableCheckpoints: false,
})
Expand Down
3 changes: 2 additions & 1 deletion evals/packages/types/src/roo-code-defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ export const rooCodeDefaults: RooCodeSettings = {
requestDelaySeconds: 5,
alwaysAllowMcp: true,
alwaysAllowModeSwitch: true,
alwaysAllowSubtasks: true,
alwaysAllowSubtaskCreation: true,
alwaysAllowSubtaskCompletion: true,
alwaysAllowExecute: true,
allowedCommands: ["*"],

Expand Down
6 changes: 4 additions & 2 deletions evals/packages/types/src/roo-code.ts
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,8 @@ export const globalSettingsSchema = z.object({
requestDelaySeconds: z.number().optional(),
alwaysAllowMcp: z.boolean().optional(),
alwaysAllowModeSwitch: z.boolean().optional(),
alwaysAllowSubtasks: z.boolean().optional(),
alwaysAllowSubtaskCreation: z.boolean().optional(),
alwaysAllowSubtaskCompletion: z.boolean().optional(),
alwaysAllowExecute: z.boolean().optional(),
allowedCommands: z.array(z.string()).optional(),

Expand Down Expand Up @@ -561,7 +562,8 @@ const globalSettingsRecord: GlobalSettingsRecord = {
requestDelaySeconds: undefined,
alwaysAllowMcp: undefined,
alwaysAllowModeSwitch: undefined,
alwaysAllowSubtasks: undefined,
alwaysAllowSubtaskCreation: undefined,
alwaysAllowSubtaskCompletion: undefined,
alwaysAllowExecute: undefined,
allowedCommands: undefined,

Expand Down
9 changes: 6 additions & 3 deletions src/core/webview/ClineProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1180,7 +1180,8 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements
alwaysAllowBrowser,
alwaysAllowMcp,
alwaysAllowModeSwitch,
alwaysAllowSubtasks,
alwaysAllowSubtaskCreation,
alwaysAllowSubtaskCompletion,
soundEnabled,
ttsEnabled,
ttsSpeed,
Expand Down Expand Up @@ -1237,7 +1238,8 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements
alwaysAllowBrowser: alwaysAllowBrowser ?? false,
alwaysAllowMcp: alwaysAllowMcp ?? false,
alwaysAllowModeSwitch: alwaysAllowModeSwitch ?? false,
alwaysAllowSubtasks: alwaysAllowSubtasks ?? false,
alwaysAllowSubtaskCreation: alwaysAllowSubtaskCreation ?? false,
alwaysAllowSubtaskCompletion: alwaysAllowSubtaskCompletion ?? false,
uriScheme: vscode.env.uriScheme,
currentTaskItem: this.getCurrentCline()?.taskId
? (taskHistory || []).find((item: HistoryItem) => item.id === this.getCurrentCline()?.taskId)
Expand Down Expand Up @@ -1330,7 +1332,8 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements
alwaysAllowBrowser: stateValues.alwaysAllowBrowser ?? false,
alwaysAllowMcp: stateValues.alwaysAllowMcp ?? false,
alwaysAllowModeSwitch: stateValues.alwaysAllowModeSwitch ?? false,
alwaysAllowSubtasks: stateValues.alwaysAllowSubtasks ?? false,
alwaysAllowSubtaskCreation: stateValues.alwaysAllowSubtaskCreation ?? false,
alwaysAllowSubtaskCompletion: stateValues.alwaysAllowSubtaskCompletion ?? false,
taskHistory: stateValues.taskHistory,
allowedCommands: stateValues.allowedCommands,
soundEnabled: stateValues.soundEnabled ?? false,
Expand Down
8 changes: 6 additions & 2 deletions src/core/webview/webviewMessageHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,12 @@ export const webviewMessageHandler = async (provider: ClineProvider, message: We
await updateGlobalState("alwaysAllowModeSwitch", message.bool)
await provider.postStateToWebview()
break
case "alwaysAllowSubtasks":
await updateGlobalState("alwaysAllowSubtasks", message.bool)
case "alwaysAllowSubtaskCreation":
await updateGlobalState("alwaysAllowSubtaskCreation", message.bool)
await provider.postStateToWebview()
break
case "alwaysAllowSubtaskCompletion":
await updateGlobalState("alwaysAllowSubtaskCompletion", message.bool)
await provider.postStateToWebview()
break
case "askResponse":
Expand Down
3 changes: 2 additions & 1 deletion src/exports/roo-code.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,8 @@ type GlobalSettings = {
requestDelaySeconds?: number | undefined
alwaysAllowMcp?: boolean | undefined
alwaysAllowModeSwitch?: boolean | undefined
alwaysAllowSubtasks?: boolean | undefined
alwaysAllowSubtaskCreation?: boolean | undefined
alwaysAllowSubtaskCompletion?: boolean | undefined
alwaysAllowExecute?: boolean | undefined
allowedCommands?: string[] | undefined
browserToolEnabled?: boolean | undefined
Expand Down
3 changes: 2 additions & 1 deletion src/exports/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,8 @@ type GlobalSettings = {
requestDelaySeconds?: number | undefined
alwaysAllowMcp?: boolean | undefined
alwaysAllowModeSwitch?: boolean | undefined
alwaysAllowSubtasks?: boolean | undefined
alwaysAllowSubtaskCreation?: boolean | undefined
alwaysAllowSubtaskCompletion?: boolean | undefined
alwaysAllowExecute?: boolean | undefined
allowedCommands?: string[] | undefined
browserToolEnabled?: boolean | undefined
Expand Down
2 changes: 2 additions & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { telemetryService } from "./services/telemetry/TelemetryService"
import { TerminalRegistry } from "./integrations/terminal/TerminalRegistry"
import { API } from "./exports/api"
import { migrateSettings } from "./utils/migrateSettings"
import { migrateSubtasksSettings } from "./utils/migrateSubtasksSettings"

import { handleUri, registerCommands, registerCodeActions, registerTerminalActions } from "./activate"
import { formatLanguage } from "./shared/language"
Expand All @@ -48,6 +49,7 @@ export async function activate(context: vscode.ExtensionContext) {

// Migrate old settings to new
await migrateSettings(context, outputChannel)
await migrateSubtasksSettings(context, outputChannel)

// Initialize telemetry service after environment variables are loaded.
telemetryService.initialize()
Expand Down
6 changes: 4 additions & 2 deletions src/schemas/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,8 @@ export const globalSettingsSchema = z.object({
requestDelaySeconds: z.number().optional(),
alwaysAllowMcp: z.boolean().optional(),
alwaysAllowModeSwitch: z.boolean().optional(),
alwaysAllowSubtasks: z.boolean().optional(),
alwaysAllowSubtaskCreation: z.boolean().optional(),
alwaysAllowSubtaskCompletion: z.boolean().optional(),
alwaysAllowExecute: z.boolean().optional(),
allowedCommands: z.array(z.string()).optional(),

Expand Down Expand Up @@ -577,7 +578,8 @@ const globalSettingsRecord: GlobalSettingsRecord = {
requestDelaySeconds: undefined,
alwaysAllowMcp: undefined,
alwaysAllowModeSwitch: undefined,
alwaysAllowSubtasks: undefined,
alwaysAllowSubtaskCreation: undefined,
alwaysAllowSubtaskCompletion: undefined,
alwaysAllowExecute: undefined,
allowedCommands: undefined,

Expand Down
3 changes: 2 additions & 1 deletion src/shared/ExtensionMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ export type ExtensionState = Pick<
// | "requestDelaySeconds" // Optional in GlobalSettings, required here.
| "alwaysAllowMcp"
| "alwaysAllowModeSwitch"
| "alwaysAllowSubtasks"
| "alwaysAllowSubtaskCreation"
| "alwaysAllowSubtaskCompletion"
| "alwaysAllowExecute"
| "allowedCommands"
| "browserToolEnabled"
Expand Down
3 changes: 2 additions & 1 deletion src/shared/WebviewMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ export interface WebviewMessage {
| "alwaysAllowBrowser"
| "alwaysAllowMcp"
| "alwaysAllowModeSwitch"
| "alwaysAllowSubtasks"
| "alwaysAllowSubtaskCreation"
| "alwaysAllowSubtaskCompletion"
| "playSound"
| "playTts"
| "stopTts"
Expand Down
41 changes: 41 additions & 0 deletions src/utils/migrateSubtasksSettings.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import * as vscode from "vscode"

/**
* Migrates old subtasks setting to new subtaskCreation and subtaskCompletion settings.
*
* TODO: Remove this migration code in September 2025 (6 months after implementation)
*/
export async function migrateSubtasksSettings(
context: vscode.ExtensionContext,
outputChannel: vscode.OutputChannel,
): Promise<void> {
// Old and new setting keys
const subtasksKey = "alwaysAllowSubtasks"
const subtaskCreationKey = "alwaysAllowSubtaskCreation"
const subtaskCompletionKey = "alwaysAllowSubtaskCompletion"

try {
// Get old value
const oldValue = await context.globalState.get(subtasksKey)

if (oldValue !== undefined && typeof oldValue === "boolean") {
// Update new settings
await Promise.all([
context.globalState.update(subtaskCreationKey, oldValue),
context.globalState.update(subtaskCompletionKey, oldValue),
])

// Schedule cleanup
setTimeout(async () => {
try {
await context.globalState.update(subtasksKey, undefined)
outputChannel.appendLine("Migrated subtasks settings")
} catch (error) {
outputChannel.appendLine(`Failed to delete old subtasks setting: ${error}`)
}
}, 0)
}
} catch (error) {
outputChannel.appendLine(`Migrating subtasks settings failed: ${error}`)
}
}
42 changes: 29 additions & 13 deletions webview-ui/src/components/chat/AutoApproveMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@ const AutoApproveMenu = ({ style }: AutoApproveMenuProps) => {
setAlwaysAllowMcp,
alwaysAllowModeSwitch,
setAlwaysAllowModeSwitch,
alwaysAllowSubtasks,
setAlwaysAllowSubtasks,
alwaysAllowSubtaskCreation,
setAlwaysAllowSubtaskCreation,
alwaysAllowSubtaskCompletion,
setAlwaysAllowSubtaskCompletion,
alwaysApproveResubmit,
setAlwaysApproveResubmit,
autoApprovalEnabled,
Expand Down Expand Up @@ -87,11 +89,18 @@ const AutoApproveMenu = ({ style }: AutoApproveMenuProps) => {
description: t("chat:autoApprove.actions.switchModes.description"),
},
{
id: "subtasks",
label: t("chat:autoApprove.actions.subtasks.label"),
shortName: t("chat:autoApprove.actions.subtasks.shortName"),
enabled: alwaysAllowSubtasks ?? false,
description: t("chat:autoApprove.actions.subtasks.description"),
id: "subtaskCreation",
label: t("chat:autoApprove.actions.subtaskCreation.label"),
shortName: t("chat:autoApprove.actions.subtaskCreation.shortName"),
enabled: alwaysAllowSubtaskCreation ?? false,
description: t("chat:autoApprove.actions.subtaskCreation.description"),
},
{
id: "subtaskCompletion",
label: t("chat:autoApprove.actions.subtaskCompletion.label"),
shortName: t("chat:autoApprove.actions.subtaskCompletion.shortName"),
enabled: alwaysAllowSubtaskCompletion ?? false,
description: t("chat:autoApprove.actions.subtaskCompletion.description"),
},
{
id: "retryRequests",
Expand Down Expand Up @@ -148,11 +157,17 @@ const AutoApproveMenu = ({ style }: AutoApproveMenuProps) => {
vscode.postMessage({ type: "alwaysAllowModeSwitch", bool: newValue })
}, [alwaysAllowModeSwitch, setAlwaysAllowModeSwitch])

const handleSubtasksChange = useCallback(() => {
const newValue = !(alwaysAllowSubtasks ?? false)
setAlwaysAllowSubtasks(newValue)
vscode.postMessage({ type: "alwaysAllowSubtasks", bool: newValue })
}, [alwaysAllowSubtasks, setAlwaysAllowSubtasks])
const handleSubtaskCreationChange = useCallback(() => {
const newValue = !(alwaysAllowSubtaskCreation ?? false)
setAlwaysAllowSubtaskCreation(newValue)
vscode.postMessage({ type: "alwaysAllowSubtaskCreation", bool: newValue })
}, [alwaysAllowSubtaskCreation, setAlwaysAllowSubtaskCreation])

const handleSubtaskCompletionChange = useCallback(() => {
const newValue = !(alwaysAllowSubtaskCompletion ?? false)
setAlwaysAllowSubtaskCompletion(newValue)
vscode.postMessage({ type: "alwaysAllowSubtaskCompletion", bool: newValue })
}, [alwaysAllowSubtaskCompletion, setAlwaysAllowSubtaskCompletion])

const handleRetryChange = useCallback(() => {
const newValue = !(alwaysApproveResubmit ?? false)
Expand All @@ -176,7 +191,8 @@ const AutoApproveMenu = ({ style }: AutoApproveMenuProps) => {
useBrowser: handleBrowserChange,
useMcp: handleMcpChange,
switchModes: handleModeSwitchChange,
subtasks: handleSubtasksChange,
subtaskCreation: handleSubtaskCreationChange,
subtaskCompletion: handleSubtaskCompletionChange,
retryRequests: handleRetryChange,
}

Expand Down
14 changes: 10 additions & 4 deletions webview-ui/src/components/chat/ChatView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ const ChatView = ({ isHidden, showAnnouncement, hideAnnouncement, showHistoryVie
setMode,
autoApprovalEnabled,
alwaysAllowModeSwitch,
alwaysAllowSubtasks,
alwaysAllowSubtaskCreation,
alwaysAllowSubtaskCompletion,
customModes,
telemetrySetting,
} = useExtensionState()
Expand Down Expand Up @@ -694,8 +695,12 @@ const ChatView = ({ isHidden, showAnnouncement, hideAnnouncement, showHistoryVie
return alwaysAllowModeSwitch
}

if (["newTask", "finishTask"].includes(tool?.tool)) {
return alwaysAllowSubtasks
if (["newTask"].includes(tool?.tool)) {
return alwaysAllowSubtaskCreation
}

if (["finishTask"].includes(tool?.tool)) {
return alwaysAllowSubtaskCompletion
}

const isOutsideWorkspace = !!tool.isOutsideWorkspace
Expand Down Expand Up @@ -725,7 +730,8 @@ const ChatView = ({ isHidden, showAnnouncement, hideAnnouncement, showHistoryVie
alwaysAllowMcp,
isMcpToolAlwaysAllowed,
alwaysAllowModeSwitch,
alwaysAllowSubtasks,
alwaysAllowSubtaskCreation,
alwaysAllowSubtaskCompletion,
],
)

Expand Down
31 changes: 23 additions & 8 deletions webview-ui/src/components/settings/AutoApproveSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ type AutoApproveSettingsProps = HTMLAttributes<HTMLDivElement> & {
requestDelaySeconds: number
alwaysAllowMcp?: boolean
alwaysAllowModeSwitch?: boolean
alwaysAllowSubtasks?: boolean
alwaysAllowSubtaskCreation?: boolean
alwaysAllowSubtaskCompletion?: boolean
alwaysAllowExecute?: boolean
allowedCommands?: string[]
setCachedStateField: SetCachedStateField<
Expand All @@ -35,7 +36,8 @@ type AutoApproveSettingsProps = HTMLAttributes<HTMLDivElement> & {
| "requestDelaySeconds"
| "alwaysAllowMcp"
| "alwaysAllowModeSwitch"
| "alwaysAllowSubtasks"
| "alwaysAllowSubtaskCreation"
| "alwaysAllowSubtaskCompletion"
| "alwaysAllowExecute"
| "allowedCommands"
>
Expand All @@ -52,7 +54,8 @@ export const AutoApproveSettings = ({
requestDelaySeconds,
alwaysAllowMcp,
alwaysAllowModeSwitch,
alwaysAllowSubtasks,
alwaysAllowSubtaskCreation,
alwaysAllowSubtaskCompletion,
alwaysAllowExecute,
allowedCommands,
setCachedStateField,
Expand Down Expand Up @@ -234,13 +237,25 @@ export const AutoApproveSettings = ({

<div>
<VSCodeCheckbox
checked={alwaysAllowSubtasks}
onChange={(e: any) => setCachedStateField("alwaysAllowSubtasks", e.target.checked)}
data-testid="always-allow-subtasks-checkbox">
<span className="font-medium">{t("settings:autoApprove.subtasks.label")}</span>
checked={alwaysAllowSubtaskCreation}
onChange={(e: any) => setCachedStateField("alwaysAllowSubtaskCreation", e.target.checked)}
data-testid="always-allow-subtask-creation-checkbox">
<span className="font-medium">{t("settings:autoApprove.subtaskCreation.label")}</span>
</VSCodeCheckbox>
<div className="text-vscode-descriptionForeground text-sm mt-1">
{t("settings:autoApprove.subtasks.description")}
{t("settings:autoApprove.subtaskCreation.description")}
</div>
</div>

<div>
<VSCodeCheckbox
checked={alwaysAllowSubtaskCompletion}
onChange={(e: any) => setCachedStateField("alwaysAllowSubtaskCompletion", e.target.checked)}
data-testid="always-allow-subtask-completion-checkbox">
<span className="font-medium">{t("settings:autoApprove.subtaskCompletion.label")}</span>
</VSCodeCheckbox>
<div className="text-vscode-descriptionForeground text-sm mt-1">
{t("settings:autoApprove.subtaskCompletion.description")}
</div>
</div>

Expand Down
9 changes: 6 additions & 3 deletions webview-ui/src/components/settings/SettingsView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ const SettingsView = forwardRef<SettingsViewRef, SettingsViewProps>(({ onDone, t
alwaysAllowExecute,
alwaysAllowMcp,
alwaysAllowModeSwitch,
alwaysAllowSubtasks,
alwaysAllowSubtaskCreation,
alwaysAllowSubtaskCompletion,
alwaysAllowWrite,
alwaysAllowWriteOutsideWorkspace,
alwaysApproveResubmit,
Expand Down Expand Up @@ -247,7 +248,8 @@ const SettingsView = forwardRef<SettingsViewRef, SettingsViewProps>(({ onDone, t
vscode.postMessage({ type: "currentApiConfigName", text: currentApiConfigName })
vscode.postMessage({ type: "updateExperimental", values: experiments })
vscode.postMessage({ type: "alwaysAllowModeSwitch", bool: alwaysAllowModeSwitch })
vscode.postMessage({ type: "alwaysAllowSubtasks", bool: alwaysAllowSubtasks })
vscode.postMessage({ type: "alwaysAllowSubtaskCreation", bool: alwaysAllowSubtaskCreation })
vscode.postMessage({ type: "alwaysAllowSubtaskCompletion", bool: alwaysAllowSubtaskCompletion })
vscode.postMessage({ type: "upsertApiConfiguration", text: currentApiConfigName, apiConfiguration })
vscode.postMessage({ type: "telemetrySetting", text: telemetrySetting })
setChangeDetected(false)
Expand Down Expand Up @@ -431,7 +433,8 @@ const SettingsView = forwardRef<SettingsViewRef, SettingsViewProps>(({ onDone, t
requestDelaySeconds={requestDelaySeconds}
alwaysAllowMcp={alwaysAllowMcp}
alwaysAllowModeSwitch={alwaysAllowModeSwitch}
alwaysAllowSubtasks={alwaysAllowSubtasks}
alwaysAllowSubtaskCreation={alwaysAllowSubtaskCreation}
alwaysAllowSubtaskCompletion={alwaysAllowSubtaskCompletion}
alwaysAllowExecute={alwaysAllowExecute}
allowedCommands={allowedCommands}
setCachedStateField={setCachedStateField}
Expand Down
Loading
Loading