Browse Source

Add type for RooCodeEventName.TaskSpawned (#7465)

Matt Rubens 4 months ago
parent
commit
0f6079a3a3

+ 1 - 1
packages/types/npm/package.metadata.json

@@ -1,6 +1,6 @@
 {
 	"name": "@roo-code/types",
-	"version": "1.61.0",
+	"version": "1.62.0",
 	"description": "TypeScript type definitions for Roo Code.",
 	"publishConfig": {
 		"access": "public",

+ 3 - 0
packages/types/src/task.ts

@@ -57,6 +57,9 @@ export type TaskProviderEvents = {
 	[RooCodeEventName.TaskInteractive]: [taskId: string]
 	[RooCodeEventName.TaskResumable]: [taskId: string]
 	[RooCodeEventName.TaskIdle]: [taskId: string]
+
+	// Subtask Lifecycle
+	[RooCodeEventName.TaskSpawned]: [taskId: string]
 }
 
 /**

+ 2 - 1
src/core/tools/__tests__/newTaskTool.spec.ts

@@ -84,6 +84,7 @@ const mockCline = {
 	consecutiveMistakeCount: 0,
 	isPaused: false,
 	pausedModeSlug: "ask",
+	taskId: "mock-parent-task-id",
 	providerRef: {
 		deref: vi.fn(() => ({
 			getState: vi.fn(() => ({ customModes: [], mode: "ask" })),
@@ -157,7 +158,7 @@ describe("newTaskTool", () => {
 		)
 
 		// Verify side effects
-		expect(mockCline.emit).toHaveBeenCalledWith("taskSpawned", expect.any(String)) // Assuming initCline returns a mock task ID
+		expect(mockCline.emit).toHaveBeenCalledWith("taskSpawned", "mock-subtask-id")
 		expect(mockCline.isPaused).toBe(true)
 		expect(mockCline.emit).toHaveBeenCalledWith("taskPaused")
 		expect(mockPushToolResult).toHaveBeenCalledWith(expect.stringContaining("Successfully created new task"))