(result: AgentToolResult, setAppState: SetAppState)
| 410 | * Complete an agent task with result. |
| 411 | */ |
| 412 | export function completeAgentTask(result: AgentToolResult, setAppState: SetAppState): void { |
| 413 | const taskId = result.agentId; |
| 414 | updateTaskState<LocalAgentTaskState>(taskId, setAppState, task => { |
| 415 | if (task.status !== 'running') { |
| 416 | return task; |
| 417 | } |
| 418 | task.unregisterCleanup?.(); |
| 419 | return { |
| 420 | ...task, |
| 421 | status: 'completed', |
| 422 | result, |
| 423 | endTime: Date.now(), |
| 424 | evictAfter: task.retain ? undefined : Date.now() + PANEL_GRACE_MS, |
| 425 | abortController: undefined, |
| 426 | unregisterCleanup: undefined, |
| 427 | selectedAgent: undefined |
| 428 | }; |
| 429 | }); |
| 430 | void evictTaskOutput(taskId); |
| 431 | // Note: Notification is sent by AgentTool via enqueueAgentNotification |
| 432 | } |
| 433 | |
| 434 | /** |
| 435 | * Fail an agent task with error. |
nothing calls this directly
no test coverage detected