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: recover unavailable Instances snapshots with explicit retry (#9448)
[._.]/ Adam Eivyceaa5b007547
diff --git a/client/src/pages/Instances.jsx b/client/src/pages/Instances.jsxindex bdaf4bc7b0..937f83c096 100644--- a/client/src/pages/Instances.jsx+++ b/client/src/pages/Instances.jsx@@ -1571,13 +1571,23 @@ function InstancesContent() {// card needs a slice of it. Running a check is on-demand per card.const [parityReports, setParityReports] = useState({});const [loading, setLoading] = useState(true);+ const [snapshotError, setSnapshotError] = useState(false);+ const [snapshotLoaded, setSnapshotLoaded] = useState(false);+ const [snapshotLoading, setSnapshotLoading] = useState(false);+ const snapshotRequest = useRef(0);const fetchData = useCallback(async () => {- const data = await getInstances().catch(() => null);+ const request = ++snapshotRequest.current;+ setSnapshotLoading(true);+ const data = await getInstances({ silent: true }).catch(() => null);+ if (request !== snapshotRequest.current) return;+ setSnapshotLoading(false);+ setSnapshotError(!data);if (data) {setSelf(data.self);setPeers(data.peers);setSyncStatus(data.syncStatus ?? null);+ setSnapshotLoaded(true);}}, []);@@ -1609,6 +1619,7 @@ function InstancesContent() {return () => {active = false;+ snapshotRequest.current += 1;socket.off('instances:peers:updated', handlePeersUpdated);};}, [fetchData]);@@ -1662,6 +1673,15 @@ function InstancesContent() {<span>{networkExposure?.setup?.complete ? 'Tailscale HTTPS ready' : 'Network setup available'}</span><span>{peers.filter((peer) => peer.status === 'online').length} / {peers.length} peers online</span></div>+ {snapshotError && (+ <div role="alert" className="rounded-lg border border-port-warning/40 p-3 text-sm text-port-warning">+ <p>{snapshotLoaded ? 'Instance snapshot unavailable. Showing last loaded data.' : 'Instance snapshot unavailable. Peer and instance settings could not be loaded.'}</p>+ <button type="button" onClick={fetchData} disabled={snapshotLoading}+ className="mt-2 min-h-[44px] rounded-lg border border-port-border px-3 disabled:opacity-50">+ {snapshotLoading ? 'Retrying snapshot…' : 'Retry snapshot'}+ </button>+ </div>+ )}{(orphanCount > 0 || serveStatus?.status === 'failed') && (<button type="button" onClick={() => openDrawer('settings', 'relay')}className="block w-full rounded-lg border border-port-warning/40 p-3 text-left text-sm text-port-warning">@@ -1699,7 +1719,7 @@ function InstancesContent() {</div>)}- {peers.length === 0 && (+ {snapshotLoaded && !snapshotError && peers.length === 0 && (<EmptyStateicon={Network}title="No peers registered yet"@@ -1721,6 +1741,15 @@ function InstancesContent() {activeTab={settingsTab} onTabChange={setSettingsTab}>{settingsTab === 'instance' && (<div className="space-y-4">+ {!self && (+ <div className="rounded-lg border border-port-warning/40 p-3 text-sm text-port-warning">+ <p>This instance settings are unavailable until the instance snapshot loads.</p>+ <button type="button" onClick={fetchData} disabled={snapshotLoading}+ className="mt-2 min-h-[44px] rounded-lg border border-port-border px-3 disabled:opacity-50">+ {snapshotLoading ? 'Retrying snapshot…' : 'Retry instance settings'}+ </button>+ </div>+ )}<SelfCard self={self} onUpdate={fetchData} syncStatus={syncStatus} tailnetInfo={tailnetInfo}editing={editingSelf} setEditing={setEditingSelf} name={selfName} setName={setSelfName} /><BrainParitySchedule />diff --git a/client/src/pages/Instances.test.jsx b/client/src/pages/Instances.test.jsxindex 009ee8c027..ccb3f12f27 100644--- a/client/src/pages/Instances.test.jsx+++ b/client/src/pages/Instances.test.jsx@@ -358,6 +358,34 @@ describe('Instances page connection drawers', () => {api.listPeerSubscriptions.mockResolvedValue({ subscriptions: [] });});+ it('recovers an unavailable snapshot through the drawer and preserves data on refresh failure', async () => {+ api.getInstances.mockRejectedValueOnce(new Error('Unavailable'));+ renderUI(<MemoryRouter><Instances /></MemoryRouter>);+ expect(await screen.findByRole('alert')).toHaveTextContent('Instance snapshot unavailable');+ expect(screen.queryByText('No peers registered yet')).not.toBeInTheDocument();+ fireEvent.click(screen.getByRole('button', { name: 'Connection settings' }));+ expect(screen.getByText('This instance settings are unavailable until the instance snapshot loads.')).toBeInTheDocument();+ const updatePeers = socket.on.mock.calls.find(([event]) => event === 'instances:peers:updated')[1];+ act(() => updatePeers([]));+ expect(screen.getByRole('alert')).toBeInTheDocument();+ fireEvent.click(screen.getByRole('button', { name: 'Retry instance settings' }));+ expect(await within(screen.getByRole('dialog')).findByRole('button', { name: 'Edit', exact: true })).toBeEnabled();+ expect(screen.queryByRole('alert')).not.toBeInTheDocument();+ expect(screen.getByRole('button', { name: 'Sync now' })).toBeEnabled();+ expect(api.getInstances).toHaveBeenLastCalledWith({ silent: true });+ api.getInstances.mockRejectedValueOnce(new Error('Refresh failed'));+ const connectHandler = socket.on.mock.calls.find(([event]) => event === 'connect')[1];+ await act(async () => connectHandler());+ expect(await screen.findByRole('alert')).toHaveTextContent('Showing last loaded data');+ expect(screen.getByRole('button', { name: 'Sync now' })).toBeEnabled();+ expect(within(screen.getByRole('dialog')).getByRole('button', { name: 'Edit', exact: true })).toBeEnabled();+ api.getInstances.mockResolvedValueOnce({ self: { name: 'Recovered' }, peers: [], syncStatus: { cursors: {} } });+ fireEvent.click(screen.getByRole('button', { name: 'Retry snapshot' }));+ expect(await screen.findByText('No peers registered yet')).toBeInTheDocument();+ expect(screen.queryByRole('alert')).not.toBeInTheDocument();+ expect(screen.getAllByText('Recovered').length).toBeGreaterThan(0);+ });+// Regression: the full setup stack displaced peer actions, and moving it to// remounting drawers could discard drafts or accidentally start networking.it('prioritizes peers and retains drafts across drawer sections and failed adds', async () => {