MCPcopy Create free account
hub / github.com/RioArisk/claudecode_api_RemoteControl / syncTodoPanelLifecycle

Function syncTodoPanelLifecycle

app/src/modules/todo.js:40–73  ·  view source on GitHub ↗
(tasks)

Source from the content-addressed store, hash-verified

38}
39
40function syncTodoPanelLifecycle(tasks) {
41 const hasTasks = tasks.length > 0;
42 const hasPendingCreates = todoState.pendingCreates.size > 0;
43 const hasOpenTasks = tasks.some(([, task]) => (task.status || 'pending') !== 'completed');
44
45 if (!hasTasks) {
46 cancelTodoAutoClear();
47 todoState.autoOpenedForBatch = false;
48 todoState.panelOpen = false;
49 return;
50 }
51
52 if (!todoState.autoOpenedForBatch) {
53 todoState.autoOpenedForBatch = true;
54 todoState.panelOpen = true;
55 }
56
57 if (hasOpenTasks || hasPendingCreates) {
58 cancelTodoAutoClear();
59 return;
60 }
61
62 if (!todoState.clearTimer) {
63 todoState.clearTimer = setTimeout(() => {
64 todoState.clearTimer = null;
65 const latestTasks = Array.from(todoState.tasks.values());
66 const latestHasPendingCreates = todoState.pendingCreates.size > 0;
67 const latestHasOpenTasks = latestTasks.some(task => (task.status || 'pending') !== 'completed');
68 if (!latestHasPendingCreates && latestTasks.length > 0 && !latestHasOpenTasks) {
69 clearTodoBatch();
70 }
71 }, TODO_AUTO_CLEAR_DELAY_MS);
72 }
73}
74
75export function handleTodoToolUse(b) {
76 const { name, id, input } = b;

Callers 1

renderTodoPanelFunction · 0.70

Calls 2

cancelTodoAutoClearFunction · 0.70
clearTodoBatchFunction · 0.70

Tested by

no test coverage detected