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.

Deleted things stay deleted; notes save themselves

Yashwanth Kamireddi48d75ab49e95
diff --git a/.uiverify/keyboard.mjs b/.uiverify/keyboard.mjs
index e234870..339dccf 100644
--- a/.uiverify/keyboard.mjs
+++ b/.uiverify/keyboard.mjs
@@ -10,6 +10,20 @@ const SERVICES = ["account","archivews","calendar","ckdatabasews","ckdeviceservi
"sharedstreams","ubiquity","uploadimagews"];
function installStub({ screen, services, twoFactor }) {
+ // Enough reminders to exercise the controls on a row. The keyboard driver is about
+ // behaviour, so the data only has to be shaped right, not large.
+ const lists = [
+ { guid: "L1", title: "Daily", colour: "#c8912a", ctag: null, sortOrder: 0, enabled: true },
+ { guid: "L2", title: "Study", colour: "#1badf8", ctag: null, sortOrder: 1, enabled: true },
+ ];
+ const items = [
+ { guid: "R1", listGuid: "L1", title: "Water the plants", notes: null, dueAt: null,
+ completedAt: null, priority: 0, flagged: false, recurFrequency: null,
+ recurInterval: null, etag: "t1" },
+ { guid: "R2", listGuid: "L1", title: "Evening run", notes: null, dueAt: null,
+ completedAt: null, priority: 1, flagged: false, recurFrequency: null,
+ recurInterval: null, etag: "t2" },
+ ];
window.__TAURI_INTERNALS__ = {
transformCallback: (cb) => cb,
invoke: async (cmd) => {
@@ -26,8 +40,8 @@ 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_lists": return [];
- case "reminders_in": return [];
+ case "reminder_lists": return lists;
+ case "reminders_in": return items;
case "reminders_due_between": return [];
case "reminder_create": return null;
case "reminder_delete": return null;
@@ -35,7 +49,7 @@ function installStub({ screen, services, twoFactor }) {
case "reminder_edit": return null;
case "reminder_list_create": case "reminder_list_rename": case "reminder_list_delete":
return null;
- case "reminders_smart": return [];
+ case "reminders_smart": return items;
case "note_folders": return [];
case "note_save": case "note_delete": case "note_move": return null;
case "note_create": return "Note/new";
@@ -184,6 +198,53 @@ const focused = (page) =>
await ctx.close();
}
+// --- the pop-up button: one tab stop, arrows move, Escape leaves it alone ---
+{
+ const { ctx, page } = await open("library");
+ await page.getByRole("button", { name: "Reminders" }).click();
+ await page.waitForSelector(".rem-list-items li");
+
+ // Open a reminder's details, where the pickers live.
+ await page.locator(".rem-more").first().click({ force: true });
+ await page.waitForSelector(".rem-detail .picker-button");
+
+ const picker = page.locator(".rem-detail .picker-button").first();
+ const before = await picker.innerText();
+ await picker.click();
+ await page.waitForSelector(".picker-menu");
+
+ const options = await page.locator(".picker-menu li").count();
+ check("the menu is ours, not the operating system's", options > 1, `${options} options`);
+
+ const tabbable = await page.evaluate(
+ () => document.querySelectorAll('.picker-menu li[tabindex="0"]').length
+ );
+ check("menu is ONE tab stop, not one per option", tabbable === 1, `${tabbable} tabbable`);
+
+ await page.keyboard.press("Escape");
+ const closed = (await page.locator(".picker-menu").count()) === 0;
+ const after = await picker.innerText();
+ check("Escape closes it without changing the value", closed && before === after, `${before} → ${after}`);
+
+ // Arrows move the highlight, Enter takes it. The value on screen still comes from the
+ // library, so this asserts the interaction rather than a stub echoing a choice back.
+ await page.keyboard.press("ArrowDown");
+ await page.waitForSelector(".picker-menu");
+ const first = await page.locator(".picker-menu li.is-active").innerText();
+ await page.keyboard.press("ArrowDown");
+ const second = await page.locator(".picker-menu li.is-active").innerText();
+ check("ArrowDown moves the highlight", first !== second, `${first.trim()} → ${second.trim()}`);
+
+ await page.keyboard.press("Enter");
+ await page.waitForTimeout(150);
+ const dismissed = (await page.locator(".picker-menu").count()) === 0;
+ const focusBack = await page.evaluate(
+ () => document.activeElement?.classList.contains("picker-button") ?? false
+ );
+ check("Enter takes the choice and returns focus", dismissed && focusBack);
+ await ctx.close();
+}
+
await browser.close();
let failed = 0;
for (const c of checks) {
diff --git a/crates/quince-icloud/src/notes.rs b/crates/quince-icloud/src/notes.rs
index 3e4dcb7..b19b96e 100644
--- a/crates/quince-icloud/src/notes.rs
+++ b/crates/quince-icloud/src/notes.rs
@@ -126,15 +126,24 @@ pub fn apply_cloudkit(
let mut locked_notes: std::collections::HashSet<String> = std::collections::HashSet::new();
for record in &records {
- let Some(kind) = field::record_type(record) else {
- continue;
- };
let removed = record
.get("deleted")
.and_then(Value::as_bool)
.unwrap_or(false)
|| field::flag(record, "Deleted");
+ let Some(kind) = field::record_type(record) else {
+ // A tombstone has a name and nothing else. Skipping them left notes deleted
+ // elsewhere on screen here, and saving one of those wrote it back to Apple —
+ // which is exactly how a deleted note reappears.
+ if removed {
+ if let Some(name) = field::record_name(record) {
+ gone.push(name);
+ }
+ }
+ continue;
+ };
+
match kind.as_str() {
"Note" => {
let Some(name) = field::record_name(record) else {
diff --git a/crates/quince-icloud/src/reminders.rs b/crates/quince-icloud/src/reminders.rs
index f13e268..f1eacaf 100644
--- a/crates/quince-icloud/src/reminders.rs
+++ b/crates/quince-icloud/src/reminders.rs
@@ -582,9 +582,6 @@ pub fn apply_cloudkit(
let mut rules: std::collections::HashMap<String, (i64, i64)> = std::collections::HashMap::new();
for record in &records {
- let Some(kind) = field::record_type(record) else {
- continue; // tombstone with no type; nothing to act on
- };
let Some(name) = field::record_name(record) else {
continue;
};
@@ -595,6 +592,18 @@ pub fn apply_cloudkit(
.unwrap_or(false)
|| field::flag(record, "Deleted");
+ let Some(kind) = field::record_type(record) else {
+ // A tombstone carries a name and nothing else — no type, no fields. Skipping
+ // them meant anything deleted on a phone stayed on screen here forever, and
+ // saving one of those ghosts wrote it back to Apple. The name is enough: it
+ // says which record is gone, and a name only ever belongs to one thing.
+ if removed {
+ gone_reminders.push(name.clone());
+ gone_lists.push(name);
+ }
+ continue;
+ };
+
match kind.as_str() {
"Reminder" => {
if removed {
@@ -2221,3 +2230,106 @@ mod priority_and_move_tests {
assert!(server.received_requests().await.unwrap().is_empty());
}
}
+
+#[cfg(test)]
+mod tombstone_tests {
+ use super::*;
+ use serde_json::json;
+
+ fn library_with(guid: &str) -> quince_core::Library {
+ let mut library = quince_core::Library::in_memory().unwrap();
+ library
+ .put_reminder_lists(&[ReminderList {
+ guid: "List/a".into(),
+ title: "Daily".into(),
+ colour: None,
+ ctag: None,
+ sort_order: 0,
+ enabled: true,
+ }])
+ .unwrap();
+ library
+ .put_reminders(&[Reminder {
+ guid: guid.into(),
+ list_guid: "List/a".into(),
+ title: "Deleted on the phone".into(),
+ notes: None,
+ due_at: None,
+ completed_at: None,
+ priority: 0,
+ flagged: false,
+ recur_frequency: None,
+ recur_interval: None,
+ etag: None,
+ raw: None,
+ }])
+ .unwrap();
+ library
+ }
+
+ fn apply(library: &mut quince_core::Library, records: Vec<Value>) {
+ apply_cloudkit(
+ library,
+ RemindersFetch {
+ records,
+ token: Some("t".into()),
+ incremental: true,
+ },
+ )
+ .unwrap();
+ }
+
+ /// The bug this fixes: a record deleted elsewhere comes back as a tombstone with a name
+ /// and nothing else — no recordType, no fields. Those were skipped, so anything deleted
+ /// on a phone stayed on screen here forever.
+ #[test]
+ fn a_bare_tombstone_removes_the_reminder() {
+ let mut library = library_with("Reminder/1");
+ assert_eq!(library.reminders_in("List/a", true).unwrap().len(), 1);
+
+ apply(
+ &mut library,
+ vec![json!({ "recordName": "Reminder/1", "deleted": true })],
+ );
+ assert!(
+ library.reminders_in("List/a", true).unwrap().is_empty(),
+ "a tombstone must remove the reminder"
+ );
+ }
+
+ /// And a tombstone for a list takes the list with it.
+ #[test]
+ fn a_bare_tombstone_removes_the_list() {
+ let mut library = library_with("Reminder/1");
+ apply(
+ &mut library,
+ vec![json!({ "recordName": "List/a", "deleted": true })],
+ );
+ assert!(library.reminder_lists().unwrap().is_empty());
+ }
+
+ /// A tombstone that is not marked deleted is just a record we cannot read, and guessing
+ /// it away would delete things that still exist.
+ #[test]
+ fn an_untyped_record_that_is_not_deleted_is_left_alone() {
+ let mut library = library_with("Reminder/1");
+ apply(&mut library, vec![json!({ "recordName": "Reminder/1" })]);
+ assert_eq!(
+ library.reminders_in("List/a", true).unwrap().len(),
+ 1,
+ "only an explicit deletion may remove anything"
+ );
+ }
+
+ /// A name that matches nothing must not disturb what is there.
+ #[test]
+ fn a_tombstone_for_something_we_never_had_is_harmless() {
+ let mut library = library_with("Reminder/1");
+ apply(
+ &mut library,
+ vec![json!({ "recordName": "Reminder/999", "deleted": true })],
+ );
+ assert_eq!(library.reminders_in("List/a", true).unwrap().len(), 1);
+ assert_eq!(library.reminder_lists().unwrap().len(), 1);
+ }
+}
diff --git a/probe/src/main.rs b/probe/src/main.rs
index 0547fd5..04191c3 100644
--- a/probe/src/main.rs
+++ b/probe/src/main.rs
@@ -1423,6 +1423,61 @@ async fn main() -> Result<()> {
}
}
+ // ---- what is in a RecurrenceRule record? --------------------------------------
+ // Setting a repeat means writing one of these and linking it. Measure it first.
+ println!("\n\x1b[1m── RecurrenceRule: every field Apple writes ──\x1b[0m");
+ if let Some(ck) = session.service_url("ckdatabasews") {
+ let zc = quince_icloud::cloudkit::ZoneClient::new(
+ client.http(),
+ &ck,
+ "com.apple.reminders",
+ client.service_params(),
+ );
+ if let Ok((records, _)) = zc.all_records("Reminders", None).await {
+ for rec in records
+ .iter()
+ .filter(|r| r.get("recordType").and_then(|t| t.as_str()) == Some("RecurrenceRule"))
+ .take(2)
+ {
+ println!(
+ " {}",
+ quince_icloud::cloudkit::field::record_name(rec).unwrap_or_default()
+ );
+ if let Some(fields) = rec.get("fields").and_then(|f| f.as_object()) {
+ for (k, v) in fields {
+ println!(
+ " {k} = {}",
+ v.to_string().chars().take(120).collect::<String>()
+ );
+ }
+ }
+ }
+
+ // And how the reminder points at its rule.
+ for rec in records
+ .iter()
+ .filter(|r| {
+ r.get("recordType").and_then(|t| t.as_str()) == Some("Reminder")
+ && r.pointer("/fields/RecurrenceRuleIDs/value")
+ .and_then(|v| v.as_array())
+ .is_some_and(|a| !a.is_empty())
+ })
+ .take(2)
+ {
+ println!(
+ " reminder {} RecurrenceRuleIDs = {}",
+ quince_icloud::cloudkit::field::record_name(rec).unwrap_or_default(),
+ rec.pointer("/fields/RecurrenceRuleIDs")
+ .map(std::string::ToString::to_string)
+ .unwrap_or_default()
+ .chars()
+ .take(200)
+ .collect::<String>()
+ );
+ }
+ }
+ }
+
// ---- 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 which
diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs
index 76e10d2..53996ce 100644
--- a/src-tauri/src/main.rs
+++ b/src-tauri/src/main.rs
@@ -611,7 +611,26 @@ async fn note_save(
quince_icloud::notes::edit_cloudkit(&http, &root, params.clone(), &note, &body)
.await
.map_err(|e| e.to_string())?;
- resync_notes(&http, &root, params, &data).await
+ resync_notes(&http, &root, params, &data).await?;
+
+ // Apple accepted the body, but its change feed does not always carry our own write back
+ // on the very next pass. Without this the editor re-reads the old text a moment after
+ // saving, which reads as the edit having been lost — and typing on from there would
+ // save the stale version over the good one.
+ let (title, snippet) = quince_icloud::notes::title_and_snippet(&body);
+ let mut library = data.0.lock().await;
+ if let Some(mut stored) = library
+ .notes_in(None)
+ .map_err(|e| e.to_string())?
+ .into_iter()
+ .find(|n| n.guid == guid)
+ {
+ stored.body = Some(body);
+ stored.title = title;
+ stored.snippet = Some(snippet).filter(|s| !s.is_empty());
+ library.put_notes(&[stored]).map_err(|e| e.to_string())?;
+ }
+ Ok(())
}
/// Write a new note and return the record name Apple gave it.
diff --git a/src/components/Picker.tsx b/src/components/Picker.tsx
new file mode 100644
index 0000000..ae1ecc4
--- /dev/null
+++ b/src/components/Picker.tsx
@@ -0,0 +1,149 @@
+import { useCallback, useEffect, useId, useRef, useState } from "react";
+
+export type PickerOption = { value: string; label: string };
+
+/**
+ * A pop-up button, in the shape macOS actually uses.
+ *
+ * A native `<select>` renders its menu from the operating system, so on Linux it arrives as
+ * a square grey list with a blue band through it — the one piece of the window that looks
+ * like it belongs to a different decade. Everything visible here is ours: the closed
+ * control, the menu, the checkmark against the current choice.
+ *
+ * It behaves the way a listbox is supposed to: one tab stop, arrows move the highlight,
+ * Enter takes it, Escape leaves without changing anything, and focus comes back to the
+ * button either way.
+ */
+export function Picker({
+ value,
+ options,
+ onChange,
+ label,
+ disabled = false,
+ className = "",
+}: {
+ value: string;
+ options: PickerOption[];
+ onChange: (value: string) => void;
+ /** Names the control for anyone who cannot see it. */
+ label: string;
+ disabled?: boolean;
+ className?: string;
+}) {
+ const [open, setOpen] = useState(false);
+ const [active, setActive] = useState(0);
+ const root = useRef<HTMLDivElement | null>(null);
+ const button = useRef<HTMLButtonElement | null>(null);
+ const items = useRef<(HTMLLIElement | null)[]>([]);
+ const listId = useId();
+
+ const current = options.find((o) => o.value === value);
+
+ const close = useCallback(
+ (restoreFocus: boolean) => {
+ setOpen(false);
+ if (restoreFocus) button.current?.focus();
+ },
+ []
+ );
+
+ const choose = useCallback(
+ (index: number) => {
+ const option = options[index];
+ if (option) onChange(option.value);
+ close(true);
+ },
+ [options, onChange, close]
+ );
+
+ // Opening lands the highlight on what is already chosen, not at the top — the current
+ // value is where someone is navigating away from.
+ const openMenu = () => {
+ if (disabled) return;
+ setActive(Math.max(0, options.findIndex((o) => o.value === value)));
+ setOpen(true);
+ };
+
+ useEffect(() => {
+ if (open) items.current[active]?.focus();
+ }, [open, active]);
+
+ // Clicking anywhere else dismisses the menu, which is what every menu does.
+ useEffect(() => {
+ if (!open) return undefined;
+ const onDown = (e: MouseEvent) => {
+ if (!root.current?.contains(e.target as Node)) setOpen(false);
+ };
+ document.addEventListener("mousedown", onDown);
+ return () => document.removeEventListener("mousedown", onDown);
+ }, [open]);
+
+ const onListKey = (e: React.KeyboardEvent) => {
+ const move = (to: number) => {
+ e.preventDefault();
+ setActive(Math.max(0, Math.min(to, options.length - 1)));
+ };
+ if (e.key === "ArrowDown") move(active + 1);
+ else if (e.key === "ArrowUp") move(active - 1);
+ else if (e.key === "Home") move(0);
+ else if (e.key === "End") move(options.length - 1);
+ else if (e.key === "Enter" || e.key === " ") {
+ e.preventDefault();
+ choose(active);
+ } else if (e.key === "Escape" || e.key === "Tab") {
+ e.preventDefault();
+ close(true);
+ }
+ };
+
+ return (
+ <div className={`picker ${className}`.trim()} ref={root}>
+ <button
+ type="button"
+ ref={button}
+ className="picker-button"
+ aria-haspopup="listbox"
+ aria-expanded={open}
+ aria-label={label}
+ disabled={disabled}
+ onClick={() => (open ? close(false) : openMenu())}
+ onKeyDown={(e) => {
+ if (e.key === "ArrowDown" || e.key === "ArrowUp") {
+ e.preventDefault();
+ openMenu();
+ }
+ }}
+ >
+ <span className="picker-value">{current?.label ?? ""}</span>
+ <span className="picker-chevron" aria-hidden="true">
+ ⌄
+ </span>
+ </button>
+
+ {open && (
+ <ul className="picker-menu" role="listbox" id={listId} aria-label={label}>
+ {options.map((option, index) => (
+ <li
+ key={option.value}
+ ref={(el) => {
+ items.current[index] = el;
+ }}
+ role="option"
+ aria-selected={option.value === value}
+ tabIndex={index === active ? 0 : -1}
+ className={index === active ? "is-active" : undefined}
+ onKeyDown={onListKey}
+ onClick={() => choose(index)}
+ onMouseEnter={() => setActive(index)}
+ >
+ <span className="picker-check" aria-hidden="true">
+ {option.value === value ? "✓" : ""}
+ </span>
+ <span className="picker-label">{option.label}</span>
+ </li>
+ ))}
+ </ul>
+ )}
+ </div>
+ );
+}
diff --git a/src/screens/CalendarView.tsx b/src/screens/CalendarView.tsx
index 34b3c6e..c9e41c2 100644
--- a/src/screens/CalendarView.tsx
+++ b/src/screens/CalendarView.tsx
@@ -1,6 +1,7 @@
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
import { api, messageOf, type Calendar, type CalendarEvent, type Reminder } from "../lib/ipc";
import { useSync } from "../lib/sync";
+import { Picker } from "../components/Picker";
const ZONE = Intl.DateTimeFormat().resolvedOptions().timeZone || "UTC";
@@ -489,19 +490,15 @@ export function CalendarView() {
placeholder="New event"
/>
</label>
- <label>
+ <div className="cal-field">
<span>Calendar</span>
- <select
+ <Picker
+ label="Calendar"
value={draft.calendarGuid}
- onChange={(e) => setDraft({ ...draft, calendarGuid: e.target.value })}
- >
- {calendars.map((c) => (
- <option key={c.guid} value={c.guid}>
- {c.title}
- </option>
- ))}
- </select>
- </label>
+ onChange={(guid) => setDraft({ ...draft, calendarGuid: guid })}
+ options={calendars.map((c) => ({ value: c.guid, label: c.title }))}
+ />
+ </div>
<label>
<span>Starts</span>
<input
diff --git a/src/screens/NotesView.tsx b/src/screens/NotesView.tsx
index 2b1c848..841e7ec 100644
--- a/src/screens/NotesView.tsx
+++ b/src/screens/NotesView.tsx
@@ -1,6 +1,7 @@
-import { useCallback, useEffect, useMemo, useState } from "react";
+import { useCallback, useEffect, useMemo, useRef, useState } from "react";
import { api, messageOf, type Note, type NoteFolder } from "../lib/ipc";
import { useSync } from "../lib/sync";
+import { Picker } from "../components/Picker";
const ALL = "__all__";
@@ -108,14 +109,47 @@ export function NotesView() {
const dirty = draft !== null && open !== null && draft !== (open.body ?? "");
- const save = useCallback(async () => {
- if (!open || draft === null || !dirty) return;
- const body = draft;
- if (await write(() => api.noteSave(open.guid, body))) {
- setDraft(null);
+ /**
+ * Saving is not something anyone should have to remember.
+ *
+ * Apple's Notes has no save button because a note is not a document you commit — it is
+ * just there, and what you typed is what it says. Typing schedules a save; leaving the
+ * note or the field takes it immediately, so nothing is ever waiting on a timer when you
+ * walk away.
+ */
+ const pending = useRef<{ guid: string; body: string } | null>(null);
+
+ const flush = useCallback(async () => {
+ const next = pending.current;
+ if (!next) return;
+ pending.current = null;
+ if (await write(() => api.noteSave(next.guid, next.body))) {
+ // The draft has served its purpose: the library now holds what was typed.
+ setDraft((current) => (current === next.body ? null : current));
setSaved(true);
}
- }, [open, draft, dirty, write]);
+ }, [write]);
+
+ const type = useCallback(
+ (body: string) => {
+ if (!open) return;
+ setDraft(body);
+ setSaved(false);
+ pending.current = body === (open.body ?? "") ? null : { guid: open.guid, body };
+ },
+ [open]
+ );
+
+ // A pause in typing is the signal. Long enough not to write on every keystroke, short
+ // enough that closing the window a second later has already saved.
+ useEffect(() => {
+ if (!pending.current) return undefined;
+ const timer = window.setTimeout(() => void flush(), 900);
+ return () => window.clearTimeout(timer);
+ }, [draft, flush]);
+
+ // Leaving the note takes whatever is outstanding with it, before the draft is cleared.
+ useEffect(() => () => void flush(), [openGuid, flush]);
const create = useCallback(async () => {
const guid = await api
@@ -188,18 +222,15 @@ export function NotesView() {
{/* Shown only when the folder column has folded away. */}
<div className="notes-folder-picker">
- <select
+ <Picker
+ label="Folder"
value={folder}
- onChange={(e) => setFolder(e.target.value)}
- aria-label="Folder"
- >
- <option value={ALL}>All Notes</option>
- {folders.map((f) => (
- <option key={f.guid} value={f.guid}>
- {f.title}
- </option>
- ))}
- </select>
+ onChange={setFolder}
+ options={[
+ { value: ALL, label: "All Notes" },
+ ...folders.map((f) => ({ value: f.guid, label: f.title })),
+ ]}
+ />
</div>
{error && <p className="error" role="alert">{error}</p>}
@@ -247,27 +278,19 @@ export function NotesView() {
<div className="note-bar">
<p className="note-when">
- {saved ? "Saved" : dirty ? "Unsaved changes" : when(open.modifiedAt)}
+ {busy ? "Saving…" : dirty ? "Saving…" : saved ? "Saved" : when(open.modifiedAt)}
</p>
<div className="note-bar-actions">
- <select
+ <Picker
+ label={`Folder for ${open.title}`}
value={open.folderGuid ?? ALL}
- onChange={(e) => void moveTo(e.target.value)}
disabled={busy}
- aria-label={`Folder for ${open.title}`}
- >
- <option value={ALL}>No folder</option>
- {folders.map((f) => (
- <option key={f.guid} value={f.guid}>
- {f.title}
- </option>
- ))}
- </select>
- {open.editable && (
- <button className="quiet" onClick={() => void save()} disabled={!dirty || busy}>
- {busy ? "Saving…" : "Save"}
- </button>
- )}
+ onChange={(guid) => void moveTo(guid)}
+ options={[
+ { value: ALL, label: "No folder" },
+ ...folders.map((f) => ({ value: f.guid, label: f.title })),
+ ]}
+ />
<button className="quiet danger" onClick={() => void remove()} disabled={busy}>
Delete
</button>
@@ -279,16 +302,15 @@ export function NotesView() {
className="note-text"
aria-label={`Body of ${open.title}`}
value={draft ?? open.body ?? ""}
- disabled={busy}
- onChange={(e) => setDraft(e.target.value)}
+ onChange={(e) => type(e.target.value)}
onKeyDown={(e) => {
- // Apple's own shortcut, and the one a keyboard user reaches for.
+ // Nothing needs saving by hand, but the reflex deserves an answer.
if ((e.metaKey || e.ctrlKey) && e.key === "s") {
e.preventDefault();
- void save();
+ void flush();
}
}}
- onBlur={() => void save()}
+ onBlur={() => void flush()}
spellCheck
/>
) : (
diff --git a/src/screens/RemindersView.tsx b/src/screens/RemindersView.tsx
index f5f4945..6c82b0d 100644
--- a/src/screens/RemindersView.tsx
+++ b/src/screens/RemindersView.tsx
@@ -7,6 +7,7 @@ import {
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 }[] = [
@@ -490,38 +491,31 @@ export function RemindersView() {
{repeat}. Ticking it moves it to the next one.
</p>
)}
- <label>
+ {/* A pop-up button is not a labelled field: it names itself, and
+ wrapping one in a <label> associates a label with nothing. */}
+ <div className="rem-field">
<span>Priority</span>
- <select
- value={reminder.priority}
+ <Picker
+ label={`Priority for ${reminder.title}`}
+ value={String(reminder.priority)}
disabled={busyGuid === reminder.guid}
- onChange={(e) =>
- void setPriority(reminder, Number(e.target.value))
- }
- >
- {PRIORITIES.map((p) => (
- <option key={p.value} value={p.value}>
- {p.label}
- </option>
- ))}
- </select>
- </label>
- <label>
+ onChange={(v) => void setPriority(reminder, Number(v))}
+ options={PRIORITIES.map((p) => ({
+ value: String(p.value),
+ label: p.label,
+ }))}
+ />
+ </div>
+ <div className="rem-field">
<span>List</span>
- <select
+ <Picker
+ label={`List for ${reminder.title}`}
value={reminder.listGuid}
disabled={busyGuid === reminder.guid}
- onChange={(e) =>
- void moveToList(reminder, e.target.value)
- }
- >
- {lists.map((l) => (
- <option key={l.guid} value={l.guid}>
- {l.title}
- </option>
- ))}
- </select>
- </label>
+ onChange={(guid) => void moveToList(reminder, guid)}
+ options={lists.map((l) => ({ value: l.guid, label: l.title }))}
+ />
+ </div>
<label>
<span>Notes</span>
<textarea
diff --git a/src/styles/app.css b/src/styles/app.css
index 7c4bfef..8873756 100644
--- a/src/styles/app.css
+++ b/src/styles/app.css
@@ -942,14 +942,7 @@ textarea.note-text:disabled {
gap: 6px;
}
-.note-bar-actions select {
- font-size: var(--t-11);
- padding: 3px 6px;
- border-radius: var(--r-field);
- border: 0.5px solid var(--field-edge);
- background: var(--field);
- color: var(--text);
-}
+.note-bar-actions .picker { max-width: 170px; }
.quiet.danger { color: var(--danger); }
@@ -979,19 +972,7 @@ textarea.note-text:disabled {
.notes-folder-picker { display: block; }
}
-.notes-folder-picker select {
- width: 100%;
- font: inherit;
- font-size: var(--t-13);
- color: var(--text);
- background: var(--field);
- border: 1px solid var(--field-edge);
- border-radius: var(--r-field);
- padding: 4px 7px;
- margin-bottom: 8px;
-}
-
-.notes-folder-picker select:focus-visible { outline: 3px solid var(--gold-ring); outline-offset: 1px; }
+.notes-folder-picker .picker { width: 100%; margin-bottom: 8px; }
.content:has(.notes) { display: flex; flex-direction: column; overflow: hidden; }
@@ -1200,7 +1181,8 @@ textarea.note-text:disabled {
outline: none;
}
-.rem-title-edit:hover { background: color-mix(in srgb, var(--text) 5%, transparent); }
+/* No hover of its own: the row is already the highlight, and two of them stacked read as
+ a grey slab dropped across the title. Editing shows itself when the caret arrives. */
.rem-title-edit:focus { background: var(--field); box-shadow: 0 0 0 2px var(--gold-ring); }
.is-done .rem-title-edit { color: var(--text-3); text-decoration: line-through; }
@@ -1214,8 +1196,10 @@ textarea.note-text:disabled {
background: color-mix(in srgb, var(--text) 4.5%, transparent);
}
-.rem-detail label { display: grid; grid-template-columns: 48px 1fr; gap: 8px; align-items: start; }
-.rem-detail label > span { font-size: var(--t-11); color: var(--text-2); padding-top: 5px; }
+.rem-detail label,
+.rem-detail .rem-field { display: grid; grid-template-columns: 48px 1fr; gap: 8px; align-items: start; }
+.rem-detail label > span,
+.rem-detail .rem-field > span { font-size: var(--t-11); color: var(--text-2); padding-top: 5px; }
.rem-detail input,
.rem-detail select,
@@ -1421,7 +1405,8 @@ button.cal-day-item:hover { background: color-mix(in srgb, var(--sheet) 92%, var
align-items: end;
}
-.cal-form label {
+.cal-form label,
+.cal-form .cal-field {
display: flex;
flex-direction: column;
gap: 3px;
@@ -1462,3 +1447,99 @@ button.cal-day-item:hover { background: color-mix(in srgb, var(--sheet) 92%, var
gap: 8px;
margin-top: 2px;
}
+
+/* ── Pop-up button ──────────────────────────────────────────────────────────────────────
+ A native select renders its menu from the operating system, which on Linux is a square
+ grey list with a blue band through it. This is the macOS shape instead: a compact
+ control, a menu that belongs to the window, and a checkmark against the current choice. */
+.picker { position: relative; display: inline-flex; min-width: 0; }
+
+.picker-button {
+ display: flex;
+ align-items: center;
+ gap: 6px;
+ width: 100%;
+ min-width: 0;
+ font: inherit;
+ font-size: var(--t-13);
+ color: var(--text);
+ background: var(--field);
+ border: 0.5px solid var(--field-edge);
+ border-radius: var(--r-field);
+ box-shadow: var(--shadow-field);
+ padding: 4px 7px;
+ cursor: pointer;
+ text-align: left;
+}
+
+.picker-button:hover:not(:disabled) { border-color: var(--field-edge-hover); }
+.picker-button:disabled { color: var(--text-3); cursor: default; }
+
+.picker-button:focus-visible {
+ outline: none;
+ border-color: var(--gold);
+ box-shadow: 0 0 0 3px var(--gold-ring);
+}
+
+.picker-value {
+ flex: 1;
+ min-width: 0;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+}
+
+.picker-chevron {
+ flex: none;
+ color: var(--text-3);
+ font-size: var(--t-11);
+ line-height: 1;
+ margin-top: -3px;
+}
+
+.picker-menu {
+ position: absolute;
+ z-index: 40;
+ top: calc(100% + 4px);
+ left: 0;
+ min-width: 100%;
+ max-height: 260px;
+ overflow-y: auto;
+ margin: 0;
+ padding: 4px;
+ list-style: none;
+ background: var(--sheet);
+ border-radius: var(--r-plateau);
+ box-shadow: var(--shadow-sheet), 0 0 0 0.5px var(--glass-edge);
+ animation: picker-in 140ms var(--ease) both;
+}
+
+@keyframes picker-in {
+ from { opacity: 0; transform: translateY(-4px) scale(0.98); }
+ to { opacity: 1; transform: none; }
+}
+
+.picker-menu li {
+ display: flex;
+ align-items: center;
+ gap: 6px;
+ padding: 4px 8px 4px 4px;
+ border-radius: 5px;
+ font-size: var(--t-13);
+ white-space: nowrap;
+ cursor: pointer;
+ outline: none;
+}
+
+.picker-menu li.is-active { background: var(--gold); color: #fff; }
+.picker-menu li.is-active .picker-check { color: #fff; }
+
+.picker-check {
+ flex: none;
+ width: 14px;
+ text-align: center;
+ color: var(--gold-strong);
+ font-size: var(--t-11);
+}
+
+.picker-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; }