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: reconcile ambiguous erasure responses without retrying deletion
[._.]/ Adam Eivy69c7e3c82d47
diff --git a/client/src/components/timeline/ManageImportedDataPanel.jsx b/client/src/components/timeline/ManageImportedDataPanel.jsxindex 70f5be0658..471c734c62 100644--- a/client/src/components/timeline/ManageImportedDataPanel.jsx+++ b/client/src/components/timeline/ManageImportedDataPanel.jsx@@ -3,6 +3,7 @@ import { Trash2, Loader2 } from 'lucide-react';import * as api from '../../services/api';import toast from '../ui/Toast';import CollapsibleListItem from '../ui/CollapsibleListItem';+import useMounted from '../../hooks/useMounted';import { formatCount, formatDateNumeric } from '../../utils/formatters';// Per-source counts with a typed-confirmation erase (#12987). Deleting is@@ -18,6 +19,7 @@ export default function ManageImportedDataPanel({ reloadKey, onChanged }) {const [removing, setRemoving] = useState(null);const pending = useRef(false);const generation = useRef(0);+ const mounted = useMounted();useEffect(() => {let active = true;@@ -42,8 +44,27 @@ export default function ManageImportedDataPanel({ reloadKey, onChanged }) {setBusy(true);setError(null);const result = await api.eraseTimelineSource(source, { silent: true })- .catch((err) => { setError(err.message || 'Could not delete imported data.'); return null; });+ .catch(async (err) => {+ if (!mounted.current) return null;+ setError(err.message || 'Could not delete imported data.');+ // A lost acknowledgement can follow a committed delete. Re-read once;+ // never repeat the mutation or turn an unavailable read into absence.+ const current = ++generation.current;+ const fresh = await api.getTimelineSources({ silent: true }).catch(() => null);+ if (!mounted.current || generation.current !== current || !Array.isArray(fresh?.sources)) return null;+ if (fresh.sources.some(row => row.source === source)) setSources(fresh.sources);+ else {+ const next = [...fresh.sources];+ const index = sources.findIndex(row => row.source === source);+ if (index !== -1) next.splice(Math.min(index, next.length), 0, sources[index]);+ setSources(next);+ setRemoving(source);+ cancel();+ }+ return null;+ });pending.current = false;+ if (!mounted.current) return;setBusy(false);if (!result) return;toast.success(`Deleted ${formatCount(result.deleted)} ${source} event(s)`);diff --git a/client/src/components/timeline/ManageImportedDataPanel.test.jsx b/client/src/components/timeline/ManageImportedDataPanel.test.jsxindex 4b88a30bc2..18d957c10c 100644--- a/client/src/components/timeline/ManageImportedDataPanel.test.jsx+++ b/client/src/components/timeline/ManageImportedDataPanel.test.jsx@@ -47,15 +47,33 @@ it('retains the row and confirmation and shows a refused deletion', async () =>const onChanged = vi.fn();render(<ManageImportedDataPanel onChanged={onChanged} />);await screen.findByText('browser');+ api.getTimelineSources.mockResolvedValueOnce({ sources: [{ source: 'browser', eventCount: 1 }, sources[1]] });fireEvent.click(screen.getAllByRole('button', { name: 'Delete' })[0]);fireEvent.change(screen.getByRole('textbox'), { target: { value: 'browser' } });fireEvent.click(screen.getByRole('button', { name: 'Confirm delete' }));expect(await screen.findByRole('alert')).toHaveTextContent('Deletion unavailable');expect(screen.getByRole('textbox')).toHaveValue('browser');+ expect(screen.getByText(/to delete all 1 events/)).toBeInTheDocument();expect(screen.getByRole('button', { name: 'Confirm delete' })).toBeEnabled();expect(onChanged).not.toHaveBeenCalled();});+it('reconciles a lost delete acknowledgement from a fresh read without repeating the mutation', async () => {+ const onChanged = vi.fn();+ api.eraseTimelineSource.mockRejectedValueOnce(new Error('Response lost'));+ render(<ManageImportedDataPanel onChanged={onChanged} />);+ await screen.findByText('browser');+ api.getTimelineSources.mockResolvedValueOnce({ sources: [sources[1]] });+ fireEvent.click(screen.getAllByRole('button', { name: 'Delete' })[0]);+ fireEvent.change(screen.getByRole('textbox'), { target: { value: 'browser' } });+ fireEvent.click(screen.getByRole('button', { name: 'Confirm delete' }));+ await waitFor(() => expect(screen.queryByText('browser')).not.toBeInTheDocument());+ expect(screen.getByText('discord')).toBeInTheDocument();+ expect(screen.getByRole('alert')).toHaveTextContent('Response lost');+ expect(api.eraseTimelineSource).toHaveBeenCalledTimes(1);+ expect(onChanged).toHaveBeenCalledTimes(1);+});+it('shows a failed source-count read instead of hiding the management panel', async () => {api.getTimelineSources.mockRejectedValueOnce(new Error('Sources unavailable'));render(<ManageImportedDataPanel />);diff --git a/client/src/pages/Timeline.jsx b/client/src/pages/Timeline.jsxindex 0907a21f9b..a5e8f5e413 100644--- a/client/src/pages/Timeline.jsx+++ b/client/src/pages/Timeline.jsx@@ -251,7 +251,7 @@ export default function Timeline() {))}</div>- {loading ? (+ {loading && !day ? (<PageSkeleton header="none" label="Loading timeline" cards={4} sidebar={false} />) : events.length === 0 ? (<div className="rounded border border-dashed border-port-border py-12 text-center text-gray-500">diff --git a/client/src/pages/Timeline.test.jsx b/client/src/pages/Timeline.test.jsxindex 2d3de66593..b607e92a25 100644--- a/client/src/pages/Timeline.test.jsx+++ b/client/src/pages/Timeline.test.jsx@@ -1,5 +1,5 @@import { describe, it, expect, vi } from 'vitest';-import { act, render, screen, fireEvent } from '@testing-library/react';+import { act, render, screen, fireEvent, waitFor } from '@testing-library/react';import { MemoryRouter } from 'react-router';vi.mock('../services/api', () => ({@@ -72,6 +72,32 @@ describe('Timeline import-history disclosure (#3789)', () => {});describe('Timeline bounded event page (#11151)', () => {+ it('retains the populated day while a confirmed source deletion refreshes its counts', async () => {+ const empty = {+ date: '2026-01-02', today: '2026-01-02', events: [],+ counts: { total: 0, bySource: {}, byKind: {} }, histogram: [],+ };+ let finishRefresh;+ api.getTimelineDay.mockResolvedValueOnce({+ ...empty,+ events: [{ id: 'imported', source: 'browser', kind: 'web.visit', happenedAt: '2026-01-02T12:00:00Z', title: 'Imported event' }],+ counts: { total: 1, bySource: { browser: 1 }, byKind: { 'web.visit': 1 } },+ }).mockImplementationOnce(() => new Promise(resolve => { finishRefresh = resolve; }));+ api.getTimelineSources.mockResolvedValueOnce({ sources: [{ source: 'browser', eventCount: 1 }] });+ api.eraseTimelineSource.mockResolvedValueOnce({ deleted: 1 });+ await renderPage();+ await screen.findByText('Imported event');+ fireEvent.click(screen.getByRole('button', { name: `Import history (${IMPORT_SOURCE_COUNT})` }));+ fireEvent.click(await screen.findByRole('button', { name: 'Delete' }));+ fireEvent.change(screen.getByRole('textbox'), { target: { value: 'browser' } });+ fireEvent.click(screen.getByRole('button', { name: 'Confirm delete' }));+ await waitFor(() => expect(finishRefresh).toBeTypeOf('function'));+ expect(screen.getByText('Imported event')).toBeInTheDocument();+ expect(screen.queryByLabelText('Loading timeline')).not.toBeInTheDocument();+ await act(async () => { finishRefresh(empty); });+ expect(await screen.findByText('No recorded activity on this day.')).toBeInTheDocument();+ });+it('labels the listed rows as a page while totals stay full-day', async () => {api.getTimelineDay.mockResolvedValueOnce({date: '2026-01-02',