MCPcopy Create free account
hub / github.com/vercel/examples / loadChatState

Function loadChatState

python/vibe-coding-ide/frontend/src/lib/persistence.ts:78–98  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

76export const MAX_THREADS_PER_PROJECT = 5
77
78export 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
100export function saveChatState(state: PersistedChatsState): void {
101 if (typeof window === 'undefined') return

Callers 6

getProjectChatThreadsFunction · 0.85
upsertCurrentChatThreadFunction · 0.85
upsertThreadByIdFunction · 0.85
startNewChatThreadFunction · 0.85
setCurrentChatThreadFunction · 0.85
deleteChatThreadFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected