Files
ARTEX/web/src/lib/local-storage.client.ts
T
jackybabesandClaude Opus 5.5 527e2f2eec fix(web): reopen the last chat when returning to the chat page
The open conversation was kept only in the URL (?c=<id>), but the
sidebar links to a bare /chat. Leaving the chat page and coming back
always landed on the empty draft view.

The selected conversation is now also stored in localStorage and
restored on mount when the URL names none. An explicit ?c= still wins.
Starting a new conversation or deleting the open one clears it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 12:46:49 +00:00

28 lines
645 B
TypeScript

"use client";
export function setLocalStorageValue(key: string, value: string) {
try {
window.localStorage.setItem(key, value);
} catch (error) {
if (process.env.NODE_ENV !== "production") {
console.error("[localStorage] Failed to write value:", error);
}
}
}
export function getLocalStorageValue(key: string): string | null {
try {
return window.localStorage.getItem(key);
} catch {
return null;
}
}
export function removeLocalStorageValue(key: string) {
try {
window.localStorage.removeItem(key);
} catch {
// Storage unavailable (private mode, blocked site data): nothing to remove.
}
}