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
fix([issue-3264]): re-arm mounted-guard refs so StrictMode stops freezing the UI
[._.]/ Adam Eivy69e1c7367161
diff --git a/client/src/components/TagPicker.jsx b/client/src/components/TagPicker.jsxindex ff847d16b3..2077cf7db2 100644--- a/client/src/components/TagPicker.jsx+++ b/client/src/components/TagPicker.jsx@@ -14,6 +14,7 @@*/import { useEffect, useRef, useState } from 'react';+import useMounted from '../hooks/useMounted';import { X } from 'lucide-react';import { listCatalogTags } from '../services/apiCatalog';import { canonicalTagKey } from '../lib/catalogTypes';@@ -29,8 +30,7 @@ export default function TagPicker({const [input, setInput] = useState('');const [suggestions, setSuggestions] = useState([]);const [open, setOpen] = useState(false);- const mountedRef = useRef(true);- useEffect(() => () => { mountedRef.current = false; }, []);+ const mountedRef = useMounted();// Debounced autocomplete fetch. A stale generation counter prevents an// earlier-but-slower response from clobbering a later one's results.diff --git a/client/src/components/WhileAwayWidget.jsx b/client/src/components/WhileAwayWidget.jsxindex 063b3c503b..553cb7da4d 100644--- a/client/src/components/WhileAwayWidget.jsx+++ b/client/src/components/WhileAwayWidget.jsx@@ -1,4 +1,5 @@import { useState, useEffect, useCallback, useRef } from 'react';+import useMounted from '../hooks/useMounted';import { Link } from 'react-router-dom';import {Moon,@@ -68,7 +69,7 @@ export default function WhileAwayWidget() {const sinceRef = useRef(null);// A socket-driven refresh can land after the widget unmounts — guard the// async setState so it doesn't fire into the void (CLAUDE.md unmount rule).- const mountedRef = useRef(true);+ const mountedRef = useMounted();const load = useCallback(() => {const since = readLastSeen();@@ -86,7 +87,6 @@ export default function WhileAwayWidget() {const refresh = () => load();socket.on('cos:agent:completed', refresh);return () => {- mountedRef.current = false;socket.off('cos:agent:completed', refresh);};}, [load]);diff --git a/client/src/components/loraTraining/CheckpointPicker.jsx b/client/src/components/loraTraining/CheckpointPicker.jsxindex 99e0b0217c..bc6379aaf0 100644--- a/client/src/components/loraTraining/CheckpointPicker.jsx+++ b/client/src/components/loraTraining/CheckpointPicker.jsx@@ -10,7 +10,8 @@* overwrites the deployed LoRA in place.*/-import { useState, useCallback, useRef, useEffect } from 'react';+import { useState, useCallback } from 'react';+import useMounted from '../../hooks/useMounted';import { Layers, Loader2, CheckCircle2, AlertTriangle } from 'lucide-react';import toast from '../ui/Toast';import {@@ -26,8 +27,7 @@ export default function CheckpointPicker({ run, onPromoted }) {// Guards the background preview-poll setTimeout chain from firing after the// component unmounts (deferred-work-respects-unmount rule). Not reset to true// so dev-mode double-mount can't re-arm a stale chain.- const mountedRef = useRef(true);- useEffect(() => () => { mountedRef.current = false; }, []);+ const mountedRef = useMounted();const load = useCallback(() => {setLoading(true);diff --git a/client/src/components/music/MusicGenPanel.jsx b/client/src/components/music/MusicGenPanel.jsxindex 5edd84a2ca..a20d12a4d8 100644--- a/client/src/components/music/MusicGenPanel.jsx+++ b/client/src/components/music/MusicGenPanel.jsx@@ -12,7 +12,8 @@* inline (streamed download), then selected immediately.*/-import { useEffect, useMemo, useRef, useState } from 'react';+import { useEffect, useMemo, useState } from 'react';+import useMounted from '../../hooks/useMounted';import { Loader2, Wand2, Download, X } from 'lucide-react';import toast from '../ui/Toast';import {@@ -33,8 +34,7 @@ export default function MusicGenPanel({ track, prompt, lyrics, onGenerated, remiconst [installProgress, setInstallProgress] = useState(null);const [runtimeInstallEngine, setRuntimeInstallEngine] = useState(null);const [userSelectedEngine, setUserSelectedEngine] = useState(false);- const mountedRef = useRef(true);- useEffect(() => () => { mountedRef.current = false; }, []);+ const mountedRef = useMounted();const loadEngines = async () => {const data = await listMusicEngines({ silent: true }).catch(() => null);diff --git a/client/src/components/music/MusicGenPanel.test.jsx b/client/src/components/music/MusicGenPanel.test.jsxindex 9f52ba671f..32809dbc36 100644--- a/client/src/components/music/MusicGenPanel.test.jsx+++ b/client/src/components/music/MusicGenPanel.test.jsx@@ -1,4 +1,5 @@import { describe, it, expect, vi, beforeEach } from 'vitest';+import { StrictMode } from 'react';import { fireEvent, render, screen, waitFor } from '@testing-library/react';import MusicGenPanel from './MusicGenPanel';import * as api from '../../services/api';@@ -88,4 +89,27 @@ describe('MusicGenPanel', () => {fireEvent.change(select, { target: { value: 'acestep' } });expect(await screen.findByText(/ACE-Step .* is not installed yet/i)).toBeInTheDocument();});++ // The app mounts under <React.StrictMode> (client/src/main.jsx), whose dev+ // double-mount reuses the component's refs. A cleanup-only mounted guard is+ // left false by the simulated unmount, so `loadEngines` bailed before+ // `setLoading(false)` and the panel sat on "Loading generators…" forever+ // (#3264). Rendering the real StrictMode wrapper is the only way this+ // regression is visible — every other test here mounts the panel bare.+ it('loads the engine list under StrictMode instead of hanging on "Loading generators…"', async () => {+ api.listMusicEngines.mockResolvedValue({+ defaultEngine: 'musicgen',+ engines: [engine({ id: 'musicgen', name: 'MusicGen (MLX)', ready: true })],+ });++ render(+ <StrictMode>+ <MusicGenPanel track={{ id: 'track-1' }} prompt="" lyrics="" />+ </StrictMode>,+ );++ const select = await screen.findByRole('combobox', { name: /engine/i });+ expect(select).toHaveValue('musicgen');+ expect(screen.queryByText(/Loading generators/i)).not.toBeInTheDocument();+ });});diff --git a/client/src/components/pipeline/editorial/EditorialCustomCheckForm.jsx b/client/src/components/pipeline/editorial/EditorialCustomCheckForm.jsxindex b584af26b4..803eead332 100644--- a/client/src/components/pipeline/editorial/EditorialCustomCheckForm.jsx+++ b/client/src/components/pipeline/editorial/EditorialCustomCheckForm.jsx@@ -12,6 +12,7 @@* committing the check to the catalog.*/import { useEffect, useRef, useState } from 'react';+import useMounted from '../../../hooks/useMounted';import { FlaskConical, Loader2, Save, X } from 'lucide-react';import { CHECK_SCOPE_ORDER, scopeLabel, SEVERITY_BADGE_CLASSES } from '../../../lib/editorialChecks';@@ -53,8 +54,7 @@ export default function EditorialCustomCheckForm({ check = null, saving = false,const [previewing, setPreviewing] = useState(false);const [previewError, setPreviewError] = useState('');const previewReqRef = useRef(0);- const mountedRef = useRef(true);- useEffect(() => () => { mountedRef.current = false; }, []);+ const mountedRef = useMounted();// Invalidate + clear any preview when the draft or the target series changes.const invalidatePreview = () => {diff --git a/client/src/components/pipeline/manuscript/ManuscriptImpactPreview.jsx b/client/src/components/pipeline/manuscript/ManuscriptImpactPreview.jsxindex 47f1547027..f807ec6a48 100644--- a/client/src/components/pipeline/manuscript/ManuscriptImpactPreview.jsx+++ b/client/src/components/pipeline/manuscript/ManuscriptImpactPreview.jsx@@ -16,7 +16,8 @@* red/green. Diffs per changed section, never one giant concatenation.*/-import { useEffect, useMemo, useRef, useState } from 'react';+import { useMemo, useState } from 'react';+import useMounted from '../../../hooks/useMounted';import { Check, Loader2, X } from 'lucide-react';import Modal from '../../ui/Modal';import HunkDiff from '../../ui/HunkDiff';@@ -50,8 +51,7 @@ export default function ManuscriptImpactPreview({ open, onClose, seriesId, secti// The accept-all pass awaits one network round-trip per note; if the user// closes the preview mid-batch, late callbacks must not fire into a torn-down// parent. Never reset to true (handles dev-mode double-mount cleanly).- const mountedRef = useRef(true);- useEffect(() => () => { mountedRef.current = false; }, []);+ const mountedRef = useMounted();const changed = useMemo(() => {if (!open) return [];diff --git a/client/src/components/sync/SyncDetailDrawer.jsx b/client/src/components/sync/SyncDetailDrawer.jsxindex b6afefea21..1b812062a6 100644--- a/client/src/components/sync/SyncDetailDrawer.jsx+++ b/client/src/components/sync/SyncDetailDrawer.jsx@@ -14,6 +14,7 @@*/import { useEffect, useState, useCallback, useRef } from 'react';+import useMounted from '../../hooks/useMounted';import { RefreshCw, ArrowUpCircle, Download, CheckCircle2, AlertTriangle, WifiOff, Loader2 } from 'lucide-react';import toast from '../ui/Toast';import Drawer from '../Drawer';@@ -261,8 +262,7 @@ export default function SyncDetailDrawer({ kind, recordId, onClose }) {// Drop async results that resolve after the drawer unmounts (fast route// change / close while a fetch is in flight) to avoid setState-on-unmounted// warnings. Never reset to true — handles dev-mode double-mount cleanly.- const mountedRef = useRef(true);- useEffect(() => () => { mountedRef.current = false; }, []);+ const mountedRef = useMounted();// Generation counter so only the LATEST in-flight fetch commits state — a// rapid recordId change (or switch to empty) bumps this, and an older fetch// that resolves afterward fails the equality check and is dropped, insteaddiff --git a/client/src/components/universeBuilder/UniverseCategoryEditor.jsx b/client/src/components/universeBuilder/UniverseCategoryEditor.jsxindex cc2f30b5fd..e458be7b5b 100644--- a/client/src/components/universeBuilder/UniverseCategoryEditor.jsx+++ b/client/src/components/universeBuilder/UniverseCategoryEditor.jsx@@ -1,4 +1,5 @@import { useEffect, useRef, useState } from 'react';+import useMounted from '../../hooks/useMounted';import {ArrowUpCircle, Edit3, FolderTree, Loader2, Lock, Play, Plus,Sparkles, Trash2, Unlock, X,@@ -77,8 +78,7 @@ export function CategoryEditor({return () => document.removeEventListener('keydown', onKey);}, [assignOpen]);- const editorMountedRef = useRef(true);- useEffect(() => () => { editorMountedRef.current = false; }, []);+ const editorMountedRef = useMounted();const runPromote = async (idx, variation, opts) => {if (!onPromote) return;setPickerIdx(null);diff --git a/client/src/hooks/mountedRefConventions.test.js b/client/src/hooks/mountedRefConventions.test.jsnew file mode 100644index 0000000000..598acaf7a8--- /dev/null+++ b/client/src/hooks/mountedRefConventions.test.js@@ -0,0 +1,109 @@+/**+ * Repo-wide guard: a mounted-guard ref must re-arm itself on mount.+ *+ * The broken shape is a ref seeded `useRef(true)` whose ONLY assignment is+ * `false` in an effect cleanup:+ *+ * const mountedRef = useRef(true);+ * useEffect(() => () => { mountedRef.current = false; }, []); // ← no setup body+ *+ * It reads as correct, and it is — in production. But the app runs under+ * `React.StrictMode` (`client/src/main.jsx`), and React's dev build mounts every+ * component as setup → cleanup → setup on the SAME instance. Refs survive that+ * cycle, so the cleanup flips the flag to `false` and nothing ever flips it back:+ * every `if (mountedRef.current) setX(...)` in the component is dead for the rest+ * of the dev session. That shipped as two user-visible freezes — MusicGenPanel+ * stuck on "Loading generators…" forever, and every `useAsyncAction` button stuck+ * in its disabled/spinner state after one click (#3264).+ *+ * `hooks/useMounted.js` is the fix and the only sanctioned form: it assigns `true`+ * in the effect setup body, so the StrictMode remount re-arms the guard.+ *+ * The rule below is deliberately shape-based rather than name-based — a ref called+ * `editorMountedRef` (or anything else) carries the identical bug, and one of the+ * sites this guard was written for was named exactly that. Scoped to git-tracked+ * sources under `client/src` per the repo-hygiene convention in+ * `client/src/a11yConventions.test.js`, so an untracked scratch file can't fail it.+ */++import { describe, it, expect } from 'vitest';+import { execSync } from 'child_process';+import { readFileSync } from 'fs';+import { join, dirname } from 'path';+import { fileURLToPath } from 'url';++const CLIENT_ROOT = join(dirname(fileURLToPath(import.meta.url)), '..', '..');++function trackedSourceFiles() {+ const out = execSync('git ls-files src', { cwd: CLIENT_ROOT, encoding: 'utf8' });+ return out.trim().split('\n').filter((f) => /\.jsx?$/.test(f) && !f.includes('.test.'));+}++// `const <name> = useRef(true)` — the seed value that marks a mounted-style guard.+// A ref seeded `useRef(false)` and raised to `true` on mount is a different (and+// correct) pattern, so it is intentionally out of scope.+const TRUE_SEEDED_REF = /const\s+([A-Za-z_$][\w$]*)\s*=\s*useRef\(\s*true\s*\)/g;++const assignsRe = (name, value) => new RegExp(`\\b${name}\\.current\\s*=\\s*${value}\\b`);++/** Refs in `src` that are lowered to false but never re-raised to true. */+function findOneWayRefs(src) {+ const offenders = [];+ for (const match of src.matchAll(TRUE_SEEDED_REF)) {+ const name = match[1];+ if (assignsRe(name, 'false').test(src) && !assignsRe(name, 'true').test(src)) {+ offenders.push(name);+ }+ }+ return offenders;+}++describe('mounted-guard refs re-arm on mount (StrictMode)', () => {+ it('has no ref that is only ever set to false', () => {+ const violations = [];+ for (const file of trackedSourceFiles()) {+ const src = readFileSync(join(CLIENT_ROOT, file), 'utf8');+ for (const name of findOneWayRefs(src)) violations.push(`${file}: ${name}`);+ }++ expect(+ violations,+ 'These refs are seeded `useRef(true)` and set to `false` on cleanup, but never '+ + 'back to `true` on setup. Under React.StrictMode the dev mount→cleanup→mount '+ + 'cycle reuses the same ref, so each one is permanently false after first mount '+ + 'and every setState it guards silently no-ops.\n'+ + 'Fix: replace the ref + its cleanup effect with `useMounted()` from '+ + '`client/src/hooks/useMounted.js`.\n'+ + `Offenders:\n ${violations.join('\n ')}`,+ ).toEqual([]);+ });++ // Guards the guard: if the detector stops recognizing the broken shape, the test+ // above goes vacuously green and the bug class walks straight back in.+ it('detects the broken shape and accepts the useMounted shape', () => {+ const broken = `+ const mountedRef = useRef(true);+ useEffect(() => () => { mountedRef.current = false; }, []);+ `;+ const brokenRenamed = `+ const editorMountedRef = useRef(true);+ useEffect(() => () => { editorMountedRef.current = false; }, []);+ `;+ const fixed = `+ const mountedRef = useRef(true);+ useEffect(() => {+ mountedRef.current = true;+ return () => { mountedRef.current = false; };+ }, []);+ `;+ expect(findOneWayRefs(broken)).toEqual(['mountedRef']);+ expect(findOneWayRefs(brokenRenamed)).toEqual(['editorMountedRef']);+ expect(findOneWayRefs(fixed)).toEqual([]);+ });++ it('scans a non-empty set of tracked sources', () => {+ // A broken `git ls-files` (wrong cwd, detached checkout) would otherwise make+ // the whole guard pass by scanning nothing.+ expect(trackedSourceFiles().length).toBeGreaterThan(100);+ });+});diff --git a/client/src/hooks/useAsyncAction.js b/client/src/hooks/useAsyncAction.jsindex 05384446f2..9039b28c7f 100644--- a/client/src/hooks/useAsyncAction.js+++ b/client/src/hooks/useAsyncAction.js@@ -1,5 +1,6 @@-import { useState, useRef, useEffect } from 'react';+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.@@ -19,14 +20,15 @@ import toast from '../components/ui/Toast';* 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.+ * 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.*/export function useAsyncAction(fn, { errorMessage } = {}) {const [running, setRunning] = useState(false);- const mountedRef = useRef(true);- // Never reset to `true` on re-mount — this handles dev-mode double-mount- // cleanly (the cleanup runs once, the flag stays false for the dead tree).- useEffect(() => () => { mountedRef.current = false; }, []);+ const mountedRef = useMounted();const run = async (...args) => {setRunning(true);const result = await fn(...args).catch((err) => {diff --git a/client/src/hooks/useAsyncAction.test.jsx b/client/src/hooks/useAsyncAction.test.jsxindex cee2824286..5622fa656f 100644--- a/client/src/hooks/useAsyncAction.test.jsx+++ b/client/src/hooks/useAsyncAction.test.jsx@@ -1,4 +1,5 @@import { describe, it, expect, vi, beforeEach } from 'vitest';+import { StrictMode } from 'react';import { renderHook, act } from '@testing-library/react';import { useAsyncAction } from './useAsyncAction';@@ -77,4 +78,24 @@ describe('useAsyncAction', () => {expect(sawUnmountWarning).toBe(false);setStateSpy.mockRestore();});++ // 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.+ it('clears running under StrictMode so the action can be run again', async () => {+ const { result } = renderHook(() => useAsyncAction(async (x) => x * 2), {+ wrapper: StrictMode,+ });++ await act(async () => { await result.current[0](1); });+ expect(result.current[1]).toBe(false);++ // The second click is the one that broke: the button was still disabled.+ let second;+ await act(async () => { second = await result.current[0](21); });+ expect(second).toBe(42);+ expect(result.current[1]).toBe(false);+ });});diff --git a/client/src/hooks/useCatalogTypes.jsx b/client/src/hooks/useCatalogTypes.jsxindex e6e43a85f0..fa54b75760 100644--- a/client/src/hooks/useCatalogTypes.jsx+++ b/client/src/hooks/useCatalogTypes.jsx@@ -1,4 +1,5 @@-import { createContext, useContext, useState, useEffect, useCallback, useMemo, useRef } from 'react';+import { createContext, useContext, useState, useEffect, useCallback, useMemo } from 'react';+import useMounted from './useMounted';import { listCatalogTypes } from '../services/apiCatalogTypes';import { CATALOG_TYPES, mergeCatalogTypes } from '../lib/catalogTypes';@@ -34,8 +35,7 @@ const buildRegistry = (userTypesRaw) => mergeCatalogTypes(CATALOG_TYPES, userTypfunction useRegistryFetcher(enabled = true) {const [registry, setRegistry] = useState(() => buildRegistry([]));const [loading, setLoading] = useState(true);- const mountedRef = useRef(true);- useEffect(() => () => { mountedRef.current = false; }, []);+ const mountedRef = useMounted();const refresh = useCallback(() => listCatalogTypes({ silent: true }).then((data) => {diff --git a/client/src/hooks/useCityPlayback.js b/client/src/hooks/useCityPlayback.jsindex f7f572fab2..544e82648e 100644--- a/client/src/hooks/useCityPlayback.js+++ b/client/src/hooks/useCityPlayback.js@@ -1,4 +1,5 @@-import { useState, useRef, useCallback, useEffect, useMemo } from 'react';+import { useState, useCallback, useEffect, useMemo } from 'react';+import useMounted from './useMounted';import { getCitySnapshots } from '../services/apiCity.js';import { isPlayableFrame, buildPlaybackStats } from '../lib/cityPlaybackFrame.js';@@ -24,8 +25,7 @@ export function useCityPlayback() {// Guards a deferred/interval callback against firing after unmount (CLAUDE.md// deferred-work rule). Never reset to true — handles dev double-mount cleanly.- const mountedRef = useRef(true);- useEffect(() => () => { mountedRef.current = false; }, []);+ const mountedRef = useMounted();const enter = useCallback(async () => {setActive(true);diff --git a/client/src/hooks/useShellSession.js b/client/src/hooks/useShellSession.jsindex 3ede874f54..baad0c0120 100644--- a/client/src/hooks/useShellSession.js+++ b/client/src/hooks/useShellSession.js@@ -1,4 +1,5 @@import { useEffect, useRef, useState, useCallback } from 'react';+import useMounted from './useMounted';import { useSearchParams, useParams, useNavigate } from 'react-router-dom';import { Terminal } from '@xterm/xterm';import { FitAddon } from '@xterm/addon-fit';@@ -105,8 +106,7 @@ export function useShellSession({ isFullscreen } = {}) {// Flipped on unmount so deferred work (setTimeout-scheduled recovery attaches)// can short-circuit instead of firing shell:attach from a teardown component —// which would claim a session with no listener left to render it.- const mountedRef = useRef(true);- useEffect(() => () => { mountedRef.current = false; }, []);+ const mountedRef = useMounted();// useCallback for stable identity so consumers can list these in dep arrays without// causing useEffect re-binds on every render. They only touch a ref, so empty deps is correct.const setPendingAttach = useCallback((target) => {diff --git a/client/src/hooks/useUniverseDraft.js b/client/src/hooks/useUniverseDraft.jsindex d36c1858a4..47577368ab 100644--- a/client/src/hooks/useUniverseDraft.js+++ b/client/src/hooks/useUniverseDraft.js@@ -1,4 +1,5 @@import { useCallback, useEffect, useMemo, useRef, useState } from 'react';+import useMounted from './useMounted';import toast from '../components/ui/Toast';import {addUniverseStyleReference,@@ -86,7 +87,7 @@ export default function useUniverseDraft({ selectedId, goToWorld }) {const [newCategoryName, setNewCategoryName] = useState('');const [canonDirty, setCanonDirty] = useState(false);- const mountedRef = useRef(true);+ const mountedRef = useMounted();const draftRef = useRef(null);const savedDraftSnapshotRef = useRef(universeDraftSnapshot(createEmptyUniverseDraft()));const savedStyleSnapshotRef = useRef(ensureInfluences(createEmptyUniverseDraft().influences));@@ -134,7 +135,6 @@ export default function useUniverseDraft({ selectedId, goToWorld }) {lastSeenUpdatedAtRef.current.set(id, updatedAt);}, []);- useEffect(() => () => { mountedRef.current = false; }, []);useEffect(() => { draftRef.current = draft; }, [draft]);const clearPendingCanonAdditions = useCallback(() => {diff --git a/client/src/pages/LocalLlmPlayground.jsx b/client/src/pages/LocalLlmPlayground.jsxindex 549b325b4b..25b8e8684e 100644--- a/client/src/pages/LocalLlmPlayground.jsx+++ b/client/src/pages/LocalLlmPlayground.jsx@@ -1,4 +1,5 @@import { useCallback, useEffect, useMemo, useRef, useState } from 'react';+import useMounted from '../hooks/useMounted';import { Link, useSearchParams } from 'react-router-dom';import { ArrowLeft, ArrowRightLeft, Brain, Check, ChevronDown, Clock, Copy, Cpu, Gauge, MessageSquare, Play, RefreshCw, Send, TriangleAlert, X } from 'lucide-react';import BrailleSpinner from '../components/BrailleSpinner';@@ -242,7 +243,7 @@ export default function LocalLlmPlayground() {// the prompt/controls stay above the fold. Open by default on first load.const [modelsOpen, setModelsOpen] = useState(true);- const mountedRef = useRef(true);+ const mountedRef = useMounted();// Holds the AbortController for the in-flight run so the Cancel button can// abort the client fetch (which closes the server-side stream early). Cleared// in each run's .finally(). Abort the live request on unmount too.@@ -257,7 +258,6 @@ export default function LocalLlmPlayground() {const reasoningBufRef = useRef('');const flushTimerRef = useRef(null);useEffect(() => () => {- mountedRef.current = false;runControllerRef.current?.abort();if (flushTimerRef.current) clearTimeout(flushTimerRef.current);}, []);