Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix: remove deleted CoS tasks from the Tasks tab immediately

[._.]/ Adam Eivy10fa27cb1088
diff --git a/client/src/components/cos/tabs/TaskItem.jsx b/client/src/components/cos/tabs/TaskItem.jsx
index 067db61f24..657fda1678 100644
--- a/client/src/components/cos/tabs/TaskItem.jsx
+++ b/client/src/components/cos/tabs/TaskItem.jsx
@@ -346,12 +346,17 @@ export default function TaskItem({ task, agent = null, liveOutput, isSystem, spa
});
};
+ // Optimistic: drop the row immediately and reconcile with the server after.
+ // On success the server's tasks:changed event refreshes the queue, so no
+ // extra full refetch is needed; on failure refetch to restore the row.
const handleDelete = async () => {
- const result = await api.deleteCosTask(task.id, taskSource, { silent: true }).catch(err => { toast.error(err.message); return null; });
- if (!result) return;
onTaskDeleted?.(task.id, taskSource);
+ const result = await api.deleteCosTask(task.id, taskSource, { silent: true }).catch(err => { toast.error(err.message); return null; });
+ if (!result) {
+ onRefresh();
+ return;
+ }
toast.success('Task deleted');
- onRefresh();
};
// Resolve a parked challenge inline (#2471). `upheld` overturns the reviewer
diff --git a/client/src/components/cos/tabs/TaskItem.test.jsx b/client/src/components/cos/tabs/TaskItem.test.jsx
index c05f10d791..e048e7d69a 100644
--- a/client/src/components/cos/tabs/TaskItem.test.jsx
+++ b/client/src/components/cos/tabs/TaskItem.test.jsx
@@ -294,7 +294,7 @@ describe('TaskItem delete action', () => {
metadata: { blockedReason: 'Needs manual intervention' },
};
- it('calls deleteCosTask, onTaskDeleted, toast success, and onRefresh in order when confirmed', async () => {
+ it('removes the row optimistically, then toasts success without a full refetch', async () => {
api.deleteCosTask.mockResolvedValueOnce({ ok: true });
const onRefresh = vi.fn();
const onTaskDeleted = vi.fn();
@@ -309,8 +309,22 @@ describe('TaskItem delete action', () => {
await waitFor(() => expect(api.deleteCosTask).toHaveBeenCalledWith('sys-blocked-delete', 'internal', { silent: true }));
expect(onTaskDeleted).toHaveBeenCalledWith('sys-blocked-delete', 'internal');
- expect(toast.success).toHaveBeenCalledWith('Task deleted');
- expect(onRefresh).toHaveBeenCalled();
+ await waitFor(() => expect(toast.success).toHaveBeenCalledWith('Task deleted'));
+ expect(onRefresh).not.toHaveBeenCalled();
+ });
+
+ it('restores the row via refetch when the delete fails', async () => {
+ api.deleteCosTask.mockRejectedValueOnce(new Error('boom'));
+ const onRefresh = vi.fn();
+ const onTaskDeleted = vi.fn();
+
+ render(<TaskItem task={blockedTask} isSystem onRefresh={onRefresh} onTaskDeleted={onTaskDeleted} providers={providers} />);
+ fireEvent.click(screen.getByRole('button', { name: 'Delete task' }));
+ fireEvent.click(screen.getByRole('button', { name: 'Delete' }));
+
+ await waitFor(() => expect(onRefresh).toHaveBeenCalled());
+ expect(onTaskDeleted).toHaveBeenCalledWith('sys-blocked-delete', 'internal');
+ expect(toast.error).toHaveBeenCalledWith('boom');
});
});