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

Function updateTaskState

src/utils/task/framework.ts:48–72  ·  view source on GitHub ↗
(
  taskId: string,
  setAppState: SetAppState,
  updater: (task: T) => T,
)

Source from the content-addressed store, hash-verified

46 * Generic to allow type-safe updates for specific task types.
47 */
48export function updateTaskState<T extends TaskState>(
49 taskId: string,
50 setAppState: SetAppState,
51 updater: (task: T) => T,
52): void {
53 setAppState(prev => {
54 const task = prev.tasks?.[taskId] as T | undefined
55 if (!task) {
56 return prev
57 }
58 const updated = updater(task)
59 if (updated === task) {
60 // Updater returned the same reference (early-return no-op). Skip the
61 // spread so s.tasks subscribers don't re-render on unchanged state.
62 return prev
63 }
64 return {
65 ...prev,
66 tasks: {
67 ...prev.tasks,
68 [taskId]: updated,
69 },
70 }
71 })
72}
73
74/**
75 * Register a new task in AppState.

Callers 15

callFunction · 0.50
UltraplanChoiceDialogFunction · 0.50
setAwaitingPlanApprovalFunction · 0.50
framework.test.tsFile · 0.50
startDetachedPollFunction · 0.50
completeMainSessionTaskFunction · 0.50
startBackgroundSessionFunction · 0.50
completeWorkflowTaskFunction · 0.50
failWorkflowTaskFunction · 0.50
killWorkflowTaskFunction · 0.50
skipWorkflowAgentFunction · 0.50

Calls 1

setAppStateFunction · 0.50

Tested by

no test coverage detected