MCPcopy Index your code
hub / github.com/codeaashu/claude-code / killShellTasksForAgent

Function killShellTasksForAgent

src/tasks/LocalShellTask/killShellTasks.ts:53–76  ·  view source on GitHub ↗
(
  agentId: AgentId,
  getAppState: () => AppState,
  setAppState: SetAppStateFn,
)

Source from the content-addressed store, hash-verified

51 * the agent that started them (prevents 10-day fake-logs.sh zombies).
52 */
53export function killShellTasksForAgent(
54 agentId: AgentId,
55 getAppState: () => AppState,
56 setAppState: SetAppStateFn,
57): void {
58 const tasks = getAppState().tasks ?? {}
59 for (const [taskId, task] of Object.entries(tasks)) {
60 if (
61 isLocalShellTask(task) &&
62 task.agentId === agentId &&
63 task.status === 'running'
64 ) {
65 logForDebugging(
66 `killShellTasksForAgent: killing orphaned shell task ${taskId} (agent ${agentId} exiting)`,
67 )
68 killTask(taskId, setAppState)
69 }
70 }
71 // Purge any queued notifications addressed to this agent — its query loop
72 // has exited and won't drain them. killTask fires 'killed' notifications
73 // asynchronously; drop the ones already queued and any that land later sit
74 // harmlessly (no consumer matches a dead agentId).
75 dequeueAllMatching(cmd => cmd.agentId === agentId)
76}
77

Callers 1

runAgentFunction · 0.85

Calls 6

isLocalShellTaskFunction · 0.85
logForDebuggingFunction · 0.85
killTaskFunction · 0.85
dequeueAllMatchingFunction · 0.85
entriesMethod · 0.80
getAppStateFunction · 0.50

Tested by

no test coverage detected