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(digital-twin): add error handling to time capsule async operations and validate snapshot IDs
Adam Eivy2b5078cc8efb
diff --git a/client/src/components/digital-twin/tabs/TimeCapsuleTab.jsx b/client/src/components/digital-twin/tabs/TimeCapsuleTab.jsxindex a8fc70bcbc..aaddf5ffd3 100644--- a/client/src/components/digital-twin/tabs/TimeCapsuleTab.jsx+++ b/client/src/components/digital-twin/tabs/TimeCapsuleTab.jsx@@ -77,18 +77,20 @@ export default function TimeCapsuleTab({ onRefresh: _onRefresh }) {const handleCreate = async () => {if (!label.trim()) return;setCreating(true);- const snapshot = await api.createTimeCapsuleSnapshot(label.trim(), description.trim());+ const snapshot = await api.createTimeCapsuleSnapshot(label.trim(), description.trim()).catch(() => null);+ setCreating(false);+ if (!snapshot) return;setSnapshots(prev => [snapshot, ...prev]);setLabel('');setDescription('');setShowForm(false);- setCreating(false);toast.success(`Snapshot "${snapshot.label}" created`);};const handleDelete = async (id) => {const snap = snapshots.find(s => s.id === id);- await api.deleteTimeCapsuleSnapshot(id);+ const ok = await api.deleteTimeCapsuleSnapshot(id).then(() => true).catch(() => false);+ if (!ok) return;setSnapshots(prev => prev.filter(s => s.id !== id));setConfirmDelete(null);if (viewingSnapshot?.id === id) setViewingSnapshot(null);@@ -101,9 +103,9 @@ export default function TimeCapsuleTab({ onRefresh: _onRefresh }) {return;}setViewLoading(true);- const data = await api.getTimeCapsuleSnapshot(id);- setViewingSnapshot(data);+ const data = await api.getTimeCapsuleSnapshot(id).catch(() => null);setViewLoading(false);+ if (data) setViewingSnapshot(data);};const toggleCompareId = (id) => {@@ -118,9 +120,9 @@ export default function TimeCapsuleTab({ onRefresh: _onRefresh }) {const handleCompare = async () => {if (compareIds.length !== 2) return;setComparing(true);- const result = await api.compareTimeCapsuleSnapshots(compareIds[0], compareIds[1]);- setCompareResult(result);+ const result = await api.compareTimeCapsuleSnapshots(compareIds[0], compareIds[1]).catch(() => null);setComparing(false);+ if (result) setCompareResult(result);};if (loading) {diff --git a/server/routes/digital-twin.js b/server/routes/digital-twin.jsindex 76eb5efd5c..378e1fcf66 100644--- a/server/routes/digital-twin.js+++ b/server/routes/digital-twin.js@@ -665,7 +665,11 @@ router.post('/snapshots', asyncHandler(async (req, res) => {* Get a snapshot with full data*/router.get('/snapshots/:id', asyncHandler(async (req, res) => {- const snapshot = await timeCapsuleService.getSnapshot(req.params.id);+ const { id } = req.params;+ if (!/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(id)) {+ throw new ServerError('Invalid snapshot ID', { status: 400 });+ }+ const snapshot = await timeCapsuleService.getSnapshot(id);if (!snapshot) {throw new ServerError('Snapshot not found', { status: 404, code: 'NOT_FOUND' });}@@ -677,7 +681,11 @@ router.get('/snapshots/:id', asyncHandler(async (req, res) => {* Delete a snapshot*/router.delete('/snapshots/:id', asyncHandler(async (req, res) => {- const deleted = await timeCapsuleService.deleteSnapshot(req.params.id);+ const { id } = req.params;+ if (!/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(id)) {+ throw new ServerError('Invalid snapshot ID', { status: 400 });+ }+ const deleted = await timeCapsuleService.deleteSnapshot(id);if (!deleted) {throw new ServerError('Snapshot not found', { status: 404, code: 'NOT_FOUND' });}