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
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
drop useAsyncAction's unmount guard, which guards a warning React 18 removed (#3267)
[._.]/ Adam Eivy8106328615e2
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex 6e4322f2ce..beb598c3d4 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -22,6 +22,7 @@- **[issue-3264] Fixed a development-mode freeze that left panels loading and buttons stuck after one click.** Under `npm run dev`, a mount guard used across fourteen components and hooks was never re-armed after React StrictMode double-mounts a component, so anything gated on it silently stopped updating — the music generator panel sat on "Loading generators…" forever, and every button backed by the shared async-action hook stayed disabled after its first click. All fourteen now use the shared hook that re-arms correctly, and a test fails if the broken shape is reintroduced anywhere in the client.- **[issue-3265] Fixed a test that broke on its own once the calendar passed 2026-07-31.** An image-quota test compared against a reset timestamp baked into its fixture; once that instant passed, the code correctly ignored the stale time and the test started comparing against the wall clock, failing every run. The test now pins its own clock, and the ignore-a-past-reset path it accidentally exercised has coverage of its own.+- **[issue-3267] Removed the unmount guard from the shared async-action hook, along with the test that could never fail.** The guard existed to avoid a "state update on an unmounted component" warning React stopped emitting in version 18, so its only remaining effect was to skip a no-op — while being the exact shape that froze every button backed by the hook under StrictMode. Its regression test asserted that the vanished warning never appeared, which stayed green even with the guard deleted; it now unmounts mid-request and asserts the action still resolves with its value.- **[issue-3250] Stabilize Music Video project-selection tests under CI load.** Project-selection coverage now waits for the requested project to be available before opening its board, preventing intermittent false failures.## Music Videodiff --git a/client/src/hooks/useAsyncAction.js b/client/src/hooks/useAsyncAction.jsindex 9039b28c7f..4e9d07e222 100644--- a/client/src/hooks/useAsyncAction.js+++ b/client/src/hooks/useAsyncAction.js@@ -1,6 +1,5 @@import { useState } from 'react';import toast from '../components/ui/Toast';-import useMounted from './useMounted.js';/*** Wraps an async action with `running` state and toast-on-error.@@ -17,25 +16,21 @@ import useMounted from './useMounted.js';* single boolean in-flight flag — keyed/indexed loading states (e.g. "which* row is saving") need a different abstraction.*- * The trailing `setRunning(false)` is gated on a `mountedRef` so an action- * that resolves after the component unmounts (navigate-away mid-request)- * doesn't call `setState` on an unmounted component — React warns about- * that and it's a latent memory-leak signal. The guard MUST come from- * `useMounted`, which re-arms the ref on every effect setup: StrictMode runs- * mount→cleanup→mount on the same instance (refs survive), so a cleanup-only- * ref stays false forever and every button in the app would stay stuck in its- * disabled/spinner state after one click.+ * The trailing `setRunning(false)` is deliberately UNGUARDED: on React 19 a+ * `setState` after unmount is a silent no-op (the old "update on an unmounted+ * component" warning is gone), and a mounted-ref guard here is the exact thing+ * that froze every button backed by this hook under StrictMode (#3264). Don't+ * re-add one — there is nothing left for it to prevent.*/export function useAsyncAction(fn, { errorMessage } = {}) {const [running, setRunning] = useState(false);- const mountedRef = useMounted();const run = async (...args) => {setRunning(true);const result = await fn(...args).catch((err) => {toast.error(err?.message || errorMessage || 'Action failed');return null;});- if (mountedRef.current) setRunning(false);+ setRunning(false);return result;};return [run, running];diff --git a/client/src/hooks/useAsyncAction.test.jsx b/client/src/hooks/useAsyncAction.test.jsxindex 5622fa656f..1d751bf128 100644--- a/client/src/hooks/useAsyncAction.test.jsx+++ b/client/src/hooks/useAsyncAction.test.jsx@@ -52,8 +52,12 @@ describe('useAsyncAction', () => {expect(errorSpy).toHaveBeenCalledWith('Action failed');});- it('does not call setRunning after the component unmounts mid-request', async () => {- const setStateSpy = vi.spyOn(console, 'error');+ // There is no mounted guard on the trailing `setRunning(false)` (#3267): on+ // React 19 that setState is a silent no-op after unmount. Assert the+ // observable — resolving late must not throw and must still hand the caller+ // the fn's value — rather than the absence of a console warning React no+ // longer emits (an assertion that passed with the guard deleted).+ it('resolves to the fn value when the component unmounts mid-request', async () => {let release;const pending = new Promise((resolve) => { release = resolve; });const { result, unmount } = renderHook(() => useAsyncAction(async () => { await pending; return 'late'; }));@@ -65,25 +69,20 @@ describe('useAsyncAction', () => {// Unmount while the action is still pending, then let it resolve.unmount();+ let resolved;await act(async () => {release();- await runPromise;+ resolved = await runPromise;});- // React logs an "update on an unmounted component" error if the guard is- // missing — the guard keeps that console.error from ever firing.- const sawUnmountWarning = setStateSpy.mock.calls.some((call) =>- String(call[0]).includes('unmounted')- );- expect(sawUnmountWarning).toBe(false);- setStateSpy.mockRestore();+ expect(resolved).toBe('late');+ expect(errorSpy).not.toHaveBeenCalled();});- // The unmount guard above must not cost us the ordinary case. The app runs- // under <React.StrictMode>, whose dev double-mount reuses the hook's refs — a- // cleanup-only guard is left false by the simulated unmount, so `setRunning- // (false)` never fires and EVERY button backed by this hook stays disabled- // after one click (#3264). `useMounted` re-arms on setup; this pins it.+ // The app runs under <React.StrictMode>, whose dev double-mount reuses the+ // hook's refs — a cleanup-only mounted guard is left false by the simulated+ // unmount, so `setRunning(false)` never fires and EVERY button backed by this+ // hook stays disabled after one click (#3264). This pins the fix.it('clears running under StrictMode so the action can be run again', async () => {const { result } = renderHook(() => useAsyncAction(async (x) => x * 2), {wrapper: StrictMode,