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, real and on screen
Yashwanth Kamireddi4455318b129d
diff --git a/.uiverify/a11y.mjs b/.uiverify/a11y.mjsindex 5a0c650..75f60b1 100644--- a/.uiverify/a11y.mjs+++ b/.uiverify/a11y.mjs@@ -24,6 +24,10 @@ function installStub({ screen, services, twoFactor }) {case "calendar_list": return [];case "calendar_last_synced": return Math.floor(Date.now() / 1000);case "calendar_sync": return { calendars: 0, events: 0 };+ case "reminder_lists": return [];+ case "reminders_in": return [];+ case "reminders_last_synced": return Math.floor(Date.now() / 1000);+ case "reminders_sync": return [0, 0];default: return null;}},diff --git a/.uiverify/assert.mjs b/.uiverify/assert.mjsindex 9ac96ea..73f9583 100644--- a/.uiverify/assert.mjs+++ b/.uiverify/assert.mjs@@ -13,6 +13,10 @@ await ctx.addInitScript(({ services }) => {if (cmd === "calendar_list") return [];if (cmd === "calendar_last_synced") return Math.floor(Date.now() / 1000);if (cmd === "calendar_sync") return { calendars: 0, events: 0 };+ if (cmd === "reminder_lists") return [];+ if (cmd === "reminders_in") return [];+ if (cmd === "reminders_last_synced") return Math.floor(Date.now() / 1000);+ if (cmd === "reminders_sync") return [0, 0];return null;},};diff --git a/.uiverify/keyboard.mjs b/.uiverify/keyboard.mjsindex abd59d3..da62a99 100644--- a/.uiverify/keyboard.mjs+++ b/.uiverify/keyboard.mjs@@ -20,6 +20,10 @@ function installStub({ screen, services, twoFactor }) {case "calendar_list": return [];case "calendar_last_synced": return Math.floor(Date.now() / 1000);case "calendar_sync": return { calendars: 0, events: 0 };+ case "reminder_lists": return [];+ case "reminders_in": return [];+ case "reminders_last_synced": return Math.floor(Date.now() / 1000);+ case "reminders_sync": return [0, 0];default: return null;}},diff --git a/.uiverify/shots.mjs b/.uiverify/shots.mjsindex b081391..f8c8feb 100644--- a/.uiverify/shots.mjs+++ b/.uiverify/shots.mjs@@ -51,6 +51,10 @@ function installStub({ screen, services, twoFactor, calendarFixture }) {case "calendar_list": return calendars;case "calendar_last_synced": return calendarFixture ? Math.floor(Date.now()/1000) - 120 : null;case "calendar_sync": return { calendars: calendars.length, events: events.length };+ case "reminder_lists": return [];+ case "reminders_in": return [];+ case "reminders_last_synced": return Math.floor(Date.now() / 1000);+ case "reminders_sync": return [0, 0];case "auth_two_factor_options": return twoFactor;case "auth_resend_code": return null;case "auth_send_sms": return null;diff --git a/Cargo.lock b/Cargo.lockindex 2ec272e..2346c5f 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -3137,6 +3137,7 @@ dependencies = ["quince-auth","quince-core","quince-icloud",+ "reqwest 0.12.28","serde","serde_json","tauri",diff --git a/crates/quince-icloud/src/cloudkit.rs b/crates/quince-icloud/src/cloudkit.rsindex f7b9156..b23a565 100644--- a/crates/quince-icloud/src/cloudkit.rs+++ b/crates/quince-icloud/src/cloudkit.rs@@ -11,8 +11,11 @@use crate::{Error, Result};use serde_json::{json, Value};-/// Records fetched in one request. Apple's own client uses a few hundred.-const PAGE_SIZE: u64 = 200;+/// Records fetched in one request.+///+/// A real account's zone runs to thousands — mostly tombstones — so a small page turns one+/// refresh into dozens of round trips.+const PAGE_SIZE: u64 = 500;/// A ceiling on paging, so a server that always says `moreComing` cannot spin forever.const MAX_PAGES: usize = 200;@@ -308,3 +311,143 @@ mod tests {);}}++impl ZoneClient<'_> {+ /// Update one record in the zone.+ ///+ /// `changes` are merged into the record's existing fields, so only what actually changed+ /// is sent. The change tag is CloudKit's optimistic-concurrency check: if the record+ /// moved since we read it, Apple refuses rather than silently overwriting whatever the+ /// phone did.+ pub async fn update_record(+ &self,+ zone: &str,+ record_name: &str,+ record_type: &str,+ change_tag: Option<&str>,+ changes: Value,+ ) -> Result<Value> {+ let mut record = json!({+ "recordName": record_name,+ "recordType": record_type,+ "fields": changes,+ });+ if let Some(tag) = change_tag {+ record["recordChangeTag"] = Value::String(tag.to_string());+ }++ let body = json!({+ "operations": [{+ "operationType": "update",+ "record": record,+ }],+ "zoneID": { "zoneName": zone, "zoneType": "REGULAR_CUSTOM_ZONE" },+ });++ let url = format!(+ "{}/database/1/{}/production/private/records/modify",+ self.base, self.container+ );+ let response = self+ .http+ .post(url)+ .query(&self.query())+ .json(&body)+ .send()+ .await?;+ let status = response.status();+ let text = response.text().await.unwrap_or_default();++ if status.as_u16() == 450 {+ return Err(Error::ReauthRequired);+ }+ if !status.is_success() {+ return Err(Error::Protocol(format!(+ "CloudKit refused the change ({status}): {}",+ text.chars().take(200).collect::<String>()+ )));+ }++ let parsed: Value = serde_json::from_str(&text)+ .map_err(|e| Error::Protocol(format!("CloudKit returned invalid JSON: {e}")))?;++ // A 200 can still carry a per-record failure, which is how a conflict arrives.+ if let Some(reason) = parsed.pointer("/records/0/reason").and_then(Value::as_str) {+ let code = parsed+ .pointer("/records/0/serverErrorCode")+ .and_then(Value::as_str)+ .unwrap_or("");+ return Err(Error::Protocol(if code == "CONFLICT" {+ "this changed on another device first — refresh and try again".to_string()+ } else {+ format!("CloudKit refused the change: {reason}")+ }));+ }+ Ok(parsed)+ }+}++#[cfg(test)]+mod modify_tests {+ use super::*;+ use wiremock::matchers::{method, path_regex};+ use wiremock::{Mock, MockServer, ResponseTemplate};++ async fn server_returning(body: Value) -> MockServer {+ let server = MockServer::start().await;+ Mock::given(method("POST"))+ .and(path_regex(r".*/records/modify$"))+ .respond_with(ResponseTemplate::new(200).set_body_json(body))+ .mount(&server)+ .await;+ server+ }++ #[tokio::test]+ async fn an_update_sends_only_what_changed_with_its_change_tag() {+ let server = server_returning(json!({ "records": [{ "recordName": "Reminder/1" }] })).await;+ let http = reqwest::Client::new();+ let client = ZoneClient::new(&http, &server.uri(), "com.apple.reminders", vec![]);++ client+ .update_record(+ "Reminders",+ "Reminder/1",+ "Reminder",+ Some("tag-7"),+ json!({ "Completed": { "value": 1, "type": "NUMBER_INT64" } }),+ )+ .await+ .unwrap();++ let requests = server.received_requests().await.unwrap();+ let sent: Value = serde_json::from_slice(&requests[0].body).unwrap();+ assert_eq!(sent["operations"][0]["operationType"], "update");+ assert_eq!(sent["operations"][0]["record"]["recordChangeTag"], "tag-7");+ assert_eq!(+ sent["operations"][0]["record"]["fields"]["Completed"]["value"],+ 1+ );+ assert_eq!(sent["zoneID"]["zoneName"], "Reminders");+ }++ /// CloudKit reports a conflict inside a 200, so a success status is not success.+ #[tokio::test]+ async fn a_conflict_inside_a_200_is_an_error() {+ let server = server_returning(json!({+ "records": [{ "reason": "change tag mismatch", "serverErrorCode": "CONFLICT" }]+ }))+ .await;+ let http = reqwest::Client::new();+ let client = ZoneClient::new(&http, &server.uri(), "com.apple.reminders", vec![]);++ let err = client+ .update_record("Reminders", "Reminder/1", "Reminder", None, json!({}))+ .await+ .unwrap_err();+ assert!(+ err.to_string().contains("another device"),+ "a conflict should tell the user what to do: {err}"+ );+ }+}diff --git a/crates/quince-icloud/src/reminders.rs b/crates/quince-icloud/src/reminders.rsindex 5199868..8b3d7d8 100644--- a/crates/quince-icloud/src/reminders.rs+++ b/crates/quince-icloud/src/reminders.rs@@ -457,8 +457,11 @@ pub async fn sync_cloudkit(for record in &records {match field::record_type(record).as_deref() {Some("Reminder") => reminders.extend(reminder_from_record(record)),- // Apple has used more than one name for the container of a list over the years.- Some("List" | "ListSection" | "SmartList") => lists.extend(list_from_record(record)),+ // Only List records are the lists people made. ListSection is a heading inside+ // one, and SmartList is a built-in filter — Today, Scheduled, Flagged — which+ // carries a SmartListType instead of a Name and appeared as phantom entries+ // called "Reminders" that held nothing.+ Some("List") => lists.extend(list_from_record(record)),_ => {}}}@@ -577,3 +580,69 @@ mod cloudkit_tests {assert_eq!(r.title, "Untitled", "showing it beats hiding it");}}++/// Tick a CloudKit reminder off, or put it back.+///+/// Sends only the fields that change, guarded by the record's change tag, so a reminder+/// edited on the phone since we read it is refused rather than overwritten.+pub async fn set_completed_cloudkit(+ http: &reqwest::Client,+ ckdatabasews_root: &str,+ params: Vec<(String, String)>,+ reminder: &Reminder,+ done: bool,+) -> Result<()> {+ let client = ZoneClient::new(http, ckdatabasews_root, CONTAINER, params);+ client+ .update_record(+ ZONE,+ &reminder.guid,+ "Reminder",+ reminder.etag.as_deref(),+ serde_json::json!({+ "Completed": { "value": i64::from(done), "type": "NUMBER_INT64" }+ }),+ )+ .await?;+ Ok(())+}++#[cfg(test)]+mod list_kind_tests {+ use super::*;+ use serde_json::json;++ fn record(name: &str, kind: &str, title: Option<&str>) -> Value {+ let mut fields = serde_json::Map::new();+ if let Some(t) = title {+ fields.insert("Name".into(), json!({ "type": "STRING", "value": t }));+ }+ json!({ "recordName": name, "recordType": kind, "fields": fields })+ }++ /// Only records of type List are lists. A ListSection is a heading inside one, and a+ /// SmartList is a built-in filter carrying SmartListType rather than a Name — mapping+ /// either produced phantom entries called "Reminders" that held nothing.+ #[test]+ fn only_list_records_become_lists() {+ let zone = vec![+ record("List/a", "List", Some("GYM")),+ record("ListSection/b", "ListSection", None),+ record("SmartList/c", "SmartList", None),+ ];+ let kept: Vec<_> = zone+ .iter()+ .filter(|r| field::record_type(r).as_deref() == Some("List"))+ .filter_map(list_from_record)+ .collect();+ assert_eq!(kept.len(), 1);+ assert_eq!(kept[0].title, "GYM");+ }++ #[test]+ fn a_real_list_keeps_its_name() {+ let l = list_from_record(&record("List/abc", "List", Some("GYM"))).unwrap();+ assert_eq!(l.title, "GYM");+ assert_eq!(l.guid, "List/abc");+ }+}diff --git a/probe/src/main.rs b/probe/src/main.rsindex 7ac9403..3373e25 100644--- a/probe/src/main.rs+++ b/probe/src/main.rs@@ -628,6 +628,58 @@ async fn main() -> Result<()> {}}+ // ---- where do List records live? --------------------------------------------+ // Reminders reference List/<uuid>, but the Reminders zone returns none. Census every+ // zone in the container rather than guess.+ println!("\n\x1b[1m── Hunting the List records ──\x1b[0m");+ if let Some(ck) = session.service_url("ckdatabasews") {+ for zone_name in ["Reminders", "RemindersMigration", "_defaultZone"] {+ let zc = quince_icloud::cloudkit::ZoneClient::new(+ client.http(),+ &ck,+ "com.apple.reminders",+ client.service_params(),+ );+ match zc.all_records(zone_name, None).await {+ Err(e) => println!(+ " {zone_name:<20} error: {}",+ e.to_string().chars().take(70).collect::<String>()+ ),+ Ok((records, _)) => {+ let mut census: std::collections::BTreeMap<String, usize> =+ std::collections::BTreeMap::new();+ for rec in &records {+ let kind = rec+ .get("recordType")+ .and_then(|t| t.as_str())+ .unwrap_or("(tombstone)");+ *census.entry(kind.to_string()).or_default() += 1;+ }+ let summary: Vec<String> =+ census.iter().map(|(k, n)| format!("{k}={n}")).collect();+ println!(+ " {zone_name:<20} {} record(s): {}",+ records.len(),+ summary.join(" ")+ );++ // Show any List record's fields, wherever it turns up.+ for rec in &records {+ if rec.get("recordType").and_then(|t| t.as_str()) == Some("List") {+ let fields: Vec<String> = rec+ .get("fields")+ .and_then(|f| f.as_object())+ .map(|o| o.keys().cloned().collect())+ .unwrap_or_default();+ println!(" List fields: {}", fields.join(", "));+ break;+ }+ }+ }+ }+ }+ }+// ---- CloudKit containers ----------------------------------------------------// Apple's legacy /rd and /ca endpoints answer with a placeholder once data has been// upgraded to the modern format. The real records live in CloudKit, so find out whichdiff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.tomlindex ff89739..7bca949 100644--- a/src-tauri/Cargo.toml+++ b/src-tauri/Cargo.toml@@ -13,6 +13,7 @@ tauri = { version = "2", features = [] }quince-auth = { path = "../crates/quince-auth" }quince-core = { path = "../crates/quince-core" }quince-icloud = { path = "../crates/quince-icloud" }+reqwest.workspace = trueserde.workspace = trueserde_json.workspace = truetokio = { workspace = true }diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rsindex 87570ae..cc71ed4 100644--- a/src-tauri/src/main.rs+++ b/src-tauri/src/main.rs@@ -43,6 +43,19 @@ struct Data(Mutex<Library>);/// Errors cross to the UI as plain sentences a person can act on.type UiResult<T> = Result<T, String>;+/// The HTTP client, CloudKit root and query parameters, with the auth lock released before+/// any network work so a slow sync cannot block the heartbeat or a sign-out.+async fn cloudkit_context(+ auth: &State<'_, Auth>,+) -> Result<(reqwest::Client, String, Vec<(String, String)>), String> {+ let client = auth.client.lock().await;+ let root = client+ .session()+ .service_url("ckdatabasews")+ .ok_or("Apple hasn't offered CloudKit for this account.")?;+ Ok((client.http().clone(), root, client.service_params()))+}+fn state_dir(app: &tauri::AppHandle) -> PathBuf {app.path().app_data_dir()@@ -214,24 +227,17 @@ async fn calendar_list(data: State<'_, Data>) -> UiResult<Vec<Calendar>> {library.calendars().map_err(|e| e.to_string())}-/// Refresh reminders from Apple. Unlike calendar there is no date window, so one call.+/// Refresh reminders from Apple.+///+/// Reads the CloudKit zone rather than the legacy /rd endpoints: once an account's reminders+/// have been migrated, those answer with Apple's placeholder instead of the real records.#[tauri::command]-async fn reminders_sync(- timezone: String,- auth: State<'_, Auth>,- data: State<'_, Data>,-) -> UiResult<(usize, usize)> {- let (http, root, params) = {- let client = auth.client.lock().await;- let root = client- .session()- .service_url("reminders")- .ok_or("Apple hasn't offered a reminders service for this account.")?;- (client.http().clone(), root, client.service_params())- };+async fn reminders_sync(auth: State<'_, Auth>, data: State<'_, Data>) -> UiResult<(usize, usize)> {+ let (http, root, params) = cloudkit_context(&auth).await?;let mut library = data.0.lock().await;- quince_icloud::reminders::sync(&http, &root, params, &mut library, &timezone)+ quince_icloud::reminders::sync_cloudkit(&http, &root, params, &mut library, None).await+ .map(|(lists, count, _)| (lists, count)).map_err(|e| e.to_string())}@@ -253,25 +259,19 @@ async fn reminders_in(.map_err(|e| e.to_string())}-/// Tick a reminder off, or put it back. Writes to Apple first, then refreshes locally, so-/// the interface never shows a state Apple has not accepted.+/// Tick a reminder off, or put it back.+///+/// Writes to Apple first and only then refreshes locally, so the interface never shows a+/// state Apple has not accepted.#[tauri::command]async fn reminder_set_done(guid: String,list_guid: String,done: bool,- timezone: String,auth: State<'_, Auth>,data: State<'_, Data>,) -> UiResult<()> {- let (http, root, params) = {- let client = auth.client.lock().await;- let root = client- .session()- .service_url("reminders")- .ok_or("Apple hasn't offered a reminders service for this account.")?;- (client.http().clone(), root, client.service_params())- };+ let (http, root, params) = cloudkit_context(&auth).await?;let reminder = {let library = data.0.lock().await;@@ -283,13 +283,12 @@ async fn reminder_set_done(.ok_or("That reminder is no longer in the local library.")?};- quince_icloud::reminders::set_completed(&http, &root, ¶ms, &reminder, done, &timezone)+ quince_icloud::reminders::set_completed_cloudkit(&http, &root, params.clone(), &reminder, done).await.map_err(|e| e.to_string())?;- // Re-read from Apple so what we show is what Apple stored, not what we hoped.let mut library = data.0.lock().await;- quince_icloud::reminders::sync(&http, &root, params, &mut library, &timezone)+ quince_icloud::reminders::sync_cloudkit(&http, &root, params, &mut library, None).await.map_err(|e| e.to_string())?;Ok(())diff --git a/src/lib/ipc.ts b/src/lib/ipc.tsindex b033fd9..d721c23 100644--- a/src/lib/ipc.ts+++ b/src/lib/ipc.ts@@ -30,6 +30,14 @@ export const api = {invoke<CalendarEvent[]>("calendar_events", { from, to }),calendarList: () => invoke<Calendar[]>("calendar_list"),calendarLastSynced: () => invoke<number | null>("calendar_last_synced"),++ remindersSync: () => invoke<[number, number]>("reminders_sync"),+ reminderLists: () => invoke<ReminderList[]>("reminder_lists"),+ remindersIn: (listGuid: string, includeDone: boolean) =>+ invoke<Reminder[]>("reminders_in", { listGuid, includeDone }),+ remindersLastSynced: () => invoke<number | null>("reminders_last_synced"),+ reminderSetDone: (guid: string, listGuid: string, done: boolean) =>+ invoke<void>("reminder_set_done", { guid, listGuid, done }),};/** Tauri rejects with a plain string from our commands; keep it readable either way. */@@ -59,6 +67,27 @@ export type CalendarEvent = {export type SyncSummary = { calendars: number; events: number };+export type ReminderList = {+ guid: string;+ title: string;+ colour: string | null;+ ctag: string | null;+ sortOrder: number;+ enabled: boolean;+};++export type Reminder = {+ guid: string;+ listGuid: string;+ title: string;+ notes: string | null;+ dueAt: number | null;+ /** null while outstanding */+ completedAt: number | null;+ priority: number;+ etag: string | null;+};+export function messageOf(e: unknown): string {if (typeof e === "string") return e;if (e instanceof Error) return e.message;diff --git a/src/screens/Library.tsx b/src/screens/Library.tsxindex 1e31e9a..8f5facc 100644--- a/src/screens/Library.tsx+++ b/src/screens/Library.tsx@@ -1,6 +1,7 @@import { useEffect, useRef, useState } from "react";import { api, messageOf } from "../lib/ipc";import { CalendarView } from "./CalendarView";+import { RemindersView } from "./RemindersView";const NAMES: Record<string, string> = {photos: "Photos",@@ -40,7 +41,7 @@ const NAMES: Record<string, string> = {/** Services with a real screen behind them. Opening on one of these beats opening on a* placeholder, so selection prefers them. */-const BUILT = new Set(["calendar"]);+const BUILT = new Set(["calendar", "reminders"]);/** What a person actually came for, in the order they'd look for it. */const PRIMARY = [@@ -150,6 +151,8 @@ export function Library({ onSignOut }: { onSignOut: () => void }) {<main className="content">{selected === "calendar" ? (<CalendarView />+ ) : selected === "reminders" ? (+ <RemindersView />) : (<><div className="toolbar">diff --git a/src/screens/RemindersView.tsx b/src/screens/RemindersView.tsxnew file mode 100644index 0000000..82f7f69--- /dev/null+++ b/src/screens/RemindersView.tsx@@ -0,0 +1,198 @@+import { useCallback, useEffect, useMemo, useRef, useState } from "react";+import { api, messageOf, type Reminder, type ReminderList } from "../lib/ipc";++const dueLabel = (seconds: number) => {+ const due = new Date(seconds * 1000);+ const today = new Date();+ const sameDay =+ due.getFullYear() === today.getFullYear() &&+ due.getMonth() === today.getMonth() &&+ due.getDate() === today.getDate();+ if (sameDay) return `Today ${due.toLocaleTimeString(undefined, { hour: "numeric", minute: "2-digit" })}`;+ return due.toLocaleDateString(undefined, { day: "numeric", month: "short" });+};++function relative(seconds: number | null): string {+ if (seconds === null) return "never";+ const ago = Math.max(0, Math.floor(Date.now() / 1000) - seconds);+ if (ago < 60) return "just now";+ if (ago < 3600) return `${Math.floor(ago / 60)} min ago`;+ if (ago < 86_400) return `${Math.floor(ago / 3600)} h ago`;+ return `${Math.floor(ago / 86_400)} d ago`;+}++export function RemindersView() {+ const [lists, setLists] = useState<ReminderList[]>([]);+ const [selected, setSelected] = useState<string | null>(null);+ const [items, setItems] = useState<Reminder[]>([]);+ const [showDone, setShowDone] = useState(false);+ const [lastSynced, setLastSynced] = useState<number | null>(null);+ const [syncing, setSyncing] = useState(false);+ const [busyGuid, setBusyGuid] = useState<string | null>(null);+ const [loaded, setLoaded] = useState(false);+ const [error, setError] = useState<string | null>(null);++ const readLists = useCallback(async () => {+ const [found, synced] = await Promise.all([+ api.reminderLists(),+ api.remindersLastSynced(),+ ]);+ const safe = Array.isArray(found) ? found : [];+ setLists(safe);+ setLastSynced(typeof synced === "number" ? synced : null);+ // Prefer a list with something outstanding: opening on an empty one looks broken.+ if (safe.length > 0) {+ const counts = await Promise.all(+ safe.map(async (l) => [l.guid, (await api.remindersIn(l.guid, false)).length] as const)+ );+ setSelected((current) => {+ if (current) return current;+ const busiest = counts.reduce((a, b) => (b[1] > a[1] ? b : a));+ return busiest[1] > 0 ? busiest[0] : safe[0].guid;+ });+ }+ setLoaded(true);+ }, []);++ const readItems = useCallback(async () => {+ if (!selected) return setItems([]);+ const found = await api.remindersIn(selected, showDone);+ setItems(Array.isArray(found) ? found : []);+ }, [selected, showDone]);++ const refreshRef = useRef<null | (() => Promise<void>)>(null);++ const refresh = useCallback(async () => {+ setSyncing(true);+ setError(null);+ try {+ await api.remindersSync();+ await readLists();+ await readItems();+ } catch (e) {+ // The library still holds the last good data, so the list stays usable.+ setError(messageOf(e));+ } finally {+ setSyncing(false);+ }+ }, [readLists, readItems]);+ refreshRef.current = refresh;++ // Render from the library first, then fetch if nothing is stored yet.+ useEffect(() => {+ let cancelled = false;+ (async () => {+ try {+ await readLists();+ if (cancelled) return;+ const synced = await api.remindersLastSynced();+ if (!cancelled && synced === null) void refreshRef.current?.();+ } catch (e) {+ if (!cancelled) {+ setError(messageOf(e));+ setLoaded(true);+ }+ }+ })();+ return () => {+ cancelled = true;+ };+ }, [readLists]);++ useEffect(() => {+ readItems().catch((e) => setError(messageOf(e)));+ }, [readItems]);++ async function toggle(reminder: Reminder) {+ setBusyGuid(reminder.guid);+ setError(null);+ try {+ // Writes to Apple, then re-reads — so what's on screen is what Apple stored.+ await api.reminderSetDone(reminder.guid, reminder.listGuid, !reminder.completedAt);+ await readItems();+ } catch (e) {+ setError(messageOf(e));+ } finally {+ setBusyGuid(null);+ }+ }++ const current = useMemo(+ () => lists.find((l) => l.guid === selected) ?? null,+ [lists, selected]+ );+ const outstanding = items.filter((r) => !r.completedAt).length;++ return (+ <div className="rem">+ <aside className="rem-lists" aria-label="Reminder lists">+ {lists.map((list) => (+ <button+ key={list.guid}+ className="rem-list"+ aria-current={selected === list.guid}+ onClick={() => setSelected(list.guid)}+ >+ <span className="dot" style={{ background: list.colour || "var(--gold)" }} />+ <span className="rem-list-name">{list.title}</span>+ </button>+ ))}+ {loaded && lists.length === 0 && <p className="badge">No lists yet</p>}+ </aside>++ <section className="rem-items">+ <header className="cal-bar">+ <div className="cal-nav">+ <h1>{current?.title ?? "Reminders"}</h1>+ {outstanding > 0 && <span className="badge">{outstanding} left</span>}+ </div>+ <div className="cal-actions">+ <button className="quiet" onClick={() => setShowDone((v) => !v)}>+ {showDone ? "Hide completed" : "Show completed"}+ </button>+ <span className="badge">Updated {relative(lastSynced)}</span>+ <button className="quiet" onClick={refresh} disabled={syncing}>+ {syncing ? "Refreshing…" : "Refresh"}+ </button>+ </div>+ </header>++ {error && <p className="error" role="alert">{error}</p>}++ <ul className="rem-list-items">+ {items.map((reminder) => (+ <li key={reminder.guid} className={reminder.completedAt ? "is-done" : undefined}>+ <button+ className="tick"+ role="checkbox"+ aria-checked={Boolean(reminder.completedAt)}+ aria-label={reminder.title}+ disabled={busyGuid === reminder.guid}+ onClick={() => toggle(reminder)}+ style={{ borderColor: current?.colour || "var(--gold)" }}+ >+ {reminder.completedAt && (+ <span+ className="tick-fill"+ style={{ background: current?.colour || "var(--gold)" }}+ />+ )}+ </button>+ <div className="rem-text">+ <span className="rem-title">{reminder.title}</span>+ {reminder.notes && <span className="rem-notes">{reminder.notes}</span>}+ </div>+ {reminder.dueAt && <span className="rem-due">{dueLabel(reminder.dueAt)}</span>}+ </li>+ ))}+ </ul>++ {loaded && items.length === 0 && !error && (+ <p className="cal-empty">+ {showDone ? "Nothing in this list." : "All done here."}+ </p>+ )}+ </section>+ </div>+ );+}diff --git a/src/styles/app.css b/src/styles/app.cssindex e72eac5..3962838 100644--- a/src/styles/app.css+++ b/src/styles/app.css@@ -466,3 +466,103 @@/* The content pane holds the grid, so it must not scroll independently. */.content:has(.cal) { display: flex; flex-direction: column; overflow: hidden; }++/* ---- reminders ------------------------------------------------------------------+ Apple Reminders: lists on the left, items on the right, a ring that fills when ticked. */++.rem {+ display: grid;+ grid-template-columns: 176px 1fr;+ gap: 20px;+ height: 100%;+ min-height: 0;+}++.rem-lists {+ overflow-y: auto;+ padding-right: 4px;+ border-right: 1px solid var(--separator);+}++.rem-list {+ display: flex;+ align-items: center;+ gap: 8px;+ width: 100%;+ border: 0;+ background: none;+ color: var(--text);+ font: inherit;+ font-size: var(--t-13);+ text-align: left;+ padding: 6px 8px;+ border-radius: var(--r-field);+ cursor: pointer;+}++.rem-list:hover { background: color-mix(in srgb, var(--text) 6%, transparent); }+.rem-list[aria-current="true"] { background: var(--gold-tint); font-weight: 550; }+.rem-list:focus-visible { outline: 3px solid var(--gold-ring); outline-offset: -1px; }+.rem-list-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }++.rem-items { display: flex; flex-direction: column; min-height: 0; }++.rem-list-items {+ list-style: none;+ margin: 0;+ padding: 0;+ overflow-y: auto;+ min-height: 0;+}++.rem-list-items li {+ display: grid;+ grid-template-columns: 18px 1fr auto;+ align-items: start;+ gap: 10px;+ padding: 7px 8px;+ border-bottom: 1px solid var(--separator);+}++.rem-list-items li:hover { background: color-mix(in srgb, var(--text) 4%, transparent); }++/* Apple's ring: an outline that fills with the list's colour when ticked. */+.tick {+ width: 18px;+ height: 18px;+ margin-top: 1px;+ border: 1.5px solid var(--field-edge);+ border-radius: var(--r-pill);+ background: none;+ cursor: pointer;+ padding: 0;+ display: grid;+ place-items: center;+ flex: none;+}++.tick:disabled { opacity: 0.5; cursor: progress; }+.tick:focus-visible { outline: 3px solid var(--gold-ring); outline-offset: 2px; }+.tick-fill { width: 10px; height: 10px; border-radius: var(--r-pill); }++.rem-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }+.rem-title { font-size: var(--t-13); }+.rem-notes {+ font-size: var(--t-11);+ color: var(--text-2);+ overflow: hidden;+ text-overflow: ellipsis;+ white-space: nowrap;+}++.rem-due {+ font-size: var(--t-11);+ color: var(--text-2);+ font-variant-numeric: tabular-nums;+ white-space: nowrap;+}++.is-done .rem-title { color: var(--text-3); text-decoration: line-through; }+.is-done .rem-notes { color: var(--text-3); }++.content:has(.rem) { display: flex; flex-direction: column; overflow: hidden; }