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 can be searched
Yashwanth Kamireddi5a27f3187489
diff --git a/.uiverify/assert.mjs b/.uiverify/assert.mjsindex bd43476..1d31d95 100644--- a/.uiverify/assert.mjs+++ b/.uiverify/assert.mjs@@ -410,6 +410,49 @@ let failures = 0;await page.close();}+// ── Reminders can be searched, across every list ──────────────────────────────────────+{+ const page = await ctx.newPage();+ await page.addInitScript(() => {+ const r = (guid, listGuid, title) => ({ guid, listGuid, title, notes: null, dueAt: null,+ completedAt: null, priority: 0, flagged: false, parentGuid: null, recurFrequency: null,+ recurInterval: null, sectionGuid: null, etag: null });+ window.__TAURI_INTERNALS__ = {+ transformCallback: (cb) => cb,+ invoke: async (cmd, args) => {+ if (cmd === "auth_status") return { hasStoredSession: true, signedIn: true };+ if (cmd === "auth_resume") return true;+ if (cmd === "account_services") return ["reminders"];+ if (cmd === "reminder_lists") return [+ { guid: "G", title: "GYM", colour: "#0a84ff", ctag: null, sortOrder: 0, enabled: true },+ { guid: "D", title: "Daily", colour: "#ffd60a", ctag: null, sortOrder: 1, enabled: true }];+ if (cmd === "reminder_counts") return { today: 0, scheduled: 0, flagged: 0, all: 2, lists: [] };+ if (cmd === "reminders_smart" || cmd === "reminders_in") return [r("A", "G", "Evening run"), r("B", "D", "Water the plants")];+ if (cmd === "reminders_search") return args.query.includes("plant") ? [r("B", "D", "Water the plants")] : [];+ if (cmd === "sync_all" || cmd === "sync_status") return { services: [], asOf: 1, tookMs: 0 };+ if (cmd === "plugin:event|listen") return 0;+ return [];+ },+ };+ });+ await page.goto("http://localhost:4173", { waitUntil: "networkidle" });+ await page.getByRole("button", { name: "Reminders", exact: true }).click();+ await page.waitForTimeout(300);+ await page.fill('input[aria-label="Search reminders"]', "plant");+ await page.waitForTimeout(300);+ const titles = await page.evaluate(() =>+ [...document.querySelectorAll(".rem-list-items li input")].map((i) => i.value));+ const heads = await page.locator(".rem-section").allInnerTexts();+ const right = JSON.stringify(titles) === JSON.stringify(["Water the plants"]) && heads.includes("Daily");+ console.log(+ right+ ? "PASS searching reminders finds across lists, under the list it came from"+ : `FAIL reminder search showed ${JSON.stringify(titles)} under ${JSON.stringify(heads)}`+ );+ if (!right) failures++;+ await page.close();+}+// ── A list shows its own sections ─────────────────────────────────────────────────────// Inside a real list, reminders outside any section come first with no heading, then each// section under its own heading — how Apple shows it, and how the phone showed "🌅".diff --git a/crates/quince-core/src/reminders.rs b/crates/quince-core/src/reminders.rsindex a822b39..f5f168a 100644--- a/crates/quince-core/src/reminders.rs+++ b/crates/quince-core/src/reminders.rs@@ -623,6 +623,60 @@ impl Library {////// Ordering matters: a list that buries today's task under last month's completed ones/// is useless.+ /// Reminders still to do whose title or notes hold every word of `query`, across every+ /// enabled list.+ ///+ /// Matched in Rust rather than SQL for the reason Notes search is: SQLite folds case for+ /// ASCII alone. Bounded like every other view, so a search that matches everything on a+ /// ten-year account does not carry all of it into the window.+ pub fn search_reminders(&self, query: &str) -> Result<Vec<Reminder>> {+ let words: Vec<String> = query.split_whitespace().map(str::to_lowercase).collect();+ if words.is_empty() {+ return Ok(Vec::new());+ }+ 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.flagged, r.parent_guid, r.recur_frequency, r.recur_interval, r.etag,+ r.timezone, r.section_guid+ FROM reminders r+ JOIN reminder_lists l ON l.guid = r.list_guid+ WHERE l.enabled = 1 AND r.completed_at IS NULL+ ORDER BY r.due_at IS NULL, r.due_at, r.priority DESC, r.title",+ )?;+ let rows = stmt.query_map([], |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)?,+ flagged: row.get::<_, i64>(7)? != 0,+ parent_guid: row.get(8)?,+ recur_frequency: row.get(9)?,+ recur_interval: row.get(10)?,+ etag: row.get(11)?,+ raw: None,+ timezone: row.get(12)?,+ section_guid: row.get(13)?,+ })+ })?;+ let mut found = Vec::new();+ for row in rows {+ let r = row?;+ let haystack =+ format!("{}\n{}", r.title, r.notes.as_deref().unwrap_or("")).to_lowercase();+ if words.iter().all(|w| haystack.contains(w.as_str())) {+ found.push(r);+ if found.len() == MOST_AT_ONCE {+ break;+ }+ }+ }+ Ok(found)+ }+pub fn reminders_in(&self, list_guid: &str, include_done: bool) -> Result<Vec<Reminder>> {let mut stmt = self.conn.prepare("SELECT guid, list_guid, title, notes, due_at, completed_at, priority, flagged,@@ -1547,3 +1601,77 @@ mod section_tests {assert_eq!(lib.reminders_in("List/L", true).unwrap().len(), 3);}}++#[cfg(test)]+mod search_tests {+ use super::*;++ fn r(guid: &str, title: &str, notes: Option<&str>, done: bool) -> Reminder {+ Reminder {+ guid: guid.into(),+ list_guid: "List/L".into(),+ title: title.into(),+ notes: notes.map(ToString::to_string),+ due_at: None,+ completed_at: done.then_some(1),+ priority: 0,+ flagged: false,+ parent_guid: None,+ recur_frequency: None,+ recur_interval: None,+ etag: None,+ raw: None,+ timezone: None,+ section_guid: None,+ }+ }++ fn library() -> Library {+ let mut lib = Library::in_memory().unwrap();+ lib.put_reminder_lists(&[ReminderList {+ guid: "List/L".into(),+ title: "GYM".into(),+ colour: None,+ ctag: None,+ sort_order: 0,+ enabled: true,+ }])+ .unwrap();+ lib.put_reminders(&[+ r("A", "Evening run", Some("Legs today"), false),+ r("B", "Water the plants", None, false),+ r("C", "Evening walk", None, true),+ r("D", "Café run", None, false),+ ])+ .unwrap();+ lib+ }++ fn found(q: &str) -> Vec<String> {+ library()+ .search_reminders(q)+ .unwrap()+ .into_iter()+ .map(|r| r.guid)+ .collect()+ }++ #[test]+ fn title_and_notes_are_both_searched() {+ assert_eq!(found("plants"), vec!["B"]);+ assert_eq!(found("legs"), vec!["A"]);+ }++ #[test]+ fn finished_reminders_are_not_found() {+ assert_eq!(found("evening"), vec!["A"]);+ }++ #[test]+ fn case_folds_beyond_ascii_and_every_word_counts() {+ assert_eq!(found("CAFÉ"), vec!["D"]);+ assert_eq!(found("run evening"), vec!["A"]);+ assert!(found("evening plants").is_empty());+ assert!(found(" ").is_empty());+ }+}diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rsindex ae77f07..e32378d 100644--- a/src-tauri/src/main.rs+++ b/src-tauri/src/main.rs@@ -376,6 +376,13 @@ async fn reminder_counts(library.reminder_counts(until).map_err(|e| e.to_string())}+/// Reminders still to do holding every word of `query`, across every enabled list.+#[tauri::command]+async fn reminders_search(query: String, data: State<'_, Data>) -> UiResult<Vec<Reminder>> {+ let library = data.0.lock().await;+ library.search_reminders(&query).map_err(|e| e.to_string())+}+/// The headings inside one reminders list, in the order they were made.#[tauri::command]async fn reminder_sections(@@ -1426,6 +1433,7 @@ fn main() {calendar_list,reminder_lists,reminder_sections,+ reminders_search,reminder_counts,reminders_in,reminders_due_between,diff --git a/src/lib/ipc.ts b/src/lib/ipc.tsindex 20ba8c8..b1b3a8e 100644--- a/src/lib/ipc.ts+++ b/src/lib/ipc.ts@@ -80,6 +80,8 @@ export const api = {invoke<void>("reminder_list_rename", { listGuid, title }),reminderListDelete: (listGuid: string) =>invoke<void>("reminder_list_delete", { listGuid }),+ /** Reminders still to do holding every word typed, across every list. */+ remindersSearch: (query: string) => invoke<Reminder[]>("reminders_search", { query }),remindersSmart: (kind: SmartList, until: number) =>invoke<Reminder[]>("reminders_smart", { kind, until }),reminderCreate: (listGuid: string, title: string) =>diff --git a/src/screens/RemindersView.tsx b/src/screens/RemindersView.tsxindex 2549822..37d884a 100644--- a/src/screens/RemindersView.tsx+++ b/src/screens/RemindersView.tsx@@ -197,15 +197,21 @@ export function RemindersView() {};}, [selection, revision]);+ /** What is typed in the search field. While it holds anything, the pane is the results. */+ const [query, setQuery] = useState("");+ const searching = query.trim().length > 0;+const readItems = useCallback(async (): Promise<Reminder[]> => {- const found =- selection.type === "smart"+ // Search reaches every list, as Apple's does, whatever is open in the sidebar.+ const found = searching+ ? await api.remindersSearch(query)+ : selection.type === "smart"? await api.remindersSmart(selection.kind, endOfToday()): await api.remindersIn(selection.guid, showDone);const fresh = Array.isArray(found) ? found : [];setItems(fresh);return fresh;- }, [selection, showDone]);+ }, [selection, showDone, query, searching]);// Both reads come from the library. `revision` ticks when the shared refresh finishes —// pressed, or on the timer — so a reminder ticked on the phone appears here without this@@ -475,11 +481,30 @@ export function RemindersView() {* which gather from everywhere, but not under a list heading where it would repeat.*/const showListName =+ !searching &&!inList &&(selection as { kind: SmartList }).kind !== "all" &&(selection as { kind: SmartList }).kind !== "flagged";const sections = useMemo(() => {+ if (searching) {+ // Results gather from every list, so the list each came from is the grouping — as in+ // All.+ const byList = new Map<string, typeof threaded>();+ for (const row of threaded) {+ byList.set(row.reminder.listGuid, [...(byList.get(row.reminder.listGuid) ?? []), row]);+ }+ return [...byList.entries()].map(([guid, rows]) => {+ const list = lists.find((l) => l.guid === guid);+ return {+ key: guid,+ heading: list?.title ?? "Reminders",+ colour: list?.colour ?? null,+ dated: false,+ rows,+ };+ });+ }if (inList) {// Inside a real list the grouping is the list's own sections, which is how Apple shows// it: reminders outside any section first with no heading, then each section in the@@ -591,7 +616,7 @@ export function RemindersView() {dated: false,rows,}));- }, [threaded, inList, selection, lists, listSections]);+ }, [threaded, inList, selection, lists, listSections, searching]);return (<div className="rem">@@ -720,7 +745,7 @@ export function RemindersView() {<section className="rem-items"><header className="cal-bar"><div className="cal-nav">- <h1>{heading}</h1>+ <h1>{searching ? "Search" : heading}</h1>{outstanding > 0 && <span className="badge">{outstanding}</span>}</div><div className="cal-actions">@@ -731,6 +756,17 @@ export function RemindersView() {)}</div></header>+ <input+ className="notes-search"+ type="search"+ placeholder="Search"+ aria-label="Search reminders"+ value={query}+ onChange={(e) => setQuery(e.target.value)}+ onKeyDown={(e) => {+ if (e.key === "Escape") setQuery("");+ }}+ />{error && (<p className="error" role="alert">