- PWA share target: shared text/links start a new chat or go into a
recent session (chooser dialog)
- Prompt templates (personal + global for admins) with {{placeholders}}
that are asked for on insert; managed under Settings → Templates
- Ctrl/Cmd+K command palette; Alt+N new session, Alt+Up/Down switch
sessions, Ctrl+, settings
- Sessions can be pinned, archived and filed into folders; the list can
be grouped by date or by project, groups are collapsible
- Fix: the "What's new" dialog was never shown to signed-in users
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
36 lines
1.5 KiB
TypeScript
36 lines
1.5 KiB
TypeScript
/** PWA share target: Android's "Share" sheet opens /?share_title=…&share_text=…&share_url=… */
|
|
|
|
const SHARED = "codecraft.shared";
|
|
const PREFILL = "codecraft.prefill.";
|
|
|
|
/** Move shared content from the URL into sessionStorage (survives the login screen). */
|
|
export function captureShare() {
|
|
const q = new URLSearchParams(location.search);
|
|
if (!q.has("share_title") && !q.has("share_text") && !q.has("share_url")) return;
|
|
const parts = [q.get("share_title"), q.get("share_text"), q.get("share_url")].map((s) => (s ?? "").trim()).filter(Boolean);
|
|
// Many apps put the URL into the text as well.
|
|
const unique = parts.filter((p, i) => !parts.some((o, j) => j !== i && o.includes(p) && (o.length > p.length || j < i)));
|
|
if (unique.length) sessionStorage.setItem(SHARED, unique.join("\n\n"));
|
|
history.replaceState(null, "", "/" + location.hash);
|
|
}
|
|
|
|
export function pendingShare(): string | null {
|
|
return sessionStorage.getItem(SHARED);
|
|
}
|
|
|
|
export function clearShare() {
|
|
sessionStorage.removeItem(SHARED);
|
|
}
|
|
|
|
/** Text to put into a composer once ("new" = new-session wizard, else a session id). */
|
|
export function setPrefill(target: string, text: string) {
|
|
sessionStorage.setItem(PREFILL + target, text);
|
|
}
|
|
|
|
export function takePrefill(target: string): string | null {
|
|
const v = sessionStorage.getItem(PREFILL + target);
|
|
// Removed a moment later: React StrictMode runs state initialisers twice.
|
|
if (v !== null) setTimeout(() => sessionStorage.removeItem(PREFILL + target), 500);
|
|
return v;
|
|
}
|