()
| 284 | this.emit(RooCodeEventName.TaskCompleted, taskId, tokenUsage, toolUsage) |
| 285 | } |
| 286 | const onTaskAborted = async () => { |
| 287 | this.emit(RooCodeEventName.TaskAborted, instance.taskId) |
| 288 | |
| 289 | try { |
| 290 | // Only rehydrate on genuine streaming failures. |
| 291 | // User-initiated cancels are handled by cancelTask(). |
| 292 | if (instance.abortReason === "streaming_failed") { |
| 293 | // Defensive safeguard: if another path already replaced this instance, skip |
| 294 | const current = this.getCurrentTask() |
| 295 | if (current && current.instanceId !== instance.instanceId) { |
| 296 | this.log( |
| 297 | `[onTaskAborted] Skipping rehydrate: current instance ${current.instanceId} != aborted ${instance.instanceId}`, |
| 298 | ) |
| 299 | return |
| 300 | } |
| 301 | |
| 302 | const { historyItem } = await this.getTaskWithId(instance.taskId) |
| 303 | const rootTask = instance.rootTask |
| 304 | const parentTask = instance.parentTask |
| 305 | await this.createTaskWithHistoryItem({ ...historyItem, rootTask, parentTask }) |
| 306 | } |
| 307 | } catch (error) { |
| 308 | this.log( |
| 309 | `[onTaskAborted] Failed to rehydrate after streaming failure: ${ |
| 310 | error instanceof Error ? error.message : String(error) |
| 311 | }`, |
| 312 | ) |
| 313 | } |
| 314 | } |
| 315 | const onTaskFocused = () => this.emit(RooCodeEventName.TaskFocused, instance.taskId) |
| 316 | const onTaskUnfocused = () => this.emit(RooCodeEventName.TaskUnfocused, instance.taskId) |
| 317 | const onTaskActive = (taskId: string) => this.emit(RooCodeEventName.TaskActive, taskId) |
nothing calls this directly
no test coverage detected