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
Show sharing load failures instead of empty states (#11705)
[._.]/687cf4a26361
diff --git a/client/src/components/sharing/ConflictsTab.jsx b/client/src/components/sharing/ConflictsTab.jsxindex 06f17e7331..e4bf7b5ce7 100644--- a/client/src/components/sharing/ConflictsTab.jsx+++ b/client/src/components/sharing/ConflictsTab.jsx@@ -10,6 +10,7 @@ import { Loader2, GitMerge, RotateCcw, Trash2, ChevronDown, ChevronRight } fromimport toast from '../ui/Toast';import InlineDiff from '../ui/InlineDiff';import { listConflicts, resolveConflict, deleteConflict } from '../../services/api';+import LoadFailedState from '../ui/LoadFailedState';const asText = (v) => {if (v === null || v === undefined) return '';@@ -18,7 +19,7 @@ const asText = (v) => {export default function ConflictsTab() {const [loading, setLoading] = useState(true);- const [conflicts, setConflicts] = useState([]);+ const [conflicts, setConflicts] = useState(null);// #7260 — when the server reports the sync base-hash store as unreadable,// detection is running fail-closed (every overwrite journals) but nothing// persists. Show it so an empty list can't read as "no conflicts".@@ -26,9 +27,11 @@ export default function ConflictsTab() {const load = useCallback(async () => {setLoading(true);- const res = await listConflicts('pending', { silent: true }).catch(() => ({ conflicts: [] }));- setConflicts(res.conflicts || []);- setDegraded(res.conflictDetection?.degraded ? res.conflictDetection : null);+ const result = await listConflicts('pending', { silent: true })+ .then((res) => ({ res: Array.isArray(res?.conflicts) ? res : null }))+ .catch(() => ({ res: null }));+ setConflicts(result.res?.conflicts ?? null);+ setDegraded(result.res?.conflictDetection?.degraded ? result.res.conflictDetection : null);setLoading(false);}, []);@@ -40,6 +43,7 @@ export default function ConflictsTab() {return (<div className="space-y-4">+ {conflicts === null && <LoadFailedState title="Could not load pending conflicts." hint="Retry to try again." onRetry={load} />}{degraded && (<div className="bg-port-warning/10 border border-port-warning/40 rounded-lg px-3 py-2 text-sm text-port-warning">⚠️ Conflict detection is degraded — {degraded.reason || 'the sync base-hash store is unreadable'}. Overwrites are still archived here fail-closed.@@ -49,10 +53,10 @@ export default function ConflictsTab() {When two machines edited the same record, sync keeps the newest by timestamp — but the overwritten version isarchived here so nothing is lost. Restore yours, merge back specific fields, or discard.</p>- {conflicts.length === 0 ? (+ {conflicts?.length === 0 ? (<div className="text-sm text-gray-500 py-8 text-center border border-port-border rounded-lg">✓ No pending conflicts.</div>) : (- conflicts.map((c) => <ConflictEntry key={c.id} entry={c} onResolved={load} />)+ conflicts?.map((c) => <ConflictEntry key={c.id} entry={c} onResolved={load} />))}</div>);diff --git a/client/src/components/sharing/ConflictsTab.test.jsx b/client/src/components/sharing/ConflictsTab.test.jsxindex 529e2976cb..0e32ea8e66 100644--- a/client/src/components/sharing/ConflictsTab.test.jsx+++ b/client/src/components/sharing/ConflictsTab.test.jsx@@ -32,6 +32,32 @@ beforeEach(() => {});describe('ConflictsTab', () => {+ it('shows a retryable load failure and does not claim the queue is empty', async () => {+ api.listConflicts.mockRejectedValueOnce(new Error('journal unavailable'));+ const user = userEvent.setup();+ render(<ConflictsTab />);+ expect(await screen.findByRole('alert')).toHaveTextContent('Could not load pending conflicts.');+ expect(screen.queryByText(/No pending conflicts/)).not.toBeInTheDocument();++ await user.click(screen.getByRole('button', { name: 'Retry' }));+ expect(await screen.findByText(/2 field\(s\)/)).toBeInTheDocument();+ expect(api.listConflicts).toHaveBeenCalledTimes(2);+ });++ it('shows the existing empty copy after a successful empty response', async () => {+ api.listConflicts.mockResolvedValue({ conflicts: [] });+ render(<ConflictsTab />);+ expect(await screen.findByText(/No pending conflicts/)).toBeInTheDocument();+ expect(screen.queryByRole('alert')).not.toBeInTheDocument();+ });++ it('treats a malformed successful payload as a load failure', async () => {+ api.listConflicts.mockResolvedValue({});+ render(<ConflictsTab />);+ expect(await screen.findByRole('alert')).toHaveTextContent('Could not load pending conflicts.');+ expect(screen.queryByText(/No pending conflicts/)).not.toBeInTheDocument();+ });+it('shows the degraded-detection banner when the base-hash store is latched (#7260)', async () => {api.listConflicts.mockResolvedValue({conflicts: [],diff --git a/client/src/components/sharing/DuplicatesTab.jsx b/client/src/components/sharing/DuplicatesTab.jsxindex 25511c1e61..c4a047ca61 100644--- a/client/src/components/sharing/DuplicatesTab.jsx+++ b/client/src/components/sharing/DuplicatesTab.jsx@@ -13,25 +13,30 @@ import { useEffect, useState, useCallback } from 'react';import { Loader2 } from 'lucide-react';import { listUniverseDuplicates, listSeriesDuplicates } from '../../services/api';import { useRecordMerge } from '../../hooks/useRecordMerge';+import LoadFailedState from '../ui/LoadFailedState';import DuplicateGroup from './DuplicateGroup';import MergeModal from './MergeModal';export default function DuplicatesTab() {const [loading, setLoading] = useState(true);- const [universeGroups, setUniverseGroups] = useState([]);- const [seriesGroups, setSeriesGroups] = useState([]);+ const [universeGroups, setUniverseGroups] = useState(null);+ const [seriesGroups, setSeriesGroups] = useState(null);const [orphanCount, setOrphanCount] = useState(0);const [dismissed, setDismissed] = useState(() => new Set());const load = useCallback(async () => {setLoading(true);const [uni, ser] = await Promise.all([- listUniverseDuplicates({ silent: true }).catch(() => ({ groups: [] })),- listSeriesDuplicates({ silent: true }).catch(() => ({ series: [], orphanCount: 0 })),+ listUniverseDuplicates({ silent: true })+ .then((value) => ({ value: Array.isArray(value?.groups) ? value : null }))+ .catch(() => ({ value: null })),+ listSeriesDuplicates({ silent: true })+ .then((value) => ({ value: Array.isArray(value?.series) ? value : null }))+ .catch(() => ({ value: null })),]);- setUniverseGroups(uni.groups || []);- setSeriesGroups(ser.series || []);- setOrphanCount(ser.orphanCount || 0);+ setUniverseGroups(uni.value?.groups ?? null);+ setSeriesGroups(ser.value?.series ?? null);+ setOrphanCount(ser.value?.orphanCount || 0);setLoading(false);}, []);@@ -45,9 +50,10 @@ export default function DuplicatesTab() {return <div className="flex items-center gap-2 text-gray-400 text-sm py-8"><Loader2 className="animate-spin" size={16} /> Scanning for duplicates…</div>;}- const visibleUniverse = universeGroups.filter((g) => !dismissed.has(groupKey('universe', g.normalizedName)));- const visibleSeries = seriesGroups.filter((g) => !dismissed.has(groupKey('series', g.normalizedName, g.universeId)));+ const visibleUniverse = (universeGroups || []).filter((g) => !dismissed.has(groupKey('universe', g.normalizedName)));+ const visibleSeries = (seriesGroups || []).filter((g) => !dismissed.has(groupKey('series', g.normalizedName, g.universeId)));const nothing = visibleUniverse.length === 0 && visibleSeries.length === 0;+ const failed = universeGroups === null || seriesGroups === null;return (<div className="space-y-6">@@ -56,7 +62,9 @@ export default function DuplicatesTab() {“Clandestiny”). Merge folds one into the other (unioning canon, re-pointing children) or rename one to keep both.</p>- {nothing && (+ {universeGroups === null && <LoadFailedState title="Could not load universe duplicates." hint="Retry to try again." onRetry={load} />}+ {seriesGroups === null && <LoadFailedState title="Could not load series duplicates." hint="Retry to try again." onRetry={load} />}+ {nothing && !failed && (<div className="text-sm text-gray-500 py-8 text-center border border-port-border rounded-lg">✓ No duplicates found.{orphanCount > 0 && <div className="mt-1 text-xs text-port-warning">{orphanCount} orphan series (no universe) — they’ll be adopted on next migration.</div>}diff --git a/client/src/components/sharing/DuplicatesTab.test.jsx b/client/src/components/sharing/DuplicatesTab.test.jsxindex 9862052d24..7007f0a46a 100644--- a/client/src/components/sharing/DuplicatesTab.test.jsx+++ b/client/src/components/sharing/DuplicatesTab.test.jsx@@ -37,6 +37,44 @@ beforeEach(() => {});describe('DuplicatesTab', () => {+ it('shows a section-specific retry when universe duplicate loading fails', async () => {+ api.listUniverseDuplicates.mockRejectedValueOnce(new Error('unavailable'));+ api.listSeriesDuplicates.mockResolvedValue({ series: [], orphanCount: 0 });+ const user = userEvent.setup();+ render(<DuplicatesTab />);+ expect(await screen.findByText('Could not load universe duplicates.')).toBeInTheDocument();+ expect(screen.queryByText(/No duplicates found/)).not.toBeInTheDocument();+ await user.click(screen.getByRole('button', { name: 'Retry' }));+ expect(await screen.findByText(/2 copies/)).toBeInTheDocument();+ });++ it('shows a section-specific retry when series duplicate loading fails', async () => {+ api.listUniverseDuplicates.mockResolvedValue({ groups: [] });+ api.listSeriesDuplicates.mockRejectedValueOnce(new Error('unavailable'));+ render(<DuplicatesTab />);+ expect(await screen.findByText('Could not load series duplicates.')).toBeInTheDocument();+ expect(screen.queryByText(/No duplicates found/)).not.toBeInTheDocument();+ });++ it('shows the existing empty copy after both requests succeed empty', async () => {+ api.listUniverseDuplicates.mockResolvedValue({ groups: [] });+ api.listSeriesDuplicates.mockResolvedValue({ series: [], orphanCount: 0 });+ render(<DuplicatesTab />);+ expect(await screen.findByText(/No duplicates found/)).toBeInTheDocument();+ expect(screen.queryByRole('alert')).not.toBeInTheDocument();+ });++ it.each([+ ['universe', () => api.listUniverseDuplicates.mockResolvedValue({}), () => api.listSeriesDuplicates.mockResolvedValue({ series: [], orphanCount: 0 })],+ ['series', () => api.listUniverseDuplicates.mockResolvedValue({ groups: [] }), () => api.listSeriesDuplicates.mockResolvedValue({})],+ ])('treats a malformed successful %s payload as a section failure', async (_section, setUniverse, setSeries) => {+ setUniverse();+ setSeries();+ render(<DuplicatesTab />);+ expect(await screen.findByRole('alert')).toHaveTextContent(`Could not load ${_section} duplicates.`);+ expect(screen.queryByText(/No duplicates found/)).not.toBeInTheDocument();+ });+it('lists a universe duplicate group with both records', async () => {render(<DuplicatesTab />);await waitFor(() => expect(screen.getByText(/2 copies/)).toBeInTheDocument());