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:
@@ -22,6 +22,7 @@ export interface IpcDeps {
|
||||
availableGroups: AvailableGroup[],
|
||||
registeredJids: Set<string>,
|
||||
) => void;
|
||||
onTasksChanged: () => void;
|
||||
}
|
||||
|
||||
let ipcWatcherRunning = false;
|
||||
@@ -270,6 +271,7 @@ export async function processTaskIpc(
|
||||
{ taskId, sourceGroup, targetFolder, contextMode },
|
||||
'Task created via IPC',
|
||||
);
|
||||
deps.onTasksChanged();
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -282,6 +284,7 @@ export async function processTaskIpc(
|
||||
{ taskId: data.taskId, sourceGroup },
|
||||
'Task paused via IPC',
|
||||
);
|
||||
deps.onTasksChanged();
|
||||
} else {
|
||||
logger.warn(
|
||||
{ taskId: data.taskId, sourceGroup },
|
||||
@@ -300,6 +303,7 @@ export async function processTaskIpc(
|
||||
{ taskId: data.taskId, sourceGroup },
|
||||
'Task resumed via IPC',
|
||||
);
|
||||
deps.onTasksChanged();
|
||||
} else {
|
||||
logger.warn(
|
||||
{ taskId: data.taskId, sourceGroup },
|
||||
@@ -318,6 +322,7 @@ export async function processTaskIpc(
|
||||
{ taskId: data.taskId, sourceGroup },
|
||||
'Task cancelled via IPC',
|
||||
);
|
||||
deps.onTasksChanged();
|
||||
} else {
|
||||
logger.warn(
|
||||
{ taskId: data.taskId, sourceGroup },
|
||||
@@ -388,6 +393,7 @@ export async function processTaskIpc(
|
||||
{ taskId: data.taskId, sourceGroup, updates },
|
||||
'Task updated via IPC',
|
||||
);
|
||||
deps.onTasksChanged();
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user