fix: add watcher TTL and cleanup task-scoped artifacts

This commit is contained in:
Eyejoker
2026-03-25 21:54:15 +09:00
parent 113c540f10
commit c3c75882e4
8 changed files with 233 additions and 5 deletions

View File

@@ -9,6 +9,7 @@ import {
setRegisteredGroup,
} from './db.js';
import { processTaskIpc, IpcDeps } from './ipc.js';
import { DEFAULT_WATCH_CI_MAX_DURATION_MS } from './task-watch-status.js';
import { RegisteredGroup } from './types.js';
// Set up registered groups used across tests
@@ -580,12 +581,32 @@ Check the run.
const tasks = getAllTasks();
expect(tasks).toHaveLength(1);
expect(tasks[0].schedule_type).toBe('interval');
expect(tasks[0].max_duration_ms).toBe(DEFAULT_WATCH_CI_MAX_DURATION_MS);
const nextRun = new Date(tasks[0].next_run!).getTime();
expect(nextRun).toBeGreaterThanOrEqual(before - 1000);
expect(nextRun).toBeLessThanOrEqual(Date.now() + 1000);
expect(deps.nudgeScheduler).toHaveBeenCalledTimes(1);
});
it('does not assign a max duration to regular scheduled tasks', async () => {
await processTaskIpc(
{
type: 'schedule_task',
prompt: 'regular interval task',
schedule_type: 'interval',
schedule_value: '60000',
targetJid: 'other@g.us',
},
'whatsapp_main',
true,
deps,
);
const tasks = getAllTasks();
expect(tasks).toHaveLength(1);
expect(tasks[0].max_duration_ms).toBeNull();
});
it('rejects invalid interval (non-numeric)', async () => {
await processTaskIpc(
{