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.

Reminders sidebar takes Apple's own arrangement

Yashwanth Kamireddi04f55d8784c6
diff --git a/.uiverify/a11y.mjs b/.uiverify/a11y.mjs
index 27af910..a4a897b 100644
--- a/.uiverify/a11y.mjs
+++ b/.uiverify/a11y.mjs
@@ -27,6 +27,7 @@ function installStub({ screen, services, twoFactor }) {
case "event_save": return "E-new";
case "event_delete": return null;
case "calendar_sync": return { calendars: 0, events: 0 };
+ case "reminder_counts": return { today: 4, scheduled: 7, flagged: 2, all: 12, lists: [["L1", 5], ["L2", 3], ["lists", 4]] };
case "reminder_lists": return [];
case "reminders_in": return [];
case "reminders_due_between": return [];
diff --git a/.uiverify/assert.mjs b/.uiverify/assert.mjs
index 5d80255..6152f27 100644
--- a/.uiverify/assert.mjs
+++ b/.uiverify/assert.mjs
@@ -14,6 +14,7 @@ await ctx.addInitScript(({ services }) => {
if (cmd === "event_save") return "E-new";
if (cmd === "event_delete") return null;
if (cmd === "calendar_sync") return { calendars: 0, events: 0 };
+ if (cmd === "reminder_counts") return { today: 4, scheduled: 7, flagged: 2, all: 12, lists: [["L1", 5], ["L2", 3], ["lists", 4]] };
if (cmd === "reminder_lists") return [];
if (cmd === "reminders_in") return [];
if (cmd === "reminders_due_between") return [];
diff --git a/.uiverify/crash.mjs b/.uiverify/crash.mjs
index 896b01a..5ca6969 100644
--- a/.uiverify/crash.mjs
+++ b/.uiverify/crash.mjs
@@ -14,6 +14,7 @@ await ctx.addInitScript(() => {
case "calendar_events": case "calendar_list": case "reminders_due_between": return [];
case "calendar_last_synced": case "reminders_last_synced": case "notes_last_synced":
case "contacts_last_synced": return Math.floor(Date.now() / 1000);
+ case "reminder_counts": return { today: 4, scheduled: 7, flagged: 2, all: 12, lists: [["L1", 5], ["L2", 3], ["lists", 4]] };
case "reminder_lists": case "reminders_in": case "reminders_smart":
case "note_folders": case "notes_in": case "contacts_list": case "drive_children": return [];
case "event_save": return "E-new";
diff --git a/.uiverify/keyboard.mjs b/.uiverify/keyboard.mjs
index e65c9c7..87d893e 100644
--- a/.uiverify/keyboard.mjs
+++ b/.uiverify/keyboard.mjs
@@ -40,6 +40,7 @@ function installStub({ screen, services, twoFactor }) {
case "event_save": return "E-new";
case "event_delete": return null;
case "calendar_sync": return { calendars: 0, events: 0 };
+ case "reminder_counts": return { today: 4, scheduled: 7, flagged: 2, all: 12, lists: [["L1", 5], ["L2", 3], ["lists", 4]] };
case "reminder_lists": return lists;
case "reminders_in": return items;
case "reminders_due_between": return [];
diff --git a/.uiverify/shots.mjs b/.uiverify/shots.mjs
index 8bf4116..ceffeba 100644
--- a/.uiverify/shots.mjs
+++ b/.uiverify/shots.mjs
@@ -128,6 +128,7 @@ function installStub({ screen, services, twoFactor, calendarFixture, notesFixtur
case "event_save": return "E-new";
case "event_delete": return null;
case "calendar_sync": return { calendars: calendars.length, events: events.length };
+ case "reminder_counts": return { today: 4, scheduled: 7, flagged: 2, all: 12, lists: [["L1", 5], ["L2", 3], ["lists", 4]] };
case "reminder_lists": return !remindersFixture ? [] : reminderLists;
case "reminders_in": return !remindersFixture ? [] : reminderItems;
case "reminders_due_between": return calendarFixture ? dueReminders : [];
diff --git a/crates/quince-core/src/reminders.rs b/crates/quince-core/src/reminders.rs
index 63909d6..51c17d9 100644
--- a/crates/quince-core/src/reminders.rs
+++ b/crates/quince-core/src/reminders.rs
@@ -41,6 +41,18 @@ pub struct Reminder {
pub raw: Option<String>,
}
+/// What every entry in the sidebar is holding.
+#[derive(Debug, Clone, Default, Serialize, Deserialize, PartialEq, Eq)]
+#[serde(rename_all = "camelCase")]
+pub struct ReminderCounts {
+ pub today: usize,
+ pub scheduled: usize,
+ pub flagged: usize,
+ pub all: usize,
+ /// Outstanding reminders per list, keyed by list guid.
+ pub lists: Vec<(String, usize)>,
+}
+
/// Apple's built-in views over every list.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
@@ -217,6 +229,55 @@ impl Library {
/// These are the entry points people actually use: what is due today, everything with a
/// date, and whatever has been flagged. They are queries rather than stored lists, which
/// is what lets them stay correct as the clock moves.
+ /// How many reminders each smart list and each list is holding.
+ ///
+ /// Apple puts a count on every entry in the sidebar, and it is the number that makes
+ /// the sidebar worth looking at. Counting in SQL rather than by fetching each list and
+ /// measuring it is the difference between one cheap query and a dozen full reads.
+ pub fn reminder_counts(&self, until: i64) -> Result<ReminderCounts> {
+ // The same conditions the smart lists themselves use, so a tile can never disagree
+ // with what opening it shows.
+ let one = |clause: &str, args: &[i64]| -> Result<usize> {
+ let sql = format!(
+ "SELECT COUNT(*) FROM reminders r
+ JOIN reminder_lists l ON l.guid = r.list_guid
+ WHERE l.enabled = 1 AND {clause}"
+ );
+ let count: i64 = self.conn.query_row(
+ &sql,
+ rusqlite::params_from_iter(args.iter().copied()),
+ |row| row.get(0),
+ )?;
+ Ok(usize::try_from(count).unwrap_or(0))
+ };
+
+ let mut stmt = self.conn.prepare(
+ "SELECT l.guid, COUNT(r.guid)
+ FROM reminder_lists l
+ LEFT JOIN reminders r ON r.list_guid = l.guid AND r.completed_at IS NULL
+ GROUP BY l.guid",
+ )?;
+ let lists = stmt
+ .query_map([], |row| {
+ Ok((row.get::<_, String>(0)?, row.get::<_, i64>(1)?))
+ })?
+ .collect::<rusqlite::Result<Vec<_>>>()?
+ .into_iter()
+ .map(|(guid, n)| (guid, usize::try_from(n).unwrap_or(0)))
+ .collect();
+
+ Ok(ReminderCounts {
+ today: one(
+ "r.completed_at IS NULL AND r.due_at IS NOT NULL AND r.due_at < ?1",
+ &[until],
+ )?,
+ scheduled: one("r.completed_at IS NULL AND r.due_at IS NOT NULL", &[])?,
+ flagged: one("r.completed_at IS NULL AND r.flagged = 1", &[])?,
+ all: one("r.completed_at IS NULL", &[])?,
+ lists,
+ })
+ }
+
pub fn reminders_smart(&self, kind: SmartList, until: i64) -> Result<Vec<Reminder>> {
// Only Today is bounded by the clock, so only Today binds a value — binding one
// regardless is what SQLite rejects as a parameter-count mismatch.
@@ -747,3 +808,114 @@ mod smart_tests {
assert!(lib.reminders_in("l1", true).unwrap()[0].flagged);
}
}
+
+#[cfg(test)]
+mod count_tests {
+ use super::*;
+
+ fn library() -> Library {
+ let mut lib = Library::in_memory().unwrap();
+ lib.put_reminder_lists(&[
+ ReminderList {
+ guid: "L1".into(),
+ title: "Daily".into(),
+ colour: None,
+ ctag: None,
+ sort_order: 0,
+ enabled: true,
+ },
+ ReminderList {
+ guid: "L2".into(),
+ title: "Off".into(),
+ colour: None,
+ ctag: None,
+ sort_order: 1,
+ enabled: false,
+ },
+ ])
+ .unwrap();
+ lib
+ }
+
+ fn reminder(guid: &str, list: &str, due: Option<i64>, done: bool, flagged: bool) -> Reminder {
+ Reminder {
+ guid: guid.into(),
+ list_guid: list.into(),
+ title: guid.into(),
+ notes: None,
+ due_at: due,
+ completed_at: done.then_some(1),
+ priority: 0,
+ flagged,
+ recur_frequency: None,
+ recur_interval: None,
+ etag: None,
+ raw: None,
+ }
+ }
+
+ /// A count on a tile that disagrees with what opening it shows is worse than no count,
+ /// so both come from the same conditions. This holds them to it.
+ #[test]
+ fn every_count_matches_what_opening_it_shows() {
+ let mut lib = library();
+ let now = 1_000_000;
+ lib.put_reminders(&[
+ reminder("overdue", "L1", Some(now - 500), false, false),
+ reminder("later", "L1", Some(now + 5_000), false, true),
+ reminder("undated", "L1", None, false, false),
+ reminder("done", "L1", Some(now - 100), true, false),
+ ])
+ .unwrap();
+
+ let counts = lib.reminder_counts(now).unwrap();
+ for (kind, count) in [
+ (SmartList::Today, counts.today),
+ (SmartList::Scheduled, counts.scheduled),
+ (SmartList::Flagged, counts.flagged),
+ (SmartList::All, counts.all),
+ ] {
+ assert_eq!(
+ lib.reminders_smart(kind, now).unwrap().len(),
+ count,
+ "{kind:?} count must equal what the list shows"
+ );
+ }
+ assert_eq!(counts.today, 1, "overdue counts as today");
+ assert_eq!(counts.all, 3, "completed does not count");
+ }
+
+ /// A list nobody has switched on contributes to nothing.
+ #[test]
+ fn a_disabled_list_is_left_out_of_the_smart_counts() {
+ let mut lib = library();
+ lib.put_reminders(&[reminder("hidden", "L2", Some(10), false, true)])
+ .unwrap();
+ let counts = lib.reminder_counts(1_000_000).unwrap();
+ assert_eq!(counts.all, 0);
+ assert_eq!(counts.flagged, 0);
+ }
+
+ /// Every list appears, including the empty ones — a sidebar that hid them would be
+ /// missing rows that are really there.
+ #[test]
+ fn every_list_gets_a_count_even_at_zero() {
+ let mut lib = library();
+ lib.put_reminders(&[reminder("a", "L1", None, false, false)])
+ .unwrap();
+ let counts = lib.reminder_counts(1_000_000).unwrap();
+ let by_guid: std::collections::HashMap<_, _> = counts.lists.into_iter().collect();
+ assert_eq!(by_guid.get("L1"), Some(&1));
+ assert_eq!(by_guid.get("L2"), Some(&0), "an empty list still shows");
+ }
+
+ #[test]
+ fn an_empty_library_counts_zero_rather_than_failing() {
+ let lib = library();
+ let counts = lib.reminder_counts(1_000_000).unwrap();
+ assert_eq!(
+ (counts.today, counts.scheduled, counts.flagged, counts.all),
+ (0, 0, 0, 0)
+ );
+ }
+}
diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs
index 51eecef..6e4ea01 100644
--- a/src-tauri/src/main.rs
+++ b/src-tauri/src/main.rs
@@ -347,6 +347,16 @@ async fn calendar_list(data: State<'_, Data>) -> UiResult<Vec<Calendar>> {
library.calendars().map_err(|e| e.to_string())
}
+/// What every entry in the Reminders sidebar is holding.
+#[tauri::command]
+async fn reminder_counts(
+ until: i64,
+ data: State<'_, Data>,
+) -> UiResult<quince_core::reminders::ReminderCounts> {
+ let library = data.0.lock().await;
+ library.reminder_counts(until).map_err(|e| e.to_string())
+}
+
#[tauri::command]
async fn reminder_lists(data: State<'_, Data>) -> UiResult<Vec<ReminderList>> {
let library = data.0.lock().await;
@@ -868,6 +878,7 @@ fn main() {
event_delete,
calendar_list,
reminder_lists,
+ reminder_counts,
reminders_in,
reminders_due_between,
reminder_create,
diff --git a/src/lib/ipc.ts b/src/lib/ipc.ts
index 3832b52..ca65882 100644
--- a/src/lib/ipc.ts
+++ b/src/lib/ipc.ts
@@ -60,6 +60,7 @@ export const api = {
invoke<CalendarEvent[]>("calendar_events", { from, to }),
calendarList: () => invoke<Calendar[]>("calendar_list"),
+ reminderCounts: (until: number) => invoke<ReminderCounts>("reminder_counts", { until }),
reminderLists: () => invoke<ReminderList[]>("reminder_lists"),
remindersIn: (listGuid: string, includeDone: boolean) =>
invoke<Reminder[]>("reminders_in", { listGuid, includeDone }),
@@ -151,6 +152,16 @@ export type ReminderList = {
export type SmartList = "today" | "scheduled" | "flagged" | "all";
+/** What every entry in the Reminders sidebar is holding. */
+export type ReminderCounts = {
+ today: number;
+ scheduled: number;
+ flagged: number;
+ all: number;
+ /** [list guid, outstanding count] */
+ lists: [string, number][];
+};
+
/** How often a reminder comes back. Frequency: 0 daily, 1 weekly, 2 monthly, 3 yearly. */
export type Repeat = { frequency: number; interval: number };
diff --git a/src/screens/RemindersView.tsx b/src/screens/RemindersView.tsx
index efcf909..384de7d 100644
--- a/src/screens/RemindersView.tsx
+++ b/src/screens/RemindersView.tsx
@@ -4,17 +4,19 @@ import {
messageOf,
type Reminder,
type ReminderList,
+ type ReminderCounts,
type SmartList,
} from "../lib/ipc";
import { useSync } from "../lib/sync";
import { Picker } from "../components/Picker";
/** Apple's built-in views, which is how most people enter Reminders. */
-const SMART: { kind: SmartList; title: string }[] = [
- { kind: "today", title: "Today" },
- { kind: "scheduled", title: "Scheduled" },
- { kind: "flagged", title: "Flagged" },
- { kind: "all", title: "All" },
+/** Apple's built-in views, in Apple's order, each with the glyph and colour its app uses. */
+const SMART: { kind: SmartList; title: string; glyph: string; colour: string }[] = [
+ { kind: "today", title: "Today", glyph: "\u2600", colour: "#0a84ff" },
+ { kind: "scheduled", title: "Scheduled", glyph: "\ud83d\udcc5", colour: "#ff453a" },
+ { kind: "all", title: "All", glyph: "\u2261", colour: "#8e8e93" },
+ { kind: "flagged", title: "Flagged", glyph: "\u2691", colour: "#ff9f0a" },
];
/** End of today in the viewer's own timezone — the interface knows it, the backend doesn't. */
@@ -120,6 +122,8 @@ export function RemindersView() {
const [loaded, setLoaded] = useState(false);
const [error, setError] = useState<string | null>(null);
const { revision } = useSync();
+ /** What each sidebar entry is holding. Apple puts a number on every one. */
+ const [counts, setCounts] = useState<ReminderCounts | null>(null);
/** A repeating reminder that was just ticked forward, and where it landed. */
const [moved, setMoved] = useState<{ guid: string; text: string } | null>(
null,
@@ -129,8 +133,12 @@ export function RemindersView() {
const listGuid = inList ? selection.guid : null;
const readLists = useCallback(async () => {
- const found = await api.reminderLists();
+ const [found, tally] = await Promise.all([
+ api.reminderLists(),
+ api.reminderCounts(endOfToday()),
+ ]);
setLists(Array.isArray(found) ? found : []);
+ setCounts(tally);
setLoaded(true);
}, []);
@@ -299,18 +307,29 @@ export function RemindersView() {
return (
<div className="rem">
<aside className="rem-lists" aria-label="Reminder lists">
- {SMART.map((s) => (
- <button
- key={s.kind}
- className="rem-list"
- aria-current={
- selection.type === "smart" && selection.kind === s.kind
- }
- onClick={() => setSelection({ type: "smart", kind: s.kind })}
- >
- <span className="rem-list-name">{s.title}</span>
- </button>
- ))}
+ {/* Apple's own arrangement: the four built-in views as a grid of tiles, each
+ with its glyph and its count, above the lists you made yourself. */}
+ <div className="rem-smart-grid">
+ {SMART.map((smart) => (
+ <button
+ key={smart.kind}
+ className="rem-smart"
+ aria-current={
+ selection.type === "smart" && selection.kind === smart.kind
+ }
+ aria-label={`${smart.title}, ${counts?.[smart.kind] ?? 0} reminders`}
+ onClick={() => setSelection({ type: "smart", kind: smart.kind })}
+ >
+ <span className="rem-smart-top">
+ <span className="rem-smart-glyph" style={{ background: smart.colour }}>
+ {smart.glyph}
+ </span>
+ <span className="rem-smart-count">{counts?.[smart.kind] ?? 0}</span>
+ </span>
+ <span className="rem-smart-name">{smart.title}</span>
+ </button>
+ ))}
+ </div>
<p className="rem-lists-heading">My Lists</p>
{lists.map((list) => (
@@ -353,6 +372,9 @@ export function RemindersView() {
style={{ background: list.colour || "var(--gold)" }}
/>
<span className="rem-list-name">{list.title}</span>
+ <span className="rem-list-count">
+ {counts?.lists.find(([guid]) => guid === list.guid)?.[1] ?? 0}
+ </span>
</button>
<button
className="rem-list-action"
diff --git a/src/styles/app.css b/src/styles/app.css
index 65730ee..6629260 100644
--- a/src/styles/app.css
+++ b/src/styles/app.css
@@ -634,7 +634,81 @@
.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-list-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
+
+/* Apple puts the number on every entry, and it is what makes a sidebar worth glancing at.
+ Tabular figures so the column does not jitter as counts change. */
+.rem-list-count {
+ flex: none;
+ font-size: var(--t-11);
+ color: var(--text-3);
+ font-variant-numeric: tabular-nums;
+}
+
+/* ── The built-in views, arranged the way Reminders arranges them ───────────────────────
+ Four tiles above the lists you made: a filled glyph in the view's own colour, the count
+ large on the right, the name beneath. Two across, because that is what fits a sidebar. */
+.rem-smart-grid {
+ display: grid;
+ grid-template-columns: 1fr 1fr;
+ gap: 6px;
+ margin-bottom: 4px;
+}
+
+.rem-smart {
+ display: flex;
+ flex-direction: column;
+ gap: 3px;
+ min-width: 0;
+ border: 0;
+ padding: 7px 9px 8px;
+ border-radius: var(--r-plateau);
+ background: color-mix(in srgb, var(--text) 5%, transparent);
+ color: var(--text);
+ font: inherit;
+ text-align: left;
+ cursor: pointer;
+ transition: background 140ms var(--ease);
+}
+
+.rem-smart:hover { background: color-mix(in srgb, var(--text) 8%, transparent); }
+.rem-smart[aria-current="true"] { background: var(--gold-tint); box-shadow: inset 0 0 0 1px var(--gold-ring); }
+.rem-smart:focus-visible { outline: 3px solid var(--gold-ring); outline-offset: -1px; }
+
+.rem-smart-top {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: 6px;
+}
+
+.rem-smart-glyph {
+ flex: none;
+ width: 19px;
+ height: 19px;
+ border-radius: var(--r-pill);
+ display: grid;
+ place-items: center;
+ font-size: 10px;
+ line-height: 1;
+ color: #fff;
+}
+
+.rem-smart-count {
+ font-size: var(--t-17);
+ font-weight: 620;
+ font-variant-numeric: tabular-nums;
+ letter-spacing: -0.3px;
+}
+
+.rem-smart-name {
+ font-size: var(--t-11);
+ font-weight: 550;
+ color: var(--text-2);
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+}
.rem-items { display: flex; flex-direction: column; min-height: 0; min-width: 0; }