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.

Builds for Windows; reminder rows take the keyboard

Yashwanth Kamireddida354b5e611e
diff --git a/.uiverify/reminders-keys.mjs b/.uiverify/reminders-keys.mjs
index 27acacf..77c686d 100644
--- a/.uiverify/reminders-keys.mjs
+++ b/.uiverify/reminders-keys.mjs
@@ -67,5 +67,24 @@ await page.getByLabel(`Rename ${last}`).click();
await page.keyboard.press("End");
await page.keyboard.type("!");
ok((await page.getByLabel(`Rename ${last}`).inputValue()).endsWith("!"), "a reminder's title still takes typing");
+
+// The row takes the keyboard: Escape leaves a title for its row, arrows go row to row,
+// Space ticks the row, Return goes back into its title.
+await page.getByLabel("Rename Pick up the parcel").focus();
+await page.keyboard.press("Escape");
+const focusedRow = () => page.evaluate(() => document.activeElement?.classList.contains("rx-row") ? document.activeElement.querySelector(".rx-title")?.value : null);
+ok((await focusedRow()) === "Pick up the parcel", "Escape leaves the title for its row");
+const startRow = await focusedRow();
+await page.keyboard.press("ArrowDown");
+const below = await focusedRow();
+ok(below && below !== startRow, `Down goes to the next row ${startRow} → ${below}`);
+await page.keyboard.press("ArrowUp");
+ok((await focusedRow()) === startRow, "and Up comes back");
+await page.keyboard.press(" ");
+await page.waitForTimeout(200);
+const done = await page.evaluate(() => window.__done?.at(-1));
+ok(done && done.done === true && done.guid === "r2", `Space ticks that row, and only it ${JSON.stringify(done)}`);
+await page.keyboard.press("Enter");
+ok(await page.evaluate(() => document.activeElement?.classList.contains("rx-title")), "Return goes into its title");
await b.close();
process.exitCode = failures ? 1 : 0;
diff --git a/.uiverify/stub.mjs b/.uiverify/stub.mjs
index c1dad47..dfb9a69 100644
--- a/.uiverify/stub.mjs
+++ b/.uiverify/stub.mjs
@@ -181,7 +181,7 @@ export function installStub({ screen, services, twoFactor, calendarFixture, note
flagged: args.flagged ?? false, parentGuid: null, etag: null });
return null;
case "reminder_delete": return null;
- case "reminder_set_done": return null;
+ case "reminder_set_done": (window.__done ??= []).push(args); return null;
case "reminder_set_repeat": return null;
case "reminder_edit": {
(window.__edits ??= []).push(args.edit);
diff --git a/probe/examples/note_field_census.rs b/probe/examples/note_field_census.rs
new file mode 100644
index 0000000..7395718
--- /dev/null
+++ b/probe/examples/note_field_census.rs
@@ -0,0 +1,108 @@
+//! Read-only: across every note, how often each attribute-run field (and each paragraph-style
+//! field inside field 2) is used — to know which of Apple's formatting the account really holds
+//! before building any of it. Nothing is written.
+use anyhow::{anyhow, Result};
+use std::collections::BTreeMap;
+
+fn varint(b: &[u8], mut at: usize) -> Option<(u64, usize)> {
+ let mut v = 0u64;
+ let mut s = 0;
+ loop {
+ let x = *b.get(at)?;
+ at += 1;
+ v |= u64::from(x & 0x7f) << s;
+ s += 7;
+ if x < 0x80 {
+ return Some((v, at));
+ }
+ }
+}
+
+/// Each field's number, its bytes when length-delimited, and its value when a varint.
+fn fields(b: &[u8]) -> Vec<(u64, Option<&[u8]>, u64)> {
+ let mut out = Vec::new();
+ let mut at = 0;
+ while at < b.len() {
+ let Some((key, n)) = varint(b, at) else { break };
+ at = n;
+ match key & 7 {
+ 0 => {
+ let Some((v, n)) = varint(b, at) else { break };
+ at = n;
+ out.push((key >> 3, None, v));
+ }
+ 2 => {
+ let Some((len, n)) = varint(b, at) else { break };
+ let end = n + len as usize;
+ if end > b.len() {
+ break;
+ }
+ out.push((key >> 3, Some(&b[n..end]), 0));
+ at = end;
+ }
+ 5 => {
+ at += 4;
+ out.push((key >> 3, None, 0));
+ }
+ 1 => {
+ at += 8;
+ out.push((key >> 3, None, 0));
+ }
+ _ => break,
+ }
+ }
+ out
+}
+
+#[tokio::main]
+async fn main() -> Result<()> {
+ let dir = std::path::PathBuf::from(std::env::var("HOME")?).join(".local/share/quince-probe");
+ let mut client = quince_auth::Client::new(&dir)?;
+ if !client.resume().await? {
+ return Err(anyhow!("no session"));
+ }
+ let root = client
+ .session()
+ .service_url("ckdatabasews")
+ .ok_or_else(|| anyhow!("no ck"))?;
+ let (http, p) = (client.http().clone(), client.service_params());
+ let zc = quince_icloud::cloudkit::ZoneClient::new(&http, &root, "com.apple.notes", p.clone());
+ let walk = zc.all_records("Notes", None).await?;
+ let (mut run_fields, mut para_fields) = (BTreeMap::new(), BTreeMap::new());
+ let mut notes_with: BTreeMap<String, u32> = BTreeMap::new();
+ let mut notes = 0;
+ use base64::Engine;
+ for r in walk.records.iter().filter(|r| r["recordType"] == "Note") {
+ let Some(v) = r["fields"]["TextDataEncrypted"]["value"].as_str() else {
+ continue;
+ };
+ let Ok(raw) = base64::engine::general_purpose::STANDARD.decode(v) else {
+ continue;
+ };
+ notes += 1;
+ let mut seen = std::collections::BTreeSet::new();
+ for run in quince_icloud::ckdocument::debug_attribute_runs(&raw) {
+ for (f, body, _) in fields(&run) {
+ *run_fields.entry(f).or_insert(0u32) += 1;
+ seen.insert(format!("run.{f}"));
+ if f == 2 {
+ for (pf, _, value) in fields(body.unwrap_or_default()) {
+ if pf == 2 {
+ seen.insert(format!("align={value}"));
+ }
+ *para_fields.entry(pf).or_insert(0u32) += 1;
+ seen.insert(format!("para.{pf}"));
+ }
+ }
+ }
+ }
+ for s in seen {
+ *notes_with.entry(s).or_insert(0) += 1;
+ }
+ }
+ println!("{notes} notes");
+ println!("attribute-run fields (runs using it): {run_fields:?}");
+ println!("paragraph-style fields (runs using it): {para_fields:?}");
+ println!("notes using each: {notes_with:?}");
+ Ok(())
+}
diff --git a/probe/examples/note_run_fields.rs b/probe/examples/note_run_fields.rs
new file mode 100644
index 0000000..fb55e0b
--- /dev/null
+++ b/probe/examples/note_run_fields.rs
@@ -0,0 +1,103 @@
+//! Read-only: every field of every attribute run of the note whose title starts with the
+//! given words — numbers and raw values, to see how colour is kept.
+use anyhow::{anyhow, Result};
+#[tokio::main]
+async fn main() -> Result<()> {
+ let start = std::env::args()
+ .nth(1)
+ .ok_or_else(|| anyhow!("title start"))?;
+ let dir = std::path::PathBuf::from(std::env::var("HOME")?).join(".local/share/quince-probe");
+ let mut client = quince_auth::Client::new(&dir)?;
+ if !client.resume().await? {
+ return Err(anyhow!("no session"));
+ }
+ let root = client
+ .session()
+ .service_url("ckdatabasews")
+ .ok_or_else(|| anyhow!("no ck"))?;
+ let (http, p) = (client.http().clone(), client.service_params());
+ let zc = quince_icloud::cloudkit::ZoneClient::new(&http, &root, "com.apple.notes", p.clone());
+ let walk = zc.all_records("Notes", None).await?;
+ let note = walk
+ .records
+ .iter()
+ .find(|r| {
+ r["recordType"] == "Note"
+ && r["fields"]["TextDataEncrypted"]["value"]
+ .as_str()
+ .and_then(quince_icloud::ckdocument::text_from_base64)
+ .is_some_and(|t| t.starts_with(&start))
+ })
+ .ok_or_else(|| anyhow!("no such note"))?;
+ let v = note["fields"]["TextDataEncrypted"]["value"]
+ .as_str()
+ .unwrap();
+ use base64::Engine;
+ let raw = base64::engine::general_purpose::STANDARD.decode(v)?;
+ let text = quince_icloud::ckdocument::text_from_base64(v).unwrap_or_default();
+ println!(
+ "text ({} chars): {:?}",
+ text.chars().count(),
+ text.chars().take(700).collect::<String>()
+ );
+ println!(
+ "modified: {} by device {:?}",
+ note["modified"]["timestamp"], note["modified"]["deviceID"]
+ );
+ for (i, run) in quince_icloud::ckdocument::debug_attribute_runs(&raw)
+ .iter()
+ .enumerate()
+ {
+ let mut at = 0;
+ let mut parts = vec![];
+ let b = run.as_slice();
+ let vint = |b: &[u8], mut at: usize| {
+ let mut v = 0u64;
+ let mut s = 0;
+ loop {
+ let x = b[at];
+ at += 1;
+ v |= u64::from(x & 0x7f) << s;
+ s += 7;
+ if x < 0x80 {
+ return (v, at);
+ }
+ }
+ };
+ while at < b.len() {
+ let (k, n) = vint(b, at);
+ at = n;
+ match k & 7 {
+ 0 => {
+ let (x, n) = vint(b, at);
+ at = n;
+ parts.push(format!("{}={x}", k >> 3));
+ }
+ 2 => {
+ let (len, n) = vint(b, at);
+ let s = &b[n..n + len as usize];
+ at = n + len as usize;
+ parts.push(format!(
+ "{}:[{}]",
+ k >> 3,
+ s.iter()
+ .map(|c| format!("{c:02x}"))
+ .collect::<Vec<_>>()
+ .join("")
+ ));
+ }
+ 5 => {
+ parts.push(format!("{}=f32 {:?}", k >> 3, &b[at..at + 4]));
+ at += 4;
+ }
+ 1 => {
+ at += 8;
+ parts.push(format!("{}=64", k >> 3));
+ }
+ _ => break,
+ }
+ }
+ println!("run {i}: {}", parts.join(" "));
+ }
+ Ok(())
+}
diff --git a/src-tauri/icons/icon.ico b/src-tauri/icons/icon.ico
new file mode 100644
index 0000000..68c27a6
Binary files /dev/null and b/src-tauri/icons/icon.ico differ
diff --git a/src-tauri/src/alerts.rs b/src-tauri/src/alerts.rs
index 46a7b81..7a22b78 100644
--- a/src-tauri/src/alerts.rs
+++ b/src-tauri/src/alerts.rs
@@ -10,7 +10,9 @@
use crate::{Auth, Data};
use quince_core::alarms::DueAlarm;
use std::time::Duration;
-use tauri::{AppHandle, Emitter, Manager};
+#[cfg(all(unix, not(target_os = "macos")))]
+use tauri::Emitter;
+use tauri::{AppHandle, Manager};
use tokio::sync::Notify;
/// Something that can move the next alarm has happened.
@@ -25,6 +27,7 @@ const LONGEST_SLEEP: Duration = Duration::from_secs(10 * 60);
const STILL_WORTH_SAYING: i64 = 6 * 60 * 60;
/// Snooze, as the phone offers it.
+#[cfg(all(unix, not(target_os = "macos")))]
const SNOOZE: i64 = 60 * 60;
/// The app's icon, carried in the binary so an alert shows it on any desktop. A notification
@@ -49,6 +52,7 @@ fn icon_path(app: &AppHandle) -> Option<&'static str> {
}
/// Emitted to the window to open a reminder an alert was clicked for.
+#[cfg(all(unix, not(target_os = "macos")))]
pub const OPEN_REMINDER: &str = "quince://open-reminder";
/// Tell the task to look again: the reminders or their alarms may have changed.
@@ -160,56 +164,72 @@ fn show(app: AppHandle, due: DueAlarm) {
.map(ToString::to_string)
.or_else(|| due.list_title.clone())
.unwrap_or_default();
- let shown = notify_rust::Notification::new()
- .appname("Quince")
- .summary(&due.title)
- .body(&body)
- .icon(icon_path(&app).unwrap_or("quince"))
- .hint(notify_rust::Hint::Category("reminder".into()))
- .hint(notify_rust::Hint::DesktopEntry("quince".into()))
- .hint(notify_rust::Hint::Resident(true))
- .action("default", "Open")
- .action("complete", "Mark as Completed")
- .action("snooze", "Remind Me in 1 Hour")
- .timeout(notify_rust::Timeout::Never)
- .show();
- let Ok(handle) = shown else {
- return;
- };
- handle.wait_for_action(|action| match action {
- "complete" => {
- let app = app.clone();
- let due = due.clone();
- tauri::async_runtime::block_on(async move {
- let auth = app.state::<Auth>();
- let data = app.state::<Data>();
- if let Err(e) =
- crate::set_done(&auth, &data, &due.reminder_guid, &due.list_guid, true)
- .await
- {
- eprintln!("could not complete {}: {e}", due.reminder_guid);
- }
- // Every open screen looks again, as after any pass.
- let report = crate::refresh::status(&data.0).await;
- app.emit(crate::SYNCED, &report).ok();
- });
- }
- "snooze" => {
- let app = app.clone();
- let guid = due.reminder_guid.clone();
- tauri::async_runtime::block_on(async move {
- let data = app.state::<Data>();
- let mut library = data.0.lock().await;
- library.snooze_reminder(&guid, now() + SNOOZE).ok();
- });
- changed();
- }
- "default" => {
- crate::show_window(&app);
- app.emit(OPEN_REMINDER, &due.reminder_guid).ok();
- }
- _ => {}
- });
+ // The phone's choices on the alert are the freedesktop notification spec's actions. Windows
+ // and macOS take no buttons through this crate, so the alert says what is due and
+ // the reminder is completed or put off in the app.
+ #[cfg(not(all(unix, not(target_os = "macos"))))]
+ {
+ notify_rust::Notification::new()
+ .appname("Quince")
+ .summary(&due.title)
+ .body(&body)
+ .icon(icon_path(&app).unwrap_or("quince"))
+ .show()
+ .ok();
+ }
+ #[cfg(all(unix, not(target_os = "macos")))]
+ {
+ let shown = notify_rust::Notification::new()
+ .appname("Quince")
+ .summary(&due.title)
+ .body(&body)
+ .icon(icon_path(&app).unwrap_or("quince"))
+ .hint(notify_rust::Hint::Category("reminder".into()))
+ .hint(notify_rust::Hint::DesktopEntry("quince".into()))
+ .hint(notify_rust::Hint::Resident(true))
+ .action("default", "Open")
+ .action("complete", "Mark as Completed")
+ .action("snooze", "Remind Me in 1 Hour")
+ .timeout(notify_rust::Timeout::Never)
+ .show();
+ let Ok(handle) = shown else {
+ return;
+ };
+ handle.wait_for_action(|action| match action {
+ "complete" => {
+ let app = app.clone();
+ let due = due.clone();
+ tauri::async_runtime::block_on(async move {
+ let auth = app.state::<Auth>();
+ let data = app.state::<Data>();
+ if let Err(e) =
+ crate::set_done(&auth, &data, &due.reminder_guid, &due.list_guid, true)
+ .await
+ {
+ eprintln!("could not complete {}: {e}", due.reminder_guid);
+ }
+ // Every open screen looks again, as after any pass.
+ let report = crate::refresh::status(&data.0).await;
+ app.emit(crate::SYNCED, &report).ok();
+ });
+ }
+ "snooze" => {
+ let app = app.clone();
+ let guid = due.reminder_guid.clone();
+ tauri::async_runtime::block_on(async move {
+ let data = app.state::<Data>();
+ let mut library = data.0.lock().await;
+ library.snooze_reminder(&guid, now() + SNOOZE).ok();
+ });
+ changed();
+ }
+ "default" => {
+ crate::show_window(&app);
+ app.emit(OPEN_REMINDER, &due.reminder_guid).ok();
+ }
+ _ => {}
+ });
+ }
});
}
@@ -325,21 +345,34 @@ fn show_event(app: AppHandle, event: quince_core::calendar::Event, minutes: i64)
if let Some(place) = event.location.as_deref().filter(|p| !p.trim().is_empty()) {
body.push_str(&format!("\n{place}"));
}
- let shown = notify_rust::Notification::new()
- .appname("Quince")
- .summary(&event.title)
- .body(&body)
- .icon(icon_path(&app).unwrap_or("quince"))
- .hint(notify_rust::Hint::Category("calendar".into()))
- .hint(notify_rust::Hint::DesktopEntry("quince".into()))
- .action("default", "Open")
- .show();
- if let Ok(handle) = shown {
- handle.wait_for_action(|action| {
- if action == "default" {
- crate::show_window(&app);
- }
- });
+ #[cfg(not(all(unix, not(target_os = "macos"))))]
+ {
+ notify_rust::Notification::new()
+ .appname("Quince")
+ .summary(&event.title)
+ .body(&body)
+ .icon(icon_path(&app).unwrap_or("quince"))
+ .show()
+ .ok();
+ }
+ #[cfg(all(unix, not(target_os = "macos")))]
+ {
+ let shown = notify_rust::Notification::new()
+ .appname("Quince")
+ .summary(&event.title)
+ .body(&body)
+ .icon(icon_path(&app).unwrap_or("quince"))
+ .hint(notify_rust::Hint::Category("calendar".into()))
+ .hint(notify_rust::Hint::DesktopEntry("quince".into()))
+ .action("default", "Open")
+ .show();
+ if let Ok(handle) = shown {
+ handle.wait_for_action(|action| {
+ if action == "default" {
+ crate::show_window(&app);
+ }
+ });
+ }
}
});
}
diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json
index 4863a65..94d5cb6 100644
--- a/src-tauri/tauri.conf.json
+++ b/src-tauri/tauri.conf.json
@@ -36,6 +36,7 @@
"icons/64x64.png",
"icons/128x128.png",
+ "icons/icon.ico",
"icons/icon.png"
],
"category": "Productivity",
diff --git a/src/screens/RemindersView.tsx b/src/screens/RemindersView.tsx
index 1ee5fc9..2b1cda9 100644
--- a/src/screens/RemindersView.tsx
+++ b/src/screens/RemindersView.tsx
@@ -1124,6 +1124,30 @@ export function RemindersView() {
setDragging(reminder.guid);
}}
onDragEnd={() => { setDragging(null); setDropBefore(null); }}
+ // The row itself takes the keyboard, as on icloud.com and the Mac: arrows go
+ // from row to row, Space ticks it, Return edits its title. Delete is left out:
+ // a reminder deleted here cannot be brought back.
+ tabIndex={-1}
+ data-guid={reminder.guid}
+ onKeyDown={(e) => {
+ if (e.target !== e.currentTarget) return;
+ const rows = [...document.querySelectorAll<HTMLElement>(".rx-rows .rx-row")];
+ const at = rows.indexOf(e.currentTarget);
+ const go = (i: number) => rows[Math.max(0, Math.min(rows.length - 1, i))]?.focus();
+ if (e.key === "ArrowDown" || e.key === "ArrowUp") {
+ e.preventDefault();
+ go(at + (e.key === "ArrowDown" ? 1 : -1));
+ } else if (e.key === "Home" || e.key === "End") {
+ e.preventDefault();
+ go(e.key === "Home" ? 0 : rows.length - 1);
+ } else if (e.key === " ") {
+ e.preventDefault();
+ if (!busy.has(reminder.guid)) void toggle(reminder);
+ } else if (e.key === "Enter") {
+ e.preventDefault();
+ e.currentTarget.querySelector<HTMLInputElement>(".rx-title")?.focus();
+ }
+ }}
// Right-click, as on the Mac: what can be done to this reminder, in one menu.
onMouseDownCapture={() => {
// What had focus before this press: the press itself focuses a title it
@@ -1191,8 +1215,9 @@ export function RemindersView() {
e.currentTarget.blur();
window.setTimeout(() => document.querySelector<HTMLInputElement>(".rx-add input")?.focus(), 0);
} else if (e.key === "Escape") {
+ // Back to the row, which then takes the arrows and Space.
e.currentTarget.value = reminder.title;
- e.currentTarget.blur();
+ e.currentTarget.closest<HTMLElement>(".rx-row")?.focus();
} else if (inList && (e.key === "Tab" || ((e.ctrlKey || e.metaKey) && (e.key === "]" || e.key === "[")))) {
// Tab and Shift-Tab, or Command-] and Command-[ as the Mac's menu has them.
e.preventDefault();
diff --git a/src/styles/reminders.css b/src/styles/reminders.css
index b0e0ea8..54ef6ae 100644
--- a/src/styles/reminders.css
+++ b/src/styles/reminders.css
@@ -358,6 +358,13 @@
background: var(--separator);
}
.rx-row:last-child::after { display: none; }
+/* A row chosen from the keyboard: the selection Reminders draws, a rounded tint behind it, with
+ no outline drawn around the text. */
+.rx-row:focus { outline: none; }
+.rx-row:focus-visible {
+ background: color-mix(in srgb, var(--accent) 14%, transparent);
+ border-radius: 8px;
+}
.rx-row.is-subtask { margin-left: 30px; }
.rx-tick {