diff --git a/src/core/task/Task.ts b/src/core/task/Task.ts index 77be503435..34669027bf 100644 --- a/src/core/task/Task.ts +++ b/src/core/task/Task.ts @@ -356,7 +356,7 @@ export class Task extends EventEmitter implements TaskLike { if (startTask) { if (task || images) { - this.startTask(task, images, initialTodos) + this.startTask(task, images) } else if (historyItem) { this.resumeTaskFromHistory() } else { @@ -937,7 +937,7 @@ export class Task extends EventEmitter implements TaskLike { // Start / Abort / Resume - private async startTask(task?: string, images?: string[], initialTodos?: TodoItem[]): Promise { + private async startTask(task?: string, images?: string[]): Promise { // `conversationHistory` (for API) and `clineMessages` (for webview) // need to be in sync. // If the extension process were killed, then on restart the diff --git a/src/core/tools/newTaskTool.ts b/src/core/tools/newTaskTool.ts index feb38860e4..6ebf92af49 100644 --- a/src/core/tools/newTaskTool.ts +++ b/src/core/tools/newTaskTool.ts @@ -51,7 +51,11 @@ export async function newTaskTool( // Get the experimental setting for requiring todos const provider = cline.providerRef.deref() - const state = await provider?.getState() + if (!provider) { + pushToolResult(formatResponse.toolError("Provider reference lost")) + return + } + const state = await provider.getState() const requireTodos = Experiments.isEnabled(state?.experiments ?? {}, EXPERIMENT_IDS.NEW_TASK_REQUIRE_TODOS) // Check if todos are required based on experimental setting @@ -82,7 +86,7 @@ export async function newTaskTool( const unescapedMessage = message.replace(/\\\\@/g, "\\@") // Verify the mode exists - const targetMode = getModeBySlug(mode, (await cline.providerRef.deref()?.getState())?.customModes) + const targetMode = getModeBySlug(mode, state?.customModes) if (!targetMode) { pushToolResult(formatResponse.toolError(`Invalid mode: ${mode}`)) @@ -102,9 +106,7 @@ export async function newTaskTool( return } - if (!provider) { - return - } + // Provider is guaranteed to be defined here due to earlier check if (cline.enableCheckpoints) { cline.checkpointSave(true) diff --git a/webview-ui/src/context/ExtensionStateContext.tsx b/webview-ui/src/context/ExtensionStateContext.tsx index d240e3cccc..c25c36263d 100644 --- a/webview-ui/src/context/ExtensionStateContext.tsx +++ b/webview-ui/src/context/ExtensionStateContext.tsx @@ -7,6 +7,7 @@ import { type ModeConfig, type ExperimentId, type OrganizationAllowList, + type TodoItem, ORGANIZATION_ALLOW_ALL, } from "@roo-code/types" @@ -31,7 +32,7 @@ export interface ExtensionStateContextType extends ExtensionState { mcpServers: McpServer[] hasSystemPromptOverride?: boolean currentCheckpoint?: string - currentTaskTodos?: any[] // Initial todos for the current task + currentTaskTodos?: TodoItem[] // Initial todos for the current task filePaths: string[] openedTabs: Array<{ label: string; isActive: boolean; path?: string }> commands: Command[]