MCPcopy
hub / github.com/codeaashu/claude-code / killAsyncAgent

Function killAsyncAgent

src/tasks/LocalAgentTask/LocalAgentTask.tsx:281–303  ·  view source on GitHub ↗
(taskId: string, setAppState: SetAppState)

Source from the content-addressed store, hash-verified

279 * Kill an agent task. No-op if already killed/completed.
280 */
281export function killAsyncAgent(taskId: string, setAppState: SetAppState): void {
282 let killed = false;
283 updateTaskState<LocalAgentTaskState>(taskId, setAppState, task => {
284 if (task.status !== 'running') {
285 return task;
286 }
287 killed = true;
288 task.abortController?.abort();
289 task.unregisterCleanup?.();
290 return {
291 ...task,
292 status: 'killed',
293 endTime: Date.now(),
294 evictAfter: task.retain ? undefined : Date.now() + PANEL_GRACE_MS,
295 abortController: undefined,
296 unregisterCleanup: undefined,
297 selectedAgent: undefined
298 };
299 });
300 if (killed) {
301 void evictTaskOutput(taskId);
302 }
303}
304
305/**
306 * Kill all running agent tasks.

Callers 6

runAsyncAgentLifecycleFunction · 0.85
callFunction · 0.85
killFunction · 0.85
killAllRunningAgentTasksFunction · 0.85
registerAsyncAgentFunction · 0.85
registerAgentForegroundFunction · 0.85

Calls 2

evictTaskOutputFunction · 0.85
updateTaskStateFunction · 0.50

Tested by

no test coverage detected