Mic permission failure shows an inline alert; setModel only switches on server confirmation and reverts + reports in the transcript on failure; a failed session refresh after a turn no longer becomes a retryable turn error; a voice clip during a turn queues instead of dropping; blocked localStorage falls back to a per-load channel id; a failed install offers Retry/Not now again; rename/branch use a labelled Dialog instead of window.prompt; a failed cancel is reported; a stopped turn no longer blocks transcript reloads.
25 lines
728 B
TypeScript
25 lines
728 B
TypeScript
import { randomUUID } from "@/lib/uuid";
|
|
|
|
const CHANNEL_KEY = "archie.web.chat.channel";
|
|
|
|
/**
|
|
* The browser's chat identity. The server keys a conversation on the channel
|
|
* alone (the browser has no threading), so this is persisted: a reload rejoins
|
|
* the conversation instead of starting a second one beside it.
|
|
*/
|
|
export function channelID(): string {
|
|
// Storage can be blocked (private mode, policy): fall back to a per-load id
|
|
// rather than throwing a DOMException on every send.
|
|
let id: string | null = null;
|
|
try {
|
|
id = localStorage.getItem(CHANNEL_KEY);
|
|
if (!id) {
|
|
id = randomUUID();
|
|
localStorage.setItem(CHANNEL_KEY, id);
|
|
}
|
|
} catch {
|
|
id = id ?? randomUUID();
|
|
}
|
|
return id;
|
|
}
|