Native iCloud apps for Windows and Linux, built in Rust. Notes, Reminders, Calendar, Contacts, Drive and Photos, offline and in sync with your iPhone.
Rust apple-notesapple-reminderscloudkitcrdtdesktop-appicloudicloud-calendaricloud-driveicloud-notesicloud-photosiphonelinuxlinux-desktoplocal-firstoffline-firstprivacyrusttauritauri-appwindows
Startup: the window reads 14% less code before it can draw
Yashwanth Kamireddifbebe12234fd
diff --git a/.uiverify/startup-time.mjs b/.uiverify/startup-time.mjsnew file mode 100644index 0000000..3cd7513--- /dev/null+++ b/.uiverify/startup-time.mjs@@ -0,0 +1,55 @@+// How long the window takes to open, in the page: from navigation to the window being told it may+// show (window_ready), to its first paint, and to the last-open app (Contacts) drawn with rows; and+// the first open of another app (Notes), whose code comes in then. Median of N runs (N=9).+// A measure, not a pass or fail: run before and after a change, the same way.+// BASE=http://localhost:4173 ENGINE=webkit node .uiverify/startup-time.mjs+import { engine, engineName } from "./engine.mjs";+import { SERVICES, installStub } from "./stub.mjs";+const N = Number(process.env.N ?? 9);+const b = await engine.launch();+const ready = [], painted = [], rows = [], firstSwitch = [];+for (let i = 0; i < N; i++) {+ const ctx = await b.newContext({ viewport: { width: 1280, height: 800 } });+ await ctx.addInitScript(() => { try { localStorage.setItem("quince.library.screen", "contacts"); } catch {} });+ await ctx.addInitScript(installStub, { screen: "library", services: SERVICES, twoFactor: null, contactsFixture: true, notesFixture: true, calendarFixture: true, remindersFixture: true, driveFixture: true });+ await ctx.addInitScript(() => {+ const wrap = () => {+ const t = window.__TAURI_INTERNALS__;+ if (!t || t.__timed) return;+ const inner = t.invoke;+ t.invoke = (cmd, args) => { if (cmd === "window_ready") window.__ready ??= performance.now(); return inner(cmd, args); };+ t.__timed = true;+ };+ wrap();+ document.addEventListener("DOMContentLoaded", wrap);+ // The moment the first contact row is in the page.+ new MutationObserver((_, o) => {+ if (document.querySelector(".contact-row")) { window.__rows ??= performance.now(); o.disconnect(); }+ }).observe(document, { childList: true, subtree: true });+ });+ const page = await ctx.newPage();+ await page.goto(process.env.BASE ?? "http://localhost:4173");+ await page.waitForFunction(() => window.__ready && window.__rows, null, { timeout: 20000 });+ const r = await page.evaluate(() => ({+ ready: window.__ready,+ rows: window.__rows,+ paint: performance.getEntriesByType("paint").find((p) => p.name === "first-contentful-paint")?.startTime ?? NaN,+ }));+ ready.push(r.ready);+ rows.push(r.rows);+ painted.push(r.paint);+ await page.waitForLoadState("networkidle");+ await page.waitForTimeout(400);+ firstSwitch.push(await page.evaluate(async () => {+ const btn = [...document.querySelectorAll(".nav-item")].find((x) => x.textContent.includes("Notes"));+ const t = performance.now();+ btn.click();+ await new Promise((res) => { const look = () => document.querySelector(".content > .screen-slot:not([hidden]) .notes") ? requestAnimationFrame(() => setTimeout(res, 0)) : requestAnimationFrame(look); look(); });+ return performance.now() - t;+ }));+ await ctx.close();+}+const med = (a) => { const s = a.filter((x) => !Number.isNaN(x)).sort((x, y) => x - y); return s.length ? s[Math.floor(s.length / 2)].toFixed(0) : "n/a"; };+const all = (a) => a.map((x) => x.toFixed(0)).join(" ");+console.log(`${engineName}: window_ready ${med(ready)} ms [${all(ready)}]; first paint ${med(painted)} ms; contacts drawn ${med(rows)} ms [${all(rows)}]; first open of Notes ${med(firstSwitch)} ms`);+await b.close();diff --git a/src/components/ArrivalSheet.tsx b/src/components/ArrivalSheet.tsxnew file mode 100644index 0000000..c600906--- /dev/null+++ b/src/components/ArrivalSheet.tsx@@ -0,0 +1,273 @@+import { useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";+import { createPortal } from "react-dom";+import { api, type Arrival, type Calendar, type ImportEvent } from "../lib/ipc";+import { Picker } from "./Picker";+import { useModalFocus } from "../lib/focus";+import { fadeIn } from "../lib/fade";+import "../styles/intake.css";++/**+ * One arrived file's sheet (ImportSheet.tsx keeps the queue): what it holds, and one button+ * that adds it. In a chunk of its own, fetched only when a file has arrived — the window opens+ * without reading it.+ */+export default function ArrivalSheet({ arrival: current, onDone: done }: { arrival: Arrival; onDone: () => void }) {+ return createPortal(+ <div className="modal-veil ix-veil">+ {current.kind === "events" ? (+ <EventsSheet arrival={current} onDone={done} />+ ) : current.kind === "contacts" ? (+ <ContactsSheet arrival={current} onDone={done} />+ ) : (+ <Shell label={`Can’t open “${current.file}”`} onCancel={done}>+ <h2>Can’t open “{current.file}”</h2>+ <p className="ix-reason">{current.reason}</p>+ <div className="sheet-actions">+ <button className="primary" autoFocus onClick={done}>+ OK+ </button>+ </div>+ </Shell>+ )}+ </div>,+ document.body,+ );+}++function Shell({ label, onCancel, children }: { label: string; onCancel: () => void; children: React.ReactNode }) {+ const sheetRef = useRef<HTMLDivElement | null>(null);+ useModalFocus(sheetRef);+ // The next file's sheet takes the last one's place on the same dim, where the page-wide+ // fade (lib/fade fadeSheetsIn) does not look: it fades itself in, before it is painted.+ useLayoutEffect(() => fadeIn(sheetRef.current, { duration: 140 }), []);+ return (+ <div+ ref={sheetRef}+ className="modal-sheet ix-sheet"+ role="dialog"+ aria-modal="true"+ aria-label={label}+ onKeyDown={(e) => {+ if (e.key === "Escape") {+ e.stopPropagation();+ onCancel();+ }+ }}+ >+ {children}+ </div>+ );+}++const plural = (n: number, one: string, many: string) => `${n} ${n === 1 ? one : many}`;++/** When an event is, as Calendar says it: the day, and its time in its own zone. */+function when(e: ImportEvent): string {+ const day: Intl.DateTimeFormatOptions = { weekday: "short", day: "numeric", month: "short", year: "numeric" };+ if (e.allDay) {+ const last = e.endsAt - 86400;+ const first = new Date(e.startsAt * 1000).toLocaleDateString(undefined, day);+ return last > e.startsAt ? `${first} – ${new Date(last * 1000).toLocaleDateString(undefined, day)}` : `${first}, all day`;+ }+ const zone = e.timezone ?? undefined;+ const fmt = (t: number, o: Intl.DateTimeFormatOptions) => {+ try {+ return new Date(t * 1000).toLocaleString(undefined, { ...o, timeZone: zone });+ } catch {+ return new Date(t * 1000).toLocaleString(undefined, o);+ }+ };+ const time: Intl.DateTimeFormatOptions = { hour: "numeric", minute: "2-digit" };+ const start = fmt(e.startsAt, { ...day, ...time });+ const end = e.endsAt > e.startsAt ? `–${fmt(e.endsAt, time)}` : "";+ const here = Intl.DateTimeFormat().resolvedOptions().timeZone;+ const elsewhere = zone && zone !== here ? ` (${zone.replace(/_/g, " ")})` : "";+ return `${start}${end}${elsewhere}`;+}++function repeatPhrase(e: ImportEvent): string | null {+ const r = e.repeat;+ if (!r) return null;+ const unit = { daily: "day", weekly: "week", monthly: "month", yearly: "year" }[r.freq];+ const every = r.interval === 1 ? `Every ${unit}` : `Every ${r.interval} ${unit}s`;+ return r.count ? `${every}, ${r.count} times` : every;+}++function EventsSheet({ arrival, onDone }: { arrival: Extract<Arrival, { kind: "events" }>; onDone: () => void }) {+ const [calendars, setCalendars] = useState<Calendar[] | null>(null);+ const [target, setTarget] = useState("");+ const [busy, setBusy] = useState<{ done: number; failed: string[] } | null>(null);+ const [finished, setFinished] = useState<string | null>(null);+ const fresh = useMemo(() => arrival.events.filter((e) => !e.duplicate), [arrival]);++ useEffect(() => {+ api+ .calendarList()+ .then((all) => {+ // Only the account's own calendars take a new event: not a subscribed feed, not the+ // Birthdays and Holidays calendars Skykeep draws itself.+ const writable = all.filter((c) => c.writable && !c.guid.startsWith("quince:"));+ setCalendars(writable);+ setTarget((t) => t || (writable.find((c) => c.isDefault) ?? writable[0])?.guid || "");+ })+ .catch(() => setCalendars([]));+ }, []);++ async function add() {+ let failed: string[] = [];+ setBusy({ done: 0, failed });+ for (const [i, e] of fresh.entries()) {+ try {+ await api.eventSave({+ guid: null,+ calendarGuid: target,+ title: e.title,+ location: e.location,+ startsAt: e.startsAt,+ endsAt: e.endsAt,+ allDay: e.allDay,+ timezone: e.timezone,+ notes: e.notes,+ url: e.url,+ ...(e.alerts ? { alerts: e.alerts } : {}),+ ...(e.repeat ? { repeat: e.repeat, repeatChanged: true } : {}),+ });+ } catch (err) {+ failed = [...failed, `${e.title}: ${String(err)}`];+ }+ setBusy({ done: i + 1, failed });+ }+ // The calendar's screens redraw from the library once the pass lands.+ api.syncSome(["calendar"]).catch(() => {});+ if (failed.length === 0) return onDone();+ setBusy(null);+ setFinished(+ `${plural(fresh.length - failed.length, "event was", "events were")} added. ${plural(failed.length, "wasn’t", "weren’t")}:\n${failed.join("\n")}`,+ );+ }++ const single = fresh.length === 1;+ const heading =+ fresh.length === 0+ ? arrival.events.length > 0+ ? "These events are already in your calendar"+ : "Nothing in this file can be added"+ : single+ ? `Add “${fresh[0].title}” to`+ : `Add ${fresh.length} events to`;+ const options = (calendars ?? []).map((c) => ({ value: c.guid, label: c.title }));++ return (+ // Not put away mid-import: the import finishing would then put away the next file.+ <Shell label={`Import “${arrival.file}”`} onCancel={busy ? () => {} : onDone}>+ <div className="ix-head">+ <h2>{heading}</h2>+ {fresh.length > 0 && calendars && calendars.length > 0 && (+ <Picker value={target} options={options} onChange={setTarget} label="Calendar" disabled={!!busy} />+ )}+ </div>+ <p className="ix-file">{arrival.file}</p>+ <ul className="ix-list" aria-label="Events in this file">+ {arrival.events.map((e, i) => (+ <li key={i} className={e.duplicate ? "is-skipped" : undefined}>+ <span className="ix-title">{e.title}</span>+ <span className="ix-sub">{when(e)}</span>+ {(repeatPhrase(e) || e.duplicate) && (+ <span className="ix-sub">{e.duplicate ? "Already in your calendar" : repeatPhrase(e)}</span>+ )}+ </li>+ ))}+ {arrival.refused.map((r, i) => (+ <li key={`r${i}`} className="is-refused">+ <span className="ix-title">{r.title}</span>+ <span className="ix-sub">Can’t be added. {r.reason}</span>+ </li>+ ))}+ </ul>+ {calendars && calendars.length === 0 && fresh.length > 0 && (+ <p className="ix-reason">This account has no calendar that can take new events.</p>+ )}+ {finished && <p className="ix-reason ix-error">{finished}</p>}+ <div className="sheet-actions">+ {finished || fresh.length === 0 ? (+ <button className="primary" autoFocus onClick={onDone}>+ {finished ? "Done" : "OK"}+ </button>+ ) : (+ <>+ <button className="quiet" onClick={onDone} disabled={!!busy}>+ Cancel+ </button>+ <button className="primary" autoFocus onClick={add} disabled={!!busy || !target}>+ {busy ? `Adding ${busy.done + 1 > fresh.length ? fresh.length : busy.done + 1} of ${fresh.length}…` : single ? "Add Event" : `Add ${fresh.length} Events`}+ </button>+ </>+ )}+ </div>+ </Shell>+ );+}++function ContactsSheet({ arrival, onDone }: { arrival: Extract<Arrival, { kind: "contacts" }>; onDone: () => void }) {+ const [busy, setBusy] = useState(false);+ const [error, setError] = useState<string | null>(null);+ const live = useRef(true);+ useEffect(() => () => void (live.current = false), []);+ const fresh = arrival.contacts.filter((c) => !c.known);+ const single = fresh.length === 1;+ const heading =+ fresh.length === 0+ ? arrival.contacts.length === 1+ ? `${arrival.contacts[0].name} is already in Contacts`+ : "Everyone in this file is already in Contacts"+ : single+ ? `Add contact ${fresh[0].name}`+ : `Add ${fresh.length} contacts`;++ async function add() {+ setBusy(true);+ setError(null);+ try {+ // The same import the Contacts app's own Import uses: someone already there is left out.+ await api.contactsImport([arrival.path]);+ if (live.current) onDone();+ } catch (err) {+ if (live.current) {+ setBusy(false);+ setError(String(err));+ }+ }+ }++ return (+ <Shell label={`Import “${arrival.file}”`} onCancel={busy ? () => {} : onDone}>+ <h2>{heading}</h2>+ <p className="ix-file">{arrival.file}</p>+ <ul className="ix-list" aria-label="Contacts in this file">+ {arrival.contacts.map((c, i) => (+ <li key={i} className={c.known ? "is-skipped" : undefined}>+ <span className="ix-title">{c.name}</span>+ {(c.detail || c.known) && <span className="ix-sub">{c.known ? "Already in Contacts" : c.detail}</span>}+ </li>+ ))}+ </ul>+ {error && <p className="ix-reason ix-error">{error}</p>}+ <div className="sheet-actions">+ {fresh.length === 0 ? (+ <button className="primary" autoFocus onClick={onDone}>+ OK+ </button>+ ) : (+ <>+ <button className="quiet" onClick={onDone} disabled={busy}>+ Cancel+ </button>+ <button className="primary" autoFocus onClick={add} disabled={busy}>+ {busy ? "Adding…" : single ? "Add Contact" : `Add ${fresh.length} Contacts`}+ </button>+ </>+ )}+ </div>+ </Shell>+ );+}diff --git a/src/components/ImportSheet.tsx b/src/components/ImportSheet.tsxindex 5c69672..c66c710 100644--- a/src/components/ImportSheet.tsx+++ b/src/components/ImportSheet.tsx@@ -1,11 +1,8 @@-import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";-import { createPortal } from "react-dom";+import { lazy, Suspense, useCallback, useEffect, useRef, useState } from "react";import { listen } from "@tauri-apps/api/event";-import { api, intakeApi, INTAKE, type Arrival, type Calendar, type ImportEvent } from "../lib/ipc";-import { Picker } from "./Picker";-import { useModalFocus } from "../lib/focus";-import { fadeIn } from "../lib/fade";-import "../styles/intake.css";+import { intakeApi, INTAKE, type Arrival } from "../lib/ipc";++const ArrivalSheet = lazy(() => import("./ArrivalSheet"));/*** A calendar or contacts file opened with Skykeep (src-tauri/src/intake.rs): what it holds,@@ -41,262 +38,9 @@ export function ImportSheet() {if (!head) return null;const current = head.arrival;const done = () => setQueue((q) => q.filter((x) => x.id !== head.id));- return createPortal(- <div className="modal-veil ix-veil">- {current.kind === "events" ? (- <EventsSheet key={head.id} arrival={current} onDone={done} />- ) : current.kind === "contacts" ? (- <ContactsSheet key={head.id} arrival={current} onDone={done} />- ) : (- <Shell label={`Can’t open “${current.file}”`} onCancel={done}>- <h2>Can’t open “{current.file}”</h2>- <p className="ix-reason">{current.reason}</p>- <div className="sheet-actions">- <button className="primary" autoFocus onClick={done}>- OK- </button>- </div>- </Shell>- )}- </div>,- document.body,- );-}--function Shell({ label, onCancel, children }: { label: string; onCancel: () => void; children: React.ReactNode }) {- const sheetRef = useRef<HTMLDivElement | null>(null);- useModalFocus(sheetRef);- // The next file's sheet takes the last one's place on the same dim, where the page-wide- // fade (lib/fade fadeSheetsIn) does not look: it fades itself in, before it is painted.- useLayoutEffect(() => fadeIn(sheetRef.current, { duration: 140 }), []);- return (- <div- ref={sheetRef}- className="modal-sheet ix-sheet"- role="dialog"- aria-modal="true"- aria-label={label}- onKeyDown={(e) => {- if (e.key === "Escape") {- e.stopPropagation();- onCancel();- }- }}- >- {children}- </div>- );-}--const plural = (n: number, one: string, many: string) => `${n} ${n === 1 ? one : many}`;--/** When an event is, as Calendar says it: the day, and its time in its own zone. */-function when(e: ImportEvent): string {- const day: Intl.DateTimeFormatOptions = { weekday: "short", day: "numeric", month: "short", year: "numeric" };- if (e.allDay) {- const last = e.endsAt - 86400;- const first = new Date(e.startsAt * 1000).toLocaleDateString(undefined, day);- return last > e.startsAt ? `${first} – ${new Date(last * 1000).toLocaleDateString(undefined, day)}` : `${first}, all day`;- }- const zone = e.timezone ?? undefined;- const fmt = (t: number, o: Intl.DateTimeFormatOptions) => {- try {- return new Date(t * 1000).toLocaleString(undefined, { ...o, timeZone: zone });- } catch {- return new Date(t * 1000).toLocaleString(undefined, o);- }- };- const time: Intl.DateTimeFormatOptions = { hour: "numeric", minute: "2-digit" };- const start = fmt(e.startsAt, { ...day, ...time });- const end = e.endsAt > e.startsAt ? `–${fmt(e.endsAt, time)}` : "";- const here = Intl.DateTimeFormat().resolvedOptions().timeZone;- const elsewhere = zone && zone !== here ? ` (${zone.replace(/_/g, " ")})` : "";- return `${start}${end}${elsewhere}`;-}--function repeatPhrase(e: ImportEvent): string | null {- const r = e.repeat;- if (!r) return null;- const unit = { daily: "day", weekly: "week", monthly: "month", yearly: "year" }[r.freq];- const every = r.interval === 1 ? `Every ${unit}` : `Every ${r.interval} ${unit}s`;- return r.count ? `${every}, ${r.count} times` : every;-}--function EventsSheet({ arrival, onDone }: { arrival: Extract<Arrival, { kind: "events" }>; onDone: () => void }) {- const [calendars, setCalendars] = useState<Calendar[] | null>(null);- const [target, setTarget] = useState("");- const [busy, setBusy] = useState<{ done: number; failed: string[] } | null>(null);- const [finished, setFinished] = useState<string | null>(null);- const fresh = useMemo(() => arrival.events.filter((e) => !e.duplicate), [arrival]);-- useEffect(() => {- api- .calendarList()- .then((all) => {- // Only the account's own calendars take a new event: not a subscribed feed, not the- // Birthdays and Holidays calendars Skykeep draws itself.- const writable = all.filter((c) => c.writable && !c.guid.startsWith("quince:"));- setCalendars(writable);- setTarget((t) => t || (writable.find((c) => c.isDefault) ?? writable[0])?.guid || "");- })- .catch(() => setCalendars([]));- }, []);-- async function add() {- let failed: string[] = [];- setBusy({ done: 0, failed });- for (const [i, e] of fresh.entries()) {- try {- await api.eventSave({- guid: null,- calendarGuid: target,- title: e.title,- location: e.location,- startsAt: e.startsAt,- endsAt: e.endsAt,- allDay: e.allDay,- timezone: e.timezone,- notes: e.notes,- url: e.url,- ...(e.alerts ? { alerts: e.alerts } : {}),- ...(e.repeat ? { repeat: e.repeat, repeatChanged: true } : {}),- });- } catch (err) {- failed = [...failed, `${e.title}: ${String(err)}`];- }- setBusy({ done: i + 1, failed });- }- // The calendar's screens redraw from the library once the pass lands.- api.syncSome(["calendar"]).catch(() => {});- if (failed.length === 0) return onDone();- setBusy(null);- setFinished(- `${plural(fresh.length - failed.length, "event was", "events were")} added. ${plural(failed.length, "wasn’t", "weren’t")}:\n${failed.join("\n")}`,- );- }-- const single = fresh.length === 1;- const heading =- fresh.length === 0- ? arrival.events.length > 0- ? "These events are already in your calendar"- : "Nothing in this file can be added"- : single- ? `Add “${fresh[0].title}” to`- : `Add ${fresh.length} events to`;- const options = (calendars ?? []).map((c) => ({ value: c.guid, label: c.title }));-- return (- // Not put away mid-import: the import finishing would then put away the next file.- <Shell label={`Import “${arrival.file}”`} onCancel={busy ? () => {} : onDone}>- <div className="ix-head">- <h2>{heading}</h2>- {fresh.length > 0 && calendars && calendars.length > 0 && (- <Picker value={target} options={options} onChange={setTarget} label="Calendar" disabled={!!busy} />- )}- </div>- <p className="ix-file">{arrival.file}</p>- <ul className="ix-list" aria-label="Events in this file">- {arrival.events.map((e, i) => (- <li key={i} className={e.duplicate ? "is-skipped" : undefined}>- <span className="ix-title">{e.title}</span>- <span className="ix-sub">{when(e)}</span>- {(repeatPhrase(e) || e.duplicate) && (- <span className="ix-sub">{e.duplicate ? "Already in your calendar" : repeatPhrase(e)}</span>- )}- </li>- ))}- {arrival.refused.map((r, i) => (- <li key={`r${i}`} className="is-refused">- <span className="ix-title">{r.title}</span>- <span className="ix-sub">Can’t be added. {r.reason}</span>- </li>- ))}- </ul>- {calendars && calendars.length === 0 && fresh.length > 0 && (- <p className="ix-reason">This account has no calendar that can take new events.</p>- )}- {finished && <p className="ix-reason ix-error">{finished}</p>}- <div className="sheet-actions">- {finished || fresh.length === 0 ? (- <button className="primary" autoFocus onClick={onDone}>- {finished ? "Done" : "OK"}- </button>- ) : (- <>- <button className="quiet" onClick={onDone} disabled={!!busy}>- Cancel- </button>- <button className="primary" autoFocus onClick={add} disabled={!!busy || !target}>- {busy ? `Adding ${busy.done + 1 > fresh.length ? fresh.length : busy.done + 1} of ${fresh.length}…` : single ? "Add Event" : `Add ${fresh.length} Events`}- </button>- </>- )}- </div>- </Shell>- );-}--function ContactsSheet({ arrival, onDone }: { arrival: Extract<Arrival, { kind: "contacts" }>; onDone: () => void }) {- const [busy, setBusy] = useState(false);- const [error, setError] = useState<string | null>(null);- const live = useRef(true);- useEffect(() => () => void (live.current = false), []);- const fresh = arrival.contacts.filter((c) => !c.known);- const single = fresh.length === 1;- const heading =- fresh.length === 0- ? arrival.contacts.length === 1- ? `${arrival.contacts[0].name} is already in Contacts`- : "Everyone in this file is already in Contacts"- : single- ? `Add contact ${fresh[0].name}`- : `Add ${fresh.length} contacts`;-- async function add() {- setBusy(true);- setError(null);- try {- // The same import the Contacts app's own Import uses: someone already there is left out.- await api.contactsImport([arrival.path]);- if (live.current) onDone();- } catch (err) {- if (live.current) {- setBusy(false);- setError(String(err));- }- }- }-return (- <Shell label={`Import “${arrival.file}”`} onCancel={busy ? () => {} : onDone}>- <h2>{heading}</h2>- <p className="ix-file">{arrival.file}</p>- <ul className="ix-list" aria-label="Contacts in this file">- {arrival.contacts.map((c, i) => (- <li key={i} className={c.known ? "is-skipped" : undefined}>- <span className="ix-title">{c.name}</span>- {(c.detail || c.known) && <span className="ix-sub">{c.known ? "Already in Contacts" : c.detail}</span>}- </li>- ))}- </ul>- {error && <p className="ix-reason ix-error">{error}</p>}- <div className="sheet-actions">- {fresh.length === 0 ? (- <button className="primary" autoFocus onClick={onDone}>- OK- </button>- ) : (- <>- <button className="quiet" onClick={onDone} disabled={busy}>- Cancel- </button>- <button className="primary" autoFocus onClick={add} disabled={busy}>- {busy ? "Adding…" : single ? "Add Contact" : `Add ${fresh.length} Contacts`}- </button>- </>- )}- </div>- </Shell>+ <Suspense fallback={null}>+ <ArrivalSheet key={head.id} arrival={current} onDone={done} />+ </Suspense>);}diff --git a/src/main.tsx b/src/main.tsxindex ceeb880..d8d4a72 100644--- a/src/main.tsx+++ b/src/main.tsx@@ -1,7 +1,6 @@-import React from "react";+import React, { lazy, Suspense } from "react";import ReactDOM from "react-dom/client";import App from "./App";-import { QuickCapture } from "./components/QuickCapture";import "./styles/tokens.css";import "./styles/kit.css";import "./styles/app.css";@@ -46,12 +45,20 @@ document.addEventListener("contextmenu", (e) => {if (!editable) e.preventDefault();});-// The quick-capture window (`skykeep --new reminder`) is one field, not the library.+// The quick-capture window (`skykeep --new reminder`) is one field, not the library — and the+// library's window never reads its code.const capture = new URLSearchParams(window.location.search).get("capture");+const QuickCapture = lazy(() => import("./components/QuickCapture").then((m) => ({ default: m.QuickCapture })));ReactDOM.createRoot(document.getElementById("root")!).render(<React.StrictMode>- {capture === "reminder" || capture === "note" ? <QuickCapture initial={capture} /> : <App />}+ {capture === "reminder" || capture === "note" ? (+ <Suspense fallback={null}>+ <QuickCapture initial={capture} />+ </Suspense>+ ) : (+ <App />+ )}</React.StrictMode>);diff --git a/src/screens/Library.tsx b/src/screens/Library.tsxindex 39a02d7..6d79043 100644--- a/src/screens/Library.tsx+++ b/src/screens/Library.tsx@@ -4,7 +4,7 @@ import { EmptyState } from "../components/EmptyState";import { StatusLine } from "../components/StatusLine";import { lazy, Suspense, useCallback, useEffect, useLayoutEffect, useRef, useState } from "react";import { listen } from "@tauri-apps/api/event";-import { getCurrentWindow } from "@tauri-apps/api/window";+import { invoke } from "@tauri-apps/api/core";import { PanelLeft } from "lucide-react";import { api, messageOf, NEW_EVENT, OPEN_REMINDER } from "../lib/ipc";import { SyncProvider, useSync } from "../lib/sync";@@ -62,7 +62,8 @@ import { ScreenBoundary } from "../components/ScreenBoundary";import { ScreenActive, modalOpen } from "../lib/screen";import { AppIcon } from "../components/AppIcon";import { GlobalSearch } from "../components/GlobalSearch";-import { ShortcutsSheet } from "../components/ShortcutsSheet";+// Only when asked for (Ctrl-/): the window opens without its code.+const ShortcutsSheet = lazy(() => import("../components/ShortcutsSheet").then((m) => ({ default: m.ShortcutsSheet })));/*** What the sidebar holds: the services with a real screen behind them, most used first.@@ -131,7 +132,11 @@ function AppKeys({ screen, onSettings }: { screen: string | null; onSettings: ()window.addEventListener("keydown", onKey);return () => window.removeEventListener("keydown", onKey);}, [onSettings]);- return sheet ? <ShortcutsSheet front={screen} onClose={() => setSheet(false)} /> : null;+ return sheet ? (+ <Suspense fallback={null}>+ <ShortcutsSheet front={screen} onClose={() => setSheet(false)} />+ </Suspense>+ ) : null;}/**@@ -325,8 +330,11 @@ export function Library({ onSignOut, onShown }: { onSignOut: (keep: boolean) =>const title = selected === "settings" ? "Settings" : SCREENS.find((s) => s.key === selected)?.name;if (!title) return;document.title = title;+ // Asked of the window plugin by itself: `@tauri-apps/api/window` for this one call was a+ // quarter of the code the window had to read before it could draw anything.try {- void getCurrentWindow().setTitle(title).catch(() => {});+ const label = (window as { __TAURI_INTERNALS__?: { metadata?: { currentWindow?: { label?: string } } } }).__TAURI_INTERNALS__?.metadata?.currentWindow?.label;+ if (label) void invoke("plugin:window|set_title", { label, value: title }).catch(() => {});} catch {// Not in a Tauri window.}