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
Calendar shows reminders beside events, the way Apple's does
Yashwanth Kamireddi701a04bfbd60
diff --git a/.uiverify/a11y.mjs b/.uiverify/a11y.mjsindex 75f60b1..b0ac094 100644--- a/.uiverify/a11y.mjs+++ b/.uiverify/a11y.mjs@@ -27,6 +27,7 @@ function installStub({ screen, services, twoFactor }) {case "reminder_lists": return [];case "reminders_in": return [];case "reminders_last_synced": return Math.floor(Date.now() / 1000);+ case "reminders_due_between": return [];case "reminders_sync": return [0, 0];default: return null;}diff --git a/.uiverify/assert.mjs b/.uiverify/assert.mjsindex 73f9583..1f5fa4b 100644--- a/.uiverify/assert.mjs+++ b/.uiverify/assert.mjs@@ -16,6 +16,7 @@ await ctx.addInitScript(({ services }) => {if (cmd === "reminder_lists") return [];if (cmd === "reminders_in") return [];if (cmd === "reminders_last_synced") return Math.floor(Date.now() / 1000);+ if (cmd === "reminders_due_between") return [];if (cmd === "reminders_sync") return [0, 0];return null;},diff --git a/.uiverify/keyboard.mjs b/.uiverify/keyboard.mjsindex da62a99..634a5f2 100644--- a/.uiverify/keyboard.mjs+++ b/.uiverify/keyboard.mjs@@ -23,6 +23,7 @@ function installStub({ screen, services, twoFactor }) {case "reminder_lists": return [];case "reminders_in": return [];case "reminders_last_synced": return Math.floor(Date.now() / 1000);+ case "reminders_due_between": return [];case "reminders_sync": return [0, 0];default: return null;}diff --git a/.uiverify/shots.mjs b/.uiverify/shots.mjsindex f8c8feb..3150222 100644--- a/.uiverify/shots.mjs+++ b/.uiverify/shots.mjs@@ -32,6 +32,14 @@ function installStub({ screen, services, twoFactor, calendarFixture }) {startsAt: base + 3 * DAY, endsAt: base + 4 * DAY, allDay: true,timezone: "Asia/Kolkata", url: null, notes: null, etag: null },];+ const dueReminders = !calendarFixture ? [] : [+ { guid: "r1", listGuid: "daily", title: "Water the plants", notes: null,+ dueAt: base + DAY + 8 * HOUR, completedAt: null, priority: 0, etag: null },+ { guid: "r2", listGuid: "health", title: "Evening run", notes: null,+ dueAt: base + 6 * HOUR, completedAt: null, priority: 0, etag: null },+ { guid: "r3", listGuid: "daily", title: "Plan tomorrow", notes: null,+ dueAt: base + 13 * HOUR, completedAt: base + 13 * HOUR, priority: 0, etag: null },+ ];const calendars = [{ guid: "work", title: "Work", colour: "#cc73e1", ctag: null, sortOrder: 0, enabled: true },{ guid: "home", title: "Home", colour: "#0088ff", ctag: null, sortOrder: 1, enabled: true },@@ -54,6 +62,7 @@ function installStub({ screen, services, twoFactor, calendarFixture }) {case "reminder_lists": return [];case "reminders_in": return [];case "reminders_last_synced": return Math.floor(Date.now() / 1000);+ case "reminders_due_between": return calendarFixture ? dueReminders : [];case "reminders_sync": return [0, 0];case "auth_two_factor_options": return twoFactor;case "auth_resend_code": return null;diff --git a/crates/quince-core/src/reminders.rs b/crates/quince-core/src/reminders.rsindex bfce699..1ebc1de 100644--- a/crates/quince-core/src/reminders.rs+++ b/crates/quince-core/src/reminders.rs@@ -102,6 +102,36 @@ impl Library {Ok(())}+ /// Dated reminders falling inside `[from, to)`, for the calendar.+ ///+ /// Apple's Calendar shows reminders alongside events, which is most of what fills a+ /// month for someone who lives in Reminders rather than Calendar.+ pub fn reminders_due_between(&self, from: i64, to: i64) -> Result<Vec<Reminder>> {+ let mut stmt = self.conn.prepare(+ "SELECT r.guid, r.list_guid, r.title, r.notes, r.due_at, r.completed_at,+ r.priority, r.etag, r.raw+ FROM reminders r+ JOIN reminder_lists l ON l.guid = r.list_guid+ WHERE l.enabled = 1 AND r.due_at IS NOT NULL+ AND r.due_at >= ?1 AND r.due_at < ?2+ ORDER BY r.due_at",+ )?;+ let rows = stmt.query_map(params![from, to], |row| {+ Ok(Reminder {+ guid: row.get(0)?,+ list_guid: row.get(1)?,+ title: row.get(2)?,+ notes: row.get(3)?,+ due_at: row.get(4)?,+ completed_at: row.get(5)?,+ priority: row.get(6)?,+ etag: row.get(7)?,+ raw: row.get(8)?,+ })+ })?;+ Ok(rows.collect::<rusqlite::Result<Vec<_>>>()?)+ }+/// Where a service's last sync got to, for resuming.pub fn sync_token(&self, service: &str) -> Result<Option<String>> {Ok(self@@ -339,6 +369,39 @@ mod tests {assert_eq!(lib.reminder_lists().unwrap().len(), 1);}+ #[test]+ fn dated_reminders_are_found_by_range() {+ let mut lib = seeded();+ lib.put_reminders(&[+ reminder("before", Some(50), None),+ reminder("inside", Some(150), None),+ reminder("also-inside", Some(199), Some(400)), // completed still shows on its day+ reminder("after", Some(250), None),+ reminder("undated", None, None),+ ])+ .unwrap();++ let found = lib.reminders_due_between(100, 200).unwrap();+ assert_eq!(+ found.iter().map(|r| r.guid.as_str()).collect::<Vec<_>>(),+ vec!["inside", "also-inside"],+ "only dated reminders inside the window, in due order"+ );+ }++ #[test]+ fn a_disabled_list_hides_its_reminders_from_the_calendar() {+ let mut lib = seeded();+ lib.put_reminders(&[reminder("r1", Some(150), None)])+ .unwrap();+ assert_eq!(lib.reminders_due_between(0, 1000).unwrap().len(), 1);++ let mut hidden = list("l1");+ hidden.enabled = false;+ lib.put_reminder_lists(&[hidden]).unwrap();+ assert!(lib.reminders_due_between(0, 1000).unwrap().is_empty());+ }+#[test]fn a_sync_token_round_trips() {let lib = seeded();diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rsindex 0aa0dd7..5e1f341 100644--- a/src-tauri/src/main.rs+++ b/src-tauri/src/main.rs@@ -298,6 +298,19 @@ async fn reminder_set_done(Ok(())}+/// Dated reminders inside a window, for the calendar grid.+#[tauri::command]+async fn reminders_due_between(+ from: i64,+ to: i64,+ data: State<'_, Data>,+) -> UiResult<Vec<Reminder>> {+ let library = data.0.lock().await;+ library+ .reminders_due_between(from, to)+ .map_err(|e| e.to_string())+}+#[tauri::command]async fn reminders_last_synced(data: State<'_, Data>) -> UiResult<Option<i64>> {let library = data.0.lock().await;@@ -345,6 +358,7 @@ fn main() {reminder_lists,reminders_in,reminders_last_synced,+ reminders_due_between,reminder_set_done,]).run(tauri::generate_context!())diff --git a/src/lib/ipc.ts b/src/lib/ipc.tsindex d721c23..7ab891c 100644--- a/src/lib/ipc.ts+++ b/src/lib/ipc.ts@@ -36,6 +36,8 @@ export const api = {remindersIn: (listGuid: string, includeDone: boolean) =>invoke<Reminder[]>("reminders_in", { listGuid, includeDone }),remindersLastSynced: () => invoke<number | null>("reminders_last_synced"),+ remindersDueBetween: (from: number, to: number) =>+ invoke<Reminder[]>("reminders_due_between", { from, to }),reminderSetDone: (guid: string, listGuid: string, done: boolean) =>invoke<void>("reminder_set_done", { guid, listGuid, done }),};diff --git a/src/screens/CalendarView.tsx b/src/screens/CalendarView.tsxindex b827158..86ddfed 100644--- a/src/screens/CalendarView.tsx+++ b/src/screens/CalendarView.tsx@@ -1,5 +1,5 @@import { useCallback, useEffect, useMemo, useRef, useState } from "react";-import { api, messageOf, type Calendar, type CalendarEvent } from "../lib/ipc";+import { api, messageOf, type Calendar, type CalendarEvent, type Reminder } from "../lib/ipc";const ZONE = Intl.DateTimeFormat().resolvedOptions().timeZone || "UTC";@@ -58,6 +58,7 @@ export function CalendarView() {const today = useMemo(() => new Date(), []);const [anchor, setAnchor] = useState(() => new Date(today.getFullYear(), today.getMonth(), 1));const [events, setEvents] = useState<CalendarEvent[]>([]);+ const [dueReminders, setDueReminders] = useState<Reminder[]>([]);const [calendars, setCalendars] = useState<Calendar[]>([]);const [lastSynced, setLastSynced] = useState<number | null>(null);const [syncing, setSyncing] = useState(false);@@ -74,12 +75,16 @@ export function CalendarView() {);const read = useCallback(async () => {- const [found, cals, synced] = await Promise.all([+ // Apple's Calendar shows reminders beside events, which for most people is most of+ // what fills a month.+ const [found, cals, synced, due] = await Promise.all([api.calendarEvents(range.from, range.to),api.calendarList(),api.calendarLastSynced(),+ api.remindersDueBetween(range.from, range.to),]);setEvents(Array.isArray(found) ? found : []);+ setDueReminders(Array.isArray(due) ? due : []);setCalendars(Array.isArray(cals) ? cals : []);setLastSynced(typeof synced === "number" ? synced : null);setLoaded(true);@@ -128,9 +133,19 @@ export function CalendarView() {[calendars]);- /** Events keyed by local day, so each cell is a lookup rather than a scan. */+ /** What a day cell shows: an event, or a reminder due that day. */+ type Entry =+ | { kind: "event"; event: CalendarEvent }+ | { kind: "reminder"; reminder: Reminder };++ /** Entries keyed by local day, so each cell is a lookup rather than a scan. */const byDay = useMemo(() => {- const map = new Map<string, CalendarEvent[]>();+ const map = new Map<string, Entry[]>();+ const push = (key: string, entry: Entry) => {+ const bucket = map.get(key);+ if (bucket) bucket.push(entry);+ else map.set(key, [entry]);+ };for (const event of events) {// An event spanning days belongs in every day it touches.let cursor = new Date(event.startsAt * 1000);@@ -138,15 +153,24 @@ export function CalendarView() {const last = new Date(Math.max(event.endsAt - 1, event.startsAt) * 1000);let guard = 0;while (cursor <= last && guard++ < 60) {- const key = cursor.toDateString();- const bucket = map.get(key);- if (bucket) bucket.push(event);- else map.set(key, [event]);+ push(cursor.toDateString(), { kind: "event", event });cursor = new Date(cursor.getFullYear(), cursor.getMonth(), cursor.getDate() + 1);}}+ for (const reminder of dueReminders) {+ if (reminder.dueAt === null) continue;+ push(new Date(reminder.dueAt * 1000).toDateString(), { kind: "reminder", reminder });+ }+ // Within a day, order by time so the cell reads like a schedule.+ for (const bucket of map.values()) {+ bucket.sort((a, b) => {+ const at = a.kind === "event" ? a.event.startsAt : (a.reminder.dueAt ?? 0);+ const bt = b.kind === "event" ? b.event.startsAt : (b.reminder.dueAt ?? 0);+ return at - bt;+ });+ }return map;- }, [events]);+ }, [events, dueReminders]);const shift = (months: number) =>setAnchor((a) => new Date(a.getFullYear(), a.getMonth() + months, 1));@@ -211,35 +235,52 @@ export function CalendarView() {{day.getDate()}</span><div className="chips">- {items.slice(0, 3).map((event) => (- <span- key={event.guid + day.getDate()}- className={`chip${event.allDay ? " all-day" : ""}`}- style={- event.allDay- ? {+ {items.slice(0, 3).map((entry) =>+ entry.kind === "event" ? (+ <span+ key={entry.event.guid + day.getDate()}+ className={`chip${entry.event.allDay ? " all-day" : ""}`}+ style={+ entry.event.allDay+ ? {+ background:+ colours.get(entry.event.calendarGuid) || "var(--gold)",+ }+ : undefined+ }+ title={entry.event.title}+ >+ {!entry.event.allDay && (+ <span+ className="chip-dot"+ style={{background:- colours.get(event.calendarGuid) || "var(--gold)",- }- : undefined- }- title={event.title}- >- {!event.allDay && (- <span- className="chip-dot"- style={{- background:- colours.get(event.calendarGuid) || "var(--gold)",- }}- />- )}- {!event.allDay && (- <span className="chip-time">{clockTime(event.startsAt)}</span>- )}- <span className="chip-title">{event.title}</span>- </span>- ))}+ colours.get(entry.event.calendarGuid) || "var(--gold)",+ }}+ />+ )}+ {!entry.event.allDay && (+ <span className="chip-time">+ {clockTime(entry.event.startsAt)}+ </span>+ )}+ <span className="chip-title">{entry.event.title}</span>+ </span>+ ) : (+ <span+ key={entry.reminder.guid + day.getDate()}+ className={`chip reminder${entry.reminder.completedAt ? " is-done" : ""}`}+ title={entry.reminder.title}+ >+ {/* A ring rather than a dot, so a reminder reads as a task. */}+ <span className="chip-ring" />+ <span className="chip-time">+ {clockTime(entry.reminder.dueAt ?? 0)}+ </span>+ <span className="chip-title">{entry.reminder.title}</span>+ </span>+ )+ )}{items.length > 3 && (<span className="chip more">{items.length - 3} more</span>)}@@ -251,7 +292,7 @@ export function CalendarView() {))}</div>- {loaded && events.length === 0 && !error && (+ {loaded && events.length === 0 && dueReminders.length === 0 && !error && (<p className="cal-empty">No events in this month. Quince keeps them on this computer once synced, so theyopen instantly and work offline.diff --git a/src/styles/app.css b/src/styles/app.cssindex 3962838..33762b9 100644--- a/src/styles/app.css+++ b/src/styles/app.css@@ -566,3 +566,26 @@.is-done .rem-notes { color: var(--text-3); }.content:has(.rem) { display: flex; flex-direction: column; overflow: hidden; }++/* A reminder in the calendar reads as a task, not an event: a ring rather than a dot. */+.chip.reminder .chip-title { color: var(--text); }++.chip-ring {+ width: 7px;+ height: 7px;+ border-radius: var(--r-pill);+ border: 1.5px solid var(--text-3);+ flex: none;+ box-sizing: border-box;+}++.chip.reminder.is-done .chip-title,+.chip.reminder.is-done .chip-time {+ color: var(--text-3);+ text-decoration: line-through;+}++.chip.reminder.is-done .chip-ring {+ background: var(--text-3);+ border-color: var(--text-3);+}