MCPcopy Index your code
hub / github.com/claude-code-best/claude-code / evictTerminalTask

Function evictTerminalTask

src/utils/task/framework.ts:125–144  ·  view source on GitHub ↗
(
  taskId: string,
  setAppState: SetAppState,
)

Source from the content-addressed store, hash-verified

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

Callers 3

CoordinatorTaskPanelFunction · 0.85
framework.test.tsFile · 0.85
runInProcessTeammateFunction · 0.85

Calls 3

isTerminalTaskStatusFunction · 0.85
nowMethod · 0.80
setAppStateFunction · 0.50

Tested by

no test coverage detected