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: keep stopped maintenance toasts on completed-count

[._.]/ Adam Eivyfdb8c0233051
diff --git a/client/src/components/cos/tabs/schedule/MaintenanceRunStatus.jsx b/client/src/components/cos/tabs/schedule/MaintenanceRunStatus.jsx
index f38df6c7bc..605059c6e0 100644
--- a/client/src/components/cos/tabs/schedule/MaintenanceRunStatus.jsx
+++ b/client/src/components/cos/tabs/schedule/MaintenanceRunStatus.jsx
@@ -14,9 +14,10 @@ export function maintenanceRunProgress(run = {}) {
const activeIndex = steps.findIndex((entry) => (activeId
? entry.id === activeId
: Boolean(activeType) && entry.taskRef?.taskType === activeType && !Object.hasOwn(completed, entry.id)));
- const current = activeIndex >= 0
+ const running = run.status === 'running';
+ const current = running && activeIndex >= 0
? activeIndex + 1
- : (run.status === 'running' && total > 0 && done < total ? done + 1 : done);
+ : (running && total > 0 && done < total ? done + 1 : done);
const step = activeType || steps.find((entry) => !Object.hasOwn(completed, entry.id))?.taskRef?.taskType;
return { current, done, total, step };
}
diff --git a/client/src/hooks/useOnDemandTaskToast.test.jsx b/client/src/hooks/useOnDemandTaskToast.test.jsx
index bc2ff3dc25..c146995e4e 100644
--- a/client/src/hooks/useOnDemandTaskToast.test.jsx
+++ b/client/src/hooks/useOnDemandTaskToast.test.jsx
@@ -1,5 +1,5 @@
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
-import { renderHook, cleanup } from '@testing-library/react';
+import { render, renderHook, cleanup, screen } from '@testing-library/react';
// Capture the socket handler the hook registers so tests can drive the
// `cos:schedule:on-demand-empty` event, and record toast calls.
@@ -241,3 +241,22 @@ it('updates one maintenance notification with an agent link and expires terminal
unmount();
expect(handlers.has('cos:maintenance:updated')).toBe(false);
});
+
+it('keeps a stopped run on completed-count even when the stale active step is retained', () => {
+ toastSpy.mockClear();
+ const { unmount } = renderHook(() => useOnDemandTaskToast());
+ const update = handlers.get('cos:maintenance:updated');
+ const steps = ['better-structural-drift', 'simplify', 'module-hygiene', 'better-complexity', 'performance', 'better-cognitive-load', 'documentation']
+ .map((taskType, index) => ({ id: `maint-1-${index}`, taskRef: { taskType } }));
+ update({
+ id: 'maint-stopped', status: 'stopped', steps,
+ completed: { 'maint-1-0': 'done', 'maint-1-1': 'done' },
+ active: { stepId: 'maint-1-2', taskType: 'module-hygiene' },
+ updatedAt: 'stopped',
+ });
+ expect(toastSpy.mock.calls[0][1]).toMatchObject({ label: 'Maintenance · 2/7 · stopped' });
+ render(toastSpy.mock.calls[0][0]());
+ expect(screen.getByRole('status')).toHaveTextContent('stopped · 2/7 steps');
+ expect(screen.getByRole('progressbar')).toHaveAttribute('value', '2');
+ unmount();
+});