MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / evictTerminalTask

Function evictTerminalTask

source code/utils/task/framework.ts:127–146  ·  view source on GitHub ↗
(
  taskId: string,
  setAppState: SetAppState,
)

Source from the content-addressed store, hash-verified

125 * The lazy GC in generateTaskAttachments() remains as a safety net.
126 */
127export function evictTerminalTask(
128 taskId: string,
129 setAppState: SetAppState,
130): void {
131 setAppState(prev => {
132 const task = prev.tasks?.[taskId]
133 if (!task) return prev
134 if (!isTerminalTaskStatus(task.status)) return prev
135 if (!task.notified) return prev
136 // Panel grace period — blocks eviction until deadline passes.
137 // 'retain' in task narrows to LocalAgentTaskState (the only type with
138 // that field); evictAfter is optional so 'evictAfter' in task would
139 // miss tasks that haven't had it set yet.
140 if ('retain' in task && (task.evictAfter ?? Infinity) > Date.now()) {
141 return prev
142 }
143 const { [taskId]: _, ...remainingTasks } = prev.tasks
144 return { ...prev, tasks: remainingTasks }
145 })
146}
147
148/**
149 * Get all running tasks.

Callers 2

CoordinatorTaskPanelFunction · 0.85
runInProcessTeammateFunction · 0.85

Calls 1

isTerminalTaskStatusFunction · 0.85

Tested by

no test coverage detected