Skip to content
Merged
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: 3 additions & 0 deletions packages/types/src/task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@ export type TaskEvents = {
[RooCodeEventName.TaskPaused]: [taskId: string]
[RooCodeEventName.TaskUnpaused]: [taskId: string]
[RooCodeEventName.TaskSpawned]: [taskId: string]
[RooCodeEventName.TaskDelegated]: [childTaskId: string]
[RooCodeEventName.TaskDelegationCompleted]: [childTaskId: string, summary: string]
[RooCodeEventName.TaskDelegationResumed]: [childTaskId: string]

// Task Execution
[RooCodeEventName.Message]: [{ action: "created" | "updated"; message: ClineMessage }]
Expand Down
8 changes: 4 additions & 4 deletions src/__mocks__/fs/promises.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ const mockFs = {

// Handle file not found
const error = new Error(`ENOENT: no such file or directory, open '${filePath}'`)
;(error as any).code = "ENOENT"
;(error as NodeJS.ErrnoException).code = "ENOENT"
throw error
}),

Expand Down Expand Up @@ -113,7 +113,7 @@ const mockFs = {
currentPath += "/" + parts[i]
if (!mockDirectories.has(currentPath)) {
const error = new Error(`ENOENT: no such file or directory, mkdir '${path}'`)
;(error as any).code = "ENOENT"
;(error as NodeJS.ErrnoException).code = "ENOENT"
throw error
}
}
Expand All @@ -130,7 +130,7 @@ const mockFs = {
return Promise.resolve()
}
const error = new Error(`ENOENT: no such file or directory, access '${path}'`)
;(error as any).code = "ENOENT"
;(error as NodeJS.ErrnoException).code = "ENOENT"
throw error
}),

Expand All @@ -146,7 +146,7 @@ const mockFs = {
}
// If old file doesn't exist, throw an error
const error = new Error(`ENOENT: no such file or directory, rename '${oldPath}'`)
;(error as any).code = "ENOENT"
;(error as NodeJS.ErrnoException).code = "ENOENT"
throw error
}),

Expand Down
37 changes: 18 additions & 19 deletions src/__tests__/ClineProvider.delegation.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,15 @@ function makeStoreStub(
* `parent`. Without flushPendingToolResultsToHistory the method hits its
* non-fatal flush-error branch and never reaches the happy delegation path.
*/
const makeParentTask = () =>
({
taskId: "parent-1",
apiConfiguration: { apiProvider: providerIdentifiers.anthropic, anthropicApiKey: "task-local-key" },
getTaskMode: vi.fn().mockResolvedValue("code"),
getTaskApiConfigName: vi.fn().mockResolvedValue("task-local-profile"),
emit: vi.fn(),
flushPendingToolResultsToHistory: vi.fn().mockResolvedValue(true),
retrySaveApiConversationHistory: vi.fn(),
}) as any
const makeParentTask = () => ({
taskId: "parent-1",
apiConfiguration: { apiProvider: providerIdentifiers.anthropic, anthropicApiKey: "task-local-key" },
getTaskMode: vi.fn().mockResolvedValue("code"),
getTaskApiConfigName: vi.fn().mockResolvedValue("task-local-profile"),
emit: vi.fn(),
flushPendingToolResultsToHistory: vi.fn().mockResolvedValue(true),
retrySaveApiConversationHistory: vi.fn(),
})

describe("ClineProvider.delegateParentAndOpenChild()", () => {
it("rejects a stale restored action before delegation side effects", async () => {
Expand Down Expand Up @@ -150,7 +149,7 @@ describe("ClineProvider.delegateParentAndOpenChild()", () => {
}
const parentTask = makeParentTask()
const child = { taskId: "child-1", run: vi.fn().mockResolvedValue(undefined) }
const getCurrentTask = vi.fn(() => parentTask)
const getCurrentTask = vi.fn((): { taskId: string } => parentTask)
const createTask = vi.fn(async () => {
getCurrentTask.mockReturnValue(child)
return child
Expand Down Expand Up @@ -218,7 +217,7 @@ describe("ClineProvider.delegateParentAndOpenChild()", () => {
taskHistoryStore,
} as unknown as ClineProvider

const child = await (ClineProvider.prototype as any).delegateParentAndOpenChild.call(provider, {
const child = await ClineProvider.prototype.delegateParentAndOpenChild.call(provider, {
parentTaskId: "parent-1",
message: "Do something",
initialTodos: [],
Expand Down Expand Up @@ -416,7 +415,7 @@ describe("ClineProvider.delegateParentAndOpenChild()", () => {
taskHistoryStore,
} as unknown as ClineProvider

await (ClineProvider.prototype as any).delegateParentAndOpenChild.call(provider, {
await ClineProvider.prototype.delegateParentAndOpenChild.call(provider, {
parentTaskId: "parent-1",
message: "Do something",
initialTodos: [],
Expand Down Expand Up @@ -450,7 +449,7 @@ describe("ClineProvider.delegateParentAndOpenChild()", () => {
taskHistoryStore,
} as unknown as ClineProvider

await (ClineProvider.prototype as any).delegateParentAndOpenChild.call(provider, {
await ClineProvider.prototype.delegateParentAndOpenChild.call(provider, {
parentTaskId: "parent-1",
message: "Do something",
initialTodos: [],
Expand Down Expand Up @@ -491,7 +490,7 @@ describe("ClineProvider.delegateParentAndOpenChild()", () => {
taskHistoryStore,
} as unknown as ClineProvider

await (ClineProvider.prototype as any).delegateParentAndOpenChild.call(provider, {
await ClineProvider.prototype.delegateParentAndOpenChild.call(provider, {
parentTaskId: "parent-1",
message: "Do something",
initialTodos: [],
Expand Down Expand Up @@ -538,7 +537,7 @@ describe("ClineProvider.delegateParentAndOpenChild()", () => {
taskHistoryStore,
} as unknown as ClineProvider

await (ClineProvider.prototype as any).delegateParentAndOpenChild.call(provider, {
await ClineProvider.prototype.delegateParentAndOpenChild.call(provider, {
parentTaskId: "parent-1",
message: "Continue",
initialTodos: [],
Expand Down Expand Up @@ -603,7 +602,7 @@ describe("ClineProvider.delegateParentAndOpenChild()", () => {
} as unknown as ClineProvider

await expect(
(ClineProvider.prototype as any).delegateParentAndOpenChild.call(provider, {
ClineProvider.prototype.delegateParentAndOpenChild.call(provider, {
parentTaskId: "parent-1",
message: "Continue",
initialTodos: [],
Expand All @@ -614,7 +613,7 @@ describe("ClineProvider.delegateParentAndOpenChild()", () => {
// The authoritative preflight rejects before either provider mutates its stack.
expect(child.run).not.toHaveBeenCalled()
expect(createTask).not.toHaveBeenCalled()
expect((provider as any).deleteTaskWithId).not.toHaveBeenCalled()
expect(provider.deleteTaskWithId).not.toHaveBeenCalled()
})

it("rejects a delegated parent whose awaited-child identity is missing", async () => {
Expand Down Expand Up @@ -744,7 +743,7 @@ describe("ClineProvider.delegateParentAndOpenChild()", () => {
} as unknown as ClineProvider

await expect(
(ClineProvider.prototype as any).delegateParentAndOpenChild.call(provider, {
ClineProvider.prototype.delegateParentAndOpenChild.call(provider, {
parentTaskId: "parent-1",
message: "Do something",
initialTodos: [],
Expand Down
Loading
Loading