()
| 86 | } |
| 87 | |
| 88 | export async function loadServerSession(): Promise<ChatSession | null> { |
| 89 | try { |
| 90 | const res = await fetch("/api/session"); |
| 91 | if (!res.ok) { |
| 92 | return null; |
| 93 | } |
| 94 | const parsed = (await res.json()) as ChatSession | null; |
| 95 | if (!parsed?.id || !Array.isArray(parsed.messages)) { |
| 96 | return null; |
| 97 | } |
| 98 | return repairSession(parsed); |
| 99 | } catch { |
| 100 | return null; |
| 101 | } |
| 102 | } |
| 103 | |
| 104 | export async function saveServerSession(session: ChatSession): Promise<void> { |
| 105 | try { |
no test coverage detected