Skip to content

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

fix: show Links unavailable banner with Retry instead of false empty state (#9723)

[._.]/ Adam Eivyce36046d93bd
diff --git a/client/src/components/brain/tabs/LinksTab.jsx b/client/src/components/brain/tabs/LinksTab.jsx
index 2dab4969a7..6a3a11970c 100644
--- a/client/src/components/brain/tabs/LinksTab.jsx
+++ b/client/src/components/brain/tabs/LinksTab.jsx
@@ -32,6 +32,7 @@ import {
} from 'lucide-react';
import BrailleSpinner from '../../BrailleSpinner';
import toast from '../../ui/Toast';
+import Banner from '../../ui/Banner';
import InlineConfirmRow from '../../ui/InlineConfirmRow';
import { timeAgo } from '../../../utils/formatters';
import { sameJsonShape } from '../../../lib/sameJsonShape';
@@ -121,6 +122,8 @@ export default function LinksTab({ onRefresh }) {
const [links, setLinks] = useState([]);
const [buckets, setBuckets] = useState([]);
const [loading, setLoading] = useState(true);
+ // A local action-refresh read (revert after a failed optimistic update) failed.
+ const [actionReadFailed, setActionReadFailed] = useState(false);
const [filter, setFilter] = useState('all'); // all, repo, scanned, other, ungrouped
const [search, setSearch] = useState('');
const [editingId, setEditingId] = useState(null);
@@ -137,8 +140,15 @@ export default function LinksTab({ onRefresh }) {
// from list views, search, and bucket boards). The server schema caps at
// 5000, which is ample headroom for a single-user bookmark collection.
const fetchLinks = useCallback(async () => {
- const data = await api.getBrainLinks({ limit: 5000, silent: true }).catch(() => ({ links: [] }));
- setLinks(data.links || []);
+ // On failure keep the last good snapshot and flag the collection as
+ // unavailable rather than substituting an empty (and authoritative-looking) list.
+ const data = await api.getBrainLinks({ limit: 5000, silent: true }).catch(() => null);
+ if (data) {
+ setLinks(data.links || []);
+ setActionReadFailed(false);
+ } else {
+ setActionReadFailed(true);
+ }
setLoading(false);
}, []);
@@ -159,7 +169,7 @@ export default function LinksTab({ onRefresh }) {
})));
return { updates };
}, []);
- const { data: changes, loading: reading } = useSocketResource(readChanges, {
+ const { data: changes, loading: reading, error: readError, refetch } = useSocketResource(readChanges, {
events: LINK_EVENTS,
matchesEvent: payload => typeof payload?.id === 'string',
compare: sameJsonShape
@@ -194,6 +204,12 @@ export default function LinksTab({ onRefresh }) {
});
}, [changes, reading]);
+ const unavailable = Boolean(readError) || actionReadFailed;
+ const retryRead = () => {
+ if (actionReadFailed) fetchLinks();
+ refetch();
+ };
+
// Client-side filter (type / bucket membership) then keyword search.
const matchesFilter = (link) => {
if (filter === 'repo') return link.isRepo;
@@ -553,6 +569,27 @@ export default function LinksTab({ onRefresh }) {
onDragEnd={handleDragEnd}
onDragCancel={handleDragCancel}
>
+ {unavailable && (
+ <Banner
+ tone="error"
+ icon={AlertCircle}
+ title="Links unavailable"
+ className="mb-4"
+ actions={(
+ <button
+ type="button"
+ onClick={retryRead}
+ className="flex items-center gap-1 px-3 py-1.5 min-h-[40px] rounded border border-port-error/40 text-port-error hover:bg-port-error/10 text-xs"
+ >
+ <RefreshCw size={12} /> Retry
+ </button>
+ )}
+ >
+ {links.length > 0 || buckets.length > 0
+ ? 'Could not refresh your saved links. The list below may be out of date.'
+ : 'Could not load your saved links. This does not mean the collection is empty.'}
+ </Banner>
+ )}
<div className="grid grid-cols-1 lg:grid-cols-[minmax(0,1fr)_minmax(340px,440px)] gap-6 items-start">
{/* Left column: entry form, filters, and the full link list */}
<div className="min-w-0 flex flex-col">
@@ -1078,7 +1115,7 @@ export default function LinksTab({ onRefresh }) {
</div>
)}
- {links.length === 0 && (
+ {links.length === 0 && !unavailable && (
<div className="text-center py-12 text-gray-500">
<Link2 className="w-12 h-12 mx-auto mb-3 opacity-30" />
<p>No links saved yet.</p>
diff --git a/client/src/components/brain/tabs/LinksTab.test.jsx b/client/src/components/brain/tabs/LinksTab.test.jsx
index c330229529..2220be4ee1 100644
--- a/client/src/components/brain/tabs/LinksTab.test.jsx
+++ b/client/src/components/brain/tabs/LinksTab.test.jsx
@@ -400,3 +400,39 @@ describe('LinksTab drag-and-drop wiring', () => {
expect(message).toBe('Alpha was dropped outside a valid destination and did not move.');
});
});
+
+describe('LinksTab unavailable collection', () => {
+ const failure = () => Object.assign(new Error('boom'), { status: 500 });
+
+ it('shows Links unavailable with Retry instead of the empty state, then recovers', async () => {
+ getBrainLinks.mockRejectedValueOnce(failure());
+ await renderTab();
+ expect(screen.getByText('Links unavailable')).toBeTruthy();
+ expect(screen.queryByText('No links saved yet.')).toBeNull();
+ getBrainLinks.mockResolvedValue({ links: [link('a', 'cloned')] });
+ await act(async () => { fireEvent.click(screen.getByRole('button', { name: /Retry/ })); });
+ await act(async () => { await Promise.resolve(); await Promise.resolve(); });
+ expect(screen.queryByText('Links unavailable')).toBeNull();
+ expect(screen.getByText('repo-a')).toBeTruthy();
+ });
+
+ it('keeps the paste-a-URL onboarding for a successful empty read', async () => {
+ getBrainLinks.mockResolvedValue({ links: [] });
+ await renderTab();
+ expect(screen.queryByText('Links unavailable')).toBeNull();
+ expect(screen.getByText('No links saved yet.')).toBeTruthy();
+ });
+
+ it('preserves prior links and search when a refresh read fails', async () => {
+ getBrainLinks.mockResolvedValueOnce({ links: [link('a', 'cloned'), link('b', 'cloned')] });
+ await renderTab();
+ fireEvent.change(screen.getByPlaceholderText(/Search links/), { target: { value: 'repo-a' } });
+ getBrainLinks.mockRejectedValue(failure());
+ await act(async () => { socket.emit('connect'); });
+ await act(async () => { await Promise.resolve(); await Promise.resolve(); });
+ expect(screen.getByText('Links unavailable')).toBeTruthy();
+ expect(screen.getByText(/may be out of date/)).toBeTruthy();
+ expect(screen.getByText('repo-a')).toBeTruthy();
+ expect(screen.getByPlaceholderText(/Search links/).value).toBe('repo-a');
+ });
+});