MCPcopy
hub / github.com/claude-code-best/claude-code / killTask

Function killTask

src/tasks/LocalShellTask/killShellTasks.ts:16–46  ·  view source on GitHub ↗
(taskId: string, setAppState: SetAppStateFn)

Source from the content-addressed store, hash-verified

14type SetAppStateFn = (updater: (prev: AppState) => AppState) => void
15
16export function killTask(taskId: string, setAppState: SetAppStateFn): void {
17 updateTaskState(taskId, setAppState, task => {
18 if ((task as any).status !== 'running' || !isLocalShellTask(task)) {
19 return task
20 }
21
22 try {
23 logForDebugging(`LocalShellTask ${taskId} kill requested`)
24 task.shellCommand?.kill()
25 task.shellCommand?.cleanup()
26 } catch (error) {
27 logError(error)
28 }
29
30 task.unregisterCleanup?.()
31 if (task.cleanupTimeoutId) {
32 clearTimeout(task.cleanupTimeoutId)
33 }
34
35 return {
36 ...task,
37 status: 'killed',
38 notified: true,
39 shellCommand: null,
40 unregisterCleanup: undefined,
41 cleanupTimeoutId: undefined,
42 endTime: Date.now(),
43 }
44 })
45 void evictTaskOutput(taskId)
46}
47
48/**
49 * Kill all running bash tasks spawned by a given agent.

Callers 4

killShellTasksForAgentFunction · 0.85
killFunction · 0.85
spawnShellTaskFunction · 0.85
registerForegroundFunction · 0.85

Calls 8

isLocalShellTaskFunction · 0.85
evictTaskOutputFunction · 0.85
nowMethod · 0.80
updateTaskStateFunction · 0.50
logForDebuggingFunction · 0.50
logErrorFunction · 0.50
killMethod · 0.45
cleanupMethod · 0.45

Tested by

no test coverage detected