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([issue-2737]): don't orphan a slow silent op's spinner on error

[._.]/ Adam Eivy838257b520ef
diff --git a/client/src/hooks/useAIStatusNotifications.js b/client/src/hooks/useAIStatusNotifications.js
index 65e993b54e..b51002238b 100644
--- a/client/src/hooks/useAIStatusNotifications.js
+++ b/client/src/hooks/useAIStatusNotifications.js
@@ -135,11 +135,14 @@ export function useAIStatusNotifications() {
if (event.phase === 'error') {
if (state.slowTimer) clearTimeout(state.slowTimer);
opsRef.current.delete(event.id);
- // User-triggered ops toast immediately, individually, with the real
- // reason — failures the user is waiting on matter and must not be
- // aggregated away. Silent-op failures (unattended background jobs) are
- // coalesced per-provider so a systematic failure yields one toast, not N.
- if (state.silent || event.silent) {
+ // Coalesce ONLY silent ops that never surfaced their own toast — the
+ // fast-fail fan-out case an unattended job produces. A silent op that
+ // already opened a loading toast (a slow call whose spinner the user is
+ // now watching, id === event.id) must update THAT toast in place, or the
+ // Infinity-duration loading toast is orphaned and spins forever. A
+ // user-triggered op always toasts immediately, individually, with the
+ // real reason — that's load-bearing and must not be aggregated away.
+ if ((state.silent || event.silent) && !state.opened) {
coalesceSilentError(event);
} else {
toast.error(event.message || 'AI call failed', { id: event.id, duration: 6000, icon: '✕' });
diff --git a/client/src/hooks/useAIStatusNotifications.test.jsx b/client/src/hooks/useAIStatusNotifications.test.jsx
index 43d5ed49c3..b29722af3a 100644
--- a/client/src/hooks/useAIStatusNotifications.test.jsx
+++ b/client/src/hooks/useAIStatusNotifications.test.jsx
@@ -108,6 +108,30 @@ describe('useAIStatusNotifications — silent-op error coalescing', () => {
expect(provA[provA.length - 1].message).toBe('Provider A failed on 2 background AI calls');
});
+ it('does NOT coalesce a silent op that already surfaced its own (slow-call) toast — it updates that toast in place', () => {
+ renderHook(() => useAIStatusNotifications());
+
+ act(() => {
+ emit({ id: 'slow-op', phase: 'start', silent: true, providerId: 'prov-1', providerName: 'Example Provider', message: 'Calling…' });
+ });
+ // Cross the slow-call threshold so the deferred toast opens under id 'slow-op'.
+ act(() => { vi.advanceTimersByTime(3000); });
+ const loadingCall = toastCalls.find(c => c.type === 'loading');
+ expect(loadingCall?.opts?.id).toBe('slow-op');
+
+ act(() => {
+ emit({ id: 'slow-op', phase: 'error', silent: true, providerId: 'prov-1', providerName: 'Example Provider', message: 'HTTP 401 Unauthorized' });
+ });
+
+ const errs = errorCalls();
+ expect(errs).toHaveLength(1);
+ // Updates the already-visible spinner in place (id === op id), NOT the
+ // provider-keyed coalescing toast — otherwise the Infinity-duration loading
+ // toast would be orphaned and spin forever.
+ expect(errs[0].opts?.id).toBe('slow-op');
+ expect(errs[0].message).toBe('HTTP 401 Unauthorized');
+ });
+
it('starts a fresh coalescing window after the previous one lapses', () => {
renderHook(() => useAIStatusNotifications());