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.

Nothing replays on coming back; drawings select by their own edges

Yashwanth Kamireddi7baf451b5475
diff --git a/.uiverify/notes-drawing-link.mjs b/.uiverify/notes-drawing-link.mjs
index 17301ea..4167a93 100644
--- a/.uiverify/notes-drawing-link.mjs
+++ b/.uiverify/notes-drawing-link.mjs
@@ -48,14 +48,22 @@ for (const scheme of ["light", "dark"]) {
await page.waitForTimeout(150);
ok(await page.getByRole("dialog", { name: "Drawing" }).isVisible(), `${scheme}: a click shows it large`);
await page.keyboard.press("Escape");
+ // Chosen in the note, its ring is the drawing's own edges, not the width of the line.
+ const ring = await drawing.evaluate((img) => {
+ const box = img.closest(".nf-attachment");
+ return { selected: box.classList.contains("ProseMirror-selectednode"), img: getComputedStyle(img).outlineStyle, box: getComputedStyle(box).outlineStyle };
+ });
+ ok(!ring.selected || (ring.img === "solid" && ring.box === "none"), `${scheme}: chosen, the ring sits on the drawing itself ${JSON.stringify(ring)}`);
+ ok((await page.locator(".ProseMirror a[target]").count()) === 0, `${scheme}: no link opens a window of its own`);
// The link to another note: that note opens, in Quince.
const link = page.locator(".ProseMirror a", { hasText: "The plan" });
ok((await link.count()) === 1, `${scheme}: the link to a note shows as a link`);
await link.click();
await page.waitForTimeout(600);
ok(page.url().startsWith("http://localhost:4173"), `${scheme}: following it stays in Quince`);
- ok((await page.locator(".note-row[aria-current='true'], .note-row.is-open, .note-row[aria-selected='true']", { hasText: "The plan" }).count()) === 1
- || /The plan/.test(await page.locator(".note-rich").first().innerText()), `${scheme}: and opens the note it links to`);
+ const opened = (await page.locator(".note-rich .nf-p").first().innerText()).trim();
+ ok(opened === "The plan" && /Step one/.test(await page.locator(".note-rich").first().innerText()),
+ `${scheme}: and opens the note it links to (the note open is "${opened}")`);
await ctx.close();
}
await b.close();
diff --git a/.uiverify/screens-return.mjs b/.uiverify/screens-return.mjs
new file mode 100644
index 0000000..b8aa92c
--- /dev/null
+++ b/.uiverify/screens-return.mjs
@@ -0,0 +1,80 @@
+// Coming back to a screen is coming back to it as it was: nothing on it plays again. Screens
+// stay loaded out of sight, and a CSS animation starts over whenever its element comes back
+// into view — every face in Contacts faded in anew, every ticked reminder sprang in again.
+// Also: a toggle whose glyph says its state wears no fill that reads as a stuck hover.
+import zlib from "node:zlib";
+import { engine } from "./engine.mjs";
+import { SERVICES, installStub, openScreen } from "./stub.mjs";
+const png = (() => {
+ const { deflateSync, crc32 } = zlib;
+ const w = 64, h = 64, raw = Buffer.alloc((w * 3 + 1) * h, 120);
+ for (let y = 0; y < h; y++) raw[y * (w * 3 + 1)] = 0;
+ const chunk = (t, d) => { const l = Buffer.alloc(4); l.writeUInt32BE(d.length); const td = Buffer.concat([Buffer.from(t), d]); const c = Buffer.alloc(4); c.writeUInt32BE(crc32(td)); return Buffer.concat([l, td, c]); };
+ const ihdr = Buffer.alloc(13); ihdr.writeUInt32BE(w, 0); ihdr.writeUInt32BE(h, 4); ihdr[8] = 8; ihdr[9] = 2;
+ return Buffer.concat([Buffer.from([137, 80, 78, 71, 13, 10, 26, 10]), chunk("IHDR", ihdr), chunk("IDAT", deflateSync(raw)), chunk("IEND", Buffer.alloc(0))]);
+})();
+const b = await engine.launch();
+const ctx = await b.newContext({ viewport: { width: 1280, height: 800 } });
+await ctx.addInitScript(() => {
+ window.__picBase = "http://pics.test";
+ // Every contact with a picture of their own.
+ const add = () => {
+ const internals = window.__TAURI_INTERNALS__;
+ if (!internals || internals.__faces) return;
+ internals.__faces = true;
+ const invoke = internals.invoke;
+ internals.invoke = async (cmd, args) => {
+ const answer = await invoke(cmd, args);
+ return cmd === "contacts_list" && Array.isArray(answer) ? answer.map((c) => ({ ...c, photoUrl: "https://example.test/p" })) : answer;
+ };
+ };
+ window.__afterStub = add;
+});
+await ctx.addInitScript(installStub, { screen: "library", services: SERVICES, twoFactor: null, contactsFixture: true, remindersFixture: true, notesFixture: true });
+await ctx.addInitScript(() => window.__afterStub?.());
+await ctx.route("http://pics.test/**", (r) => r.fulfill({ status: 200, contentType: "image/png", body: png }));
+const page = await ctx.newPage();
+page.on("pageerror", (e) => { console.log(`FAIL page error: ${e.message}`); process.exitCode = 1; });
+await page.goto("http://localhost:4173", { waitUntil: "networkidle" });
+let failures = 0;
+const ok = (p, m) => { console.log(`${p ? "PASS" : "FAIL"} ${m}`); if (!p) failures++; };
+const playing = (sel) => page.evaluate((s) => [...document.querySelectorAll(s)].flatMap((e) => e.getAnimations({ subtree: true })).filter((a) => a.playState === "running").length, sel);
+
+await openScreen(page, "Contacts");
+await page.waitForTimeout(800);
+const faces = await page.locator(".face-photo").count();
+ok(faces > 0, `contacts show their pictures (${faces})`);
+ok((await playing(".face-photo")) === 0, "drawn without a fade");
+await openScreen(page, "Notes");
+await page.waitForTimeout(300);
+await openScreen(page, "Contacts");
+ok((await playing(".face-photo")) === 0, "back to Contacts: no face fades in again");
+
+// Reminders: a tick springs in on the press, and only then.
+await openScreen(page, "Reminders");
+await page.locator(".rx-list", { hasText: "Daily" }).click();
+await page.waitForTimeout(400);
+await page.evaluate(() => { window.__doneDelay = 4000; });
+const tick = page.locator(".rx-row", { has: page.getByLabel("Rename Pick up the parcel") }).locator(".rx-tick");
+await tick.click();
+ok((await playing(".rx-tick.is-pressed")) > 0, "a tick pressed springs in");
+await page.waitForTimeout(400);
+await openScreen(page, "Notes");
+await page.waitForTimeout(200);
+await openScreen(page, "Reminders");
+ok((await playing(".rx-tick")) === 0, "back to Reminders: no tick springs again");
+
+// Photos: the square/whole toggle wears no fill until it is hovered.
+await openScreen(page, "Photos");
+await page.waitForTimeout(600);
+const toggle = page.locator(".px-cap.is-glyph-state");
+if (await toggle.count()) {
+ await page.mouse.move(5, 5);
+ await toggle.click();
+ await page.mouse.move(5, 5);
+ await page.waitForTimeout(200);
+ const bg = await toggle.evaluate((e) => getComputedStyle(e).backgroundColor);
+ ok(bg === "rgba(0, 0, 0, 0)", `the square/whole toggle shows its state by its glyph, no fill (${bg})`);
+} else ok(true, "no photos toggle in this fixture");
+await b.close();
+process.exitCode = failures ? 1 : 0;
diff --git a/crates/quince-icloud/src/ckdocument.rs b/crates/quince-icloud/src/ckdocument.rs
index a460db8..71074b5 100644
--- a/crates/quince-icloud/src/ckdocument.rs
+++ b/crates/quince-icloud/src/ckdocument.rs
@@ -2013,10 +2013,7 @@ mod tests {
#[test]
fn reads_text_from_a_gzipped_document() {
let payload = gzipped(&document("Move more"));
- assert_eq!(
- text_from_bytes(&payload).as_deref(),
- Some("Move more")
- );
+ assert_eq!(text_from_bytes(&payload).as_deref(), Some("Move more"));
}
/// Real titles carry emoji and accents, so the decode must be UTF-8, not ASCII.
diff --git a/probe/examples/notes_attachment_info.rs b/probe/examples/notes_attachment_info.rs
new file mode 100644
index 0000000..6f42da5
--- /dev/null
+++ b/probe/examples/notes_attachment_info.rs
@@ -0,0 +1,36 @@
+//! Read-only: what Quince reads of one note attachment (note_media::info), and whether its
+//! file can be fetched — as the window asks for it.
+use anyhow::{anyhow, Result};
+#[tokio::main]
+async fn main() -> Result<()> {
+ let id = std::env::args()
+ .nth(1)
+ .ok_or_else(|| anyhow!("attachment id"))?;
+ 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());
+ println!(
+ "info: {:?}",
+ quince_icloud::note_media::info(&http, &root, p.clone(), &id).await
+ );
+ match quince_icloud::note_media::bytes(
+ &http,
+ &root,
+ p,
+ &id,
+ quince_icloud::note_media::Part::File,
+ )
+ .await
+ {
+ Ok(b) => println!("file: {} bytes", b.len()),
+ Err(e) => println!("file: {e}"),
+ }
+ Ok(())
+}
diff --git a/src/components/Face.tsx b/src/components/Face.tsx
index 54fb8fe..b3615de 100644
--- a/src/components/Face.tsx
+++ b/src/components/Face.tsx
@@ -3,11 +3,11 @@ import { useLayoutEffect, useRef, useState } from "react";
/**
* A person's picture over their initials, as Contacts draws one.
*
- * The initials hold the place until the picture is decoded, and the picture then fades in
- * over them — never initials swapped for a picture in one jump, which read as a flicker.
- * A picture already to hand (the backend keeps each on disk, the window keeps it in memory)
- * is drawn at once with no fade: there is nothing to wait for, so nothing should move. One
- * that cannot be had leaves the initials, never a broken frame.
+ * The initials hold the place until the picture is decoded, and the picture then takes it,
+ * drawn whole in one frame (decoded before it is drawn, never shown half-way). A picture
+ * already to hand (the backend keeps each on disk, the window keeps it in memory) is drawn at
+ * once. Nothing fades: a fade replayed every time Contacts came back into view. One that
+ * cannot be had leaves the initials, never a broken frame.
*/
export function Face({ src, initials }: { src: string | null; initials: string }) {
const img = useRef<HTMLImageElement | null>(null);
@@ -26,7 +26,7 @@ export function Face({ src, initials }: { src: string | null; initials: string }
className={`face-photo is-${state}`}
src={src}
alt=""
- decoding="async"
+ decoding="sync"
draggable={false}
onLoad={() => setState((s) => (s === "instant" ? s : "ready"))}
onError={() => setState("failed")}
diff --git a/src/screens/PhotosView.tsx b/src/screens/PhotosView.tsx
index 8c47787..3968a1e 100644
--- a/src/screens/PhotosView.tsx
+++ b/src/screens/PhotosView.tsx
@@ -2319,7 +2319,7 @@ export function PhotosView() {
)}
<div className="px-capsule">
<button
- className="px-cap"
+ className="px-cap is-glyph-state"
aria-label={fit ? "Show Square Photos" : "Show Whole Photos"}
aria-pressed={fit}
title={fit ? "Square photos" : "Whole photos"}
diff --git a/src/screens/RemindersView.tsx b/src/screens/RemindersView.tsx
index bf869ce..82eeb0f 100644
--- a/src/screens/RemindersView.tsx
+++ b/src/screens/RemindersView.tsx
@@ -1268,7 +1268,14 @@ export function RemindersView() {
aria-checked={Boolean(reminder.completedAt)}
aria-label={reminder.title}
style={{ "--tick": colourOf(home) } as React.CSSProperties}
- onClick={() => toggle(reminder)}
+ // The fill springs in on the press itself, and only then: kept as state,
+ // it sprang in again every time Reminders came back into view.
+ onClick={(e) => {
+ const tick = e.currentTarget;
+ tick.classList.add("is-pressed");
+ window.setTimeout(() => tick.classList.remove("is-pressed"), 300);
+ toggle(reminder);
+ }}
/>
<div className="rx-text">
diff --git a/src/screens/notes/NoteEditor.tsx b/src/screens/notes/NoteEditor.tsx
index 40f937a..47dc030 100644
--- a/src/screens/notes/NoteEditor.tsx
+++ b/src/screens/notes/NoteEditor.tsx
@@ -8,7 +8,7 @@ import { baseKeymap, splitBlockAs, toggleMark, chainCommands } from "prosemirror
import { Fragment, Slice, type Node as PMNode } from "prosemirror-model";
import type { Run } from "./Formatted";
import { fromDoc, LIST_STYLES, schema, STYLE, tableCells, toDoc } from "./rich";
-import { api, noteMediaSrc, type NoteAttachment } from "../../lib/ipc";
+import { api, messageOf, noteMediaSrc, type NoteAttachment } from "../../lib/ipc";
import { RowMenu, type MenuEntry } from "../../components/RowMenu";
import { autolink, openLinkAt } from "./links";
@@ -56,7 +56,12 @@ const described = new Map<string, Promise<NoteAttachment | null>>();
function describe(id: string): Promise<NoteAttachment | null> {
let known = described.get(id);
if (!known) {
- known = api.noteAttachmentInfo(id).catch(() => null);
+ // A lookup that failed (offline, the session being renewed) is not kept: the next time
+ // the note is drawn asks again, rather than leaving the attachment a blank chip all session.
+ known = api.noteAttachmentInfo(id).catch(() => {
+ described.delete(id);
+ return null;
+ });
described.set(id, known);
}
return known;
@@ -80,7 +85,15 @@ export type PictureShown = { id: string; name: string; src: string; srcDark?: st
function drawMedia(dom: HTMLElement, info: NoteAttachment) {
const name = info.filename ?? info.title ?? (info.kind === "audio" ? "Recording" : "Attachment");
- const open = () => void api.noteAttachmentOpen(info.id).catch(() => {});
+ // Opened in the app this computer uses for it; one that cannot be says why, on the chip
+ // itself, rather than a click that seems to do nothing.
+ let said: HTMLElement | null = null;
+ const open = () =>
+ void api.noteAttachmentOpen(info.id).catch((e) => {
+ if (!said) return;
+ said.textContent = `Couldn’t open: ${messageOf(e)}`;
+ said.classList.add("is-trouble");
+ });
const chip = () => {
const c = document.createElement("button");
c.type = "button";
@@ -96,6 +109,7 @@ function drawMedia(dom: HTMLElement, info: NoteAttachment) {
const meta = document.createElement("span");
meta.className = "nf-file-meta";
meta.textContent = size(info.size);
+ said = meta;
c.append(glyph, label, meta);
c.title = `Open ${name}`;
c.addEventListener("click", open);
diff --git a/src/screens/notes/rich.ts b/src/screens/notes/rich.ts
index 5059e04..19e9a18 100644
--- a/src/screens/notes/rich.ts
+++ b/src/screens/notes/rich.ts
@@ -109,7 +109,9 @@ export const schema = new Schema({
attrs: { href: {} },
inclusive: false,
parseDOM: [{ tag: "a[href]", getAttrs: (d) => ({ href: (d as HTMLElement).getAttribute("href") }) }],
- toDOM: (m) => ["a", { href: m.attrs.href, rel: "noreferrer", target: "_blank" }, 0],
+ // No target: a click is the editor's to follow (notes/links), never a new window — one
+ // opened by WebKitGTK for a link to a note went to the browser.
+ toDOM: (m) => ["a", { href: m.attrs.href, rel: "noreferrer" }, 0],
},
},
});
diff --git a/src/styles/app.css b/src/styles/app.css
index c97ee82..34769e0 100644
--- a/src/styles/app.css
+++ b/src/styles/app.css
@@ -1997,10 +1997,10 @@
.avatar { position: relative; overflow: hidden; }
.face-photo { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.face-photo.is-loading { opacity: 0; }
-.face-photo.is-ready { opacity: 1; animation: face-in 180ms ease-out; }
-.face-photo.is-instant { opacity: 1; }
-@keyframes face-in { from { opacity: 0; } to { opacity: 1; } }
-@media (prefers-reduced-motion: reduce) { .face-photo.is-ready { animation: none; } }
+/* Shown the moment it is ready, never faded: a fade here was an animation, and an animation
+ starts again whenever its screen comes back into view — every face in Contacts faded in
+ anew on every visit, a flicker (and fades flicker on WebKitGTK's compositor anyway). */
+.face-photo.is-ready, .face-photo.is-instant { opacity: 1; }
@media (min-width: 901px) {
.is-rail .sidebar-foot { display: flex; }
.is-rail .sidebar-account { justify-content: center; padding-inline: 0; }
diff --git a/src/styles/notes.css b/src/styles/notes.css
index 9169f55..6ae9ccf 100644
--- a/src/styles/notes.css
+++ b/src/styles/notes.css
@@ -487,3 +487,13 @@ textarea.note-title::placeholder { color: var(--text-3); }
}
:root[data-theme="dark"] .nf-ink-light { display: none; }
:root[data-theme="dark"] .nf-ink-dark { display: block; }
+
+/* An attachment chosen in the note (clicked once, as Notes selects one): marked by an accent
+ ring around the thing itself — a picture's own edges, a chip's own — never the box the
+ line gives it, which ran the width of the note. */
+.note-rich .ProseMirror-selectednode { outline: none; }
+.note-rich .nf-attachment.ProseMirror-selectednode:not(.is-image) > *,
+.note-rich .nf-attachment.ProseMirror-selectednode.is-image img {
+ outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px;
+}
+.nf-file-meta.is-trouble { color: var(--danger); white-space: normal; }
diff --git a/src/styles/photos.css b/src/styles/photos.css
index 3e5ba1a..1e64a9f 100644
--- a/src/styles/photos.css
+++ b/src/styles/photos.css
@@ -326,6 +326,10 @@
.px-viewer-when strong { font-size: var(--t-13); font-weight: 600; }
.px-viewer-when span { color: var(--text-2); font-size: var(--t-11); }
.px-cap[aria-pressed="true"] { background: color-mix(in srgb, var(--text) 12%, transparent); }
+/* A button whose glyph already says which way it is set (square or whole photos), as
+ icloud.com draws it: no pressed fill as well — a fill that never left read as a hover stuck
+ on it. */
+.px-cap.is-glyph-state[aria-pressed="true"]:not(:hover) { background: none; }
.px-stage { position: relative; display: grid; place-items: center; min-width: 0; min-height: 0; overflow: hidden; padding: 62px 64px 70px; container-type: size; }
.px-stage img, .px-stage video { max-width: 100%; max-height: 100%; object-fit: contain; }
/* The photo's frame: what zooms and pans. The full picture lies over the screen-sized one,
diff --git a/src/styles/reminders.css b/src/styles/reminders.css
index 695243d..eebdb44 100644
--- a/src/styles/reminders.css
+++ b/src/styles/reminders.css
@@ -392,11 +392,12 @@
inset: 2.5px;
border-radius: 50%;
background: var(--tick);
- /* The fill lands the instant it is pressed, with the quick spring Reminders gives it. */
- animation: rx-tick-in 220ms cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
+/* The fill lands the instant it is pressed, with the quick spring Reminders gives it — on the
+ press only (is-pressed), never again when the list comes back into view. */
+.rx-tick.is-pressed[aria-checked="true"]::after { animation: rx-tick-in 220ms cubic-bezier(0.34, 1.56, 0.64, 1) both; }
@keyframes rx-tick-in { from { transform: scale(0.3); opacity: 0.4; } to { transform: scale(1); opacity: 1; } }
-@media (prefers-reduced-motion: reduce) { .rx-tick[aria-checked="true"]::after { animation: none; } }
+@media (prefers-reduced-motion: reduce) { .rx-tick.is-pressed[aria-checked="true"]::after { animation: none; } }
.rx-tick.ghost {
display: grid;
place-items: center;