odysseus-dev/odysseus · error · Error

Failed to restore session

Error message

Failed to restore session

What it means

Toast shown when unarchiving a session fails. _arcRestore POSTs to /api/session/{sid}/unarchive and throws on any non-OK response; the bare catch also swallows failures in _arcRemove/_arcRefreshUI/loadSessions.

Solutions

  1. Check the unarchive request status in the browser network tab
  2. Reload the archive view to resync ids, then retry
  3. Verify auth cookie / re-login if endpoints return 401
  4. Log the caught error instead of discarding it to pinpoint the failing step

Example fix

// before
  } catch { uiModule.showError('Failed to restore session'); }

// after
  } catch (e) {
    console.error('unarchive failed:', e);
    uiModule.showError('Failed to restore session');
  }
Defensive patterns

Strategy: try-catch

Validate before calling

if (!sid) return;
if (!navigator.onLine) { uiModule.showError('Offline — cannot restore session'); return; }

Try / catch

try { const res = await fetch(url, opts); if (!res.ok) throw new Error(`HTTP ${res.status}`); ... } catch (e) { console.error('unarchive', sid, e); uiModule.showError('Failed to restore session'); }

Prevention

When it happens

Trigger: POST /api/session/{sid}/unarchive returns non-2xx (sid not in archive on server, expired auth) or the fetch rejects (offline, server down); also any error thrown by the follow-up UI refresh.

Common situations: Archive list out of sync with server (session already restored/deleted elsewhere); backend restarted; auth session expired while the archive view was open.

Related errors


AI-assisted analysis of odysseus-dev/odysseus@f9235ebbf1 (2026-08-14). Data as JSON: /api/errors/1739da989d9e92fe. Report an issue: GitHub.

Appendix: source

Thrown at static/js/sessions.js:2956

    }
    if (window.uiModule) window.uiModule.scrollHistory();
  } catch (e) {
    console.error('Peek open failed:', e);
    uiModule.showError('Failed to open archived session');
  }
}

// When navigating away from a peeked session, just clear the state
function _checkPeekCleanup(newSessionId) {
  if (_peekingSessionId && _peekingSessionId !== newSessionId) {
    _peekingSessionId = null;
  }
}

async function _arcRestore(sid) {
  try {
    const res = await fetch(`${API_BASE}/api/session/${sid}/unarchive`, { method: 'POST' });
    if (!res.ok) throw new Error('Failed');
    _arcRemove(sid);
    _arcRefreshUI();
    uiModule.showToast('Session restored');
    loadSessions();
  } catch { uiModule.showError('Failed to restore session'); }
}

async function _arcDelete(sid) {
  if (!await window.styledConfirm('Delete this session permanently?', { confirmText: 'Delete', danger: true })) return;
  try {
    const res = await fetch(`${API_BASE}/api/session/${sid}`, { method: 'DELETE' });
    if (!res.ok) throw new Error('Failed');
    await _animateSessionRowsRemoving([sid], '#archive-grid .archive-row[data-session-id]');
    _arcRemove(sid);
    _arcRefreshUI();
    uiModule.showToast('Session deleted');
  } catch { uiModule.showError('Failed to delete session'); }
}

View on GitHub (pinned to f9235ebbf1)