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: clear the out-of-sync banner when reconciling and guard post-unmount/ignored-version updates (#3786)
[._.]/ Adam Eivy865ec2ab658d
diff --git a/client/src/components/UpdateBanners.jsx b/client/src/components/UpdateBanners.jsxindex c2296c4c52..ba043e72d8 100644--- a/client/src/components/UpdateBanners.jsx+++ b/client/src/components/UpdateBanners.jsx@@ -9,7 +9,9 @@ import * as api from '../services/api';// push the page down instead of floating over a bottom-anchored composer.export default function UpdateBanners() {const navigate = useNavigate();- const { update, outOfSync, ignoreUpdate, dismissUpdate, dismissOutOfSync } = useUpdateChecker();+ const {+ update, outOfSync, ignoreUpdate, dismissUpdate, clearOutOfSync, dismissOutOfSync+ } = useUpdateChecker();if (!update && !outOfSync) return null;@@ -27,7 +29,7 @@ export default function UpdateBanners() {<div className="flex gap-2"><buttontype="button"- onClick={goToUpdate}+ onClick={() => { clearOutOfSync(); goToUpdate(); }}className="px-2 py-1 bg-port-warning text-black text-xs rounded hover:bg-port-warning/80">Reconcilediff --git a/client/src/components/UpdateBanners.test.jsx b/client/src/components/UpdateBanners.test.jsxindex e57804ac68..35c6114727 100644--- a/client/src/components/UpdateBanners.test.jsx+++ b/client/src/components/UpdateBanners.test.jsx@@ -85,6 +85,37 @@ describe('UpdateBanners', () => {expect(screen.queryByText(/Install out of sync/)).toBeNull();});+ it('Reconcile navigates and clears the advisory for this session only', async () => {+ getUpdateStatus.mockResolvedValue({+ installState: { outOfSync: true, currentCommit: 'abc123' }+ });+ renderBanners();+ fireEvent.click(await screen.findByRole('button', { name: 'Reconcile' }));+ expect(navigate).toHaveBeenCalledWith('/apps/portos-default/update');+ // Cleared so it doesn't hover over the very page you reconcile from…+ await waitFor(() => expect(screen.queryByText(/Install out of sync/)).toBeNull());+ // …but NOT marked handled: the install is still out of sync until update.sh runs.+ expect(localStorage.getItem(__internal.OUT_OF_SYNC_DISMISS_KEY)).toBeNull();+ cleanup();+ renderBanners();+ expect(await screen.findByText(/Install out of sync/)).toBeTruthy();+ });++ it('does not re-raise an ignored version from a racing socket broadcast', async () => {+ getUpdateStatus.mockResolvedValue({+ updateAvailable: true,+ currentVersion: '1.0.0',+ latestRelease: { version: '1.1.0' }+ });+ renderBanners();+ fireEvent.click(await screen.findByRole('button', { name: 'Ignore' }));+ await waitFor(() => expect(screen.queryByText(/Update available/)).toBeNull());+ act(() => {+ handlers.get('portos:update:available')?.({ currentVersion: '1.0.0', latestVersion: '1.1.0' });+ });+ expect(screen.queryByText(/Update available/)).toBeNull();+ });+it('re-raises out-of-sync after a later pull moves the commit', async () => {localStorage.setItem(__internal.OUT_OF_SYNC_DISMISS_KEY, 'abc123');getUpdateStatus.mockResolvedValue({diff --git a/client/src/hooks/README.md b/client/src/hooks/README.mdindex e52c39b63f..5789a0c704 100644--- a/client/src/hooks/README.md+++ b/client/src/hooks/README.md@@ -76,7 +76,7 @@ grep -i "what you want to do" client/src/hooks/README.md|---|---|---|| `useSocket` | Shared socket instance + connection status. | You need to subscribe to a socket event. || `useShellSession` | All Socket.IO `shell:*` session/terminal state + lifecycle for the Shell page: owns the xterm instance, the attach/detach/generation-guard contract (`pendingAttachRef {target,generation}`, `claim`, `userIdleRef`, `mountedRef`), URL sync, and every session action. Returns `{ terminalRef, connected, sessions, activeSessionId, activeSession, interactiveCount, liveRunCount, isLiveRun, emitShellInput, sendImage, sendCommand, sendCtrlB, sendCtrlC, sendNavKey, restartSession, stopSession, startNewSession, switchToSession, killOtherSession }` so the route stays presentational. `sendImage(file, message)` is the one operation that leaves the socket — it POSTs to `/api/shell/sessions/:id/image` so a running agent TUI gets the photo's path pasted into its prompt. | The Shell page (`pages/Shell.jsx`) — don't re-roll the single-subscriber PTY attach lifecycle. |-| `useUpdateChecker` | Update-available + install-out-of-sync advisories as *state* (`{ update, outOfSync, ignoreUpdate, dismissUpdate, dismissOutOfSync }`), never toasts — a non-transient advisory must not occlude the screen's primary action (#3786). Out-of-sync dismissals persist per on-disk commit in `safeStorage`, so a later `git pull` re-raises. | Wire once at app root; render via `components/UpdateBanners`. |+| `useUpdateChecker` | Update-available + install-out-of-sync advisories as *state* (`{ update, outOfSync, ignoreUpdate, dismissUpdate, clearOutOfSync, dismissOutOfSync }`), never toasts — a non-transient advisory must not occlude the screen's primary action (#3786). Out-of-sync dismissals persist per on-disk commit in `safeStorage`, so a later `git pull` re-raises; `clearOutOfSync` is the session-only clear used when the user acts on it. | Never call it directly — `components/UpdateBanners` owns the single instance and Layout renders that once at the app root. A second caller means a second status fetch and socket subscription. || `useMounted` | `mountedRef` whose `.current` is true while mounted. | Async deferred work that must abort on unmount. || `usePrevious` | Returns the value from the previous render — snapshot updated in a `useEffect`. | Compare-and-act on prop/state change from inside a `useEffect`. || `usePreviousSync` | Same shape, but snapshot updated *during* render. | The prior value gates an in-render `setState` (React's "adjusting state on prop change" pattern); the during-render update avoids an extra discard/rerun cycle. |diff --git a/client/src/hooks/useUpdateChecker.jsx b/client/src/hooks/useUpdateChecker.jsxindex 6d3e9f96f7..7a2b661ca3 100644--- a/client/src/hooks/useUpdateChecker.jsx+++ b/client/src/hooks/useUpdateChecker.jsx@@ -1,5 +1,6 @@-import { useCallback, useEffect, useState } from 'react';+import { useCallback, useEffect, useRef, useState } from 'react';import { safeReadStorage, safeWriteStorage } from '../lib/safeStorage';+import useMounted from './useMounted';import socket from '../services/socket';import * as api from '../services/api';@@ -21,18 +22,27 @@ const dismissedCommit = () => safeReadStorage(OUT_OF_SYNC_DISMISS_KEY);* `duration: Infinity` corner toast sat permanently on top of bottom-anchored* composers and submit buttons.*- * Returns `{ update, outOfSync, ignoreUpdate, dismissUpdate, dismissOutOfSync }`.+ * Returns `{ update, outOfSync, ignoreUpdate, dismissUpdate, clearOutOfSync,+ * dismissOutOfSync }`.*/export function useUpdateChecker() {const [update, setUpdate] = useState(null);const [outOfSync, setOutOfSync] = useState(null);+ const mountedRef = useMounted();+ // Versions ignored in THIS session. The server already withholds the+ // `update:available` broadcast for an ignored version, but the ignore POST is+ // in flight while a poll may already be mid-emit — this keeps a just-ignored+ // version from flashing back in on that race.+ const ignoredRef = useRef(new Set());useEffect(() => {const onUpdateAvailable = (data) => {+ if (!mountedRef.current || ignoredRef.current.has(data.latestVersion)) return;setUpdate({ currentVersion: data.currentVersion, latestVersion: data.latestVersion });};api.getUpdateStatus().then(status => {+ if (!mountedRef.current) return;if (status.updateAvailable && status.latestRelease) {onUpdateAvailable({currentVersion: status.currentVersion,@@ -60,18 +70,26 @@ export function useUpdateChecker() {// "Ignore" is durable server-side (this version never re-raises); "dismiss"// only clears it for this session.const ignoreUpdate = useCallback(() => {- if (update) api.ignoreUpdateVersion(update.latestVersion).catch(() => null);+ if (update) {+ ignoredRef.current.add(update.latestVersion);+ api.ignoreUpdateVersion(update.latestVersion).catch(() => null);+ }setUpdate(null);}, [update]);const dismissUpdate = useCallback(() => setUpdate(null), []);+ // Acting on the advisory (navigating to the update page) clears it for this+ // session only — the install IS still out of sync until update.sh runs, so it+ // must come back on the next load rather than being marked handled.+ const clearOutOfSync = useCallback(() => setOutOfSync(null), []);+const dismissOutOfSync = useCallback(() => {if (outOfSync) safeWriteStorage(OUT_OF_SYNC_DISMISS_KEY, outOfSync.commit);setOutOfSync(null);}, [outOfSync]);- return { update, outOfSync, ignoreUpdate, dismissUpdate, dismissOutOfSync };+ return { update, outOfSync, ignoreUpdate, dismissUpdate, clearOutOfSync, dismissOutOfSync };}export const __internal = { OUT_OF_SYNC_DISMISS_KEY };