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); }