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.

Calendar: a click never leaves a half-made event behind

Yashwanth Kamireddifcbe1153ffb6
diff --git a/.uiverify/calendar.mjs b/.uiverify/calendar.mjs
index d03b159..a84f81a 100644
--- a/.uiverify/calendar.mjs
+++ b/.uiverify/calendar.mjs
@@ -109,6 +109,35 @@ ok(/Sep/.test(title) && /Oct/.test(title), `a week across two months is named fo
await page.keyboard.press("Escape");
}
+// A press whose release never arrives — what the app's WebKitGTK did — must not leave a
+// half-made event on the grid growing with every move of the mouse.
+{
+ const col = await page.locator(".cx-column").nth(2).boundingBox();
+ // A real press; the release is swallowed before the app can hear it.
+ await page.evaluate(() => {
+ const swallow = (e) => e.stopImmediatePropagation();
+ window.__swallow = swallow;
+ window.addEventListener("pointerup", swallow, true);
+ window.addEventListener("mouseup", swallow, true);
+ });
+ await page.mouse.move(col.x + 30, col.y + 13 * 48);
+ await page.mouse.down();
+ await page.mouse.up();
+ // The mouse moves on with no button held.
+ await page.mouse.move(col.x + 30, col.y + 17 * 48, { steps: 8 });
+ await page.waitForTimeout(250);
+ await page.evaluate(() => {
+ window.removeEventListener("pointerup", window.__swallow, true);
+ window.removeEventListener("mouseup", window.__swallow, true);
+ });
+ const left = await page.evaluate(() => ({
+ drafts: document.querySelectorAll(".cx-block.is-draft").length,
+ popovers: document.querySelectorAll(".cx-popover").length,
+ }));
+ ok(left.drafts === 0 && left.popovers === 0, "a press whose release is lost leaves nothing behind",
+ `a lost release left ${JSON.stringify(left)}`);
+}
+
// The whole of making an event from the + button: it opens, takes a title, and is saved with
// what was typed — the thing that has to work for Calendar to be usable at all.
{
diff --git a/install-arch.sh b/install-arch.sh
new file mode 100644
index 0000000..b65ee16
--- /dev/null
+++ b/install-arch.sh
@@ -0,0 +1,134 @@
+#!/bin/bash
+# Published prod installer with reviewed signing keys and compatible, completed releases.
+set -euo pipefail
+
+if [[ $# != 0 ]]; then
+ echo "Usage: sudo bash $0" >&2
+ exit 1
+fi
+repository_url='https://persistent.oaistatic.com/codex-app-prod/linux'
+package_name='chatgpt'
+if [[ $EUID != 0 ]]; then
+ echo "Run this script with sudo: sudo bash $0" >&2
+ exit 1
+fi
+for command in pacman pacman-key pacman-conf curl gpg uname; do
+ command -v "$command" >/dev/null || {
+ echo "Missing $command; install pacman, curl, gnupg, and coreutils before continuing." >&2
+ exit 1
+ }
+done
+
+temporary=$(mktemp -d)
+bootstrap_cache=''
+trap 'if [[ -n $bootstrap_cache ]]; then rm -f -- "$bootstrap_cache.db" "$bootstrap_cache.db.sig"; fi; rm -rf "$temporary"' EXIT
+architecture=$(uname -m)
+case "$architecture" in
+ x86_64|aarch64) ;;
+ *) echo 'Unsupported architecture.' >&2; exit 1 ;;
+esac
+versions=(26.924.51851 26.924.50649 26.924.22138)
+# The current reviewed set is authoritative for every fallback candidate.
+expected_fingerprints='3BFA0E4AE8B8CC16A2D9BA684A3B4A566C4660E4'
+verification_home="$temporary/verification"
+mkdir -m 0700 "$verification_home"
+selected=''
+for version in "${versions[@]}"; do
+ candidate="$temporary/$version"
+ mkdir "$candidate"
+ package="$package_name-bin-$version-1-$architecture.pkg.tar.zst"
+ unavailable=0
+ for relative_path in \
+ "arch/$version/repository-signing-key.gpg" \
+ "arch/$version/$architecture/$package" \
+ "arch/$version/$architecture/$package.sig" \
+ "arch/$version/$architecture/openai-$package_name.db" \
+ "arch/$version/$architecture/openai-$package_name.db.sig"; do
+ if status=$(curl --proto '=https' --tlsv1.2 --connect-timeout 15 -fL \
+ --write-out '%{http_code}' -o "$candidate/${relative_path##*/}" "$repository_url/$relative_path"); then
+ continue
+ else
+ curl_exit=$?
+ fi
+ case "$curl_exit:$status" in
+ 22:404|22:410|22:408|22:429|22:5??|5:*|6:*|7:*|18:*|28:*|52:*|56:*)
+ echo "Release $version is unavailable; trying the next published release." >&2
+ unavailable=1
+ break ;;
+ *) echo "Download failed for $relative_path; not falling back. No changes were made." >&2; exit 1 ;;
+ esac
+ done
+ if [[ $unavailable == 1 ]]; then continue; fi
+
+ if ! fingerprints=$(gpg --homedir "$verification_home" --batch --show-keys --with-colons "$candidate/repository-signing-key.gpg" |
+ awk -F: '$1 == "pub" { primary=1 } $1 == "sub" { primary=0 } $1 == "fpr" && primary { print $10; primary=0 }' |
+ LC_ALL=C sort); then
+ echo 'Invalid OpenAI signing-key bundle; not falling back. No keys imported.' >&2
+ exit 1
+ fi
+ if [[ $fingerprints != "$expected_fingerprints" ]]; then
+ echo 'OpenAI repository signing-key fingerprint mismatch; not falling back. No keys imported.' >&2
+ exit 1
+ fi
+ gpg --homedir "$verification_home" --batch --import "$candidate/repository-signing-key.gpg"
+ if ! gpg --homedir "$verification_home" --batch --no-auto-key-retrieve --no-auto-key-import \
+ --verify "$candidate/openai-$package_name.db.sig" "$candidate/openai-$package_name.db" ||
+ ! gpg --homedir "$verification_home" --batch --no-auto-key-retrieve --no-auto-key-import \
+ --verify "$candidate/$package.sig" "$candidate/$package"; then
+ echo 'OpenAI release signature verification failed; not falling back. No keys imported or configuration changed.' >&2
+ exit 1
+ fi
+ selected="$candidate"
+ if [[ $version != "${versions[0]}" ]]; then
+ echo "Using previously published release $version." >&2
+ fi
+ break
+done
+if [[ -z $selected ]]; then
+ echo 'No compatible published release is available. Files may still be propagating. No changes were made; download the installer again and retry shortly.' >&2
+ exit 1
+fi
+
+sources_file="/etc/pacman.d/openai-$package_name.conf"
+cat >"$temporary/repository.conf" <<EOF
+### THIS FILE IS AUTOMATICALLY CONFIGURED ###
+# Remove it and its Include line to opt out of automatic package updates.
+[openai-$package_name]
+SigLevel = Required DatabaseRequired TrustedOnly
+Server = $repository_url/arch/\$arch
+EOF
+if [[ -e $sources_file ]] && ! cmp -s "$sources_file" "$temporary/repository.conf"; then
+ echo "Not replacing existing pacman configuration: $sources_file" >&2
+ exit 1
+fi
+pacman-key --init
+pacman-key --add "$selected/repository-signing-key.gpg"
+while IFS= read -r fingerprint; do
+ pacman-key --lsign-key "$fingerprint"
+done <<<"$expected_fingerprints"
+install -m 0644 "$temporary/repository.conf" "$sources_file"
+include_line="Include = $sources_file"
+if ! grep -qxF "$include_line" /etc/pacman.conf; then
+ printf '\n%s\n' "$include_line" >>/etc/pacman.conf
+fi
+# The first transaction must consume the files verified above, not refetch a
+# newer CDN generation. Keep the installed configuration on the online repo.
+# Give that snapshot its own cache identity so an older fallback cannot mask
+# the online catalog's Last-Modified timestamp on the next ordinary upgrade.
+bootstrap_repo="openai-$package_name-bootstrap-${temporary##*/}"
+install -m 0644 "$selected/openai-$package_name.db" "$selected/$bootstrap_repo.db"
+install -m 0644 "$selected/openai-$package_name.db.sig" "$selected/$bootstrap_repo.db.sig"
+sed -e "s|^Server = .*|Server = file://$selected|" \
+ -e "s|^\\[openai-$package_name\\]$|[$bootstrap_repo]|" "$temporary/repository.conf" \
+ >"$temporary/repository-local.conf"
+# The copied system configuration can contain private repository credentials.
+install -m 0600 /dev/null "$temporary/pacman.conf"
+awk -v original="$include_line" -v replacement="Include = $temporary/repository-local.conf" \
+ '$0 == original { $0 = replacement } { print }' /etc/pacman.conf >"$temporary/pacman.conf"
+bootstrap_cache="$(pacman-conf --config "$temporary/pacman.conf" DBPath)/sync/$bootstrap_repo"
+# Allow pacman's unprivileged downloader to read verified artifacts while
+# keeping all files and the directory writable only by root.
+chmod 0755 "$temporary" "$selected"
+chmod 0644 "$selected"/*
+# Keep pacman's normal confirmation prompts and perform a full system upgrade.
+pacman --config "$temporary/pacman.conf" -Syu --needed "$package_name-bin"
diff --git a/src/screens/calendar/CalendarView.tsx b/src/screens/calendar/CalendarView.tsx
index e27768d..e8bcbb5 100644
--- a/src/screens/calendar/CalendarView.tsx
+++ b/src/screens/calendar/CalendarView.tsx
@@ -854,55 +854,98 @@ function TimeGrid({
return { x: r.left + (column + 1) * width, y, left: r.left + column * width } as Anchor;
};
- const onColumnDown = (e: React.PointerEvent) => {
- if (e.button !== 0 || (e.target as HTMLElement).closest(".cx-block")) return;
- const at = where(e.clientX, e.clientY);
- if (!at) return;
- const from = snap(at.minutes) - (snap(at.minutes) === 24 * 60 ? 15 : 0);
- (e.currentTarget as HTMLElement).setPointerCapture(e.pointerId);
- setDrag({ kind: "create", day: days[at.column], column: at.column, from, to: from + 15 });
+ /*
+ * A drag is followed from the window, not from the grid, and it ends on whichever comes
+ * first: the button's release, a move with no button held, the window losing focus, or
+ * Escape. In the app's WebKitGTK the release did not always reach the grid — a click left a
+ * sliver of "New Event" behind that then grew with every move of the mouse — so a release
+ * that never arrives is inferred from the next move, where the buttons say it is up.
+ */
+ const dragRef = useRef<Drag | null>(null);
+ const setDragNow = (d: Drag | null) => {
+ dragRef.current = d;
+ setDrag(d);
};
- const onPointerMove = (e: React.PointerEvent) => {
- if (!drag) return;
- const at = where(e.clientX, e.clientY);
- if (!at) return;
- if (drag.kind === "create") {
- setDrag({ ...drag, to: Math.max(drag.from + 15, snap(at.minutes)) });
+ const follow = (clientX: number, clientY: number) => {
+ const current = dragRef.current;
+ const at = where(clientX, clientY);
+ if (!current || !at) return;
+ if (current.kind === "create") {
+ setDragNow({ ...current, to: Math.max(current.from + 15, snap(at.minutes)) });
} else {
const el = columnsEl.current;
const width = el ? el.getBoundingClientRect().width / days.length : 1;
- setDrag({
- ...drag,
- dx: Math.round((e.clientX - drag.startX) / width),
- dMinutes: snap(((e.clientY - drag.startY) / HOUR) * 60),
+ setDragNow({
+ ...current,
+ dx: Math.round((clientX - current.startX) / width),
+ dMinutes: snap(((clientY - current.startY) / HOUR) * 60),
});
}
};
- const onPointerUp = (e: React.PointerEvent) => {
- if (!drag) return;
- const done = drag;
- setDrag(null);
+ const finish = (clientX: number, clientY: number) => {
+ const done = dragRef.current;
+ if (!done) return;
+ setDragNow(null);
if (done.kind === "create") {
// A click on empty time does nothing, as in Calendar — only a drag or a double-click
// makes an event, so looking around the week never opens a form by accident.
if (done.to - done.from > 15) {
const base = seconds(done.day);
- onCreate(base + done.from * 60, base + done.to * 60, false, besideColumn(done.column, e.clientY));
+ onCreate(base + done.from * 60, base + done.to * 60, false, besideColumn(done.column, clientY));
}
} else if (done.dx !== 0 || done.dMinutes !== 0) {
const shift = done.dMinutes * 60;
- const moved = (s: number) => {
- const d = dateOf(s + shift);
+ const moved = (t: number) => {
+ const d = dateOf(t + shift);
return seconds(new Date(d.getFullYear(), d.getMonth(), d.getDate() + done.dx, d.getHours(), d.getMinutes()));
};
onMove(done.event, moved(done.event.startsAt), moved(done.event.endsAt));
} else {
- onOpen(done.event, { x: e.clientX, y: e.clientY });
+ onOpen(done.event, { x: clientX, y: clientY });
}
};
+ // The newest handlers, for listeners attached once per drag.
+ const handlers = useRef({ follow, finish });
+ handlers.current = { follow, finish };
+ const dragging = drag !== null;
+ useEffect(() => {
+ if (!dragging) return undefined;
+ const move = (e: PointerEvent) => {
+ if (e.buttons === 0) handlers.current.finish(e.clientX, e.clientY);
+ else handlers.current.follow(e.clientX, e.clientY);
+ };
+ const up = (e: PointerEvent | MouseEvent) => handlers.current.finish(e.clientX, e.clientY);
+ const drop = () => setDragNow(null);
+ const key = (e: KeyboardEvent) => e.key === "Escape" && drop();
+ window.addEventListener("pointermove", move);
+ window.addEventListener("pointerup", up);
+ window.addEventListener("mouseup", up);
+ window.addEventListener("pointercancel", drop);
+ window.addEventListener("blur", drop);
+ window.addEventListener("keydown", key);
+ return () => {
+ window.removeEventListener("pointermove", move);
+ window.removeEventListener("pointerup", up);
+ window.removeEventListener("mouseup", up);
+ window.removeEventListener("pointercancel", drop);
+ window.removeEventListener("blur", drop);
+ window.removeEventListener("keydown", key);
+ };
+ }, [dragging]);
+
+ const onColumnDown = (e: React.PointerEvent) => {
+ if (e.button !== 0 || (e.target as HTMLElement).closest(".cx-block")) return;
+ const at = where(e.clientX, e.clientY);
+ if (!at) return;
+ // No text selection or native drag while making an event.
+ e.preventDefault();
+ const from = snap(at.minutes) - (snap(at.minutes) === 24 * 60 ? 15 : 0);
+ setDragNow({ kind: "create", day: days[at.column], column: at.column, from, to: from + 15 });
+ };
+
const nowMinutes = today.getHours() * 60 + today.getMinutes();
const todayColumn = days.findIndex((d) => sameDay(d, today));
@@ -971,8 +1014,6 @@ function TimeGrid({
ref={columnsEl}
style={{ "--cols": days.length } as React.CSSProperties}
onPointerDown={onColumnDown}
- onPointerMove={onPointerMove}
- onPointerUp={onPointerUp}
onDoubleClick={(e) => {
if ((e.target as HTMLElement).closest(".cx-block")) return;
const at = where(e.clientX, e.clientY);
@@ -981,7 +1022,6 @@ function TimeGrid({
const base = seconds(days[at.column]);
onCreate(base + start * 60, base + (start + 60) * 60, false, besideColumn(at.column, e.clientY));
}}
- onPointerCancel={() => setDrag(null)}
>
{days.map((d, column) => (
<div className={`cx-column${d.getDay() === 0 || d.getDay() === 6 ? " is-weekend" : ""}`} key={dayKey(d)}>
@@ -1004,9 +1044,9 @@ function TimeGrid({
onPointerDown={(e) => {
if (e.button !== 0) return;
e.stopPropagation();
- (e.currentTarget.closest(".cx-columns") as HTMLElement | null)?.setPointerCapture(e.pointerId);
+ e.preventDefault();
if (canWrite(p.event.calendarGuid)) {
- setDrag({ kind: "move", event: p.event, startX: e.clientX, startY: e.clientY, dx: 0, dMinutes: 0 });
+ setDragNow({ kind: "move", event: p.event, startX: e.clientX, startY: e.clientY, dx: 0, dMinutes: 0 });
} else {
onOpen(p.event, { x: e.clientX, y: e.clientY });
}
diff --git a/src/styles/calendar.css b/src/styles/calendar.css
index 0511c74..6edf75f 100644
--- a/src/styles/calendar.css
+++ b/src/styles/calendar.css
@@ -438,6 +438,8 @@
pointer-events: none;
}
.cx-reminder.is-done { color: var(--text-3); text-decoration: line-through; }
+/* Above the line for now, on a backing of its own, so the line never runs through a title. */
+.cx-reminder { z-index: 3; right: auto; max-width: calc(100% - 8px); padding: 0 6px 0 2px; border-radius: 4px; background: var(--bg); }
/* Now: a red line across today with a dot at its start. */
.cx-now {