1import { createEffect, createMemo, createSignal, lazy, onCleanup, onMount, Show, Suspense } from "solid-js";2import { App as CapacitorApp } from "@capacitor/app";3import { Capacitor, registerPlugin } from "@capacitor/core";4import { Keyboard } from "@capacitor/keyboard";5import { StatusBar, Style } from "@capacitor/status-bar";6import { storageGet, storageSet } from "../shared/storage";7import { sendMessage } from "../shared/bridge";8import { clearInMemoryVault, publishInMemoryVault } from "../shared/in-memory-vault";9import { ACCENT_COLORS } from "../shared/types";10import type { AccentColorName, PendingPasskeyRequest, ProFeature, VaultEntry } from "../shared/types";11import type { IncomingPairingRequest } from "../shared/sync-types";12import { isPasskeyOnly } from "../shared/types";13import { LockView } from "./views/Lock";14import { Onboarding } from "./views/Onboarding";15import { ProCelebration } from "./views/ProCelebration";16import { VaultView, type SortOrder } from "./views/Vault";17import { EntryView } from "./views/Entry";18import { AddView } from "./views/Add";19import { PeachWordmark } from "./components/PeachMark";20import { PasskeyApprovalView } from "./views/PasskeyApproval";21import { extractDomain } from "../shared/domain";22import { popupCopy } from "./copy";23import {24 DEFAULT_BINDINGS,25 formatKeybinding,26 getActiveBindings,27 matchKeybinding,28 SHORTCUT_DESCRIPTORS,29 type Keybinding,30 type ShortcutAction,31} from "../shared/shortcuts";32import { generateTOTP } from "../crypto/totp";3334export { sendMessage } from "../shared/bridge";3536const ImportView = lazy(() => import("./views/Import").then(m => ({ default: m.ImportView })));37const ExportView = lazy(() => import("./views/Export").then(m => ({ default: m.ExportView })));38const SettingsView = lazy(() => import("./views/Settings").then(m => ({ default: m.SettingsView })));39const HealthView = lazy(() => import("./views/Health").then(m => ({ default: m.HealthView })));40const TrashView = lazy(() => import("./views/TrashView").then(m => ({ default: m.TrashView })));41const PanicView = lazy(() => import("./views/Panic").then(m => ({ default: m.PanicView })));42const SyncPairingView = lazy(() => import("./views/SyncPairing").then(m => ({ default: m.SyncPairingView })));4344const Autofill = registerPlugin<{45 checkPendingSave(): Promise<{ pending: string | null }>;46 openAutofillSettings(): Promise<void>;47 isEnabledAsAutofillService(): Promise<{ enabled: boolean }>;48}>("Autofill");4950type View =51 | "lock"52 | "pro-celebration"53 | "entry"54 | "list"55 | "add"56 | "settings"57 | "sync-pairing"58 | "import"59 | "export"60 | "health"61 | "trash"62 | "panic";63type BootState = "loading" | "ready";6465const canarySuppressMap = new Map<string, boolean>();66let shellRingAnimation: Animation | null = null;6768export function isCanarySuppressed(entryId: string): boolean {69 return canarySuppressMap.get(entryId) ?? false;70}7172export function setCanarySuppressed(entryId: string, suppressed: boolean): void {73 canarySuppressMap.set(entryId, suppressed);74}7576export function clearCanarySuppressions(): void {77 canarySuppressMap.clear();78}7980export function triggerRing() {81 const shell = document.getElementById("hd-shell");82 if (!shell) return;8384 shellRingAnimation?.cancel();85 shell.dataset.glowing = "true";86 const animation = shell.animate(87 [88 { offset: 0, boxShadow: "var(--copy-shadow)" },89 {90 offset: 0.3,91 boxShadow:92 "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)",93 },94 { offset: 1, boxShadow: "var(--copy-shadow)" },95 ],96 {97 duration: 720,98 easing: "cubic-bezier(0.4, 0, 0.2, 1)",99 fill: "none",100 }101 );102 shellRingAnimation = animation;103 const clearGlow = () => {104 if (shellRingAnimation !== animation) return;105 shellRingAnimation = null;106 delete shell.dataset.glowing;107 };108 animation.onfinish = clearGlow;109 animation.oncancel = clearGlow;110}111112113export function triggerPipPulse() {114 const pip = document.querySelector(".peach-status-pip, .pip");115 if (pip) {116 pip.classList.remove("pulse");117 void (pip as HTMLElement).offsetWidth;118 pip.classList.add("pulse");119 }120}121122const ENTRY_TRANSITION_EXIT_MS = 95;123const ENTRY_TRANSITION_SETTLE_MS = 135;124125export default function App() {126 const [bootState, setBootState] = createSignal<BootState>("loading");127 const [view, setView] = createSignal<View>("lock");128 const [contentPhase, setContentPhase] = createSignal<"enter" | "exit" | "idle">(129 "enter"130 );131 const [contentTransitioning, setContentTransitioning] = createSignal(false);132 const [layoutClass, setLayoutClass] = createSignal<"compact" | "medium" | "expanded">("compact");133 const isTwoPaneLayout = () => layoutClass() === "medium" || layoutClass() === "expanded";134 const [hasVault, setHasVault] = createSignal(false);135 const [onboarded, setOnboarded] = createSignal(true);136 const [entries, setEntries] = createSignal<VaultEntry[]>([]);137 const [selectedEntry, setSelectedEntry] = createSignal<VaultEntry | null>(null);138 const [editEntry, setEditEntry] = createSignal<VaultEntry | undefined>(undefined);139 const [accentColor, setAccentColor] = createSignal<AccentColorName>("peach");140 const [theme, setTheme] = createSignal<"dark" | "light">("dark");141 const [displayFont, setDisplayFont] = createSignal<"cormorant-italic" | "cormorant" | "inter" | "system">("cormorant-italic");142 const [textSize, setTextSize] = createSignal<"small" | "medium" | "large">("medium");143 const [reduceMotion, setReduceMotion] = createSignal<boolean>(false);144 const [lockOnClose, setLockOnClose] = createSignal(true);145 const [autoLockMinutes, setAutoLockMinutes] = createSignal(5);146 const [breachMonitoring, setBreachMonitoring] = createSignal(true);147 const [shortcutBindings, setShortcutBindings] = createSignal<Record<ShortcutAction, Keybinding>>(DEFAULT_BINDINGS);148 const [showShortcutsHelp, setShowShortcutsHelp] = createSignal(false);149 const [trashRetentionDays, setTrashRetentionDays] = createSignal(30);150 const [restoreView, setRestoreView] = createSignal<"file" | null>(null);151 const [pendingPasskey, setPendingPasskey] = createSignal<PendingPasskeyRequest | null>(null);152 const [currentTabDomain, setCurrentTabDomain] = createSignal<string>("");153 const [currentTabUrl, setCurrentTabUrl] = createSignal<string>("");154 155 156 157 158 const [proStatus, setProStatus] = createSignal(false);159 const [settingsInitialSection, setSettingsInitialSection] = createSignal<string | null>(null);160 const [upgradeHighlight, setUpgradeHighlight] = createSignal<ProFeature | null>(null);161 const [sortOrder, setSortOrder] = createSignal<SortOrder>("url-first");162 const [listSearchSeed, setListSearchSeed] = createSignal("");163 const [listSearchSeedNonce, setListSearchSeedNonce] = createSignal(0);164 const [pendingCelebration, setPendingCelebration] = createSignal(false);165 const [pendingProNotice, setPendingProNotice] = createSignal<{ feature: string } | null>(null);166 const [pendingAutofillSave, setPendingAutofillSave] = createSignal<{167 domain: string;168 username: string;169 password: string;170 } | null>(null);171 const [backExitNotice, setBackExitNotice] = createSignal(false);172 const [incomingPair, setIncomingPair] = createSignal<IncomingPairingRequest | null>(null);173 const [recentPairToast, setRecentPairToast] = createSignal<string | null>(null);174 const [incomingPairResponding, setIncomingPairResponding] = createSignal(false);175 const [incomingPairTick, setIncomingPairTick] = createSignal(0);176 const incomingPairSecondsLeft = () => {177 void incomingPairTick();178 const req = incomingPair();179 if (!req) return 0;180 return Math.max(0, Math.ceil((req.expiresAt - Date.now()) / 1000));181 };182 183 184 185 const [returnToPanic, setReturnToPanic] = createSignal(false);186187 let contentPhaseTimer: number | undefined;188 let lastBackExitAt = 0;189190 function applyAccent(name: AccentColorName) {191 const color = ACCENT_COLORS.find(c => c.name === name) ?? ACCENT_COLORS[0]!;192 const hex = color.hex;193 document.documentElement.style.setProperty("--peach-accent", hex);194 195 196 document.documentElement.style.setProperty("--peach-glow", hex + "2A");197 document.documentElement.style.setProperty("--peach-surface-tint", hex + "09");198 document.documentElement.style.setProperty("--peach-border-accent", hex + "24");199 }200201 createEffect(() => {202 applyAccent(accentColor());203 });204205 createEffect(() => {206 document.documentElement.classList.toggle("light", theme() === "light");207 document.body.classList.toggle("light", theme() === "light");208 if (Capacitor.isNativePlatform()) {209 void applyMobileStatusBar(theme());210 }211 });212213 createEffect(() => {214 document.documentElement.setAttribute("data-display-font", displayFont());215 });216217 createEffect(() => {218 document.documentElement.setAttribute("data-text-size", textSize());219 });220221 createEffect(() => {222 if (reduceMotion()) {223 document.documentElement.setAttribute("data-motion", "reduce");224 } else {225 document.documentElement.removeAttribute("data-motion");226 }227 });228229 const selectedIndex = createMemo(() => {230 const currentId = selectedEntry()?.id;231 if (!currentId) return entries().length > 0 ? 0 : -1;232 return entries().findIndex((entry) => entry.id === currentId);233 });234235 async function applyAccentColor(name: AccentColorName) {236 applyAccent(name);237 setAccentColor(name);238 await sendMessage({ type: "UPDATE_SETTINGS", payload: { accentColor: name } });239 }240241 async function applyTheme(t: "dark" | "light") {242 setTheme(t);243 await sendMessage({ type: "UPDATE_SETTINGS", payload: { theme: t } });244 }245246 async function applyDisplayFont(f: "cormorant-italic" | "cormorant" | "inter" | "system") {247 setDisplayFont(f);248 await sendMessage({ type: "UPDATE_SETTINGS", payload: { displayFont: f } });249 }250251 async function applyTextSize(size: "small" | "medium" | "large") {252 setTextSize(size);253 await sendMessage({ type: "UPDATE_SETTINGS", payload: { textSize: size } });254 }255256 async function applyReduceMotion(enabled: boolean) {257 setReduceMotion(enabled);258 await sendMessage({ type: "UPDATE_SETTINGS", payload: { reduceMotion: enabled } });259 }260261 262 263 264 async function applyShortcuts(active: Record<ShortcutAction, Keybinding>) {265 setShortcutBindings(active);266 const overrides: Record<string, Keybinding> = {};267 for (const action of Object.keys(active) as ShortcutAction[]) {268 const a = active[action];269 const d = DEFAULT_BINDINGS[action];270 const same = a.key === d.key271 && Boolean(a.ctrl) === Boolean(d.ctrl)272 && Boolean(a.meta) === Boolean(d.meta)273 && Boolean(a.shift) === Boolean(d.shift)274 && Boolean(a.alt) === Boolean(d.alt);275 if (!same) overrides[action] = a;276 }277 await sendMessage({ type: "UPDATE_SETTINGS", payload: { shortcuts: overrides } });278 }279280 async function applyLockOnClose(enabled: boolean) {281 setLockOnClose(enabled);282 await sendMessage({283 type: "UPDATE_SETTINGS",284 payload: { lockOnClose: enabled },285 });286 }287288 async function applyAutoLockMinutes(minutes: number) {289 setAutoLockMinutes(minutes);290 await sendMessage({291 type: "UPDATE_SETTINGS",292 payload: { autoLockMinutes: minutes },293 });294 }295296 async function applyBreachMonitoring(enabled: boolean) {297 setBreachMonitoring(enabled);298 await sendMessage({299 type: "UPDATE_SETTINGS",300 payload: { breachMonitoring: enabled },301 });302 }303304 async function applyMobileStatusBar(nextTheme: "dark" | "light") {305 try {306 await StatusBar.setStyle({ style: nextTheme === "light" ? Style.Light : Style.Dark });307 await StatusBar.setBackgroundColor({308 color: nextTheme === "light" ? "#EEE3CC" : "#0C0A06",309 });310 } catch {311 312 }313 }314315 function handleBackNavigation() {316 if (showShortcutsHelp()) {317 setShowShortcutsHelp(false);318 return;319 }320 if (restoreView() !== null) {321 setRestoreView(null);322 return;323 }324325 switch (view()) {326 case "list":327 setView("entry");328 return;329 case "settings":330 case "add":331 case "import":332 handleBack();333 return;334 case "export":335 if (returnToPanic()) {336 setReturnToPanic(false);337 setView("panic");338 } else {339 handleBack();340 }341 return;342 case "health":343 case "panic":344 case "sync-pairing":345 setView("settings");346 return;347 case "trash":348 setView("list");349 return;350 case "entry": {351 const now = Date.now();352 if (now - lastBackExitAt < 1600) {353 void CapacitorApp.exitApp();354 return;355 }356 lastBackExitAt = now;357 setBackExitNotice(true);358 window.setTimeout(() => setBackExitNotice(false), 1400);359 return;360 }361 default:362 void CapacitorApp.exitApp();363 }364 }365366 onMount(async () => {367 if (Capacitor.isNativePlatform()) {368 document.body.classList.add("peach-mobile");369 document.documentElement.classList.add("peach-mobile-root");370 void applyMobileStatusBar(theme());371372 373 374 const updateLayoutClass = () => {375 const w = window.innerWidth;376 const cls = document.body.classList;377 cls.remove("layout-compact", "layout-medium", "layout-expanded");378 const next: "compact" | "medium" | "expanded" =379 w >= 840 ? "expanded" : w >= 600 ? "medium" : "compact";380 cls.add(`layout-${next}`);381 setLayoutClass(next);382 };383 updateLayoutClass();384 window.addEventListener("resize", updateLayoutClass);385386 const keyboardShow = await Keyboard.addListener("keyboardWillShow", (info) => {387 document.body.style.paddingBottom = `${info.keyboardHeight}px`;388 });389 const keyboardHide = await Keyboard.addListener("keyboardWillHide", () => {390 document.body.style.paddingBottom = "0";391 });392 const backButton = await CapacitorApp.addListener("backButton", () => {393 handleBackNavigation();394 });395396 let touchStartX = 0;397 let touchStartY = 0;398 const handleTouchStart = (event: TouchEvent) => {399 const touch = event.touches[0];400 if (!touch) return;401 touchStartX = touch.clientX;402 touchStartY = touch.clientY;403 };404 const handleTouchEnd = (event: TouchEvent) => {405 const touch = event.changedTouches[0];406 if (!touch) return;407 const dx = touch.clientX - touchStartX;408 const dy = Math.abs(touch.clientY - touchStartY);409 if (touchStartX < 30 && dx > 60 && dy < 40) {410 handleBackNavigation();411 }412 };413 document.addEventListener("touchstart", handleTouchStart, { passive: true });414 document.addEventListener("touchend", handleTouchEnd, { passive: true });415416 onCleanup(() => {417 void keyboardShow.remove();418 void keyboardHide.remove();419 void backButton.remove();420 window.removeEventListener("resize", updateLayoutClass);421 document.removeEventListener("touchstart", handleTouchStart);422 document.removeEventListener("touchend", handleTouchEnd);423 document.body.style.paddingBottom = "0";424 });425 }426427 428 429 430 431 432 const [unlockResponse, vaultResponse, , celebrationResponse] = await Promise.all([433 sendMessage({ type: "IS_UNLOCKED" }),434 sendMessage({ type: "HAS_VAULT" }),435 refreshCurrentTab(),436 sendMessage({ type: "SHOULD_PLAY_CELEBRATION" }),437 ]);438 const unlocked = Boolean(439 (unlockResponse as { ok: boolean; data?: boolean }).data440 );441 const vaultExists = Boolean(442 (vaultResponse as { ok: boolean; data?: boolean }).data443 );444 const shouldCelebrate = Boolean(445 (celebrationResponse as { ok: boolean; data?: boolean }).data446 );447 setHasVault(vaultExists);448 449 450 451 try {452 const onboarded = await storageGet("peach_onboarded");453 const seen = onboarded === "true";454 if (vaultExists && !seen) {455 await storageSet("peach_onboarded", "true");456 setOnboarded(true);457 } else {458 setOnboarded(seen);459 }460 } catch {461 462 setOnboarded(true);463 }464 await Promise.all([restoreSettings(), refreshProStatus()]);465466 467 if (shouldCelebrate) {468 await sendMessage({ type: "MARK_CELEBRATION_PLAYED" });469 }470471 if (unlocked && vaultExists) {472 await openVault(undefined, shouldCelebrate);473 if (shouldCelebrate) {474 setView("pro-celebration");475 window.setTimeout(() => setView("entry"), 2500);476 }477 } else if (shouldCelebrate) {478 setPendingCelebration(true);479 }480481 await refreshPendingPasskey();482 await refreshIncomingPairing();483 await consumeRecentPairing();484485 486 if (!Capacitor.isNativePlatform()) {487 const handleTabActivated = () => { void refreshCurrentTab(); };488 const handleTabUpdated = (_tabId: number, changeInfo: { url?: string; status?: string }) => {489 if (changeInfo.url || changeInfo.status === "complete") void refreshCurrentTab();490 };491 try {492 chrome.tabs.onActivated.addListener(handleTabActivated);493 chrome.tabs.onUpdated.addListener(handleTabUpdated);494 onCleanup(() => {495 chrome.tabs.onActivated.removeListener(handleTabActivated);496 chrome.tabs.onUpdated.removeListener(handleTabUpdated);497 });498 } catch {499 500 }501 }502503 setBootState("ready");504 document.getElementById("pre-lock")?.setAttribute("hidden", "true");505506 507 if (!Capacitor.isNativePlatform() && chrome.storage.session) {508 const session = await chrome.storage.session.get(["pendingProGate", "pendingProNotice"]) as509 Record<string, { feature?: string } | undefined>;510 if (session.pendingProGate?.feature) {511 await chrome.storage.session.remove("pendingProGate");512 setUpgradeHighlight((session.pendingProGate.feature as ProFeature) ?? null);513 setSettingsInitialSection("license");514 setView("settings");515 } else if (session.pendingProNotice?.feature) {516 await chrome.storage.session.remove("pendingProNotice");517 setPendingProNotice({ feature: session.pendingProNotice.feature ?? "" });518 }519 }520521 if (Capacitor.getPlatform() === "android") {522 try {523 const { pending } = await Autofill.checkPendingSave();524 if (pending) {525 const parsed = JSON.parse(pending) as {526 domain?: string;527 username?: string;528 password?: string;529 };530 if (parsed.username && parsed.password) {531 setPendingAutofillSave({532 domain: parsed.domain ?? "",533 username: parsed.username,534 password: parsed.password,535 });536 }537 }538 } catch {539 540 }541 }542543 544 545 546 547 void Promise.all([548 import("./views/Settings").catch(() => {}),549 import("./views/Import").catch(() => {}),550 import("./views/Export").catch(() => {}),551 import("./views/Health").catch(() => {}),552 import("./views/TrashView").catch(() => {}),553 ]);554555 556 557 558 if (!Capacitor.isNativePlatform()) {559 let popupPort: chrome.runtime.Port | null = null;560 try {561 popupPort = chrome.runtime.connect({ name: "popup" });562 } catch { }563 onCleanup(() => { try { popupPort?.disconnect(); } catch {} });564565 566 567 const handleRuntimeMessage = (msg: { type?: string; payload?: { feature?: ProFeature } }) => {568 if (msg?.type === "VAULT_LOCKED" && view() !== "lock") handleLock();569 if (msg?.type === "PRO_GATE_TRIGGERED") {570 setUpgradeHighlight(msg.payload?.feature ?? null);571 setSettingsInitialSection("license");572 setView("settings");573 }574 if (msg?.type === "INCOMING_PAIRING_REQUEST") {575 void refreshIncomingPairing();576 }577 };578 chrome.runtime.onMessage.addListener(handleRuntimeMessage);579 onCleanup(() => chrome.runtime.onMessage.removeListener(handleRuntimeMessage));580 }581582 583 584 585 const SHORTCUT_HANDLERS: Partial<Record<ShortcutAction, () => void>> = {586 copy_password: () => {587 const entry = selectedEntry();588 if (entry?.password) void popupCopy(entry.password, "Password").then((ok) => { if (ok) triggerRing(); });589 },590 copy_username: () => {591 const entry = selectedEntry();592 if (entry?.username) void popupCopy(entry.username, "Username").then((ok) => { if (ok) triggerRing(); });593 },594 copy_totp: () => {595 const entry = selectedEntry();596 if (!entry?.totp) return;597 try {598 const { code } = generateTOTP(entry.totp);599 void popupCopy(code, "2FA").then((ok) => { if (ok) triggerRing(); });600 } catch { }601 },602 new_entry: () => handleAdd(),603 edit_entry: () => {604 const entry = selectedEntry();605 606 607 if (!entry || isPasskeyOnly(entry)) return;608 setEditEntry(entry);609 setView("add");610 },611 delete_entry: () => {612 if (selectedEntry()) void handleDelete();613 },614 lock_vault: () => { void handleHeaderLock(); },615 search: () => openList(),616 nav_prev: () => navigate(-1),617 nav_next: () => navigate(1),618 jump_vault: () => setView("entry"),619 jump_settings: () => setView("settings"),620 show_help: () => setShowShortcutsHelp(true),621 };622623 624 625 626 const ENTRY_SCOPED: ReadonlySet<ShortcutAction> = new Set([627 "copy_password", "copy_username", "copy_totp",628 "edit_entry", "delete_entry", "nav_prev", "nav_next",629 ]);630631 const handleGlobalKeydown = (e: KeyboardEvent) => {632 const v = view();633 const inInput = (e.target as HTMLElement)?.tagName === "INPUT"634 || (e.target as HTMLElement)?.tagName === "TEXTAREA"635 || (e.target as HTMLElement)?.isContentEditable;636 const isPrintableSearchKey =637 e.key.length === 1 &&638 !e.ctrlKey &&639 !e.metaKey &&640 !e.altKey;641642 643 if (v === "pro-celebration") return;644645 646 647 if (showShortcutsHelp()) {648 if (e.key === "Escape") { e.preventDefault(); setShowShortcutsHelp(false); }649 return;650 }651652 653 if (e.key === "Escape") {654 if (v === "list") { setView("entry"); return; }655 if (v === "settings" || v === "import" || v === "export" || v === "add" || v === "health") { handleBack(); return; }656 if (v === "sync-pairing") { setView("settings"); return; }657 }658659 660 661 662 const bindings = shortcutBindings();663 for (const action of Object.keys(bindings) as ShortcutAction[]) {664 const binding = bindings[action];665 if (!matchKeybinding(e, binding)) continue;666 667 668 const hasMod = binding.ctrl || binding.meta || binding.alt || binding.shift;669 if (!hasMod && binding.key.length === 1 && inInput) return;670 if (ENTRY_SCOPED.has(action) && v !== "entry") return;671 e.preventDefault();672 SHORTCUT_HANDLERS[action]?.();673 return;674 }675676 677 678 679 680 if (v === "entry" && !inInput && isPrintableSearchKey) {681 e.preventDefault();682 primeListSearch(e.key);683 return;684 }685 };686 window.addEventListener("keydown", handleGlobalKeydown);687 onCleanup(() => window.removeEventListener("keydown", handleGlobalKeydown));688689 if (!Capacitor.isNativePlatform()) {690 const handleStorageChanged = (691 changes: Record<string, chrome.storage.StorageChange>,692 areaName: string693 ) => {694 if (areaName !== "session") return;695 if (!Object.keys(changes).some((key) => key.startsWith("passkey_pending_"))) {696 return;697 }698 void refreshPendingPasskey();699 };700 chrome.storage.onChanged.addListener(handleStorageChanged);701 onCleanup(() => chrome.storage.onChanged.removeListener(handleStorageChanged));702 }703 });704705 async function refreshCurrentTab() {706 if (Capacitor.isNativePlatform()) return;707 try {708 const [tab] = await chrome.tabs.query({ active: true, currentWindow: true });709 const url = tab?.url ?? tab?.pendingUrl ?? "";710 setCurrentTabDomain(url ? (extractDomain(url) ?? "") : "");711 712 713 const isWebUrl = /^https?:\/\//i.test(url);714 setCurrentTabUrl(isWebUrl ? url : "");715 } catch {716 setCurrentTabDomain("");717 setCurrentTabUrl("");718 }719 }720721 async function refreshPendingPasskey() {722 const res = await sendMessage({ type: "GET_PENDING_PASSKEY" });723 setPendingPasskey((res as { ok: boolean; data?: PendingPasskeyRequest | null }).data ?? null);724 }725726 async function refreshIncomingPairing() {727 const res = await sendMessage({ type: "GET_INCOMING_PAIRING_REQUEST" });728 const data = (res as { ok: boolean; data?: IncomingPairingRequest | null }).data ?? null;729 setIncomingPair(data);730 }731732 733 734 735 async function consumeRecentPairing() {736 const res = await sendMessage({ type: "GET_RECENT_PAIRING" });737 const data = (res as { ok: boolean; data?: { deviceName?: string } | null }).data;738 if (data?.deviceName) {739 setRecentPairToast(data.deviceName);740 window.setTimeout(() => setRecentPairToast(null), 4000);741 }742 }743744 async function respondIncomingPairing(accept: boolean) {745 if (incomingPairResponding()) return;746 setIncomingPairResponding(true);747 await sendMessage({ type: "RESPOND_INCOMING_PAIRING", payload: { accept } });748 setIncomingPair(null);749 setIncomingPairResponding(false);750 }751752 753 754 755 createEffect(() => {756 const req = incomingPair();757 if (!req) return;758 const handle = window.setInterval(() => {759 setIncomingPairTick((tick) => tick + 1);760 if (Date.now() >= req.expiresAt) {761 setIncomingPair(null);762 window.clearInterval(handle);763 }764 }, 1000);765 onCleanup(() => window.clearInterval(handle));766 });767768 async function refreshProStatus() {769 const res = await sendMessage({ type: "GET_LICENSE" });770 const data = (res as { ok: boolean; data?: { valid?: boolean; plan?: string } }).data;771 setProStatus(Boolean(data?.valid && data?.plan === "pro"));772 }773774 async function restoreSettings() {775 const res = await sendMessage({ type: "GET_SETTINGS" });776 const s = (res as { ok: boolean; data?: any }).data ?? {};777 if (s.accentColor && ACCENT_COLORS.some(c => c.name === s.accentColor)) {778 setAccentColor(s.accentColor as AccentColorName);779 }780 setTheme(s.theme === "light" ? "light" : "dark");781 if (s.displayFont === "cormorant" || s.displayFont === "inter" || s.displayFont === "system") {782 setDisplayFont(s.displayFont);783 } else {784 setDisplayFont("cormorant-italic");785 }786 if (s.textSize === "small" || s.textSize === "large") {787 setTextSize(s.textSize);788 } else {789 setTextSize("medium");790 }791 setReduceMotion(s.reduceMotion === true);792 setLockOnClose(s.lockOnClose !== false);793 setAutoLockMinutes(typeof s.autoLockMinutes === "number" ? s.autoLockMinutes : 5);794 setBreachMonitoring(s.breachMonitoring !== false);795 setTrashRetentionDays(typeof s.trashRetentionDays === "number" ? s.trashRetentionDays : 30);796 setShortcutBindings(getActiveBindings(s.shortcuts));797 }798799 async function applyTrashRetention(days: number) {800 setTrashRetentionDays(days);801 await sendMessage({ type: "UPDATE_SETTINGS", payload: { trashRetentionDays: days } });802 }803804 function primeListSearch(seed: string) {805 setListSearchSeed(seed);806 setListSearchSeedNonce((value) => value + 1);807 openList();808 }809810 811 812 813 async function loadEntries(): Promise<VaultEntry[] | null> {814 const response = await sendMessage({ type: "GET_ENTRIES" });815 const res = response as { ok: boolean; data?: VaultEntry[]; error?: string };816817 818 819 820 821 if (!res.ok) {822 if (823 res.error === "vault locked" ||824 res.error === "SERVICE_WORKER_UNAVAILABLE" ||825 (typeof res.error === "string" && res.error.includes("locked"))826 ) {827 handleLock();828 return null; 829 }830 return [];831 }832833 const loadedEntries = res.data ?? [];834 setEntries(loadedEntries);835 void publishInMemoryVault(loadedEntries);836837 const currentId = selectedEntry()?.id;838 if (currentId) {839 setSelectedEntry(840 loadedEntries.find((entry) => entry.id === currentId) ?? loadedEntries[0] ?? null841 );842 }843844 return loadedEntries;845 }846847 async function openVault(preferredEntryId?: string, skipViewSet = false) {848 849 const retDays = trashRetentionDays();850 if (retDays > 0) {851 void sendMessage({852 type: "PURGE_EXPIRED_TRASH",853 payload: { retentionMs: retDays * 86_400_000 },854 });855 }856857 const loadedEntries = await loadEntries();858859 860 861 if (loadedEntries === null) return;862863 864 let nextSelectedEntry: VaultEntry | null = null;865 if (preferredEntryId) {866 nextSelectedEntry = loadedEntries.find((e) => e.id === preferredEntryId) ?? null;867 }868 if (!nextSelectedEntry) {869 const tabDomain = currentTabDomain();870 if (tabDomain) {871 nextSelectedEntry = loadedEntries.find((e) => {872 if (e.type === "login") {873 if (e.url && (extractDomain(e.url) ?? "") === tabDomain) return true;874 for (const extra of e.additionalUrls ?? []) {875 if ((extractDomain(extra) ?? "") === tabDomain) return true;876 }877 return false;878 }879 if (e.passkey?.rpId) return e.passkey.rpId === tabDomain;880 return false;881 }) ?? null;882 }883 }884 nextSelectedEntry ??= loadedEntries[0] ?? null;885886 setSelectedEntry(nextSelectedEntry);887 setEditEntry(undefined);888 setContentTransitioning(false);889 setContentPhase("enter");890 queueContentIdle();891 if (!skipViewSet) setView(isTwoPaneLayout() ? "list" : "entry");892 }893894 async function handleUnlock() {895 setHasVault(true);896 triggerPipPulse();897 await restoreSettings();898 const celebrating = pendingCelebration();899 if (celebrating) {900 await sendMessage({ type: "MARK_CELEBRATION_PLAYED" });901 setPendingCelebration(false);902 }903 await openVault(undefined, celebrating);904 if (celebrating) {905 setView("pro-celebration");906 window.setTimeout(() => setView("entry"), 2500);907 }908 }909910 function handleSelectEntry(entry: VaultEntry) {911 setSelectedEntry(entry);912 setContentTransitioning(false);913 setContentPhase("enter");914 queueContentIdle();915 916 917 if (!isTwoPaneLayout()) setView("entry");918 }919920 function handleAdd() {921 setEditEntry(undefined);922 setView("add");923 }924925 async function handleDelete() {926 const entry = selectedEntry();927 if (!entry) return;928 await sendMessage({ type: "DELETE_ENTRY", payload: { id: entry.id } });929 const loadedEntries = await loadEntries() ?? [];930 setSelectedEntry(loadedEntries[0] ?? null);931 setView("entry");932 }933934 async function handleDeleteMany(ids: string[]) {935 for (const id of ids) {936 await sendMessage({ type: "DELETE_ENTRY", payload: { id } });937 }938 const loadedEntries = await loadEntries() ?? [];939 940 const stillExists = loadedEntries.find(e => e.id === selectedEntry()?.id);941 if (!stillExists) setSelectedEntry(loadedEntries[0] ?? null);942 }943944 async function handleSave(savedEntry?: VaultEntry) {945 await openVault(savedEntry?.id);946 }947948 async function savePendingAutofill() {949 const pending = pendingAutofillSave();950 if (!pending) return;951 const domain = pending.domain.trim();952 const response = await sendMessage({953 type: "ADD_ENTRY",954 payload: {955 type: "login",956 title: domain || "Saved login",957 url: domain ? `https://${domain}` : "",958 username: pending.username,959 password: pending.password,960 },961 });962 if ((response as { ok: boolean }).ok) {963 setPendingAutofillSave(null);964 await openVault((response as { data?: VaultEntry }).data?.id);965 }966 }967968 function handleBack() {969 setEditEntry(undefined);970 setView("entry");971 }972973 function handleLock() {974 clearCanarySuppressions();975 setEntries([]);976 setSelectedEntry(null);977 setEditEntry(undefined);978 setContentPhase("idle");979 setView("lock");980 void clearInMemoryVault();981 }982983 function handleHeaderLock() {984 985 986 987 handleLock();988 void sendMessage({ type: "LOCK" });989 }990991 function navigate(dir: number) {992 const allEntries = entries();993 if (allEntries.length === 0) return;994 const currentIndex = selectedIndex();995 const baseIndex = currentIndex >= 0 ? currentIndex : 0;996 const nextIndex = (baseIndex + dir + allEntries.length) % allEntries.length;997 setSelectedEntry(allEntries[nextIndex]);998 setContentPhase("enter");999 queueContentIdle();1000 }10011002 function openList() {1003 setView("list");1004 }10051006 function openHealth() {1007 setEditEntry(undefined);1008 setView("health");1009 }10101011 function handleOpenFileImport() {1012 setRestoreView("file");1013 }10141015 const isShellOverlayOpen = () => view() !== "entry" || restoreView() !== null;10161017 function handleFixEntry(entry: VaultEntry) {1018 1019 1020 if (isPasskeyOnly(entry)) {1021 setSelectedEntry(entry);1022 setView("entry");1023 return;1024 }1025 setEditEntry(entry);1026 setView("add");1027 }10281029 const isLockedView = () => view() === "lock";10301031 async function handleApprovePendingPasskey() {1032 const pending = pendingPasskey();1033 if (!pending) return;1034 if (pending.browser === "firefox" && pending.type === "create") {1035 1036 1037 1038 1039 const { createFirefoxPasskey } = await import("./firefox-passkey");1040 const result = await createFirefoxPasskey(pending);1041 if (!result.ok) {1042 console.warn("Peach Firefox passkey create failed:", result.error);1043 }1044 await sendMessage({ type: "DENY_PASSKEY", payload: { requestId: pending.requestId } });1045 setPendingPasskey(null);1046 void loadEntries();1047 return;1048 }1049 await sendMessage({ type: "APPROVE_PASSKEY", payload: { requestId: pending.requestId } });1050 setPendingPasskey(null);1051 }10521053 async function handleDenyPendingPasskey() {1054 const pending = pendingPasskey();1055 if (!pending) return;1056 await sendMessage({ type: "DENY_PASSKEY", payload: { requestId: pending.requestId } });1057 setPendingPasskey(null);1058 }10591060 function queueContentIdle(after?: () => void) {1061 if (contentPhaseTimer) window.clearTimeout(contentPhaseTimer);1062 contentPhaseTimer = window.setTimeout(() => {1063 setContentPhase("idle");1064 after?.();1065 }, ENTRY_TRANSITION_SETTLE_MS);1066 }10671068 return (1069 <div class="popup-root peach-theme">1070 <Show when={bootState() === "ready"}>1071 <Show1072 when={!pendingPasskey()}1073 fallback={1074 <PasskeyApprovalView1075 type={pendingPasskey()!.type}1076 rpName={pendingPasskey()!.rpName}1077 rpId={pendingPasskey()!.rpId}1078 userName={pendingPasskey()!.userName}1079 userDisplayName={pendingPasskey()!.userDisplayName}1080 onApprove={handleApprovePendingPasskey}1081 onDeny={handleDenyPendingPasskey}1082 />1083 }1084 >1085 <Show1086 when={!isLockedView()}1087 fallback={1088 <Show1089 when={onboarded() || hasVault()}1090 fallback={1091 <Onboarding1092 onComplete={() => { setOnboarded(true); }}1093 />1094 }1095 >1096 <LockView1097 hasVault={hasVault()}1098 ready={bootState() === "ready"}1099 isPro={proStatus()}1100 onUnlock={handleUnlock}1101 onBackToOnboarding={1102 !hasVault()1103 ? () => setOnboarded(false)1104 : undefined1105 }1106 />1107 </Show>1108 }1109 >1110 <Show1111 when={view() !== "pro-celebration"}1112 fallback={<ProCelebration />}1113 >1114 <section1115 id="hd-shell"1116 class="peach-shell peach-theme"1117 data-surface="extension"1118 >1119 <header class="peach-chrome" classList={{ "is-hidden-for-overlay": isShellOverlayOpen() }}>1120 <PeachWordmark unlocked />1121 <div class="peach-chrome-actions">1122 <button1123 class="peach-btn peach-btn--ghost peach-btn--sm peach-icon-btn"1124 onClick={() => setView("settings")}1125 aria-label="Settings"1126 >1127 <svg width="14" height="14" viewBox="0 0 14 14" fill="none">1128 <path1129 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"1130 stroke="currentColor"1131 stroke-width="0.9"1132 />1133 <circle cx="7" cy="7" r="2.1" stroke="currentColor" stroke-width="0.9" />1134 </svg>1135 </button>1136 <button1137 class="peach-btn peach-btn--ghost peach-btn--sm peach-icon-btn"1138 onClick={handleAdd}1139 aria-label="New entry"1140 >1141 <svg width="11" height="11" viewBox="0 0 11 11" fill="none" stroke="currentColor" stroke-width="1.1" stroke-linecap="round">1142 <path d="M5.5 1v9M1 5.5h9" />1143 </svg>1144 </button>1145 <button1146 class="peach-btn peach-btn--ghost peach-btn--sm peach-icon-btn peach-lock-btn"1147 onClick={() => void handleHeaderLock()}1148 aria-label="Lock vault"1149 >1150 <svg class="peach-lock-icon" width="14" height="16" viewBox="0 0 14 16" fill="none">1151 <path1152 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"1153 stroke="currentColor"1154 stroke-width="1"1155 stroke-linecap="round"1156 />1157 <rect x="1.5" y="6" width="11" height="8.5" rx="2.2" stroke="currentColor" stroke-width="1" />1158 <circle cx="7" cy="10.25" r="1" fill="currentColor" />1159 </svg>1160 </button>1161 </div>1162 </header>11631164 <Show when={recentPairToast()}>1165 <div class="peach-pair-toast" role="status" aria-live="polite">1166 Paired with <strong>{recentPairToast()}</strong>1167 </div>1168 </Show>11691170 <Show when={incomingPair() !== null}>1171 <div class="peach-pair-request-banner" role="dialog" aria-label="Pairing request">1172 <div class="peach-pair-request-header">1173 <span class="peach-pair-request-mark">🍑</span>1174 <span class="peach-pair-request-title">Pairing request</span>1175 <span class="peach-pair-request-countdown">{incomingPairSecondsLeft()}s</span>1176 </div>1177 <p class="peach-pair-request-body">1178 <strong>{incomingPair()!.deviceName}</strong> wants to sync with this Peach.1179 </p>1180 <div class="peach-pair-request-actions">1181 <button1182 class="peach-btn peach-btn--ghost peach-btn--sm"1183 onClick={() => void respondIncomingPairing(false)}1184 disabled={incomingPairResponding()}1185 >1186 Reject1187 </button>1188 <button1189 class="peach-btn peach-btn--accent peach-btn--sm"1190 onClick={() => void respondIncomingPairing(true)}1191 disabled={incomingPairResponding()}1192 >1193 Accept1194 </button>1195 </div>1196 </div>1197 </Show>11981199 <Show when={pendingProNotice() !== null}>1200 <div class="peach-pro-notice-banner">1201 <span>✦ {pendingProNotice()?.feature === "sync" ? "Sync" : "A Pro feature"} requires Peach Pro</span>1202 <button1203 class="peach-pro-notice-link"1204 onClick={() => {1205 setUpgradeHighlight((pendingProNotice()?.feature as ProFeature) ?? null);1206 setSettingsInitialSection("license");1207 setView("settings");1208 setPendingProNotice(null);1209 }}1210 >1211 Learn more →1212 </button>1213 <button class="peach-pro-notice-close" onClick={() => setPendingProNotice(null)} aria-label="Dismiss">✕</button>1214 </div>1215 </Show>12161217 <Show when={pendingAutofillSave() !== null && !isLockedView()}>1218 <div class="peach-pro-notice-banner peach-autofill-save-banner">1219 <span>1220 Save login{pendingAutofillSave()?.domain ? ` for ${pendingAutofillSave()!.domain}` : ""}?1221 </span>1222 <button1223 class="peach-pro-notice-link"1224 onClick={() => void savePendingAutofill()}1225 >1226 Save1227 </button>1228 <button1229 class="peach-pro-notice-close"1230 onClick={() => setPendingAutofillSave(null)}1231 aria-label="Dismiss"1232 >1233 x1234 </button>1235 </div>1236 </Show>12371238 <Show when={backExitNotice()}>1239 <div class="peach-pro-notice-banner peach-back-exit-banner">1240 <span>Tap back again to exit Peach</span>1241 </div>1242 </Show>12431244 <div class="peach-shell-body">1245 <div class="peach-shell-veil"></div>1246 <div class="peach-content-frame" data-content-phase={contentPhase()} classList={{ navigating: contentTransitioning() }}>1247 <EntryView1248 entry={selectedEntry()}1249 currentTabUrl={currentTabUrl()}1250 onDelete={handleDelete}1251 onFieldSaved={() => void loadEntries()}1252 onEscape={() => { setView("list"); }}1253 />1254 </div>12551256 <section class="peach-search-wrap" classList={{ "is-hidden-for-overlay": isShellOverlayOpen() }}>1257 <div class="peach-search-bar">1258 <span class="peach-search-icon">1259 <svg width="13" height="13" viewBox="0 0 13 13" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round">1260 <circle cx="5.5" cy="5.5" r="3.75" />1261 <path d="M8.75 8.75L11.5 11.5" />1262 </svg>1263 </span>1264 <input1265 class="peach-search-input"1266 placeholder="search vault..."1267 autocomplete="off"1268 aria-label="Search vault entries"1269 onClick={openList}1270 onFocus={openList}1271 readOnly1272 />1273 <div class="peach-search-meta">1274 <span class="peach-search-counter">1275 {entries().length > 01276 ? `${selectedIndex() + 1} / ${entries().length}`1277 : "0 entries"}1278 </span>1279 <span class="peach-divider"></span>1280 <button1281 class="peach-btn peach-btn--ghost peach-btn--sm peach-icon-btn"1282 onClick={() => navigate(-1)}1283 aria-label="Previous entry"1284 disabled={entries().length === 0}1285 >1286 <svg width="6" height="11" viewBox="0 0 6 11" fill="none" stroke="currentColor" stroke-width="1.1" stroke-linecap="round" stroke-linejoin="round">1287 <path d="M5 1L1 5.5L5 10" />1288 </svg>1289 </button>1290 <button1291 class="peach-btn peach-btn--ghost peach-btn--sm peach-icon-btn"1292 onClick={() => navigate(1)}1293 aria-label="Next entry"1294 disabled={entries().length === 0}1295 >1296 <svg width="6" height="11" viewBox="0 0 6 11" fill="none" stroke="currentColor" stroke-width="1.1" stroke-linecap="round" stroke-linejoin="round">1297 <path d="M1 1L5 5.5L1 10" />1298 </svg>1299 </button>1300 </div>1301 </div>1302 </section>1303 </div>13041305 <Show when={view() === "list"}>1306 <VaultView1307 entries={entries()}1308 selectedEntryId={selectedEntry()?.id}1309 currentTabDomain={currentTabDomain()}1310 sortOrder={sortOrder()}1311 searchSeed={listSearchSeed()}1312 searchSeedNonce={listSearchSeedNonce()}1313 onSelectEntry={handleSelectEntry}1314 onSortOrderChange={setSortOrder}1315 onAdd={handleAdd}1316 onClose={() => setView("entry")}1317 onOpenTrash={() => setView("trash")}1318 onDeleteMany={handleDeleteMany}1319 />1320 </Show>1321 <Show when={view() === "settings"}>1322 <Suspense fallback={<div class="peach-loading"><PeachWordmark /></div>}>1323 <SettingsView1324 entriesCount={entries().length}1325 breachMonitoring={breachMonitoring()}1326 lockOnClose={lockOnClose()}1327 autoLockMinutes={autoLockMinutes()}1328 trashRetentionDays={trashRetentionDays()}1329 theme={theme()}1330 accentColor={accentColor()}1331 displayFont={displayFont()}1332 textSize={textSize()}1333 reduceMotion={reduceMotion()}1334 isPro={proStatus()}1335 initialSection={settingsInitialSection()}1336 upgradeHighlight={upgradeHighlight()}1337 onBreachMonitoringChange={applyBreachMonitoring}1338 onLockOnCloseChange={applyLockOnClose}1339 onAutoLockMinutesChange={applyAutoLockMinutes}1340 onTrashRetentionChange={applyTrashRetention}1341 onThemeChange={applyTheme}1342 onAccentChange={applyAccentColor}1343 onDisplayFontChange={applyDisplayFont}1344 onTextSizeChange={applyTextSize}1345 onReduceMotionChange={applyReduceMotion}1346 shortcuts={shortcutBindings()}1347 onShortcutsChange={applyShortcuts}1348 onLicenseChange={async () => {1349 1350 1351 1352 1353 1354 await refreshProStatus();1355 void loadEntries();1356 const should = await sendMessage({ type: "SHOULD_PLAY_CELEBRATION" });1357 if ((should as { ok: boolean; data?: boolean }).data === true) {1358 await sendMessage({ type: "MARK_CELEBRATION_PLAYED" });1359 setView("pro-celebration");1360 window.setTimeout(() => setView("settings"), 2500);1361 }1362 }}1363 onBack={() => { setSettingsInitialSection(null); setUpgradeHighlight(null); handleBack(); }}1364 onImport={() => setView("import")}1365 onExport={() => setView("export")}1366 onBreachCheckDone={loadEntries}1367 onOpenHealth={openHealth}1368 onOpenSyncPairing={() => setView("sync-pairing")}1369 onOpenFileImport={handleOpenFileImport}1370 onOpenPanic={() => setView("panic")}1371 />1372 </Suspense>1373 </Show>1374 <Show when={view() === "sync-pairing"}>1375 <Suspense fallback={<div class="peach-loading"><PeachWordmark /></div>}>1376 <SyncPairingView1377 onClose={() => setView("settings")}1378 onPaired={() => { }}1379 />1380 </Suspense>1381 </Show>1382 <Show when={view() === "add"}>1383 <AddView1384 entry={editEntry()}1385 entries={entries()}1386 onBack={handleBack}1387 onSave={handleSave}1388 />1389 </Show>1390 <Show when={view() === "import"}>1391 <Suspense fallback={<div class="peach-loading"><PeachWordmark /></div>}>1392 <ImportView onBack={handleBack} onImport={handleSave} />1393 </Suspense>1394 </Show>1395 <Show when={view() === "export"}>1396 <Suspense fallback={<div class="peach-loading"><PeachWordmark /></div>}>1397 <ExportView1398 onBack={() => {1399 if (returnToPanic()) {1400 setReturnToPanic(false);1401 setView("panic");1402 } else {1403 handleBack();1404 }1405 }}1406 />1407 </Suspense>1408 </Show>1409 <Show when={view() === "panic"}>1410 <Suspense fallback={<div class="peach-loading"><PeachWordmark /></div>}>1411 <PanicView1412 onCancel={() => setView("settings")}1413 onOpenExport={() => {1414 setReturnToPanic(true);1415 setView("export");1416 }}1417 onDestroyed={async () => {1418 clearCanarySuppressions();1419 setEntries([]);1420 setSelectedEntry(null);1421 setEditEntry(undefined);1422 setHasVault(false);1423 setOnboarded(false);1424 setProStatus(false);1425 setPendingPasskey(null);1426 setUpgradeHighlight(null);1427 setSettingsInitialSection(null);1428 setPendingProNotice(null);1429 setPendingCelebration(false);1430 setReturnToPanic(false);1431 setContentPhase("idle");1432 setView("lock");1433 void clearInMemoryVault();1434 }}1435 />1436 </Suspense>1437 </Show>1438 <Show when={view() === "health"}>1439 <Suspense fallback={<div class="peach-loading"><PeachWordmark /></div>}>1440 <HealthView1441 entries={entries()}1442 isPro={proStatus()}1443 onFixEntry={handleFixEntry}1444 onBack={() => setView("settings")}1445 onRefresh={loadEntries}1446 />1447 </Suspense>1448 </Show>1449 <Show when={view() === "trash"}>1450 <Suspense fallback={<div class="peach-loading"><PeachWordmark /></div>}>1451 <TrashView1452 onBack={() => setView("list")}1453 onRestored={() => void loadEntries()}1454 />1455 </Suspense>1456 </Show>1457 <Show when={restoreView() === "file"}>1458 <Suspense fallback={<div class="peach-loading"><PeachWordmark /></div>}>1459 <ImportView1460 mode="onboarding"1461 replacesExistingVault={true}1462 onBack={() => setRestoreView(null)}1463 onImport={async () => {1464 setRestoreView(null);1465 await handleUnlock();1466 }}1467 />1468 </Suspense>1469 </Show>1470 </section>1471 </Show>1472 </Show>1473 </Show>1474 </Show>1475 <Show when={showShortcutsHelp()}>1476 <ShortcutsHelpOverlay1477 bindings={shortcutBindings()}1478 onClose={() => setShowShortcutsHelp(false)}1479 />1480 </Show>1481 </div>1482 );1483}14841485function ShortcutsHelpOverlay(props: {1486 bindings: Record<ShortcutAction, Keybinding>;1487 onClose: () => void;1488}) {1489 return (1490 <div class="peach-shortcuts-help-backdrop" onClick={props.onClose}>1491 <div class="peach-shortcuts-help-card" onClick={(e) => e.stopPropagation()}>1492 <div class="peach-shortcuts-help-head">1493 <h3>Keyboard shortcuts</h3>1494 <button class="peach-shortcuts-help-close" onClick={props.onClose} aria-label="Close">✕</button>1495 </div>1496 <div class="peach-shortcuts-help-body">1497 <p class="peach-settings-sub-label">ENTRY VIEW</p>1498 <ul>1499 {SHORTCUT_DESCRIPTORS.filter((d) => d.scope === "entry").map((d) => (1500 <li>1501 <span>{d.label}</span>1502 <kbd>{formatKeybinding(props.bindings[d.action])}</kbd>1503 </li>1504 ))}1505 </ul>1506 <p class="peach-settings-sub-label">ANYWHERE</p>1507 <ul>1508 {SHORTCUT_DESCRIPTORS.filter((d) => d.scope === "global").map((d) => (1509 <li>1510 <span>{d.label}</span>1511 <kbd>{formatKeybinding(props.bindings[d.action])}</kbd>1512 </li>1513 ))}1514 </ul>1515 </div>1516 </div>1517 </div>1518 );1519}