Files
professor/lib/localSession.ts
Aodhan Collins f644937604 Initial commit — AI-powered coding tutor (Professor)
Next.js 16, React 19, Monaco editor, Anthropic SDK, multi-provider AI,
Wandbox Python execution, iframe HTML preview, SQLite auth + session persistence.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-04 21:48:34 +00:00

37 lines
888 B
TypeScript

import type { Task, Message, ExecutionResult } from '@/types';
const STORAGE_KEY = 'professor_session';
export interface LocalSession {
topicId: string;
task: Task;
code: string;
messages: Message[];
executionResult: ExecutionResult | null;
}
export function saveLocalSession(session: LocalSession): void {
if (typeof window === 'undefined') return;
try {
localStorage.setItem(STORAGE_KEY, JSON.stringify(session));
} catch {
// Ignore quota errors
}
}
export function loadLocalSession(): LocalSession | null {
if (typeof window === 'undefined') return null;
try {
const raw = localStorage.getItem(STORAGE_KEY);
if (!raw) return null;
return JSON.parse(raw) as LocalSession;
} catch {
return null;
}
}
export function clearLocalSession(): void {
if (typeof window === 'undefined') return;
localStorage.removeItem(STORAGE_KEY);
}