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
Search: Show All per section; a found event opens in Calendar
Yashwanth Kamireddi933ed6f92fe7
diff --git a/.uiverify/search-calendar.mjs b/.uiverify/search-calendar.mjsnew file mode 100644index 0000000..baf75f6--- /dev/null+++ b/.uiverify/search-calendar.mjs@@ -0,0 +1,41 @@+// An event found by the search across everything opens in Calendar as Calendar opens one+// found: on its day, its calendar shown if it was hidden — and kept shown, as the tick in the+// list says, after a restart too — and the event's own popover open on it.+import { engine } from "./engine.mjs";+import { SERVICES, installStub } from "./stub.mjs";+const b = await engine.launch();+let failures = 0;+const ok = (p, m) => { console.log(`${p ? "PASS" : "FAIL"} ${m}`); if (!p) failures++; };+for (const scheme of ["light", "dark"]) {+ const ctx = await b.newContext({ viewport: { width: 1280, height: 800 }, colorScheme: scheme });+ await ctx.addInitScript(installStub, { screen: "library", services: SERVICES, twoFactor: null, calendarFixture: true });+ await ctx.addInitScript(() => {+ if (!sessionStorage.getItem("seeded")) {+ localStorage.setItem("quince.calendar.hidden", JSON.stringify(["work"]));+ sessionStorage.setItem("seeded", "1");+ }+ });+ const page = await ctx.newPage();+ page.on("pageerror", (e) => { console.log(`FAIL page error: ${e.message}`); process.exitCode = 1; });+ await page.goto("http://localhost:4173", { waitUntil: "networkidle" });+ const field = page.getByRole("combobox", { name: "Search everything" });+ await field.fill("sprint");+ await page.waitForTimeout(300);+ const panel = page.getByRole("listbox", { name: "Found" });+ ok((await panel.getByRole("region", { name: "Calendar" }).count()) === 1, `${scheme}: the event is found`);+ await page.keyboard.press("Enter");+ await page.waitForTimeout(800);+ const pop = page.locator(".cx-popover");+ ok((await pop.count()) === 1 && /Sprint planning/.test(await pop.innerText().catch(() => "") + (await pop.locator("input").first().inputValue().catch(() => ""))),+ `${scheme}: its popover is open on it`);+ const work = page.locator(".cx-cal", { hasText: "Work" }).locator("input");+ ok(await work.isChecked(), `${scheme}: its hidden calendar is shown, and ticked`);+ ok(!(await page.evaluate(() => localStorage.getItem("quince.calendar.hidden") ?? "")).includes("work"), `${scheme}: and stays shown`);+ await page.reload({ waitUntil: "networkidle" });+ await page.getByRole("link", { name: /Calendar/ }).or(page.locator(".nav-item", { hasText: "Calendar" })).first().click();+ await page.waitForTimeout(500);+ ok(await page.locator(".cx-cal", { hasText: "Work" }).locator("input").isChecked(), `${scheme}: after a restart too`);+ await ctx.close();+}+await b.close();+process.exitCode = failures ? 1 : 0;diff --git a/.uiverify/search-everything.mjs b/.uiverify/search-everything.mjsindex bc8e4ad..465eb3c 100644--- a/.uiverify/search-everything.mjs+++ b/.uiverify/search-everything.mjs@@ -10,6 +10,11 @@ for (const scheme of ["light", "dark"]) {const ctx = await b.newContext({ viewport: { width: 1280, height: 800 }, colorScheme: scheme });await ctx.addInitScript(installStub, { screen: "library", services: SERVICES, twoFactor: null,notesFixture: true, contactsFixture: true, driveFixture: true });+ // Enough people named alike that their section has more than it shows.+ await ctx.addInitScript(() => {+ window.__moreContacts = Array.from({ length: 8 }, (_, i) => ({ guid: `m${i}`, firstName: "Marlowe", lastName: `Test ${i + 1}`,+ company: null, isCompany: false, birthday: null, notes: null, etag: null, methods: [] }));+ });const page = await ctx.newPage();page.on("pageerror", (e) => { console.log(`FAIL page error: ${e.message}`); process.exitCode = 1; });await page.goto("http://localhost:4173", { waitUntil: "networkidle" });@@ -33,6 +38,26 @@ for (const scheme of ["light", "dark"]) {ok(!(await panel.isVisible()), `${scheme}: Escape puts the results away`);await page.keyboard.press("Escape");ok((await field.inputValue()) === "", `${scheme}: and a second clears the field`);+ // A section with more than it shows: Show All shows that one whole, in place; Show Less+ // puts it back; the keys reach every row of it.+ await field.fill("marlowe");+ await page.waitForTimeout(300);+ const more = panel.getByRole("button", { name: /^Show all \d+ in / }).first();+ const label = await more.getAttribute("aria-label").catch(() => null);+ if (!label) ok(false, `${scheme}: some section has more than it shows`);+ else {+ const [, total, name] = /Show all (\d+) in (.+)/.exec(label);+ const region = panel.getByRole("region", { name });+ const short = await region.getByRole("option").count();+ await more.click();+ await page.waitForTimeout(300);+ const all = await region.getByRole("option").count();+ ok(short === 5 && all === Number(total), `${scheme}: Show All shows ${name} whole (${short} → ${all} of ${total})`);+ ok(await field.evaluate((f) => f === document.activeElement), `${scheme}: and the field keeps the keys`);+ await region.getByRole("button", { name: "Show Less" }).click();+ await page.waitForTimeout(300);+ ok((await region.getByRole("option").count()) === 5, `${scheme}: Show Less puts it back`);+ }await field.fill("qqqzzz");await page.waitForTimeout(300);ok(/Nothing in your iCloud holds/.test(await panel.innerText()), `${scheme}: nothing found says so`);diff --git a/.uiverify/stub.mjs b/.uiverify/stub.mjsindex 163874a..84c4e1b 100644--- a/.uiverify/stub.mjs+++ b/.uiverify/stub.mjs@@ -636,10 +636,12 @@ export function installStub({ screen, services, twoFactor, calendarFixture, noteconst q = String(args.query).toLowerCase().split(/\s+/).filter(Boolean);const has = (t) => q.every((w) => String(t ?? "").toLowerCase().includes(w));const notes = noteList.filter((n) => has(`${n.title} ${n.body ?? ""}`));- const contacts = contactList.filter((c) => has(`${c.firstName ?? ""} ${c.lastName ?? ""} ${c.company ?? ""}`));+ const contacts = contactList.concat(window.__moreContacts ?? []).filter((c) => has(`${c.firstName ?? ""} ${c.lastName ?? ""} ${c.company ?? ""}`));const files = (driveFixture ? driveItems : []).filter((f) => has(`${f.name}.${f.extension ?? ""}`));- return { notes: notes.slice(0, 5), reminders: [], events: [], contacts: contacts.slice(0, 5), files: files.slice(0, 5), photos: [],- counts: [notes.length, 0, 0, contacts.length, files.length, 0] };+ const found = events.filter((e) => has(`${e.title} ${e.location ?? ""}`));+ const each = args.each ?? 5;+ return { notes: notes.slice(0, each), reminders: [], events: found.slice(0, each), contacts: contacts.slice(0, each), files: files.slice(0, each), photos: [],+ counts: [notes.length, 0, found.length, contacts.length, files.length, 0] };}case "drive_kept": return window.__driveFolder?.on ? [...(window.__kept ??= [])] : null;case "drive_keep":diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rsindex 1605dc2..3a0eea7 100644--- a/src-tauri/src/main.rs+++ b/src-tauri/src/main.rs@@ -809,11 +809,13 @@ async fn auth_submit_sms_code(#[tauri::command]async fn search_everything(query: String,+ each: Option<usize>,data: State<'_, Data>,) -> UiResult<quince_core::search::Everything> {let library = data.0.lock().await;+ // A few of each kind, or more of one when its section is shown whole.library- .search_everything(&query, 5)+ .search_everything(&query, each.unwrap_or(5).clamp(1, 200)).map_err(|e| e.to_string())}diff --git a/src/components/GlobalSearch.tsx b/src/components/GlobalSearch.tsxindex 37aa13c..9d26a27 100644--- a/src/components/GlobalSearch.tsx+++ b/src/components/GlobalSearch.tsx@@ -5,7 +5,8 @@* there are, and a choice opens that very thing in its own app.** The keys, as Spotlight's: typing searches, Up and Down move through what was found, Return- * opens it, Escape puts the results away (and a second Escape clears the field).+ * opens it, Escape puts the results away (and a second Escape clears the field). A section with+ * more than it shows has Show All, which shows that one whole, in place.*/import { useEffect, useMemo, useRef, useState } from "react";import { Search, X } from "lucide-react";@@ -35,6 +36,10 @@ type Everything = {counts: [number, number, number, number, number, number];};+/** How many of a kind a section shows, and the most it shows whole. */+const SHORT = 5;+const WHOLE = 200;+type Row = {key: string;screen: string;@@ -119,6 +124,8 @@ export function GlobalSearch({ onOpen, available }: { onOpen: (screen: string) =const [found, setFound] = useState<Everything | null>(null);const [open, setOpen] = useState(false);const [at, setAt] = useState(0);+ /** The one section shown whole, if any. */+ const [whole, setWhole] = useState<string | null>(null);const field = useRef<HTMLInputElement | null>(null);const box = useRef<HTMLDivElement | null>(null);const panel = useRef<HTMLDivElement | null>(null);@@ -134,11 +141,11 @@ export function GlobalSearch({ onOpen, available }: { onOpen: (screen: string) =}let current = true;const t = window.setTimeout(() => {- api.searchEverything(q).then(+ api.searchEverything(q, whole ? WHOLE : undefined).then((f) => {if (!current) return;setFound(f as Everything);- setAt(0);+ if (!whole) setAt(0);},() => current && setFound(null),);@@ -147,7 +154,10 @@ export function GlobalSearch({ onOpen, available }: { onOpen: (screen: string) =current = false;window.clearTimeout(t);};- }, [query]);+ }, [query, whole]);++ // A new search starts with every section short again.+ useEffect(() => setWhole(null), [query]);// Away when the window is clicked anywhere else.useEffect(() => {@@ -161,8 +171,11 @@ export function GlobalSearch({ onOpen, available }: { onOpen: (screen: string) =}, [open]);const groups = useMemo(- () => (found ? sections(found).filter((s) => available.includes(s.screen)) : []),- [found, available],+ () =>+ (found ? sections(found).filter((s) => available.includes(s.screen)) : []).map((s) =>+ s.screen === whole ? s : { ...s, rows: s.rows.slice(0, SHORT) },+ ),+ [found, available, whole],);const rows = useMemo(() => groups.flatMap((g) => g.rows), [groups]);@@ -249,7 +262,17 @@ export function GlobalSearch({ onOpen, available }: { onOpen: (screen: string) =<h3><AppIcon app={g.screen} /><span>{g.name}</span>- {g.count > g.rows.length && <span className="gsearch-count">{g.rows.length} of {g.count}</span>}+ {whole === g.screen ? (+ <button className="gsearch-more" onClick={() => setWhole(null)}>Show Less</button>+ ) : g.count > g.rows.length ? (+ <button+ className="gsearch-more"+ aria-label={`Show all ${g.count} in ${g.name}`}+ onClick={() => setWhole(g.screen)}+ >+ Show All {g.count}+ </button>+ ) : null}</h3>{g.rows.map((r) => {const i = rows.indexOf(r);diff --git a/src/lib/ipc.ts b/src/lib/ipc.tsindex 4d30a03..c3f7482 100644--- a/src/lib/ipc.ts+++ b/src/lib/ipc.ts@@ -107,7 +107,7 @@ export const api = {/** What the iCloud Drive folder keeps on this computer; null while the folder is off. */driveKept: () => invoke<string[] | null>("drive_kept"),/** One search across every app's library: the first few of each, and how many in all. */- searchEverything: (query: string) => invoke<unknown>("search_everything", { query }),+ searchEverything: (query: string, each?: number) => invoke<unknown>("search_everything", { query, each }),driveKeep: (drivewsid: string, on: boolean) => invoke<string[]>("drive_keep", { drivewsid, on }),photosFolderSet: (on: boolean) => invoke<DriveFolder>("photos_folder_set", { on }),/** Open at Login: whether it is on, the command it runs, and whether this desktop runs it. */diff --git a/src/screens/calendar/CalendarView.tsx b/src/screens/calendar/CalendarView.tsxindex 0c3dc63..44eadd1 100644--- a/src/screens/calendar/CalendarView.tsx+++ b/src/screens/calendar/CalendarView.tsx@@ -269,12 +269,16 @@ export function CalendarView() {const [naming, setNaming] = useState<string | null>(null);const [calMenu, setCalMenu] = useState<{ cal: Calendar; at: { x: number; y: number; alignRight: boolean } } | null>(null);const [hidden, setHidden] = useState<Set<string>>(() => readSet(HIDDEN_KEY));- // An event found by the search across everything: its day shown, and its calendar too if- // it was hidden — never a found event that cannot be seen.+ // An event found by the search across everything: its day shown, its calendar too if it+ // was hidden (and kept shown, as its tick in the list says) — never a found event that+ // cannot be seen — and the event itself opened, as Calendar opens one found.+ const [finding, setFinding] = useState<string | null>(null);useReveal("calendar", (r) => {if (r.at) setSelected(midnight(new Date(r.at * 1000)));+ if (view === "year") setView("day");const cal = r.within;- if (cal) setHidden((h) => (h.has(cal) ? new Set([...h].filter((g) => g !== cal)) : h));+ if (cal && hidden.has(cal)) toggleCalendar(cal);+ setFinding(r.id);});const [loaded, setLoaded] = useState(false);const [error, setError] = useState<string | null>(null);@@ -588,6 +592,23 @@ export function CalendarView() {);}};+ // Opened once it is drawn: its day and calendar may take a render or two to come up. One+ // that never shows (gone since it was found) is let go of rather than opened later.+ useLayoutEffect(() => {+ if (!finding) return;+ const event = events.find((e) => e.guid === finding);+ const block = document.querySelector(`[data-event="${CSS.escape(finding)}"]`);+ if (!event || !block) return;+ setFinding(null);+ block.scrollIntoView({ block: "nearest" });+ const r = block.getBoundingClientRect();+ openDraft(draftOf(event), { x: r.right, y: r.top, left: r.left });+ });+ useEffect(() => {+ if (!finding) return undefined;+ const t = window.setTimeout(() => setFinding(null), 3000);+ return () => window.clearTimeout(t);+ }, [finding]);const newAt = (startsAt: number, endsAt: number, allDay: boolean, at: Anchor) => {if (!target) return;openDraft(diff --git a/src/styles/app.css b/src/styles/app.cssindex b13b6ec..5ce34b4 100644--- a/src/styles/app.css+++ b/src/styles/app.css@@ -2130,7 +2130,12 @@font-weight: 600; color: var(--text-2);}.gsearch-group h3 .app-icon { width: 16px; height: 16px; }-.gsearch-count { margin-left: auto; font-weight: 400; color: var(--text-3); }+.gsearch-more {+ margin-left: auto; padding: 1px 6px; border: 0; border-radius: 5px; background: none;+ font: inherit; font-weight: 500; color: var(--accent); cursor: default;+}+.gsearch-more:hover { background: color-mix(in srgb, var(--accent) 12%, transparent); }+.gsearch-more:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }.gsearch-row {display: flex; align-items: center; gap: 8px; width: 100%; min-height: 36px; padding: 4px 8px; border: 0;border-radius: 7px; background: none; color: inherit; font: inherit; text-align: start; cursor: default;