Improve routine configuration: delete triggers, fix pause, add feedback

- Add trash icon button to delete triggers (full stack: service, route, API client, UI)
- Fix pause/unpause bug where saving routine could revert status by excluding
  status from the save payload (status is managed via dedicated pause/resume buttons)
- Add toast feedback for run, pause, and resume actions
- Auto-switch to Runs tab after triggering a manual run
- Add live update invalidation for routine/trigger/run activity events

Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
dotta
2026-03-19 16:45:08 -05:00
parent bdeaaeac9c
commit 5caf43349b
5 changed files with 86 additions and 6 deletions

View File

@@ -172,6 +172,33 @@ export function routineRoutes(db: Db) {
res.json(updated);
});
router.delete("/routine-triggers/:id", async (req, res) => {
const trigger = await svc.getTrigger(req.params.id as string);
if (!trigger) {
res.status(404).json({ error: "Routine trigger not found" });
return;
}
const routine = await assertCanManageExistingRoutine(req, trigger.routineId);
if (!routine) {
res.status(404).json({ error: "Routine not found" });
return;
}
await svc.deleteTrigger(trigger.id);
const actor = getActorInfo(req);
await logActivity(db, {
companyId: routine.companyId,
actorType: actor.actorType,
actorId: actor.actorId,
agentId: actor.agentId,
runId: actor.runId,
action: "routine.trigger_deleted",
entityType: "routine_trigger",
entityId: trigger.id,
details: { routineId: routine.id, kind: trigger.kind },
});
res.status(204).end();
});
router.post(
"/routine-triggers/:id/rotate-secret",
validate(rotateRoutineTriggerSecretSchema),

View File

@@ -843,6 +843,13 @@ export function routineService(db: Db) {
return (updated as RoutineTrigger | undefined) ?? null;
},
deleteTrigger: async (id: string): Promise<boolean> => {
const existing = await getTriggerById(id);
if (!existing) return false;
await db.delete(routineTriggers).where(eq(routineTriggers.id, id));
return true;
},
rotateTriggerSecret: async (
id: string,
actor: Actor,