()
| 76 | export const MAX_THREADS_PER_PROJECT = 5 |
| 77 | |
| 78 | export function loadChatState(): PersistedChatsState | null { |
| 79 | if (typeof window === 'undefined') return null |
| 80 | try { |
| 81 | const raw = window.localStorage.getItem(CHAT_STORAGE_KEY) |
| 82 | if (!raw) return { threadsByProject: {}, version: 1 } as PersistedChatsState |
| 83 | const parsed = JSON.parse(raw) as |
| 84 | | PersistedChatsState |
| 85 | | Record<string, unknown> |
| 86 | const maybe = parsed as Record<string, unknown> |
| 87 | if ( |
| 88 | !parsed || |
| 89 | typeof parsed !== 'object' || |
| 90 | typeof maybe.threadsByProject !== 'object' |
| 91 | ) { |
| 92 | return { threadsByProject: {}, version: 1 } |
| 93 | } |
| 94 | return parsed as PersistedChatsState |
| 95 | } catch { |
| 96 | return { threadsByProject: {}, version: 1 } |
| 97 | } |
| 98 | } |
| 99 | |
| 100 | export function saveChatState(state: PersistedChatsState): void { |
| 101 | if (typeof window === 'undefined') return |
no outgoing calls
no test coverage detected