fix: refresh tasks snapshot immediately after IPC task mutations
Previously, current_tasks.json was only written at container-start time, so tasks created (or paused/cancelled/updated) during a session were invisible to list_tasks until the next invocation. Add an onTasksChanged callback to IpcDeps, called after every successful mutation in processTaskIpc (schedule_task, pause_task, resume_task, cancel_task, update_task). index.ts wires it up to write fresh snapshots for all registered groups immediately, keeping no new coupling between ipc.ts and the container layer. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
15
src/index.ts
15
src/index.ts
@@ -575,6 +575,21 @@ async function main(): Promise<void> {
|
||||
getAvailableGroups,
|
||||
writeGroupsSnapshot: (gf, im, ag, rj) =>
|
||||
writeGroupsSnapshot(gf, im, ag, rj),
|
||||
onTasksChanged: () => {
|
||||
const tasks = getAllTasks();
|
||||
const taskRows = tasks.map((t) => ({
|
||||
id: t.id,
|
||||
groupFolder: t.group_folder,
|
||||
prompt: t.prompt,
|
||||
schedule_type: t.schedule_type,
|
||||
schedule_value: t.schedule_value,
|
||||
status: t.status,
|
||||
next_run: t.next_run,
|
||||
}));
|
||||
for (const group of Object.values(registeredGroups)) {
|
||||
writeTasksSnapshot(group.folder, group.isMain === true, taskRows);
|
||||
}
|
||||
},
|
||||
});
|
||||
queue.setProcessMessagesFn(processGroupMessages);
|
||||
recoverPendingMessages();
|
||||
|
||||
Reference in New Issue
Block a user