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

Function loadSessionById

demo/chat/session-api.ts:34–48  ·  view source on GitHub ↗
(id: string)

Source from the content-addressed store, hash-verified

32}
33
34export async function loadSessionById(id: string): Promise<ChatSession | null> {
35 try {
36 const res = await fetch(`/api/session?id=${encodeURIComponent(id)}`);
37 if (!res.ok) {
38 return null;
39 }
40 const parsed = (await res.json()) as ChatSession;
41 if (!parsed?.id || !Array.isArray(parsed.messages)) {
42 return null;
43 }
44 return normalizeSession(parsed);
45 } catch {
46 return null;
47 }
48}
49
50export function sessionPreview(session: ChatSession): string {
51 const firstUser = session.messages.find((m) => m.role === "user");

Callers 1

ChatAppFunction · 0.90

Calls 1

normalizeSessionFunction · 0.85

Tested by

no test coverage detected