Files
colibri/web/src/lib/storage.ts
T
ZacharyZcR 57730f6196 Web UI: runtime console + KV session panel, with runtime/storage libs and tests (#32)
* Add web runtime console and KV sessions

* test(web): cover runtime and KV session behavior

* Fix runtime helper formatting
2026-07-12 01:40:01 +02:00

20 lines
754 B
TypeScript

export interface StringStorage {
getItem(key: string): string | null
setItem(key: string, value: string): void
removeItem(key: string): void
}
export function stored(storage: Pick<StringStorage, "getItem">, key: string, fallback: string) {
try { return storage.getItem(key) || fallback } catch { return fallback }
}
export function persistPublicSettings(storage: StringStorage, baseUrl: string, model: string) {
try {
storage.setItem("colibri.baseUrl", baseUrl)
storage.setItem("colibri.model", model)
// API credentials intentionally remain memory-only. Remove values left by
// older web releases whenever public settings are persisted.
storage.removeItem("colibri.apiKey")
} catch { /* restricted storage mode */ }
}