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
Reminders: the Mac's keys for the selected reminder, and subtasks that fold
Yashwanth Kamireddi476b6d2acce5
diff --git a/.uiverify/reminders-completed.mjs b/.uiverify/reminders-completed.mjsnew file mode 100644index 0000000..b06dc83--- /dev/null+++ b/.uiverify/reminders-completed.mjs@@ -0,0 +1,81 @@+// Reminders' Completed list, as on the Mac: a tile with its count, the reminders ticked off+// grouped by list, nothing to add there, and one unticked leaves it. And the Mac's keys for the+// selected reminder: Ctrl+Shift+F flags it, Ctrl+Shift+C completes it, Ctrl+T makes it due+// today; Ctrl+Shift+H shows or hides a list's completed ones.+// BASE=http://localhost:4173 ENGINE=webkit node .uiverify/reminders-completed.mjs+import { engine } from "./engine.mjs";+import { SERVICES, installStub, openScreen } from "./stub.mjs";++const BASE = process.env.BASE ?? "http://localhost:4173";+const b = await engine.launch();+let failures = 0;+const ok = (p, m) => { console.log(`${p ? "PASS" : "FAIL"} ${m}`); if (!p) failures++; };+const until = (page, fn, arg) => page.waitForFunction(fn, arg, { timeout: 8000, polling: "raf" }).then(() => true, () => false);++const ctx = await b.newContext({ viewport: { width: 1200, height: 800 } });+await ctx.addInitScript(installStub, { screen: "library", services: SERVICES, twoFactor: null, remindersFixture: true });+const page = await ctx.newPage();+page.on("pageerror", (e) => ok(false, `page error: ${e.message}`));+await page.goto(BASE, { waitUntil: "networkidle" });+await openScreen(page, "Reminders");++// The tile, with its count, after Apple's four.+const tile = page.locator(".rx-tile", { hasText: "Completed" });+ok(await tile.count() === 1, "a Completed tile is in the sidebar");+ok((await tile.locator(".rx-tile-count").innerText()).trim() === "3", "with how many are completed");+const order = await page.locator(".rx-tile .rx-tile-name").allInnerTexts();+ok(order.slice(0, 5).join(",") === "Today,Scheduled,All,Flagged,Completed", `in Apple's order (${order.slice(0, 5)})`);++await tile.click();+ok(await until(page, () => [...document.querySelectorAll(".rx-row .rx-title")].some((t) => t.value === "Water the plants")),+ "it shows the reminders ticked off");+ok(await page.locator(".rx-row .rx-title").evaluateAll((els) => !els.some((e) => e.value === "Plan tomorrow")), "and none still to do");+ok(await page.locator(".rx-section", { hasText: "Daily" }).count() === 1, "grouped under the list each is in");+ok(await page.locator(".rx-add").count() === 0, "with nothing to add there");+ok(/1 completed/.test(await page.locator(".rx-head").innerText()), "its heading counts what is completed");++// Unticked, it is open again and leaves Completed.+await page.locator(".rx-row", { has: page.locator('.rx-title[value="Water the plants"]') }).locator(".rx-tick").click();+ok(await until(page, () => (window.__done ?? []).some((d) => d.guid === "r4" && d.done === false)), "unticking it sends it as open");+ok(await until(page, () => ![...document.querySelectorAll(".rx-row .rx-title")].some((t) => t.value === "Water the plants")),+ "and it leaves Completed");++// The Mac's keys, on the selected reminder in a list.+await page.locator(".rx-list", { hasText: "Daily" }).click();+await until(page, () => [...document.querySelectorAll(".rx-row .rx-title")].some((t) => t.value === "Plan tomorrow"));+const row = page.locator(".rx-row", { has: page.locator('.rx-title[value="Plan tomorrow"]') });+await row.focus();+await page.keyboard.press("Control+Shift+f");+ok(await until(page, () => (window.__edits ?? []).some((e) => e.flagged === true)), "Ctrl+Shift+F flags the selected reminder");+ok(await until(page, () => document.querySelector('.rx-row[data-guid="r1"] .rx-flag')?.getAttribute("aria-pressed") === "true"),+ "and it shows flagged at once");++// While its title is being typed in too.+await row.locator(".rx-title").focus();+await page.keyboard.press("Control+t");+ok(await until(page, () => {+ const d = new Date();+ const from = new Date(d.getFullYear(), d.getMonth(), d.getDate()).getTime() / 1000;+ return (window.__edits ?? []).some((e) => e.allDay === false && e.dueAt >= from && e.dueAt < from + 86400);+}),+ "Ctrl+T makes it due today, keeping its time");+ok(await until(page, () => /Today/.test(document.querySelector('.rx-row[data-guid="r1"] .rx-due')?.textContent ?? "")),+ "and its row says Today");++await row.focus();+await page.keyboard.press("Control+Shift+c");+ok(await until(page, () => (window.__done ?? []).some((d) => d.guid === "r1" && d.done === true)), "Ctrl+Shift+C completes it");++// Show and hide the list's completed reminders.+const link = page.locator(".rx-head .link");+const before = await link.innerText();+await page.mouse.click(900, 760);+await page.keyboard.press("Control+Shift+h");+ok(await until(page, (b4) => document.querySelector(".rx-head .link")?.textContent !== b4, before), "Ctrl+Shift+H shows or hides completed");+await page.keyboard.press("Control+Shift+h");+ok(await until(page, (b4) => document.querySelector(".rx-head .link")?.textContent === b4, before), "and again puts it back");++await ctx.close();+await b.close();+console.log(failures ? `\n${failures} FAILED` : "\nall passed");+process.exit(failures ? 1 : 0);diff --git a/.uiverify/reminders-subtask-fold.mjs b/.uiverify/reminders-subtask-fold.mjsnew file mode 100644index 0000000..f769b80--- /dev/null+++ b/.uiverify/reminders-subtask-fold.mjs@@ -0,0 +1,63 @@+// A reminder's subtasks fold away under it, as on the Mac: its arrow hides them and says how+// many wait there, and shows them again; Ctrl+Shift+E hides every reminder's, Ctrl+E shows+// them all. The fold is kept on this computer across a reload.+// BASE=http://localhost:4173 ENGINE=webkit node .uiverify/reminders-subtask-fold.mjs+import { engine } from "./engine.mjs";+import { SERVICES, installStub, openScreen } from "./stub.mjs";++const BASE = process.env.BASE ?? "http://localhost:4173";+const b = await engine.launch();+let failures = 0;+const ok = (p, m) => { console.log(`${p ? "PASS" : "FAIL"} ${m}`); if (!p) failures++; };+const until = (page, fn, arg) => page.waitForFunction(fn, arg, { timeout: 8000, polling: "raf" }).then(() => true, () => false);++const ctx = await b.newContext({ viewport: { width: 1200, height: 800 } });+await ctx.addInitScript(() => {+ const r = (guid, title, parentGuid = null) => ({ guid, listGuid: "l1", title, notes: null, dueAt: null, allDay: false,+ completedAt: null, priority: 0, flagged: false, parentGuid, etag: null });+ window.__extraReminders = [r("par", "Plan the move"), r("k1", "Book the van", "par"), r("k2", "Pack the kitchen", "par")];+ window.__filterLists = true;+});+await ctx.addInitScript(installStub, { screen: "library", services: SERVICES, twoFactor: null, remindersFixture: true });+const page = await ctx.newPage();+page.on("pageerror", (e) => ok(false, `page error: ${e.message}`));+await page.goto(BASE, { waitUntil: "networkidle" });+await openScreen(page, "Reminders");+await page.locator(".rx-list", { hasText: "Daily" }).click();++const shown = (title) => page.evaluate((t) => [...document.querySelectorAll(".rx-row .rx-title")].some((e) => e.value === t), title);+ok(await until(page, () => [...document.querySelectorAll(".rx-row .rx-title")].some((e) => e.value === "Book the van")), "a reminder's subtasks show under it");++const arrow = page.locator('.rx-row[data-guid="par"] .rx-kids');+ok(await arrow.count() === 1, "a reminder with subtasks has an arrow for them");+ok(await page.locator('.rx-row[data-guid="k1"] .rx-kids').count() === 0, "a subtask has none");+ok(await page.locator('.rx-row[data-guid="r1"] .rx-kids').count() === 0, "nor does a reminder without subtasks");+ok(await arrow.getAttribute("aria-expanded") === "true", "shown, the arrow says so");++await arrow.click();+ok(await until(page, () => ![...document.querySelectorAll(".rx-row .rx-title")].some((e) => e.value === "Book the van" || e.value === "Pack the kitchen")),+ "its arrow folds them away");+ok(await shown("Plan the move"), "the reminder itself stays");+ok((await arrow.innerText()).trim() === "2", "and says how many wait under it");+ok(await arrow.getAttribute("aria-expanded") === "false", "folded, the arrow says so");++// Kept across a reload, as the Mac keeps it.+await page.reload({ waitUntil: "networkidle" });+await openScreen(page, "Reminders");+await page.locator(".rx-list", { hasText: "Daily" }).click();+await until(page, () => [...document.querySelectorAll(".rx-row .rx-title")].some((e) => e.value === "Plan the move"));+ok(!(await shown("Book the van")), "the fold is kept after a reload");++// Ctrl+E shows every subtask; Ctrl+Shift+E hides them all.+await page.mouse.click(900, 760);+await page.keyboard.press("Control+e");+ok(await until(page, () => [...document.querySelectorAll(".rx-row .rx-title")].some((e) => e.value === "Book the van")), "Ctrl+E shows every subtask");+await page.keyboard.press("Control+Shift+e");+ok(await until(page, () => ![...document.querySelectorAll(".rx-row .rx-title")].some((e) => e.value === "Pack the kitchen")), "Ctrl+Shift+E hides them all");+await page.locator('.rx-row[data-guid="par"] .rx-kids').click();+ok(await until(page, () => [...document.querySelectorAll(".rx-row .rx-title")].some((e) => e.value === "Pack the kitchen")), "and its arrow shows them again");++await ctx.close();+await b.close();+console.log(failures ? `\n${failures} FAILED` : "\nall passed");+process.exit(failures ? 1 : 0);diff --git a/src/components/ShortcutsSheet.tsx b/src/components/ShortcutsSheet.tsxindex 286bcf1..8f1a003 100644--- a/src/components/ShortcutsSheet.tsx+++ b/src/components/ShortcutsSheet.tsx@@ -39,6 +39,10 @@ export const SHORTCUTS: { app: string; key: string; rows: Row[] }[] = [[[["Tab"], ["Shift", "Tab"]], "Make a subtask / move it back out"],[[["Space"], ["Return"]], "Tick / edit"],[[["Ctrl", "I"]], "Show details"],+ [[["Ctrl", "Shift", "F"], ["Ctrl", "Shift", "C"]], "Flag / complete"],+ [[["Ctrl", "T"]], "Due today"],+ [[["Ctrl", "Shift", "H"]], "Show or hide completed"],+ [[["Ctrl", "E"], ["Ctrl", "Shift", "E"]], "Show / hide all subtasks"],[[["Ctrl", "F"]], "Search"],],},diff --git a/src/screens/RemindersView.tsx b/src/screens/RemindersView.tsxindex adb7df9..a10349c 100644--- a/src/screens/RemindersView.tsx+++ b/src/screens/RemindersView.tsx@@ -14,7 +14,7 @@ import { SearchField } from "../components/SearchField";import { PaneTitle } from "../components/PaneTitle";import { Portal } from "../components/Portal";import { TimeField } from "../components/TimeField";-import { AlarmClock, ChevronLeft, Link2, ListFilter, MapPin, MessageCircle, X } from "lucide-react";+import { AlarmClock, ChevronLeft, ChevronRight, Link2, ListFilter, MapPin, MessageCircle, X } from "lucide-react";import {api,MOST_AT_ONCE,@@ -72,6 +72,24 @@ function readFolded(): Set<string> {}}+/** Reminders whose subtasks are hidden, remembered on this computer, as the Mac keeps them. */+const HIDDEN_SUBTASKS_KEY = "quince.reminders.hiddenSubtasks";+function readHiddenSubtasks(): Set<string> {+ try {+ const raw = window.localStorage.getItem(HIDDEN_SUBTASKS_KEY);+ return new Set(raw ? (JSON.parse(raw) as string[]) : []);+ } catch {+ return new Set();+ }+}+function keepHiddenSubtasks(hidden: Set<string>) {+ try {+ window.localStorage.setItem(HIDDEN_SUBTASKS_KEY, JSON.stringify([...hidden]));+ } catch {+ // Without storage they still fold; it is forgotten on restart.+ }+}+/** End of today in the viewer's own timezone — the interface knows it, the backend doesn't. */function endOfToday(): number {const d = new Date();@@ -328,6 +346,17 @@ export function RemindersView() {const [infoFor, setInfoFor] = useState<ReminderList | null>(null);const [groups, setGroups] = useState<ReminderGroup[]>([]);const [folded, setFolded] = useState<Set<string>>(readFolded);+ /** Reminders whose subtasks are folded away under them (the arrow beside one, Ctrl+E). */+ const [hiddenSubtasks, setHiddenSubtasks] = useState<Set<string>>(readHiddenSubtasks);+ const foldSubtasks = useCallback((guid: string) => {+ setHiddenSubtasks((was) => {+ const next = new Set(was);+ if (next.has(guid)) next.delete(guid);+ else next.add(guid);+ keepHiddenSubtasks(next);+ return next;+ });+ }, []);const toggleFolded = useCallback((guid: string) => {setFolded((was) => {const next = new Set(was);@@ -1030,8 +1059,12 @@ export function RemindersView() {/*** The keys Reminders on the Mac answers, with Ctrl for Command: Ctrl+N a new reminder,- * Ctrl+Shift+N a new list, Ctrl+F the search, Ctrl+I the selected reminder's info. On a row:- * Up and Down move, Space ticks it, Return edits it, Delete deletes it (asking first).+ * Ctrl+Shift+N a new list, Ctrl+F the search, Ctrl+I the selected reminder's info. For the+ * selected reminder — its row, or its title being typed in — Ctrl+Shift+F flags it,+ * Ctrl+Shift+C completes it and Ctrl+T makes it due today; Ctrl+Shift+H shows or hides a+ * list's completed reminders; Ctrl+E shows every subtask and Ctrl+Shift+E hides them. On a+ * row: Up and Down move, Space ticks it, Return edits it,+ * Delete deletes it (asking first).*/const live = useActiveRef();const searchRef = useRef<HTMLInputElement>(null);@@ -1076,6 +1109,47 @@ export function RemindersView() {searchRef.current?.select();return;}+ // The reminder the keys act on: the row the focus is in, or the one whose details are open.+ const chosen = () => {+ const row = (document.activeElement as HTMLElement | null)?.closest?.<HTMLElement>(".rx-row");+ const guid = row?.dataset.guid ?? openGuid;+ return guid ? (items.find((r) => r.guid === guid) ?? null) : null;+ };+ if (command && e.shiftKey && (k === "f" || k === "c")) {+ e.preventDefault();+ if (e.repeat) return;+ const r = chosen();+ if (!r || r.guid.startsWith(STAND_IN)) return;+ if (k === "f") void flag(r);+ else toggle(r);+ return;+ }+ if (command && k === "e") {+ // Show All Subtasks (Ctrl+E) and Hide All Subtasks (Ctrl+Shift+E), as the View menu has them.+ e.preventDefault();+ const next = e.shiftKey ? new Set([...hiddenSubtasks, ...kidsOf.keys()]) : new Set<string>();+ setHiddenSubtasks(next);+ keepHiddenSubtasks(next);+ return;+ }+ if (command && e.shiftKey && k === "h") {+ e.preventDefault();+ if (inList) setShowDone((v) => !v);+ return;+ }+ if (command && !e.shiftKey && k === "t") {+ // Due Today: the day moves to today; a time it had is kept, on its own zone's clock.+ e.preventDefault();+ if (e.repeat) return;+ const r = chosen();+ if (!r || r.guid.startsWith(STAND_IN)) return;+ const now = new Date();+ const pad2 = (n: number) => String(n).padStart(2, "0");+ const day = `${now.getFullYear()}-${pad2(now.getMonth() + 1)}-${pad2(now.getDate())}`;+ const w = r.dueAt !== null && !r.allDay ? wallIn(zoneOf(r), r.dueAt) : null;+ void setDue(r, day, w ? `${pad2(w.h)}:${pad2(w.min)}` : null);+ return;+ }if (command && !e.shiftKey && k === "i") {e.preventDefault();const row = (document.activeElement as HTMLElement | null)?.closest?.<HTMLElement>(".rx-row");@@ -1363,11 +1437,20 @@ export function RemindersView() {// has to appear at the top level rather than vanish.if (r.parentGuid && known.has(r.parentGuid)) continue;out.push({ reminder: r, depth: 0 });+ // Folded away under it, its subtasks are not drawn at all — until it is opened again.+ if (hiddenSubtasks.has(r.guid)) continue;for (const child of children.get(r.guid) ?? []) {out.push({ reminder: child, depth: 1 });}}return out;+ }, [shownItems, hiddenSubtasks]);+ /** How many subtasks each reminder in view has, for the arrow that folds them. */+ const kidsOf = useMemo(() => {+ const known = new Set(shownItems.map((r) => r.guid));+ const out = new Map<string, number>();+ for (const r of shownItems) if (r.parentGuid && known.has(r.parentGuid)) out.set(r.parentGuid, (out.get(r.parentGuid) ?? 0) + 1);+ return out;}, [shownItems]);/*** The rows arranged the way Apple arranges them.@@ -1733,6 +1816,7 @@ export function RemindersView() {rowActions.current = {toggle, askRemove, rename, indent, outdent, flag, setNotes, setUrl, setDue, setEarly, setRepeat,tagAdd, tagRemove, setPriority, moveToList, moveToSection, openTag, setOpenGuid, reorder,+ foldSubtasks,openMenu: (reminder, at) => setRowMenu({ reminder, at }),dragging: () => draggingRef.current,startDrag: (guid) => {@@ -2004,6 +2088,8 @@ export function RemindersView() {sections={isOpen ? listSections : NO_SECTIONS}section={isOpen ? sectionOf(reminder) : null}subtasks={isOpen ? items.filter((x) => x.parentGuid === reminder.guid).length : 0}+ kids={depth === 0 ? (kidsOf.get(reminder.guid) ?? 0) : 0}+ kidsHidden={hiddenSubtasks.has(reminder.guid)}/>);})}@@ -2169,6 +2255,8 @@ type RowActions = {setOpenGuid: (guid: string | null) => void;openMenu: (r: Reminder, at: { x: number; y: number; alignRight: boolean }) => void;reorder: (guid: string, before: string) => Promise<unknown>;+ /** Fold a reminder's subtasks away under it, or open them again. */+ foldSubtasks: (guid: string) => void;/** The reminder being dragged now, read at the moment it is asked. */dragging: () => string | null;startDrag: (guid: string) => void;@@ -2219,6 +2307,9 @@ type ReminderRowProps = {sections: ReminderSection[];section: string | null;subtasks: number;+ /** How many subtasks it has in view, and whether they are folded away under it. */+ kids: number;+ kidsHidden: boolean;};/**@@ -2229,6 +2320,7 @@ type ReminderRowProps = {const ReminderRow = memo(function ReminderRow({reminder, depth, dated, isOpen, marks: rowMarks, tags: rowTags, home, showListName, justMoved, waiting,leaving, settling, isDragging, canReorder, inList, act, focused, detailOf, moreOf, lists, sections, section, subtasks,+ kids, kidsHidden,}: ReminderRowProps) {const due = reminder.dueAt === null ? null : dueLabel(reminder.dueAt, dated, reminder.allDay);const repeat = repeatLabel(reminder);@@ -2627,6 +2719,19 @@ const ReminderRow = memo(function ReminderRow({</div><span className="rx-trailing">+ {/* A reminder with subtasks shows they are there, and folds them away under it. */}+ {kids > 0 && (+ <button+ className={`icon-button small rx-kids${kidsHidden ? "" : " is-open"}`}+ aria-expanded={!kidsHidden}+ aria-label={`${kidsHidden ? "Show" : "Hide"} ${kids === 1 ? "subtask" : `${kids} subtasks`} of ${reminder.title}`}+ title={kidsHidden ? `${kids === 1 ? "1 subtask" : `${kids} subtasks`}` : undefined}+ onClick={() => act.current.foldSubtasks(reminder.guid)}+ >+ {kidsHidden && <span className="rx-kids-count">{kids}</span>}+ <ChevronRight size={14} strokeWidth={2.25} aria-hidden="true" />+ </button>+ )}<buttonclassName="icon-button small rx-icon-button"aria-label={diff --git a/src/styles/reminders.css b/src/styles/reminders.cssindex ed4cb46..e489e23 100644--- a/src/styles/reminders.css+++ b/src/styles/reminders.css@@ -365,6 +365,11 @@ button.rx-tag:hover { background: color-mix(in srgb, var(--text) 12%, transparen.rx-row.is-open .rx-icon-button,.rx-icon-button.rx-flag.on { opacity: 1; }.rx-icon-button.rx-flag.on { color: var(--sys-orange); }+/* A reminder's subtasks, folded or shown: always there, as it says something about the row.+ Folded, how many wait under it; shown, the arrow points down at them. */+.rx-kids { display: inline-flex; align-items: center; gap: 1px; width: auto; min-width: 24px; padding: 0 4px; color: var(--text-2); }+.rx-kids.is-open svg { transform: rotate(90deg); }+.rx-kids-count { font-size: var(--t-11); font-variant-numeric: tabular-nums; }.rx-detail {display: flex;