Skip to content

Native iCloud apps for Windows and Linux, built in Rust. Notes, Reminders, Calendar, Contacts, Drive and Photos, offline and in sync with your iPhone.

Calendar: tick a reminder from its ring, in every view; Notes: pin, move, delete and recover show at once, recover returns to Notes

Yashwanth Kamireddi11e5ca3e4167
diff --git a/.uiverify/assert.mjs b/.uiverify/assert.mjs
index 5d69481..bb6bded 100644
--- a/.uiverify/assert.mjs
+++ b/.uiverify/assert.mjs
@@ -92,8 +92,8 @@ await p.waitForSelector(".sidebar .nav-item");
// The sidebar holds what works, most used first. Apple's thirty-odd services — "CloudKit
// data", "Push", "Account gateway" — and screens that only said they were not built (Photos,
// Mail, Find My, Shared albums) were all listed; none of them is anything to use here.
-const names = (await p.locator(".sidebar .nav-item").allInnerTexts()).map((t) => t.trim());
-const selected = (await p.textContent('.nav-item[aria-current="true"]'))?.trim();
+const names = (await p.locator(".sidebar .nav-item .nav-name").allInnerTexts()).map((t) => t.trim());
+const selected = (await p.textContent('.nav-item[aria-current="true"] .nav-name'))?.trim();
console.log("nav items :", JSON.stringify(names));
console.log("page errors :", errs.length ? errs : "none");
const collapsed =
diff --git a/.uiverify/calendar-instant.mjs b/.uiverify/calendar-instant.mjs
index b8bc79e..f102436 100644
--- a/.uiverify/calendar-instant.mjs
+++ b/.uiverify/calendar-instant.mjs
@@ -14,7 +14,7 @@ await ctx.addInitScript(() => {
const inner = t.invoke;
t.invoke = async (cmd, args) => {
if (cmd === "event_save") window.__saves.push(args);
- if (cmd === "event_save" || cmd === "event_delete") await new Promise((r) => setTimeout(r, 1500));
+ if (cmd === "event_save" || cmd === "event_delete" || cmd === "reminder_set_done") await new Promise((r) => setTimeout(r, 1500));
const out = await inner(cmd, args);
if (cmd === "calendar_events" && Array.isArray(out))
return out.map((e) => (e.guid === "e2" ? { ...e, url: "https://meet.example/dentist" } : e));
@@ -57,5 +57,13 @@ await page.evaluate(() => document.activeElement?.blur());
await page.keyboard.press("Delete");
await page.waitForTimeout(150);
ok(await page.locator(".cx-block", { hasText: "Design review" }).count() === 0, "a deleted event leaves at once");
+// A reminder on the calendar ticks there, at once, as in Calendar.
+const ring = page.getByRole("checkbox", { name: /^Complete / }).first();
+const had = await ring.count();
+if (had) {
+ await ring.click();
+ await page.waitForTimeout(150);
+ ok((await ring.getAttribute("aria-checked")) === "true", "a reminder's ring on the calendar ticks it at once");
+} else ok(false, "no reminder on the calendar to tick");
await b.close();
process.exitCode = failures ? 1 : 0;
diff --git a/.uiverify/notes-instant.mjs b/.uiverify/notes-instant.mjs
new file mode 100644
index 0000000..76511cc
--- /dev/null
+++ b/.uiverify/notes-instant.mjs
@@ -0,0 +1,40 @@
+// Notes writes show at once: a pin, a delete. The stub holds each for 1.5 s.
+import { engine } from "./engine.mjs";
+import { SERVICES, installStub, openScreen } from "./stub.mjs";
+
+const b = await engine.launch();
+const ctx = await b.newContext({ viewport: { width: 1200, height: 800 } });
+await ctx.addInitScript(installStub, { screen: "library", services: SERVICES, twoFactor: null, notesFixture: true });
+await ctx.addInitScript(() => {
+ const wrap = () => {
+ const t = window.__TAURI_INTERNALS__;
+ if (!t || t.__slow) return;
+ const inner = t.invoke;
+ t.invoke = async (cmd, args) => {
+ if (/^note_(pin|delete|move)$/.test(cmd)) await new Promise((r) => setTimeout(r, 1500));
+ return inner(cmd, args);
+ };
+ t.__slow = true;
+ };
+ wrap(); document.addEventListener("DOMContentLoaded", wrap);
+});
+const page = await ctx.newPage();
+await page.goto("http://localhost:4173", { waitUntil: "networkidle" });
+await openScreen(page, "Notes");
+await page.locator(".note-row", { hasText: "Curtains" }).click();
+await page.waitForTimeout(300);
+let failures = 0;
+const ok = (p, m) => { console.log(`${p ? "PASS" : "FAIL"} ${m}`); if (!p) failures++; };
+
+await page.getByRole("button", { name: /^(Pin|Unpin) Note$/ }).first().click();
+await page.waitForTimeout(150);
+const pressed = await page.getByRole("button", { name: /^(Pin|Unpin) Note$/ }).first().getAttribute("aria-pressed");
+ok(pressed === "true", "a pin shows at once");
+
+const before = await page.locator(".note-row").count();
+await page.getByRole("button", { name: "Delete", exact: true }).click();
+await page.waitForTimeout(150);
+ok((await page.locator(".note-row", { hasText: "Curtains" }).count()) === 0 && (await page.locator(".note-row").count()) === before - 1,
+ "a deleted note leaves the list at once");
+await b.close();
+process.exitCode = failures ? 1 : 0;
diff --git a/check.sh b/check.sh
index 13eface..97c8caf 100755
--- a/check.sh
+++ b/check.sh
@@ -51,6 +51,7 @@ step "empty today" node .uiverify/reminders-empty.mjs
step "calendar keys" node .uiverify/calendar-keys.mjs
step "reminders instant" node .uiverify/reminders-instant.mjs
step "calendar instant" node .uiverify/calendar-instant.mjs
+step "notes instant" node .uiverify/notes-instant.mjs
# The same screens in WebKit, the engine Quince draws in. Chromium above catches most things;
# this catches what only WebKit does — pointer capture, blur on removal, its own layout.
diff --git a/src/screens/NotesView.tsx b/src/screens/NotesView.tsx
index 5378556..c442d1b 100644
--- a/src/screens/NotesView.tsx
+++ b/src/screens/NotesView.tsx
@@ -78,16 +78,23 @@ export function NotesView() {
* Every write goes to Apple first and the library is re-read after, so nothing on screen
* is a guess about what was stored.
*/
+ /**
+ * A pin, a move, a delete shows the moment it is asked for, as on the phone; then it goes
+ * to Apple and the list is re-read. A refusal re-reads, which puts the note back, and says
+ * why.
+ */
const write = useCallback(
- async (run: () => Promise<void>) => {
+ async (run: () => Promise<void>, predict?: (rows: Note[]) => Note[]) => {
setBusy(true);
setError(null);
+ if (predict) setNotes((rows) => predict(rows));
try {
await run();
await read();
return true;
} catch (e) {
setError(messageOf(e));
+ read().catch(() => {});
return false;
} finally {
setBusy(false);
@@ -341,26 +348,42 @@ export function NotesView() {
) {
return;
}
- await write(() => api.noteDelete(open.guid));
+ const gone = open.guid;
+ await write(() => api.noteDelete(gone), (rows) => rows.filter((n) => n.guid !== gone));
}, [open, write]);
- /** Out of Recently Deleted and back into Notes. */
+ /** Out of Recently Deleted and back into Notes — Apple's "Notes" folder where there is one. */
const recover = useCallback(async () => {
if (!open) return;
- await write(() => api.noteMove(open.guid, null));
- }, [open, write]);
+ const back = folders.some((f) => f.guid === "DefaultFolder-CloudKit") ? "DefaultFolder-CloudKit" : null;
+ const guid = open.guid;
+ await write(() => api.noteMove(guid, back), (rows) => rows.filter((n) => n.guid !== guid));
+ }, [open, write, folders]);
const moveTo = useCallback(
async (guid: string) => {
if (!open) return;
- await write(() => api.noteMove(open.guid, guid === ALL ? null : guid));
+ const to = guid === ALL ? null : guid;
+ const moving = open.guid;
+ await write(
+ () => api.noteMove(moving, to),
+ // Out of the folder on screen; in All it stays, filed somewhere else.
+ (rows) => folder === ALL
+ ? rows.map((n) => (n.guid === moving ? { ...n, folderGuid: to } : n))
+ : rows.filter((n) => n.guid !== moving),
+ );
},
- [open, write]
+ [open, write, folder]
);
const pin = useCallback(async () => {
if (!open) return;
- await write(() => api.notePin(open.guid, !open.pinned));
+ const guid = open.guid;
+ const pinned = !open.pinned;
+ await write(
+ () => api.notePin(guid, pinned),
+ (rows) => rows.map((n) => (n.guid === guid ? { ...n, pinned } : n)),
+ );
}, [open, write]);
// A save confirmation is a moment, not a state.
diff --git a/src/screens/calendar/CalendarView.tsx b/src/screens/calendar/CalendarView.tsx
index 464965e..c689c0c 100644
--- a/src/screens/calendar/CalendarView.tsx
+++ b/src/screens/calendar/CalendarView.tsx
@@ -1,6 +1,6 @@
import { Notice } from "../../components/Notice";
import { Search } from "lucide-react";
-import { Fragment, useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
+import { createContext, Fragment, useCallback, useContext, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
import {
api,
defaultCalendar,
@@ -81,6 +81,31 @@ type Draft = {
timezone: string | null;
};
+/**
+ * A reminder's ring on the calendar is its checkbox, as in Calendar: ticking it completes the
+ * reminder there and then. It fills at once, lingers a moment so the tick is seen, and leaves
+ * the schedule — Calendar shows no completed reminders.
+ */
+const TickContext = createContext<{ ticked: Set<string>; tick: (r: Reminder) => void } | null>(null);
+function Ring({ reminder }: { reminder: Reminder }) {
+ const ctx = useContext(TickContext);
+ const done = ctx?.ticked.has(reminder.guid) ?? false;
+ return (
+ <button
+ type="button"
+ className={`cx-ring${done ? " is-ticked" : ""}`}
+ role="checkbox"
+ aria-checked={done}
+ aria-label={`Complete ${reminder.title}`}
+ onMouseDown={(e) => e.stopPropagation()}
+ onClick={(e) => {
+ e.stopPropagation();
+ if (!done) ctx?.tick(reminder);
+ }}
+ />
+ );
+}
+
const draftOf = (e: CalendarEvent): Draft => ({
guid: e.guid,
calendarGuid: e.calendarGuid,
@@ -159,6 +184,18 @@ export function CalendarView() {
}, [query]);
const [events, setEvents] = useState<CalendarEvent[]>([]);
const [due, setDue] = useState<Reminder[]>([]);
+ const [ticked, setTicked] = useState<Set<string>>(() => new Set());
+ const tickValue = useMemo(() => ({
+ ticked,
+ tick: (r: Reminder) => {
+ setTicked((was) => new Set(was).add(r.guid));
+ const untick = () => setTicked((was) => { const next = new Set(was); next.delete(r.guid); return next; });
+ api.reminderSetDone(r.guid, r.listGuid, true).then(
+ () => window.setTimeout(() => { setDue((rows) => rows.filter((x) => x.guid !== r.guid)); untick(); }, 600),
+ (e) => { untick(); setError(messageOf(e)); },
+ );
+ },
+ }), [ticked]);
const [calendars, setCalendars] = useState<Calendar[]>([]);
const [hidden, setHidden] = useState<Set<string>>(() => readSet(HIDDEN_KEY));
const [loaded, setLoaded] = useState(false);
@@ -462,6 +499,7 @@ export function CalendarView() {
);
return (
+ <TickContext.Provider value={tickValue}>
<div className="cx">
<aside className="cx-side" aria-label="Calendars">
<div className="cx-cals">
@@ -678,6 +716,7 @@ export function CalendarView() {
</div>
)}
</div>
+ </TickContext.Provider>
);
}
@@ -894,7 +933,7 @@ function MonthView({
className={`cx-item is-reminder${item.reminder.completedAt ? " is-done" : ""}`}
title={dots ? `${item.reminder.title} · ${clock(item.at)}` : undefined}
>
- <span className="cx-ring" aria-hidden="true" />
+ <Ring reminder={item.reminder} />
<span className="cx-item-title">{item.reminder.title}</span>
<span className="cx-item-time">{clock(item.at)}</span>
</span>
@@ -1287,7 +1326,7 @@ function TimeGrid({
maxWidth: `calc(${100 / m.columns}% - 8px)`,
}}
>
- <span className="cx-ring" aria-hidden="true" />
+ <Ring reminder={r} />
{r.title}
</span>
);
@@ -1713,7 +1752,7 @@ function DayPane({
{timed.map((e) => row(e, `${clock(e.startsAt)} – ${clock(e.endsAt)}`))}
{due.map((r) => (
<li key={r.guid} className="cx-pane-reminder">
- <span className="cx-ring" aria-hidden="true" />
+ <Ring reminder={r} />
<span className="cx-pane-title">{r.title}</span>
<span className="cx-pane-when">{clock(r.dueAt ?? 0)}</span>
</li>
diff --git a/src/styles/calendar.css b/src/styles/calendar.css
index 7c1b156..f35b681 100644
--- a/src/styles/calendar.css
+++ b/src/styles/calendar.css
@@ -188,7 +188,7 @@
}
.cx-found-row {
display: grid;
- grid-template-columns: 8px minmax(0, 1fr) auto;
+ grid-template-columns: 10px minmax(0, 1fr) auto;
align-items: center;
gap: 10px;
width: 100%;
@@ -307,7 +307,7 @@
.cx-items li { pointer-events: auto; }
.cx-item {
display: grid;
- grid-template-columns: 8px minmax(0, 1fr) auto;
+ grid-template-columns: 10px minmax(0, 1fr) auto;
align-items: center;
gap: 5px;
width: 100%;
@@ -324,12 +324,23 @@
}
.cx-item:hover { background: color-mix(in srgb, var(--cal, var(--text)) 14%, transparent); }
.cx-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--cal); }
-.cx-ring { width: 8px; height: 8px; border: 1.3px solid var(--text-3); border-radius: 50%; box-sizing: border-box; }
+.cx-ring {
+ position: relative; flex: none; width: 10px; height: 10px; padding: 0; margin: 0;
+ border: 1.3px solid var(--text-3); border-radius: 50%; box-sizing: border-box;
+ background: none; box-shadow: none; cursor: pointer;
+ transition: background 140ms ease, border-color 140ms ease, transform 140ms ease;
+}
+/* A target a finger or a trackpad can find, larger than the ring it draws. */
+.cx-ring::before { content: ""; position: absolute; inset: -6px; }
+.cx-ring:hover { border-color: var(--text); }
+.cx-ring:active { transform: scale(0.85); }
+.cx-ring.is-ticked { background: var(--sys-blue, #0a84ff); border-color: var(--sys-blue, #0a84ff); }
+.cx-ring:focus-visible { outline: 2px solid var(--sys-blue); outline-offset: 2px; }
.cx-item-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cx-item-time { color: var(--text-3); font-variant-numeric: tabular-nums; }
/* In a narrow cell the title matters more than the time, which Apple drops first. */
@container (max-width: 130px) {
- .cx-item { grid-template-columns: 8px minmax(0, 1fr); }
+ .cx-item { grid-template-columns: 10px minmax(0, 1fr); }
.cx-item-time { display: none; }
}
/* Dots, for a cell with no room for words: each item still opens on a click. */
@@ -515,6 +526,8 @@
text-overflow: ellipsis;
pointer-events: none;
}
+/* The label lets a drag on the timeline through; its ring is the one thing that takes a click. */
+.cx-reminder .cx-ring { pointer-events: auto; }
.cx-reminder.is-done { color: var(--text-3); text-decoration: line-through; }
/* Above the line for now, on a backing of its own, so the line never runs through a title. */
.cx-reminder { z-index: 3; right: auto; max-width: calc(100% - 8px); padding: 0 6px 0 2px; border-radius: 4px; background: var(--bg); }