import type { SelectedLineRange } from "@/context/file" type HandoffSession = { prompt: string files: Record } const MAX = 40 const store = { session: new Map(), terminal: new Map(), } const touch = (map: Map, key: K, value: V) => { map.delete(key) map.set(key, value) while (map.size > MAX) { const first = map.keys().next().value if (first === undefined) return map.delete(first) } } export const setSessionHandoff = (key: string, patch: Partial) => { const prev = store.session.get(key) ?? { prompt: "", files: {} } touch(store.session, key, { ...prev, ...patch }) } export const getSessionHandoff = (key: string) => store.session.get(key) export const setTerminalHandoff = (key: string, value: string[]) => { touch(store.terminal, key, value) } export const getTerminalHandoff = (key: string) => store.terminal.get(key)