Skip to content

Commit fbad1e9

Browse files
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
1 parent dfbd0f7 commit fbad1e9

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
@@ -356,7 +356,7 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
356356

357357
if (startTask) {
358358
if (task || images) {
359-
this.startTask(task, images, initialTodos)
359+
this.startTask(task, images)
360360
} else if (historyItem) {
361361
this.resumeTaskFromHistory()
362362
} else {
@@ -937,7 +937,7 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
937937

938938
// Start / Abort / Resume
939939

940-
private async startTask(task?: string, images?: string[], initialTodos?: TodoItem[]): Promise<void> {
940+
private async startTask(task?: string, images?: string[]): Promise<void> {
941941
// `conversationHistory` (for API) and `clineMessages` (for webview)
942942
// need to be in sync.
943943
// If the extension process were killed, then on restart the

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
@@ -7,6 +7,7 @@ import {
77
type ModeConfig,
88
type ExperimentId,
99
type OrganizationAllowList,
10+
type TodoItem,
1011
ORGANIZATION_ALLOW_ALL,
1112
} from "@roo-code/types"
1213

@@ -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)