(session: ChatSession)
| 102 | } |
| 103 | |
| 104 | export async function saveServerSession(session: ChatSession): Promise<void> { |
| 105 | try { |
| 106 | await fetch("/api/session", { |
| 107 | method: "POST", |
| 108 | headers: { "Content-Type": "application/json" }, |
| 109 | body: JSON.stringify(session), |
| 110 | }); |
| 111 | } catch { |
| 112 | // localStorage is the primary store; disk log is best-effort |
| 113 | } |
| 114 | } |
| 115 | |
| 116 | export function clearLocalSession(): void { |
| 117 | localStorage.removeItem(STORAGE_KEY); |