1import { createEffect, createMemo, createSignal, lazy, onCleanup, onMount, Show, Suspense } from "solid-js";2import { Portal } from "solid-js/web";3import { storageGet, storageSet } from "../shared/storage";4import { sendMessage } from "../shared/bridge";5import { ACCENT_COLORS } from "../shared/types";6import type { AccentColorName, PendingPasskeyRequest, ProFeature, VaultEntry } from "../shared/types";7import type { IncomingPairingRequest } from "../shared/sync-types";8import { isPasskeyOnly } from "../shared/types";9import { LockView } from "./views/Lock";10import { Onboarding } from "./views/Onboarding";11import { ProCelebration } from "./views/ProCelebration";12import { VaultView, type SortOrder } from "./views/Vault";13import { EntryView } from "./views/Entry";14import { AddView } from "./views/Add";15import { PeachMark, PeachWordmark } from "./components/PeachMark";16import { PasskeyApprovalView } from "./views/PasskeyApproval";17import { extractDomain } from "../shared/domain";18import { popupCopy } from "./copy";19import {20 DEFAULT_BINDINGS,21 formatKeybinding,22 getActiveBindings,23 matchKeybinding,24 SHORTCUT_DESCRIPTORS,25 type Keybinding,26 type ShortcutAction,27} from "../shared/shortcuts";28import { generateTOTP } from "../crypto/totp";29import { isNativePlatform, nativePlugin } from "../shared/native";3031export { sendMessage } from "../shared/bridge";3233const ImportView = lazy(() => import("./views/Import").then(m => ({ default: m.ImportView })));34const ExportView = lazy(() => import("./views/Export").then(m => ({ default: m.ExportView })));35const SettingsView = lazy(() => import("./views/Settings").then(m => ({ default: m.SettingsView })));36const HealthView = lazy(() => import("./views/Health").then(m => ({ default: m.HealthView })));37const TrashView = lazy(() => import("./views/TrashView").then(m => ({ default: m.TrashView })));38const PanicView = lazy(() => import("./views/Panic").then(m => ({ default: m.PanicView })));39const SyncPairingView = lazy(() => import("./views/SyncPairing").then(m => ({ default: m.SyncPairingView })));4041type View =42 | "lock"43 | "pro-celebration"44 | "entry"45 | "list"46 | "add"47 | "settings"48 | "sync-pairing"49 | "import"50 | "export"51 | "health"52 | "trash"53 | "panic";54type BootState = "loading" | "ready";5556const canarySuppressMap = new Map<string, boolean>();57let shellRingAnimation: Animation | null = null;5859export function isCanarySuppressed(entryId: string): boolean {60 return canarySuppressMap.get(entryId) ?? false;61}6263export function setCanarySuppressed(entryId: string, suppressed: boolean): void {64 canarySuppressMap.set(entryId, suppressed);65}6667export function clearCanarySuppressions(): void {68 canarySuppressMap.clear();69}7071export function triggerRing() {72 const shell = document.getElementById("hd-shell");73 if (!shell) return;7475 shellRingAnimation?.cancel();76 shell.dataset.glowing = "true";77 const animation = shell.animate(78 [79 { offset: 0, boxShadow: "var(--copy-shadow)" },80 {81 offset: 0.3,82 boxShadow:83 "0 2px 8px rgba(0,0,0,0.5), 0 14px 48px rgba(0,0,0,0.6), 0 0 0 1.5px color-mix(in srgb, var(--peach-accent) 58%, transparent), 0 0 22px color-mix(in srgb, var(--peach-accent) 18%, transparent)",84 },85 { offset: 1, boxShadow: "var(--copy-shadow)" },86 ],87 {88 duration: 720,89 easing: "cubic-bezier(0.4, 0, 0.2, 1)",90 fill: "none",91 }92 );93 shellRingAnimation = animation;94 const clearGlow = () => {95 if (shellRingAnimation !== animation) return;96 shellRingAnimation = null;97 delete shell.dataset.glowing;98 };99 animation.onfinish = clearGlow;100 animation.oncancel = clearGlow;101}102103104export function triggerPipPulse() {105 const pip = document.querySelector(".peach-status-pip, .pip");106 if (pip) {107 pip.classList.remove("pulse");108 void (pip as HTMLElement).offsetWidth;109 pip.classList.add("pulse");110 }111}112113const ENTRY_TRANSITION_EXIT_MS = 95;114const ENTRY_TRANSITION_SETTLE_MS = 135;115116export default function App() {117 const [bootState, setBootState] = createSignal<BootState>("loading");118 const [view, setView] = createSignal<View>("lock");119 120 121 const [sheetTranslate, setSheetTranslate] = createSignal<number | null>(null);122 const [contentPhase, setContentPhase] = createSignal<"enter" | "exit" | "idle">(123 "enter"124 );125 const [contentTransitioning, setContentTransitioning] = createSignal(false);126 const [hasVault, setHasVault] = createSignal(false);127 const [onboarded, setOnboarded] = createSignal(true);128 const [entries, setEntries] = createSignal<VaultEntry[]>([]);129 const [selectedEntry, setSelectedEntry] = createSignal<VaultEntry | null>(null);130 const [editEntry, setEditEntry] = createSignal<VaultEntry | undefined>(undefined);131 const [accentColor, setAccentColor] = createSignal<AccentColorName>("peach");132 const [theme, setTheme] = createSignal<"dark" | "light">("dark");133 const [displayFont, setDisplayFont] = createSignal<"cormorant-italic" | "cormorant" | "inter" | "system">("cormorant-italic");134 const [textSize, setTextSize] = createSignal<"small" | "medium" | "large">("medium");135 const [reduceMotion, setReduceMotion] = createSignal<boolean>(false);136 const [lockOnClose, setLockOnClose] = createSignal(true);137 const [autoLockMinutes, setAutoLockMinutes] = createSignal(5);138 const [breachMonitoring, setBreachMonitoring] = createSignal(true);139 const [shortcutBindings, setShortcutBindings] = createSignal<Record<ShortcutAction, Keybinding>>(DEFAULT_BINDINGS);140 const [showShortcutsHelp, setShowShortcutsHelp] = createSignal(false);141 const [trashRetentionDays, setTrashRetentionDays] = createSignal(30);142 const [restoreView, setRestoreView] = createSignal<"file" | null>(null);143 const [pendingPasskey, setPendingPasskey] = createSignal<PendingPasskeyRequest | null>(null);144 const [currentTabDomain, setCurrentTabDomain] = createSignal<string>("");145 const [currentTabUrl, setCurrentTabUrl] = createSignal<string>("");146 147 148 149 150 const [proStatus, setProStatus] = createSignal(false);151 const [settingsInitialSection, setSettingsInitialSection] = createSignal<string | null>(null);152 const [upgradeHighlight, setUpgradeHighlight] = createSignal<ProFeature | null>(null);153 const [sortOrder, setSortOrder] = createSignal<SortOrder>("url-first");154 const [listSearchSeed, setListSearchSeed] = createSignal("");155 const [listSearchSeedNonce, setListSearchSeedNonce] = createSignal(0);156 const [pendingCelebration, setPendingCelebration] = createSignal(false);157 const [pendingProNotice, setPendingProNotice] = createSignal<{ feature: string } | null>(null);158 const [incomingPair, setIncomingPair] = createSignal<IncomingPairingRequest | null>(null);159 const [recentPairToast, setRecentPairToast] = createSignal<string | null>(null);160 const [incomingPairResponding, setIncomingPairResponding] = createSignal(false);161 const [incomingPairTick, setIncomingPairTick] = createSignal(0);162 const incomingPairSecondsLeft = () => {163 void incomingPairTick();164 const req = incomingPair();165 if (!req) return 0;166 return Math.max(0, Math.ceil((req.expiresAt - Date.now()) / 1000));167 };168 169 170 171 const [returnToPanic, setReturnToPanic] = createSignal(false);172 173 174 175 176 const [forceRecoveryWords, setForceRecoveryWords] = createSignal(false);177178 let contentPhaseTimer: number | undefined;179180 function applyAccent(name: AccentColorName) {181 const color = ACCENT_COLORS.find(c => c.name === name) ?? ACCENT_COLORS[0]!;182 const hex = color.hex;183 document.documentElement.style.setProperty("--peach-accent", hex);184 185 186 document.documentElement.style.setProperty("--peach-glow", hex + "2A");187 document.documentElement.style.setProperty("--peach-surface-tint", hex + "09");188 document.documentElement.style.setProperty("--peach-border-accent", hex + "24");189 }190191 createEffect(() => {192 applyAccent(accentColor());193 });194195 createEffect(() => {196 document.documentElement.classList.toggle("light", theme() === "light");197 document.body.classList.toggle("light", theme() === "light");198 });199200 createEffect(() => {201 document.documentElement.setAttribute("data-display-font", displayFont());202 });203204 createEffect(() => {205 document.documentElement.setAttribute("data-text-size", textSize());206 });207208 createEffect(() => {209 if (reduceMotion()) {210 document.documentElement.setAttribute("data-motion", "reduce");211 } else {212 document.documentElement.removeAttribute("data-motion");213 }214 });215216 const selectedIndex = createMemo(() => {217 const currentId = selectedEntry()?.id;218 if (!currentId) return entries().length > 0 ? 0 : -1;219 return entries().findIndex((entry) => entry.id === currentId);220 });221222 async function applyAccentColor(name: AccentColorName) {223 applyAccent(name);224 setAccentColor(name);225 await sendMessage({ type: "UPDATE_SETTINGS", payload: { accentColor: name } });226 }227228 async function applyTheme(t: "dark" | "light") {229 setTheme(t);230 await sendMessage({ type: "UPDATE_SETTINGS", payload: { theme: t } });231 }232233 async function applyDisplayFont(f: "cormorant-italic" | "cormorant" | "inter" | "system") {234 setDisplayFont(f);235 await sendMessage({ type: "UPDATE_SETTINGS", payload: { displayFont: f } });236 }237238 async function applyTextSize(size: "small" | "medium" | "large") {239 setTextSize(size);240 await sendMessage({ type: "UPDATE_SETTINGS", payload: { textSize: size } });241 }242243 async function applyReduceMotion(enabled: boolean) {244 setReduceMotion(enabled);245 await sendMessage({ type: "UPDATE_SETTINGS", payload: { reduceMotion: enabled } });246 }247248 249 250 251 async function applyShortcuts(active: Record<ShortcutAction, Keybinding>) {252 setShortcutBindings(active);253 const overrides: Record<string, Keybinding> = {};254 for (const action of Object.keys(active) as ShortcutAction[]) {255 const a = active[action];256 const d = DEFAULT_BINDINGS[action];257 const same = a.key === d.key258 && Boolean(a.ctrl) === Boolean(d.ctrl)259 && Boolean(a.meta) === Boolean(d.meta)260 && Boolean(a.shift) === Boolean(d.shift)261 && Boolean(a.alt) === Boolean(d.alt);262 if (!same) overrides[action] = a;263 }264 await sendMessage({ type: "UPDATE_SETTINGS", payload: { shortcuts: overrides } });265 }266267 async function applyLockOnClose(enabled: boolean) {268 setLockOnClose(enabled);269 await sendMessage({270 type: "UPDATE_SETTINGS",271 payload: { lockOnClose: enabled },272 });273 }274275 async function applyAutoLockMinutes(minutes: number) {276 setAutoLockMinutes(minutes);277 await sendMessage({278 type: "UPDATE_SETTINGS",279 payload: { autoLockMinutes: minutes },280 });281 }282283 async function applyBreachMonitoring(enabled: boolean) {284 setBreachMonitoring(enabled);285 await sendMessage({286 type: "UPDATE_SETTINGS",287 payload: { breachMonitoring: enabled },288 });289 }290291 onMount(async () => {292 293 294 295 296 297 const [unlockResponse, vaultResponse, , celebrationResponse] = await Promise.all([298 sendMessage({ type: "IS_UNLOCKED" }),299 sendMessage({ type: "HAS_VAULT" }),300 refreshCurrentTab(),301 sendMessage({ type: "SHOULD_PLAY_CELEBRATION" }),302 ]);303 const unlocked = Boolean(304 (unlockResponse as { ok: boolean; data?: boolean }).data305 );306 const vaultExists = Boolean(307 (vaultResponse as { ok: boolean; data?: boolean }).data308 );309 const shouldCelebrate = Boolean(310 (celebrationResponse as { ok: boolean; data?: boolean }).data311 );312 setHasVault(vaultExists);313 314 315 316 try {317 const onboarded = await storageGet("peach_onboarded");318 const seen = onboarded === "true";319 if (vaultExists && !seen) {320 await storageSet("peach_onboarded", "true");321 setOnboarded(true);322 } else {323 setOnboarded(seen);324 }325 } catch {326 327 setOnboarded(true);328 }329 await Promise.all([restoreSettings(), refreshProStatus()]);330331 332 if (shouldCelebrate) {333 await sendMessage({ type: "MARK_CELEBRATION_PLAYED" });334 }335336 337 338 339 340 341 342 let recoveryPending = false;343 try {344 const out = await chrome.storage.local?.get("peach_recovery_pending");345 recoveryPending = (out as { peach_recovery_pending?: string })?.peach_recovery_pending === "1";346 } catch { }347348 349 350 351 352 353 if (recoveryPending && !unlocked && vaultExists && isNativePlatform()) {354 try {355 await chrome.storage.local?.remove([356 "peach_vault_a",357 "peach_vault_b",358 "peach_recovery_pending",359 "peach_onboarded",360 "peach_vault_history",361 ]);362 } catch { }363 setHasVault(false);364 setOnboarded(false);365 setView("lock");366 setBootState("ready");367 document.getElementById("pre-lock")?.setAttribute("hidden", "true");368 return;369 }370371 if (recoveryPending && unlocked) {372 373 374 setForceRecoveryWords(true);375 setView("lock");376 } else if (unlocked && vaultExists) {377 await openVault(undefined, shouldCelebrate);378 if (shouldCelebrate) {379 setView("pro-celebration");380 window.setTimeout(() => setView("entry"), 2500);381 }382 } else if (shouldCelebrate) {383 setPendingCelebration(true);384 }385386 await refreshPendingPasskey();387 await refreshIncomingPairing();388 await consumeRecentPairing();389390 391 const handleTabActivated = () => { void refreshCurrentTab(); };392 const handleTabUpdated = (_tabId: number, changeInfo: { url?: string; status?: string }) => {393 if (changeInfo.url || changeInfo.status === "complete") void refreshCurrentTab();394 };395 try {396 chrome.tabs.onActivated.addListener(handleTabActivated);397 chrome.tabs.onUpdated.addListener(handleTabUpdated);398 onCleanup(() => {399 chrome.tabs.onActivated.removeListener(handleTabActivated);400 chrome.tabs.onUpdated.removeListener(handleTabUpdated);401 });402 } catch {403 404 }405406 setBootState("ready");407 document.getElementById("pre-lock")?.setAttribute("hidden", "true");408409 410 if (chrome.storage.session) {411 const session = await chrome.storage.session.get(["pendingProGate", "pendingProNotice"]) as412 Record<string, { feature?: string } | undefined>;413 if (session.pendingProGate?.feature) {414 await chrome.storage.session.remove("pendingProGate");415 setUpgradeHighlight((session.pendingProGate.feature as ProFeature) ?? null);416 setSettingsInitialSection("license");417 setView("settings");418 } else if (session.pendingProNotice?.feature) {419 await chrome.storage.session.remove("pendingProNotice");420 setPendingProNotice({ feature: session.pendingProNotice.feature ?? "" });421 }422 }423424 425 426 427 428 void Promise.all([429 import("./views/Settings").catch(() => {}),430 import("./views/Import").catch(() => {}),431 import("./views/Export").catch(() => {}),432 import("./views/Health").catch(() => {}),433 import("./views/TrashView").catch(() => {}),434 ]);435436 437 438 439 let popupPort: chrome.runtime.Port | null = null;440 try {441 popupPort = chrome.runtime.connect({ name: "popup" });442 } catch { }443 onCleanup(() => { try { popupPort?.disconnect(); } catch {} });444445 446 447 448 if (isNativePlatform()) {449 let backgroundedAt: number | null = null;450 const CapApp = nativePlugin<{451 addListener: (452 ev: string,453 cb: (s: { isActive: boolean }) => void,454 ) => Promise<{ remove: () => Promise<void> }> | { remove: () => Promise<void> };455 }>("App");456 if (CapApp?.addListener) {457 const sub = CapApp.addListener(458 "appStateChange",459 ({ isActive }: { isActive: boolean }) => {460 if (!isActive) {461 backgroundedAt = Date.now();462 return;463 }464 if (backgroundedAt !== null && autoLockMinutes() > 0) {465 const elapsed = Date.now() - backgroundedAt;466 if (elapsed >= autoLockMinutes() * 60_000) handleHeaderLock();467 }468 backgroundedAt = null;469 }470 );471 472 onCleanup(() => {473 Promise.resolve(sub).then((s) => s?.remove?.()).catch(() => {});474 });475 }476 }477478 479 480 const handleRuntimeMessage = (msg: { type?: string; payload?: { feature?: ProFeature } }) => {481 if (msg?.type === "VAULT_LOCKED" && view() !== "lock") handleLock();482 if (msg?.type === "PRO_GATE_TRIGGERED") {483 setUpgradeHighlight(msg.payload?.feature ?? null);484 setSettingsInitialSection("license");485 setView("settings");486 }487 };488 chrome.runtime.onMessage.addListener(handleRuntimeMessage);489 onCleanup(() => chrome.runtime.onMessage.removeListener(handleRuntimeMessage));490491 492 493 494 const handlePeachBack = () => {495 const v = view();496 if (v === "lock" && !hasVault() && onboarded()) {497 setOnboarded(false);498 return;499 }500 if (v === "list") { setView("entry"); return; }501 if (v === "settings" || v === "import" || v === "export" || v === "add" || v === "health") {502 handleBack();503 return;504 }505 if (v === "sync-pairing") { setView("settings"); return; }506 };507 window.addEventListener("peach:back", handlePeachBack);508 onCleanup(() => window.removeEventListener("peach:back", handlePeachBack));509510 511 512 513 514 515 if (isNativePlatform()) {516 let touchStartY = 0;517 let touchStartX = 0;518 let lastY = 0;519 let lastT = 0;520 let dragging = false;521 let captured = false;522 const HORIZONTAL_TOLERANCE = 16;523 const ACTIVATION_DY = 8;524525 const onTouchStart = (e: TouchEvent) => {526 const t = e.touches[0];527 if (!t) return;528 const v = view();529 if (v !== "entry" && v !== "list") return;530 531 532 const inBand = v === "entry"533 ? t.clientY > window.innerHeight * 0.6534 : t.clientY < window.innerHeight * 0.35;535 if (!inBand) return;536 touchStartY = lastY = t.clientY;537 touchStartX = t.clientX;538 lastT = e.timeStamp;539 dragging = true;540 captured = false;541 };542543 const onTouchMove = (e: TouchEvent) => {544 if (!dragging) return;545 const t = e.touches[0];546 if (!t) return;547 const dy = t.clientY - touchStartY;548 const dx = Math.abs(t.clientX - touchStartX);549550 if (!captured) {551 if (dx > HORIZONTAL_TOLERANCE && Math.abs(dy) < dx) {552 553 dragging = false;554 return;555 }556 if (Math.abs(dy) < ACTIVATION_DY) return;557 captured = true;558 }559560 561 562 const v = view();563 const restClosed = window.innerHeight;564 const baseTranslate = v === "list" ? 0 : restClosed;565 const next = Math.max(0, Math.min(restClosed, baseTranslate + dy));566 setSheetTranslate(next);567 lastY = t.clientY;568 lastT = e.timeStamp;569 };570571 const onTouchEnd = (e: TouchEvent) => {572 if (!dragging) { return; }573 const t = e.changedTouches[0];574 const elapsed = Math.max(1, e.timeStamp - lastT);575 const velocity = t ? (t.clientY - lastY) / elapsed : 0; 576 const wasCaptured = captured;577 dragging = false;578 captured = false;579580 if (!wasCaptured) {581 582 setSheetTranslate(null);583 return;584 }585586 const restClosed = window.innerHeight;587 const current = sheetTranslate() ?? restClosed;588 const v = view();589590 591 592 593 594 let nextOpen: boolean;595 if (velocity < -0.2) nextOpen = true;596 else if (velocity > 0.2) nextOpen = false;597 else nextOpen = current < restClosed * 0.5;598599 if (nextOpen && v !== "list") setView("list");600 if (!nextOpen && v !== "entry") setView("entry");601 602 setSheetTranslate(null);603 };604605 document.addEventListener("touchstart", onTouchStart, { passive: true });606 document.addEventListener("touchmove", onTouchMove, { passive: true });607 document.addEventListener("touchend", onTouchEnd, { passive: true });608 document.addEventListener("touchcancel", () => { dragging = false; captured = false; setSheetTranslate(null); }, { passive: true });609 onCleanup(() => {610 document.removeEventListener("touchstart", onTouchStart);611 document.removeEventListener("touchmove", onTouchMove);612 document.removeEventListener("touchend", onTouchEnd);613 });614 }615616 617 618 619 const SHORTCUT_HANDLERS: Partial<Record<ShortcutAction, () => void>> = {620 copy_password: () => {621 const entry = selectedEntry();622 if (entry?.password) void popupCopy(entry.password, "Password").then((ok) => { if (ok) triggerRing(); });623 },624 copy_username: () => {625 const entry = selectedEntry();626 if (entry?.username) void popupCopy(entry.username, "Username").then((ok) => { if (ok) triggerRing(); });627 },628 copy_totp: () => {629 const entry = selectedEntry();630 if (!entry?.totp) return;631 try {632 const { code } = generateTOTP(entry.totp);633 void popupCopy(code, "2FA").then((ok) => { if (ok) triggerRing(); });634 } catch { }635 },636 new_entry: () => handleAdd(),637 edit_entry: () => {638 const entry = selectedEntry();639 640 641 if (!entry || isPasskeyOnly(entry)) return;642 setEditEntry(entry);643 setView("add");644 },645 delete_entry: () => {646 if (selectedEntry()) void handleDelete();647 },648 lock_vault: () => { void handleHeaderLock(); },649 search: () => openList(),650 nav_prev: () => navigate(-1),651 nav_next: () => navigate(1),652 jump_vault: () => setView("entry"),653 jump_settings: () => setView("settings"),654 show_help: () => setShowShortcutsHelp(true),655 };656657 658 659 660 const ENTRY_SCOPED: ReadonlySet<ShortcutAction> = new Set([661 "copy_password", "copy_username", "copy_totp",662 "edit_entry", "delete_entry", "nav_prev", "nav_next",663 ]);664665 const handleGlobalKeydown = (e: KeyboardEvent) => {666 const v = view();667 const inInput = (e.target as HTMLElement)?.tagName === "INPUT"668 || (e.target as HTMLElement)?.tagName === "TEXTAREA"669 || (e.target as HTMLElement)?.isContentEditable;670 const isPrintableSearchKey =671 e.key.length === 1 &&672 !e.ctrlKey &&673 !e.metaKey &&674 !e.altKey;675676 677 if (v === "pro-celebration") return;678679 680 681 if (showShortcutsHelp()) {682 if (e.key === "Escape") { e.preventDefault(); setShowShortcutsHelp(false); }683 return;684 }685686 687 if (e.key === "Escape") {688 if (v === "list") { setView("entry"); return; }689 if (v === "settings" || v === "import" || v === "export" || v === "add" || v === "health") { handleBack(); return; }690 if (v === "sync-pairing") { setView("settings"); return; }691 }692693 694 695 696 const bindings = shortcutBindings();697 for (const action of Object.keys(bindings) as ShortcutAction[]) {698 const binding = bindings[action];699 if (!matchKeybinding(e, binding)) continue;700 701 702 const hasMod = binding.ctrl || binding.meta || binding.alt || binding.shift;703 if (!hasMod && binding.key.length === 1 && inInput) return;704 if (ENTRY_SCOPED.has(action) && v !== "entry") return;705 e.preventDefault();706 SHORTCUT_HANDLERS[action]?.();707 return;708 }709710 711 712 713 714 if (v === "entry" && !inInput && isPrintableSearchKey) {715 e.preventDefault();716 primeListSearch(e.key);717 return;718 }719 };720 window.addEventListener("keydown", handleGlobalKeydown);721 onCleanup(() => window.removeEventListener("keydown", handleGlobalKeydown));722723 const handleStorageChanged = (724 changes: Record<string, chrome.storage.StorageChange>,725 areaName: string726 ) => {727 if (areaName !== "session") return;728 if (!Object.keys(changes).some((key) => key.startsWith("passkey_pending_"))) {729 return;730 }731 void refreshPendingPasskey();732 };733 chrome.storage.onChanged.addListener(handleStorageChanged);734 onCleanup(() => chrome.storage.onChanged.removeListener(handleStorageChanged));735 });736737 async function refreshCurrentTab() {738 try {739 const [tab] = await chrome.tabs.query({ active: true, currentWindow: true });740 const url = tab?.url ?? tab?.pendingUrl ?? "";741 setCurrentTabDomain(url ? (extractDomain(url) ?? "") : "");742 743 744 const isWebUrl = /^https?:\/\//i.test(url);745 setCurrentTabUrl(isWebUrl ? url : "");746 } catch {747 setCurrentTabDomain("");748 setCurrentTabUrl("");749 }750 }751752 async function refreshPendingPasskey() {753 const res = await sendMessage({ type: "GET_PENDING_PASSKEY" });754 setPendingPasskey((res as { ok: boolean; data?: PendingPasskeyRequest | null }).data ?? null);755 }756757 async function refreshIncomingPairing() {758 const res = await sendMessage({ type: "GET_INCOMING_PAIRING_REQUEST" });759 const data = (res as { ok: boolean; data?: IncomingPairingRequest | null }).data ?? null;760 setIncomingPair(data);761 }762763 764 765 766 async function consumeRecentPairing() {767 const res = await sendMessage({ type: "GET_RECENT_PAIRING" });768 const data = (res as { ok: boolean; data?: { deviceName?: string } | null }).data;769 if (data?.deviceName) {770 setRecentPairToast(data.deviceName);771 window.setTimeout(() => setRecentPairToast(null), 4000);772 }773 }774775 async function respondIncomingPairing(accept: boolean) {776 if (incomingPairResponding()) return;777 setIncomingPairResponding(true);778 await sendMessage({ type: "RESPOND_INCOMING_PAIRING", payload: { accept } });779 setIncomingPair(null);780 setIncomingPairResponding(false);781 }782783 784 785 786 createEffect(() => {787 const req = incomingPair();788 if (!req) return;789 const handle = window.setInterval(() => {790 setIncomingPairTick((tick) => tick + 1);791 if (Date.now() >= req.expiresAt) {792 setIncomingPair(null);793 window.clearInterval(handle);794 }795 }, 1000);796 onCleanup(() => window.clearInterval(handle));797 });798799 async function refreshProStatus() {800 const res = await sendMessage({ type: "GET_LICENSE" });801 const data = (res as { ok: boolean; data?: { valid?: boolean; plan?: string } }).data;802 setProStatus(Boolean(data?.valid && data?.plan === "pro"));803 }804805 async function restoreSettings() {806 const res = await sendMessage({ type: "GET_SETTINGS" });807 const s = (res as { ok: boolean; data?: any }).data ?? {};808 if (s.accentColor && ACCENT_COLORS.some(c => c.name === s.accentColor)) {809 setAccentColor(s.accentColor as AccentColorName);810 }811 setTheme(s.theme === "light" ? "light" : "dark");812 if (s.displayFont === "cormorant" || s.displayFont === "inter" || s.displayFont === "system") {813 setDisplayFont(s.displayFont);814 } else {815 setDisplayFont("cormorant-italic");816 }817 if (s.textSize === "small" || s.textSize === "large") {818 setTextSize(s.textSize);819 } else {820 setTextSize("medium");821 }822 setReduceMotion(s.reduceMotion === true);823 setLockOnClose(s.lockOnClose !== false);824 setAutoLockMinutes(typeof s.autoLockMinutes === "number" ? s.autoLockMinutes : 5);825 setBreachMonitoring(s.breachMonitoring !== false);826 setTrashRetentionDays(typeof s.trashRetentionDays === "number" ? s.trashRetentionDays : 30);827 setShortcutBindings(getActiveBindings(s.shortcuts));828 }829830 async function applyTrashRetention(days: number) {831 setTrashRetentionDays(days);832 await sendMessage({ type: "UPDATE_SETTINGS", payload: { trashRetentionDays: days } });833 }834835 function primeListSearch(seed: string) {836 setListSearchSeed(seed);837 setListSearchSeedNonce((value) => value + 1);838 openList();839 }840841 842 843 844 async function loadEntries(): Promise<VaultEntry[] | null> {845 const response = await sendMessage({ type: "GET_ENTRIES" });846 const res = response as { ok: boolean; data?: VaultEntry[]; error?: string };847848 849 850 851 852 if (!res.ok) {853 if (854 res.error === "vault locked" ||855 res.error === "SERVICE_WORKER_UNAVAILABLE" ||856 (typeof res.error === "string" && res.error.includes("locked"))857 ) {858 handleLock();859 return null; 860 }861 return [];862 }863864 const loadedEntries = res.data ?? [];865 setEntries(loadedEntries);866867 const currentId = selectedEntry()?.id;868 if (currentId) {869 setSelectedEntry(870 loadedEntries.find((entry) => entry.id === currentId) ?? loadedEntries[0] ?? null871 );872 }873874 return loadedEntries;875 }876877 async function openVault(preferredEntryId?: string, skipViewSet = false) {878 879 const retDays = trashRetentionDays();880 if (retDays > 0) {881 void sendMessage({882 type: "PURGE_EXPIRED_TRASH",883 payload: { retentionMs: retDays * 86_400_000 },884 });885 }886887 const loadedEntries = await loadEntries();888889 890 891 if (loadedEntries === null) return;892893 894 let nextSelectedEntry: VaultEntry | null = null;895 if (preferredEntryId) {896 nextSelectedEntry = loadedEntries.find((e) => e.id === preferredEntryId) ?? null;897 }898 if (!nextSelectedEntry) {899 const tabDomain = currentTabDomain();900 if (tabDomain) {901 nextSelectedEntry = loadedEntries.find((e) => {902 if (e.type === "login") {903 if (e.url && (extractDomain(e.url) ?? "") === tabDomain) return true;904 for (const extra of e.additionalUrls ?? []) {905 if ((extractDomain(extra) ?? "") === tabDomain) return true;906 }907 return false;908 }909 if (e.passkey?.rpId) return e.passkey.rpId === tabDomain;910 return false;911 }) ?? null;912 }913 }914 nextSelectedEntry ??= loadedEntries[0] ?? null;915916 setSelectedEntry(nextSelectedEntry);917 setEditEntry(undefined);918 setContentTransitioning(false);919 setContentPhase("enter");920 queueContentIdle();921 if (!skipViewSet) setView("entry");922 }923924 async function handleUnlock() {925 926 927 928 929 930 931 let recoveryPending = false;932 try {933 const out = await chrome.storage.local?.get("peach_recovery_pending");934 recoveryPending = (out as { peach_recovery_pending?: string })?.peach_recovery_pending === "1";935 } catch { }936 if (recoveryPending) {937 setForceRecoveryWords(true);938 setView("lock");939 triggerPipPulse();940 await restoreSettings();941 return;942 }943 setHasVault(true);944 triggerPipPulse();945 await restoreSettings();946 const celebrating = pendingCelebration();947 if (celebrating) {948 await sendMessage({ type: "MARK_CELEBRATION_PLAYED" });949 setPendingCelebration(false);950 }951 await openVault(undefined, celebrating);952 if (celebrating) {953 setView("pro-celebration");954 window.setTimeout(() => setView("entry"), 2500);955 }956 }957958 function handleSelectEntry(entry: VaultEntry) {959 setSelectedEntry(entry);960 setContentTransitioning(false);961 setContentPhase("enter");962 queueContentIdle();963 setView("entry");964 }965966 function handleAdd() {967 setEditEntry(undefined);968 setView("add");969 }970971 async function handleDelete() {972 const entry = selectedEntry();973 if (!entry) return;974 await sendMessage({ type: "DELETE_ENTRY", payload: { id: entry.id } });975 const loadedEntries = await loadEntries() ?? [];976 setSelectedEntry(loadedEntries[0] ?? null);977 setView("entry");978 }979980 async function handleDeleteMany(ids: string[]) {981 for (const id of ids) {982 await sendMessage({ type: "DELETE_ENTRY", payload: { id } });983 }984 const loadedEntries = await loadEntries() ?? [];985 986 const stillExists = loadedEntries.find(e => e.id === selectedEntry()?.id);987 if (!stillExists) setSelectedEntry(loadedEntries[0] ?? null);988 }989990 async function handleSave(savedEntry?: VaultEntry) {991 await openVault(savedEntry?.id);992 }993994 function handleBack() {995 setEditEntry(undefined);996 setView("entry");997 }998999 function handleLock() {1000 clearCanarySuppressions();1001 setEntries([]);1002 setSelectedEntry(null);1003 setEditEntry(undefined);1004 setContentPhase("idle");1005 setView("lock");1006 }10071008 function handleHeaderLock() {1009 1010 1011 1012 handleLock();1013 void sendMessage({ type: "LOCK" });1014 }10151016 function navigate(dir: number) {1017 const allEntries = entries();1018 if (allEntries.length === 0) return;1019 const currentIndex = selectedIndex();1020 const baseIndex = currentIndex >= 0 ? currentIndex : 0;1021 const nextIndex = (baseIndex + dir + allEntries.length) % allEntries.length;1022 setSelectedEntry(allEntries[nextIndex]);1023 setContentPhase("enter");1024 queueContentIdle();1025 }10261027 function openList() {1028 setView("list");1029 }10301031 function openHealth() {1032 setEditEntry(undefined);1033 setView("health");1034 }10351036 function handleOpenFileImport() {1037 setRestoreView("file");1038 }10391040 const isShellOverlayOpen = () => view() !== "entry" || restoreView() !== null;10411042 function handleFixEntry(entry: VaultEntry) {1043 1044 1045 if (isPasskeyOnly(entry)) {1046 setSelectedEntry(entry);1047 setView("entry");1048 return;1049 }1050 setEditEntry(entry);1051 setView("add");1052 }10531054 const isLockedView = () => view() === "lock";10551056 async function handleApprovePendingPasskey() {1057 const pending = pendingPasskey();1058 if (!pending) return;1059 if (pending.browser === "firefox" && pending.type === "create") {1060 1061 1062 1063 1064 const { createFirefoxPasskey } = await import("./firefox-passkey");1065 const result = await createFirefoxPasskey(pending);1066 if (!result.ok) {1067 console.warn("Peach Firefox passkey create failed:", result.error);1068 }1069 await sendMessage({ type: "DENY_PASSKEY", payload: { requestId: pending.requestId } });1070 setPendingPasskey(null);1071 void loadEntries();1072 return;1073 }1074 await sendMessage({ type: "APPROVE_PASSKEY", payload: { requestId: pending.requestId } });1075 setPendingPasskey(null);1076 }10771078 async function handleDenyPendingPasskey() {1079 const pending = pendingPasskey();1080 if (!pending) return;1081 await sendMessage({ type: "DENY_PASSKEY", payload: { requestId: pending.requestId } });1082 setPendingPasskey(null);1083 }10841085 function queueContentIdle(after?: () => void) {1086 if (contentPhaseTimer) window.clearTimeout(contentPhaseTimer);1087 contentPhaseTimer = window.setTimeout(() => {1088 setContentPhase("idle");1089 after?.();1090 }, ENTRY_TRANSITION_SETTLE_MS);1091 }10921093 return (1094 <div class="popup-root peach-theme">1095 <Show when={bootState() === "ready"}>1096 <Show1097 when={!pendingPasskey()}1098 fallback={1099 <PasskeyApprovalView1100 type={pendingPasskey()!.type}1101 rpName={pendingPasskey()!.rpName}1102 rpId={pendingPasskey()!.rpId}1103 userName={pendingPasskey()!.userName}1104 userDisplayName={pendingPasskey()!.userDisplayName}1105 onApprove={handleApprovePendingPasskey}1106 onDeny={handleDenyPendingPasskey}1107 />1108 }1109 >1110 <Show1111 when={!isLockedView()}1112 fallback={1113 <Show1114 when={onboarded() || hasVault()}1115 fallback={1116 <Onboarding1117 onComplete={() => { setOnboarded(true); }}1118 />1119 }1120 >1121 <LockView1122 hasVault={hasVault()}1123 ready={bootState() === "ready"}1124 isPro={proStatus()}1125 forceRecoveryWords={forceRecoveryWords()}1126 onUnlock={() => {1127 1128 1129 1130 if (forceRecoveryWords()) setForceRecoveryWords(false);1131 return handleUnlock();1132 }}1133 onBackToOnboarding={1134 !hasVault()1135 ? () => setOnboarded(false)1136 : undefined1137 }1138 />1139 </Show>1140 }1141 >1142 <Show1143 when={view() !== "pro-celebration"}1144 fallback={<ProCelebration />}1145 >1146 <section1147 id="hd-shell"1148 class="peach-shell peach-theme"1149 data-surface="extension"1150 >1151 <header class="peach-chrome" classList={{ "is-hidden-for-overlay": isShellOverlayOpen() }}>1152 <PeachWordmark unlocked />1153 <div class="peach-chrome-actions">1154 <button1155 class="peach-btn peach-btn--ghost peach-btn--sm peach-icon-btn"1156 onClick={() => setView("settings")}1157 aria-label="Settings"1158 >1159 <svg width="14" height="14" viewBox="0 0 14 14" fill="none">1160 <path1161 d="M5.91 1.11C6.38-.02 7.62-.02 8.09 1.11L8.31 1.64C8.48 2.05 8.91 2.27 9.34 2.17L9.9 2.04C11.1 1.76 11.98 2.64 11.7 3.84L11.57 4.4C11.47 4.83 11.69 5.26 12.1 5.43L12.63 5.65C13.76 6.12 13.76 7.36 12.63 7.83L12.1 8.05C11.69 8.22 11.47 8.65 11.57 9.08L11.7 9.64C11.98 10.84 11.1 11.72 9.9 11.44L9.34 11.31C8.91 11.21 8.48 11.43 8.31 11.84L8.09 12.37C7.62 13.5 6.38 13.5 5.91 12.37L5.69 11.84C5.52 11.43 5.09 11.21 4.66 11.31L4.1 11.44C2.9 11.72 2.02 10.84 2.3 9.64L2.43 9.08C2.53 8.65 2.31 8.22 1.9 8.05L1.37 7.83C.24 7.36.24 6.12 1.37 5.65L1.9 5.43C2.31 5.26 2.53 4.83 2.43 4.4L2.3 3.84C2.02 2.64 2.9 1.76 4.1 2.04L4.66 2.17C5.09 2.27 5.52 2.05 5.69 1.64L5.91 1.11Z"1162 stroke="currentColor"1163 stroke-width="0.9"1164 />1165 <circle cx="7" cy="7" r="2.1" stroke="currentColor" stroke-width="0.9" />1166 </svg>1167 </button>1168 <button1169 class="peach-btn peach-btn--ghost peach-btn--sm peach-icon-btn"1170 onClick={handleAdd}1171 aria-label="New entry"1172 >1173 <svg width="11" height="11" viewBox="0 0 11 11" fill="none" stroke="currentColor" stroke-width="1.1" stroke-linecap="round">1174 <path d="M5.5 1v9M1 5.5h9" />1175 </svg>1176 </button>1177 <button1178 class="peach-btn peach-btn--ghost peach-btn--sm peach-icon-btn peach-lock-btn"1179 onClick={() => void handleHeaderLock()}1180 aria-label="Lock vault"1181 >1182 <svg class="peach-lock-icon" width="14" height="16" viewBox="0 0 14 16" fill="none">1183 <path1184 d="M3.75 6V4.75C3.75 2.96 5.21 1.5 7 1.5C8.79 1.5 10.25 2.96 10.25 4.75V6"1185 stroke="currentColor"1186 stroke-width="1"1187 stroke-linecap="round"1188 />1189 <rect x="1.5" y="6" width="11" height="8.5" rx="2.2" stroke="currentColor" stroke-width="1" />1190 <circle cx="7" cy="10.25" r="1" fill="currentColor" />1191 </svg>1192 </button>1193 </div>1194 </header>11951196 <Show when={recentPairToast()}>1197 <div class="peach-pair-toast" role="status" aria-live="polite">1198 Paired with <strong>{recentPairToast()}</strong>1199 </div>1200 </Show>12011202 <Show when={incomingPair() !== null}>1203 <div class="peach-pair-request-banner" role="dialog" aria-label="Pairing request">1204 <div class="peach-pair-request-header">1205 <span class="peach-pair-request-mark"><PeachMark class="peach-pair-request-icon" /></span>1206 <span class="peach-pair-request-title">Pairing request</span>1207 <span class="peach-pair-request-countdown">{incomingPairSecondsLeft()}s</span>1208 </div>1209 <p class="peach-pair-request-body">1210 <strong>{incomingPair()!.deviceName}</strong> wants to sync with this Peach.1211 </p>1212 <div class="peach-pair-request-actions">1213 <button1214 class="peach-btn peach-btn--ghost peach-btn--sm"1215 onClick={() => void respondIncomingPairing(false)}1216 disabled={incomingPairResponding()}1217 >1218 Reject1219 </button>1220 <button1221 class="peach-btn peach-btn--accent peach-btn--sm"1222 onClick={() => void respondIncomingPairing(true)}1223 disabled={incomingPairResponding()}1224 >1225 Accept1226 </button>1227 </div>1228 </div>1229 </Show>12301231 <Show when={pendingProNotice() !== null}>1232 <div class="peach-pro-notice-banner">1233 <span>✦ {pendingProNotice()?.feature === "sync" ? "Sync" : "A Pro feature"} requires Peach Pro</span>1234 <button1235 class="peach-pro-notice-link"1236 onClick={() => {1237 setUpgradeHighlight((pendingProNotice()?.feature as ProFeature) ?? null);1238 setSettingsInitialSection("license");1239 setView("settings");1240 setPendingProNotice(null);1241 }}1242 >1243 Learn more →1244 </button>1245 <button class="peach-pro-notice-close" onClick={() => setPendingProNotice(null)} aria-label="Dismiss">✕</button>1246 </div>1247 </Show>12481249 <div class="peach-shell-body">1250 <div class="peach-shell-veil"></div>1251 <div class="peach-content-frame" data-content-phase={contentPhase()} classList={{ navigating: contentTransitioning() }}>1252 <EntryView1253 entry={selectedEntry()}1254 currentTabUrl={currentTabUrl()}1255 onDelete={handleDelete}1256 onFieldSaved={() => void loadEntries()}1257 onEscape={() => { setView("list"); }}1258 />1259 </div>12601261 <section class="peach-search-wrap" classList={{ "is-hidden-for-overlay": isShellOverlayOpen() }}>1262 <div class="peach-search-bar">1263 <span class="peach-search-icon">1264 <svg width="13" height="13" viewBox="0 0 13 13" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round">1265 <circle cx="5.5" cy="5.5" r="3.75" />1266 <path d="M8.75 8.75L11.5 11.5" />1267 </svg>1268 </span>1269 <input1270 class="peach-search-input"1271 placeholder="search vault..."1272 autocomplete="off"1273 aria-label="Search vault entries"1274 onClick={openList}1275 onFocus={openList}1276 readOnly1277 />1278 <div class="peach-search-meta">1279 <span class="peach-search-counter">1280 {entries().length > 01281 ? `${selectedIndex() + 1} / ${entries().length}`1282 : "0 entries"}1283 </span>1284 <span class="peach-divider"></span>1285 <button1286 class="peach-btn peach-btn--ghost peach-btn--sm peach-icon-btn"1287 onClick={() => navigate(-1)}1288 aria-label="Previous entry"1289 disabled={entries().length === 0}1290 >1291 <svg width="6" height="11" viewBox="0 0 6 11" fill="none" stroke="currentColor" stroke-width="1.1" stroke-linecap="round" stroke-linejoin="round">1292 <path d="M5 1L1 5.5L5 10" />1293 </svg>1294 </button>1295 <button1296 class="peach-btn peach-btn--ghost peach-btn--sm peach-icon-btn"1297 onClick={() => navigate(1)}1298 aria-label="Next entry"1299 disabled={entries().length === 0}1300 >1301 <svg width="6" height="11" viewBox="0 0 6 11" fill="none" stroke="currentColor" stroke-width="1.1" stroke-linecap="round" stroke-linejoin="round">1302 <path d="M1 1L5 5.5L1 10" />1303 </svg>1304 </button>1305 </div>1306 </div>1307 </section>1308 </div>13091310 {13111312}1313 <Show when={!isNativePlatform() && view() === "list"}>1314 <VaultView1315 entries={entries()}1316 selectedEntryId={selectedEntry()?.id}1317 currentTabDomain={currentTabDomain()}1318 sortOrder={sortOrder()}1319 searchSeed={listSearchSeed()}1320 searchSeedNonce={listSearchSeedNonce()}1321 onSelectEntry={handleSelectEntry}1322 onSortOrderChange={setSortOrder}1323 onAdd={handleAdd}1324 onClose={() => setView("entry")}1325 onOpenTrash={() => setView("trash")}1326 onDeleteMany={handleDeleteMany}1327 />1328 </Show>1329 <Show when={isNativePlatform() && hasVault()}>1330 <Portal>1331 <div1332 class="peach-vault-sheet"1333 classList={{ "is-open": view() === "list", "is-dragging": sheetTranslate() !== null }}1334 style={(() => {1335 const live = sheetTranslate();1336 if (live === null) return undefined;1337 return { transform: `translateY(${live}px)` };1338 })()}1339 >1340 <VaultView1341 entries={entries()}1342 selectedEntryId={selectedEntry()?.id}1343 currentTabDomain={currentTabDomain()}1344 sortOrder={sortOrder()}1345 searchSeed={listSearchSeed()}1346 searchSeedNonce={listSearchSeedNonce()}1347 onSelectEntry={handleSelectEntry}1348 onSortOrderChange={setSortOrder}1349 onAdd={handleAdd}1350 onClose={() => setView("entry")}1351 onOpenTrash={() => setView("trash")}1352 onDeleteMany={handleDeleteMany}1353 />1354 </div>1355 </Portal>1356 </Show>1357 <Show when={view() === "settings"}>1358 <Suspense fallback={<div class="peach-loading"><PeachWordmark /></div>}>1359 <SettingsView1360 entriesCount={entries().length}1361 breachMonitoring={breachMonitoring()}1362 lockOnClose={lockOnClose()}1363 autoLockMinutes={autoLockMinutes()}1364 trashRetentionDays={trashRetentionDays()}1365 theme={theme()}1366 accentColor={accentColor()}1367 displayFont={displayFont()}1368 textSize={textSize()}1369 reduceMotion={reduceMotion()}1370 isPro={proStatus()}1371 initialSection={settingsInitialSection()}1372 upgradeHighlight={upgradeHighlight()}1373 onBreachMonitoringChange={applyBreachMonitoring}1374 onLockOnCloseChange={applyLockOnClose}1375 onAutoLockMinutesChange={applyAutoLockMinutes}1376 onTrashRetentionChange={applyTrashRetention}1377 onThemeChange={applyTheme}1378 onAccentChange={applyAccentColor}1379 onDisplayFontChange={applyDisplayFont}1380 onTextSizeChange={applyTextSize}1381 onReduceMotionChange={applyReduceMotion}1382 shortcuts={shortcutBindings()}1383 onShortcutsChange={applyShortcuts}1384 onLicenseChange={async () => {1385 1386 1387 1388 1389 1390 await refreshProStatus();1391 void loadEntries();1392 const should = await sendMessage({ type: "SHOULD_PLAY_CELEBRATION" });1393 if ((should as { ok: boolean; data?: boolean }).data === true) {1394 await sendMessage({ type: "MARK_CELEBRATION_PLAYED" });1395 setView("pro-celebration");1396 window.setTimeout(() => setView("settings"), 2500);1397 }1398 }}1399 onBack={() => { setSettingsInitialSection(null); setUpgradeHighlight(null); handleBack(); }}1400 onImport={() => setView("import")}1401 onExport={() => setView("export")}1402 onBreachCheckDone={loadEntries}1403 onOpenHealth={openHealth}1404 onOpenSyncPairing={() => setView("sync-pairing")}1405 onOpenFileImport={handleOpenFileImport}1406 onOpenPanic={() => setView("panic")}1407 />1408 </Suspense>1409 </Show>1410 <Show when={view() === "sync-pairing"}>1411 <Suspense fallback={<div class="peach-loading"><PeachWordmark /></div>}>1412 <SyncPairingView1413 onClose={() => setView("settings")}1414 onPaired={() => { }}1415 />1416 </Suspense>1417 </Show>1418 <Show when={view() === "add"}>1419 <AddView1420 entry={editEntry()}1421 entries={entries()}1422 onBack={handleBack}1423 onSave={handleSave}1424 />1425 </Show>1426 <Show when={view() === "import"}>1427 <Suspense fallback={<div class="peach-loading"><PeachWordmark /></div>}>1428 <ImportView onBack={handleBack} onImport={handleSave} />1429 </Suspense>1430 </Show>1431 <Show when={view() === "export"}>1432 <Suspense fallback={<div class="peach-loading"><PeachWordmark /></div>}>1433 <ExportView1434 onBack={() => {1435 if (returnToPanic()) {1436 setReturnToPanic(false);1437 setView("panic");1438 } else {1439 handleBack();1440 }1441 }}1442 />1443 </Suspense>1444 </Show>1445 <Show when={view() === "panic"}>1446 <Suspense fallback={<div class="peach-loading"><PeachWordmark /></div>}>1447 <PanicView1448 onCancel={() => setView("settings")}1449 onOpenExport={() => {1450 setReturnToPanic(true);1451 setView("export");1452 }}1453 onDestroyed={async () => {1454 clearCanarySuppressions();1455 setEntries([]);1456 setSelectedEntry(null);1457 setEditEntry(undefined);1458 setHasVault(false);1459 setOnboarded(false);1460 setProStatus(false);1461 setPendingPasskey(null);1462 setUpgradeHighlight(null);1463 setSettingsInitialSection(null);1464 setPendingProNotice(null);1465 setPendingCelebration(false);1466 setReturnToPanic(false);1467 setContentPhase("idle");1468 setView("lock");1469 }}1470 />1471 </Suspense>1472 </Show>1473 <Show when={view() === "health"}>1474 <Suspense fallback={<div class="peach-loading"><PeachWordmark /></div>}>1475 <HealthView1476 entries={entries()}1477 isPro={proStatus()}1478 onFixEntry={handleFixEntry}1479 onBack={() => setView("settings")}1480 onRefresh={loadEntries}1481 />1482 </Suspense>1483 </Show>1484 <Show when={view() === "trash"}>1485 <Suspense fallback={<div class="peach-loading"><PeachWordmark /></div>}>1486 <TrashView1487 onBack={() => setView("list")}1488 onRestored={() => void loadEntries()}1489 />1490 </Suspense>1491 </Show>1492 <Show when={restoreView() === "file"}>1493 <Suspense fallback={<div class="peach-loading"><PeachWordmark /></div>}>1494 <ImportView1495 mode="onboarding"1496 replacesExistingVault={true}1497 onBack={() => setRestoreView(null)}1498 onImport={async () => {1499 setRestoreView(null);1500 await handleUnlock();1501 }}1502 />1503 </Suspense>1504 </Show>1505 </section>1506 </Show>1507 </Show>1508 </Show>1509 </Show>1510 <Show when={showShortcutsHelp()}>1511 <ShortcutsHelpOverlay1512 bindings={shortcutBindings()}1513 onClose={() => setShowShortcutsHelp(false)}1514 />1515 </Show>1516 </div>1517 );1518}15191520function ShortcutsHelpOverlay(props: {1521 bindings: Record<ShortcutAction, Keybinding>;1522 onClose: () => void;1523}) {1524 return (1525 <div class="peach-shortcuts-help-backdrop" onClick={props.onClose}>1526 <div class="peach-shortcuts-help-card" onClick={(e) => e.stopPropagation()}>1527 <div class="peach-shortcuts-help-head">1528 <h3>Keyboard shortcuts</h3>1529 <button class="peach-shortcuts-help-close" onClick={props.onClose} aria-label="Close">✕</button>1530 </div>1531 <div class="peach-shortcuts-help-body">1532 <p class="peach-settings-sub-label">ENTRY VIEW</p>1533 <ul>1534 {SHORTCUT_DESCRIPTORS.filter((d) => d.scope === "entry").map((d) => (1535 <li>1536 <span>{d.label}</span>1537 <kbd>{formatKeybinding(props.bindings[d.action])}</kbd>1538 </li>1539 ))}1540 </ul>1541 <p class="peach-settings-sub-label">ANYWHERE</p>1542 <ul>1543 {SHORTCUT_DESCRIPTORS.filter((d) => d.scope === "global").map((d) => (1544 <li>1545 <span>{d.label}</span>1546 <kbd>{formatKeybinding(props.bindings[d.action])}</kbd>1547 </li>1548 ))}1549 </ul>1550 </div>1551 </div>1552 </div>1553 );1554}