Skip to content

Commit c8a4b50

Browse files
author
Merge Resolver
committed
fix: address PR review comments
- Replace any[] with TodoItem[] type in ExtensionStateContext.tsx for better type safety - Remove redundant initialTodos parameter from startTask call in Task.ts (todos already set in constructor) - Improve code clarity in newTaskTool.ts by checking provider reference early and reusing state # Conflicts: # src/core/task/Task.ts # webview-ui/src/context/ExtensionStateContext.tsx
1 parent 75f5e12 commit c8a4b50

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

src/core/task/Task.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
381381

382382
if (startTask) {
383383
if (task || images) {
384-
this.startTask(task, images, initialTodos)
384+
this.startTask(task, images)
385385
} else if (historyItem) {
386386
this.resumeTaskFromHistory()
387387
} else {
@@ -1059,7 +1059,7 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
10591059

10601060
// Start / Abort / Resume
10611061

1062-
private async startTask(task?: string, images?: string[], initialTodos?: TodoItem[]): Promise<void> {
1062+
private async startTask(task?: string, images?: string[]): Promise<void> {
10631063
if (this.enableTaskBridge) {
10641064
try {
10651065
this.bridgeService = this.bridgeService || ExtensionBridgeService.getInstance()

src/core/tools/newTaskTool.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,11 @@ export async function newTaskTool(
5151

5252
// Get the experimental setting for requiring todos
5353
const provider = cline.providerRef.deref()
54-
const state = await provider?.getState()
54+
if (!provider) {
55+
pushToolResult(formatResponse.toolError("Provider reference lost"))
56+
return
57+
}
58+
const state = await provider.getState()
5559
const requireTodos = Experiments.isEnabled(state?.experiments ?? {}, EXPERIMENT_IDS.NEW_TASK_REQUIRE_TODOS)
5660

5761
// Check if todos are required based on experimental setting
@@ -82,7 +86,7 @@ export async function newTaskTool(
8286
const unescapedMessage = message.replace(/\\\\@/g, "\\@")
8387

8488
// Verify the mode exists
85-
const targetMode = getModeBySlug(mode, (await cline.providerRef.deref()?.getState())?.customModes)
89+
const targetMode = getModeBySlug(mode, state?.customModes)
8690

8791
if (!targetMode) {
8892
pushToolResult(formatResponse.toolError(`Invalid mode: ${mode}`))
@@ -102,9 +106,7 @@ export async function newTaskTool(
102106
return
103107
}
104108

105-
if (!provider) {
106-
return
107-
}
109+
// Provider is guaranteed to be defined here due to earlier check
108110

109111
if (cline.enableCheckpoints) {
110112
cline.checkpointSave(true)

webview-ui/src/context/ExtensionStateContext.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
type CustomModePrompts,
77
type ModeConfig,
88
type ExperimentId,
9+
type TodoItem,
910
} from "@roo-code/types"
1011

1112
import { type OrganizationAllowList, ORGANIZATION_ALLOW_ALL } from "@roo/cloud"
@@ -31,7 +32,7 @@ export interface ExtensionStateContextType extends ExtensionState {
3132
mcpServers: McpServer[]
3233
hasSystemPromptOverride?: boolean
3334
currentCheckpoint?: string
34-
currentTaskTodos?: any[] // Initial todos for the current task
35+
currentTaskTodos?: TodoItem[] // Initial todos for the current task
3536
filePaths: string[]
3637
openedTabs: Array<{ label: string; isActive: boolean; path?: string }>
3738
commands: Command[]

0 commit comments

Comments
 (0)