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.

Recently Deleted notes stop leaking into All Notes; a new note stops syncing before you type

Yashwanth Kamireddi2b29833aea88
diff --git a/.uiverify/shots.mjs b/.uiverify/shots.mjs
index 46d48e4..2f427f1 100644
--- a/.uiverify/shots.mjs
+++ b/.uiverify/shots.mjs
@@ -260,6 +260,16 @@ const shots = [
await p.waitForSelector(".note-rows .note-row");
await p.click('.note-row:has-text("These sources")');
} },
+ { name: "16-contacts-wide", screen: "library", theme: "dark", contactsFixture: true,
+ viewport: { width: 1920, height: 1080 },
+ act: async (p) => {
+ await p.click('.nav-item:has-text("Contacts")');
+ await p.waitForSelector(".contact-rows .contact-row");
+ await p.click('.contact-row:has-text("Zoya")');
+ } },
+ { name: "17-calendar-wide", screen: "library", theme: "dark", calendarFixture: true,
+ viewport: { width: 1920, height: 1080 },
+ act: async (p) => { await p.waitForSelector(".cal-grid"); } },
{ name: "04-library", screen: "library", theme: "light" },
{ name: "05-library-dark", screen: "library", theme: "dark" },
];
diff --git a/crates/quince-core/src/notes.rs b/crates/quince-core/src/notes.rs
index 79a0f3f..d52e0ad 100644
--- a/crates/quince-core/src/notes.rs
+++ b/crates/quince-core/src/notes.rs
@@ -12,6 +12,20 @@ pub struct NoteFolder {
pub sort_order: i64,
}
+/// Apple's identifier for the folder deleted notes go to.
+///
+/// The record name, not the title: the title is translated, so matching on "Recently
+/// Deleted" would work in English and quietly fail everywhere else.
+pub const TRASH_FOLDER: &str = "TrashFolder-CloudKit";
+
+impl NoteFolder {
+ /// Whether this is where deleted notes wait before they are really gone.
+ #[must_use]
+ pub fn is_trash(&self) -> bool {
+ self.guid == TRASH_FOLDER
+ }
+}
+
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct Note {
@@ -161,16 +175,18 @@ impl Library {
/// Notes in a folder, pinned first and then most recently changed — Apple's order.
///
- /// Passing `None` returns every note, which is what an "All Notes" view shows.
+ /// Passing `None` is the "All Notes" view, which in Apple's app means every note that
+ /// has not been deleted. Including the deleted ones put them in both places at once.
pub fn notes_in(&self, folder_guid: Option<&str>) -> Result<Vec<Note>> {
let mut stmt = self.conn.prepare(
"SELECT guid, folder_guid, title, snippet, body, locked, pinned,
created_at, modified_at, editable, etag
FROM notes
- WHERE ?1 IS NULL OR folder_guid = ?1
+ WHERE (?1 IS NULL AND (folder_guid IS NULL OR folder_guid != ?2))
+ OR folder_guid = ?1
ORDER BY pinned DESC, modified_at DESC, title",
)?;
- let rows = stmt.query_map(params![folder_guid], |row| {
+ let rows = stmt.query_map(params![folder_guid, TRASH_FOLDER], |row| {
Ok(Note {
guid: row.get(0)?,
folder_guid: row.get(1)?,
diff --git a/probe/src/main.rs b/probe/src/main.rs
index 69bcdc7..da1f9d2 100644
--- a/probe/src/main.rs
+++ b/probe/src/main.rs
@@ -2106,6 +2106,40 @@ async fn main() -> Result<()> {
}
}
+ // ---- what does a Notes Folder record carry? ------------------------------------
+ // "All Notes" must not include the ones in Recently Deleted, so something has to say
+ // which folder that is — and it cannot be the name, which is translated.
+ println!("\n\x1b[1m── Notes folders: every field ──\x1b[0m");
+ if let Some(ck) = session.service_url("ckdatabasews") {
+ let zc = quince_icloud::cloudkit::ZoneClient::new(
+ client.http(),
+ &ck,
+ "com.apple.notes",
+ client.service_params(),
+ );
+ if let Ok(quince_icloud::cloudkit::ZoneWalk { records, .. }) =
+ zc.all_records("Notes", None).await
+ {
+ for rec in records
+ .iter()
+ .filter(|r| r.get("recordType").and_then(|t| t.as_str()) == Some("Folder"))
+ {
+ 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(110).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/screens/ContactsView.tsx b/src/screens/ContactsView.tsx
index 7062db7..dca3e2a 100644
--- a/src/screens/ContactsView.tsx
+++ b/src/screens/ContactsView.tsx
@@ -306,9 +306,18 @@ export function ContactsView() {
</form>
) : open ? (
<>
- <span className="avatar large" aria-hidden="true">{initials(open)}</span>
- <h2>{displayName(open)}</h2>
- {open.company && !open.isCompany && <p className="contact-company">{open.company}</p>}
+ {/* Photo and name together at the top of the card, as Contacts arranges them.
+ The avatar used to be pinned to the pane's left edge while the name was
+ centred somewhere else entirely, so they read as two unrelated things. */}
+ <div className="contact-head">
+ <span className="avatar large" aria-hidden="true">{initials(open)}</span>
+ <div className="contact-head-names">
+ <h2>{displayName(open)}</h2>
+ {open.company && !open.isCompany && (
+ <p className="contact-company">{open.company}</p>
+ )}
+ </div>
+ </div>
<dl className="contact-methods">
{open.methods.map((m, i) => (
diff --git a/src/screens/NotesView.tsx b/src/screens/NotesView.tsx
index 841e7ec..3db60e0 100644
--- a/src/screens/NotesView.tsx
+++ b/src/screens/NotesView.tsx
@@ -151,17 +151,66 @@ export function NotesView() {
// Leaving the note takes whatever is outstanding with it, before the draft is cleared.
useEffect(() => () => void flush(), [openGuid, flush]);
+ /**
+ * A note nobody has typed into is not a note. Apple discards an empty new one the moment
+ * you look away rather than syncing a "New Note" placeholder to every device, and that
+ * had been the actual bug: pressing New note wrote junk to iCloud immediately, even if
+ * nothing was ever typed.
+ *
+ * So composing happens locally first. It becomes a real, synced note the moment there is
+ * something worth keeping — a pause after typing, or leaving it — and simply evaporates
+ * if you never type at all.
+ */
+ const [composing, setComposing] = useState<{ folderGuid: string | null; body: string } | null>(
+ null
+ );
+
+ const commitComposing = useCallback(async () => {
+ const draft = composing;
+ if (!draft) return;
+ if (!draft.body.trim()) {
+ // Nothing was ever typed. There is nothing to keep, so nothing is sent.
+ setComposing(null);
+ return;
+ }
+ setComposing(null);
+ setBusy(true);
+ setError(null);
+ try {
+ const guid = await api.noteCreate(draft.folderGuid, draft.body);
+ await read();
+ setOpenGuid(guid);
+ } catch (e) {
+ setError(messageOf(e));
+ // The write failed, not the typing — put it back rather than lose it.
+ setComposing(draft);
+ } finally {
+ setBusy(false);
+ }
+ }, [composing, read]);
+
+ // The same pause-then-save rhythm as an existing note, up until there is a real note to
+ // hand it to.
+ useEffect(() => {
+ if (!composing || !composing.body.trim()) return undefined;
+ const timer = window.setTimeout(() => void commitComposing(), 900);
+ return () => window.clearTimeout(timer);
+ }, [composing, commitComposing]);
+
+ /** Finish composing before doing anything that would otherwise abandon it mid-thought. */
+ const selectNote = useCallback(
+ async (guid: string) => {
+ if (composing) await commitComposing();
+ setOpenGuid(guid);
+ },
+ [composing, commitComposing]
+ );
+
const create = useCallback(async () => {
- const guid = await api
- .noteCreate(folder === ALL ? null : folder, "New Note\n")
- .catch((e) => {
- setError(messageOf(e));
- return null;
- });
- if (guid === null) return;
- await read();
- setOpenGuid(guid);
- }, [folder, read]);
+ if (composing) await commitComposing();
+ setOpenGuid(null);
+ setComposing({ folderGuid: folder === ALL ? null : folder, body: "" });
+ }, [composing, commitComposing, folder]);
const remove = useCallback(async () => {
if (!open) return;
@@ -241,7 +290,7 @@ export function NotesView() {
<button
className="note-row"
aria-current={openGuid === note.guid}
- onClick={() => setOpenGuid(note.guid)}
+ onClick={() => void selectNote(note.guid)}
>
<span className="note-row-title">
{note.pinned && <span className="pin" aria-label="Pinned">●</span>}
@@ -264,7 +313,19 @@ export function NotesView() {
</section>
<article className="note-body" aria-label="Note">
- {open ? (
+ {composing ? (
+ <textarea
+ key="composing"
+ className="note-text"
+ aria-label="New note"
+ autoFocus
+ value={composing.body}
+ onChange={(e) => setComposing((c) => (c ? { ...c, body: e.target.value } : c))}
+ onBlur={() => void commitComposing()}
+ placeholder="New Note"
+ spellCheck
+ />
+ ) : open ? (
open.locked ? (
<p className="cal-empty">
This note is locked. Apple keeps it encrypted, so there is nothing here to
diff --git a/src/screens/RemindersView.tsx b/src/screens/RemindersView.tsx
index d13e908..28829af 100644
--- a/src/screens/RemindersView.tsx
+++ b/src/screens/RemindersView.tsx
@@ -294,15 +294,23 @@ export function RemindersView() {
setAddingList(false);
}
+ /**
+ * A smart list is a view, not somewhere to keep things — but Apple still lets you add
+ * from Today or All, and quietly files the new reminder in a real list. The first list
+ * is the closest thing this account has to a default one, which is what a smart view
+ * targets.
+ */
+ const targetListGuid = listGuid ?? lists[0]?.guid ?? null;
+ const targetList = lists.find((l) => l.guid === targetListGuid) ?? null;
+
async function add(e: React.FormEvent) {
e.preventDefault();
const title = draft.trim();
- // Adding needs a real list: a smart list is a view, not somewhere to put things.
- if (!title || !listGuid) return;
+ if (!title || !targetListGuid) return;
setSyncing(true);
setError(null);
try {
- await api.reminderCreate(listGuid, title);
+ await api.reminderCreate(targetListGuid, title);
setDraft("");
await readItems();
} catch (err) {
@@ -492,16 +500,27 @@ export function RemindersView() {
</p>
)}
- {inList && (
+ {targetListGuid && (
<form className="rem-add" onSubmit={add}>
<span className="tick ghost" aria-hidden="true" />
<input
value={draft}
onChange={(e) => setDraft(e.target.value)}
placeholder="Add a reminder"
- aria-label={`Add a reminder to ${heading}`}
+ aria-label={
+ inList
+ ? `Add a reminder to ${heading}`
+ : `Add a reminder to ${targetList?.title ?? "a list"}`
+ }
disabled={syncing}
/>
+ {/* Only said out loud when it isn't obvious — inside a list, of course it goes
+ there. From a smart view, where it lands is worth naming. */}
+ {!inList && targetList && (
+ <span className="rem-add-target" aria-hidden="true">
+ {targetList.title}
+ </span>
+ )}
</form>
)}
diff --git a/src/styles/app.css b/src/styles/app.css
index 76c849c..ce82e20 100644
--- a/src/styles/app.css
+++ b/src/styles/app.css
@@ -85,16 +85,14 @@
/* ---- buttons ----------------------------------------------------------------- */
.primary {
- margin-top: 18px;
- width: 100%;
border: 0;
border-radius: var(--r-field);
background: var(--gold);
color: #fff;
font: inherit;
- font-size: var(--t-15);
+ font-size: var(--t-13);
font-weight: 550;
- padding: 10px 16px;
+ padding: 5px 14px;
cursor: pointer;
transition: background 130ms var(--ease), transform 130ms var(--ease);
}
@@ -108,20 +106,40 @@
}
.primary:focus-visible { outline: 3px solid var(--gold-ring); outline-offset: 2px; }
+/* A secondary button, in the macOS shape: a hairline-bordered plateau with a quiet fill.
+ It used to be bare coloured text that underlined on hover, which reads as a link — so
+ "New note" and "New contact" looked like footnotes rather than the things you press. */
.quiet {
- margin-top: 14px;
- border: 0;
- background: none;
- color: var(--gold);
+ border: 0.5px solid var(--field-edge);
+ background: var(--field);
+ box-shadow: var(--shadow-field);
+ color: var(--text);
font: inherit;
font-size: var(--t-13);
cursor: pointer;
- padding: 4px 8px;
+ padding: 4px 10px;
border-radius: var(--r-field);
+ white-space: nowrap;
+ transition: border-color 130ms var(--ease), background 130ms var(--ease);
}
-.quiet:hover { text-decoration: underline; }
-.quiet:focus-visible { outline: 3px solid var(--gold-ring); outline-offset: 1px; }
+.quiet:hover:not(:disabled) {
+ border-color: var(--field-edge-hover);
+ background: color-mix(in srgb, var(--field) 88%, var(--text) 8%);
+}
+
+.quiet:disabled { color: var(--text-3); cursor: default; }
+.quiet:focus-visible { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-ring); }
+
+/* The sign-in screen's button is the one thing on the screen, so it takes the width and
+ the weight. Everywhere else it is one control among several. */
+.shell .primary { margin-top: 18px; width: 100%; font-size: var(--t-15); padding: 10px 16px; }
+
+.quiet.danger { color: var(--danger); }
+.quiet.danger:hover:not(:disabled) { border-color: var(--danger); }
+
+/* The sign-in screen's own buttons sit under a form and need the gap they had. */
+.shell .quiet { margin-top: 14px; }
/* ---- footnotes --------------------------------------------------------------- */
@@ -337,11 +355,20 @@
gap: 4px;
}
+/* A footer link, not a control to press by accident: the one place a bordered button
+ would be heavier than what it does. */
.sidebar-signout {
align-self: flex-start;
font-size: var(--t-11);
+ border: 0;
+ background: none;
+ box-shadow: none;
+ color: var(--gold);
+ padding: 4px 8px;
}
+.sidebar-signout:hover:not(:disabled) { background: none; text-decoration: underline; }
+
.sidebar h2 {
margin: 6px 8px 10px;
font-size: var(--t-11);
@@ -382,6 +409,18 @@
opacity: 0.62;
}
+/* The count beside a screen's title, as Reminders shows it: the same size as the heading,
+ in a lighter weight and colour, so it reads as part of the title rather than as a stray
+ digit that wandered in from somewhere. */
+.cal-nav > .badge {
+ font-size: var(--t-22);
+ font-weight: 400;
+ color: var(--text-3);
+ opacity: 1;
+ font-variant-numeric: tabular-nums;
+ letter-spacing: -0.021em;
+}
+
.nav-item[aria-current="true"] .nav-toggle {
margin-top: 6px;
color: var(--text-2);
@@ -843,6 +882,15 @@
}
.rem-add input::placeholder { color: var(--text-3); }
+
+.rem-add-target {
+ flex: none;
+ font-size: var(--t-11);
+ color: var(--text-3);
+ padding: 2px 7px;
+ border-radius: var(--r-pill);
+ background: color-mix(in srgb, var(--text) 6%, transparent);
+}
.rem-add:focus-within { background: color-mix(in srgb, var(--text) 4%, transparent); }
/* A ring outline that is clearly not actionable, so the row reads as a draft. */
@@ -1160,24 +1208,33 @@ textarea.note-text:disabled {
height: 68px;
min-width: 68px;
font-size: var(--t-22);
- margin-bottom: 12px;
- align-self: flex-start;
}
.contact-detail {
overflow-y: auto;
min-height: 0;
- padding: 4px 32px 40px;
+ padding: 8px 40px 40px;
display: flex;
flex-direction: column;
+ /* One block, left-aligned. Centring the card while the avatar was pinned left is what
+ left a photo alone in the corner and a name floating in the middle of the pane. */
+ align-items: flex-start;
+}
+
+.contact-detail > * { width: 100%; max-width: min(56ch, 100%); }
+
+.contact-head {
+ display: flex;
align-items: center;
+ gap: 16px;
+ margin-bottom: 20px;
}
-.contact-detail > * { width: 100%; max-width: 46ch; }
+.contact-head-names { min-width: 0; }
.contact-detail h2 { margin: 0 0 2px; font-size: var(--t-22); font-weight: 600; letter-spacing: -0.021em; }
-.contact-company { margin: 0 0 18px; color: var(--text-2); font-size: var(--t-13); }
+.contact-company { margin: 0; color: var(--text-2); font-size: var(--t-13); }
-.contact-methods { margin: 18px 0 0; max-width: 46ch; }
+.contact-methods { margin: 0; }
.contact-methods > div {
display: grid;
@@ -1192,7 +1249,7 @@ textarea.note-text:disabled {
.contact-methods a { color: var(--gold); text-decoration: none; }
.contact-methods a:hover { text-decoration: underline; }
-.contact-notes { margin-top: 20px; max-width: 60ch; color: var(--text-2); white-space: pre-wrap; }
+.contact-notes { margin-top: 20px; color: var(--text-2); white-space: pre-wrap; }
.content:has(.contacts) { display: flex; flex-direction: column; overflow: hidden; }
@@ -1496,12 +1553,15 @@ button.cal-day-item:hover { background: color-mix(in srgb, var(--sheet) 92%, var
}
.cal-day-title {
- flex: 1;
+ min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
+/* Beside what it labels, not at the far end of the pane. */
+.cal-day-item .badge { margin-left: 4px; }
+
/* Two columns of fields, so a date and its time sit together rather than stacking into a
tall form that pushes the actions off the panel. */
.cal-form {