MCPcopy Create free account
hub / github.com/Alphanimble/htmlstream / loadLocalSession

Function loadLocalSession

demo/chat/session.ts:58–79  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

56}
57
58export function loadLocalSession(): ChatSession | null {
59 try {
60 const raw = localStorage.getItem(STORAGE_KEY);
61 if (!raw) {
62 return null;
63 }
64 const parsed = JSON.parse(raw) as ChatSession;
65 if (!parsed?.id || !Array.isArray(parsed.messages)) {
66 return null;
67 }
68 return repairSession({
69 ...parsed,
70 messages: parsed.messages.map((m) => ({
71 ...m,
72 content: typeof m.content === "string" ? m.content : "",
73 reasoning: typeof m.reasoning === "string" ? m.reasoning : undefined,
74 })),
75 });
76 } catch {
77 return null;
78 }
79}
80
81export function saveLocalSession(session: ChatSession): void {
82 localStorage.setItem(

Callers 1

ChatAppFunction · 0.90

Calls 1

repairSessionFunction · 0.85

Tested by

no test coverage detected