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
address review (claude): use the existing useMounted hook — bare useRef(true) dies under StrictMode
Adam Eivyb4cdef417cd4
diff --git a/client/src/components/apps/tabs/UpdateTab.jsx b/client/src/components/apps/tabs/UpdateTab.jsxindex 6e134ce40d..5c3c406fb5 100644--- a/client/src/components/apps/tabs/UpdateTab.jsx+++ b/client/src/components/apps/tabs/UpdateTab.jsx@@ -8,6 +8,7 @@ import * as api from '../../../services/api';import socket from '../../../services/socket';import { formatDateTime } from '../../../utils/formatters';import { useAutoRefetch } from '../../../hooks/useAutoRefetch';+import useMounted from '../../../hooks/useMounted';const STEP_LABELS = {starting: 'Starting update',@@ -50,10 +51,8 @@ export default function UpdateTab() {// unmount (e.g. the user navigates away) while the timer is pending lets// the deferred callback still fire, pop an undismissable "PortOS is// restarting..." toast (duration: Infinity), and set state on an unmounted- // component — nothing is left running to ever dismiss it. Never reset to- // `true`; this only ever needs to flip once, on unmount.- const mountedRef = useRef(true);- useEffect(() => () => { mountedRef.current = false; }, []);+ // component — nothing is left running to ever dismiss it.+ const mountedRef = useMounted();// Tracks whether the health endpoint went down during a restart poll. A// reconcile (issue #1779) often lands the SAME version (new commits, no// release bump), so version-change detection alone can't confirm completion —diff --git a/client/src/components/apps/tabs/UpdateTab.test.jsx b/client/src/components/apps/tabs/UpdateTab.test.jsxindex a420f9ea7d..e189bfb74b 100644--- a/client/src/components/apps/tabs/UpdateTab.test.jsx+++ b/client/src/components/apps/tabs/UpdateTab.test.jsx@@ -1,3 +1,4 @@+import { StrictMode } from 'react';import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';import { act, render, screen, fireEvent, waitFor } from '@testing-library/react';@@ -126,6 +127,26 @@ describe('UpdateTab reconcile flow', () => {expect(mockToast.loading).not.toHaveBeenCalled();});+ it('still confirms a real disconnect under StrictMode (mountedRef survives the dev-mode phantom mount→cleanup→remount)', async () => {+ // React 18 StrictMode (on app-wide in main.jsx) double-invokes effects on+ // mount: mount → cleanup → remount. A mountedRef implemented as a bare+ // `useRef(true)` + cleanup-only effect never resets to `true` on the+ // remount, so it reads permanently `false` for the rest of the+ // component's real lifetime — silently killing the disconnect+ // confirmation fallback in dev mode from the very first render. Plain+ // `render()` doesn't reproduce this; wrap in StrictMode explicitly.+ render(<StrictMode><UpdateTab /></StrictMode>);++ const button = await screen.findByRole('button', { name: 'Reconcile Now' });+ fireEvent.click(button);+ await waitFor(() => expect(screen.getByRole('button', { name: 'Reconciling...' })).toBeTruthy());++ mockCheckHealth.mockResolvedValue(null);+ await fireDisconnectAndConfirm();++ await waitFor(() => expect(screen.getByRole('button', { name: 'Restarting...' })).toBeTruthy());+ });+it('ignores a disconnect that happens while no update is in progress', async () => {render(<UpdateTab />);await screen.findByRole('button', { name: 'Reconcile Now' });