mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-08-28 05:27:24 +00:00
Fix/4100 subtask completion mismatch (#4738)
Co-authored-by: yansheng3 <yansheng3@staff.weibo.com>
This commit is contained in:
parent
80dd3b8320
commit
5c5ee8c324
3 changed files with 16 additions and 4 deletions
|
|
@ -5,7 +5,7 @@ import type { RooCodeSettings } from "./global-settings.js"
|
|||
import type { ProviderSettingsEntry, ProviderSettings } from "./provider-settings.js"
|
||||
import type { ClineMessage, TokenUsage } from "./message.js"
|
||||
import type { ToolUsage, ToolName } from "./tool.js"
|
||||
import type { IpcMessage, IpcServerEvents } from "./ipc.js"
|
||||
import type { IpcMessage, IpcServerEvents, IsSubtask } from "./ipc.js"
|
||||
|
||||
// TODO: Make sure this matches `RooCodeEvents` from `@roo-code/types`.
|
||||
export interface RooCodeAPIEvents {
|
||||
|
|
@ -18,7 +18,7 @@ export interface RooCodeAPIEvents {
|
|||
taskAskResponded: [taskId: string]
|
||||
taskAborted: [taskId: string]
|
||||
taskSpawned: [parentTaskId: string, childTaskId: string]
|
||||
taskCompleted: [taskId: string, tokenUsage: TokenUsage, toolUsage: ToolUsage]
|
||||
taskCompleted: [taskId: string, tokenUsage: TokenUsage, toolUsage: ToolUsage, isSubtask: IsSubtask]
|
||||
taskTokenUsageUpdated: [taskId: string, tokenUsage: TokenUsage]
|
||||
taskToolFailed: [taskId: string, toolName: ToolName, error: string]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,14 @@ import { clineMessageSchema, tokenUsageSchema } from "./message.js"
|
|||
import { toolNamesSchema, toolUsageSchema } from "./tool.js"
|
||||
import { rooCodeSettingsSchema } from "./global-settings.js"
|
||||
|
||||
/**
|
||||
* isSubtaskSchema
|
||||
*/
|
||||
export const isSubtaskSchema = z.object({
|
||||
isSubtask: z.boolean(),
|
||||
})
|
||||
export type IsSubtask = z.infer<typeof isSubtaskSchema>
|
||||
|
||||
/**
|
||||
* RooCodeEvent
|
||||
*/
|
||||
|
|
@ -41,7 +49,7 @@ export const rooCodeEventsSchema = z.object({
|
|||
[RooCodeEventName.TaskAskResponded]: z.tuple([z.string()]),
|
||||
[RooCodeEventName.TaskAborted]: z.tuple([z.string()]),
|
||||
[RooCodeEventName.TaskSpawned]: z.tuple([z.string(), z.string()]),
|
||||
[RooCodeEventName.TaskCompleted]: z.tuple([z.string(), tokenUsageSchema, toolUsageSchema]),
|
||||
[RooCodeEventName.TaskCompleted]: z.tuple([z.string(), tokenUsageSchema, toolUsageSchema, isSubtaskSchema]),
|
||||
[RooCodeEventName.TaskTokenUsageUpdated]: z.tuple([z.string(), tokenUsageSchema]),
|
||||
[RooCodeEventName.TaskToolFailed]: z.tuple([z.string(), toolNamesSchema, z.string()]),
|
||||
})
|
||||
|
|
|
|||
|
|
@ -222,7 +222,11 @@ export class API extends EventEmitter<RooCodeEvents> implements RooCodeAPI {
|
|||
})
|
||||
|
||||
cline.on("taskCompleted", async (_, tokenUsage, toolUsage) => {
|
||||
this.emit(RooCodeEventName.TaskCompleted, cline.taskId, tokenUsage, toolUsage)
|
||||
let isSubtask = false
|
||||
if (cline.rootTask != undefined) {
|
||||
isSubtask = true
|
||||
}
|
||||
this.emit(RooCodeEventName.TaskCompleted, cline.taskId, tokenUsage, toolUsage, { isSubtask: isSubtask })
|
||||
this.taskMap.delete(cline.taskId)
|
||||
|
||||
await this.fileLog(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue