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: reminders at the same time stack, and now never covers an hour label

Yashwanth Kamireddi93b88cb17d4f
diff --git a/.uiverify/calendar.mjs b/.uiverify/calendar.mjs
new file mode 100644
index 0000000..d8f89ca
--- /dev/null
+++ b/.uiverify/calendar.mjs
@@ -0,0 +1,55 @@
+// Calendar's Day and Week grids, checked in a real browser.
+import { chromium } from "playwright";
+
+const b = await chromium.launch();
+const ctx = await b.newContext({ viewport: { width: 1280, height: 900 } });
+// The moment of the screenshot this came from: 9:51 PM, so "now" sits just above 10 PM.
+await ctx.addInitScript(() => {
+ const today = new Date(2026, 8, 29, 21, 51).getTime();
+ const at = (h, m = 0) => Math.floor(new Date(2026, 8, 29, h, m).getTime() / 1000);
+ const r = (guid, title, due) => ({ guid, listGuid: "L", title, notes: null, dueAt: due, completedAt: null,
+ priority: 0, flagged: false, parentGuid: null, recurFrequency: null, recurInterval: null, etag: null });
+ window.__fixedNow = today;
+ window.__TAURI_INTERNALS__ = {
+ transformCallback: (cb) => cb,
+ invoke: async (cmd) => {
+ if (cmd === "auth_status") return { hasStoredSession: true, signedIn: true };
+ if (cmd === "auth_resume") return true;
+ if (cmd === "account_services") return ["calendar"];
+ if (cmd === "calendar_list") return [{ guid: "c", title: "Home", colour: "#0088FF", ctag: null, sortOrder: 0, enabled: true, writable: true, isDefault: true }];
+ if (cmd === "calendar_events") return [];
+ if (cmd === "reminders_due_between") return [r("a", "Pick up the parcel", at(8)), r("b", "Water the plants", at(8))];
+ if (cmd === "calendar_sync") return { calendars: 1, events: 0 };
+ if (cmd === "sync_all" || cmd === "sync_status") return { services: [], asOf: 1, tookMs: 0 };
+ if (cmd === "plugin:event|listen") return 0;
+ return [];
+ },
+ };
+});
+const page = await ctx.newPage();
+await page.clock.setFixedTime(new Date(2026, 8, 29, 21, 51));
+await page.goto("http://localhost:4173", { waitUntil: "networkidle" });
+await page.getByRole("button", { name: "Day", exact: true }).click();
+await page.waitForSelector(".cal-hours.is-day");
+await page.waitForTimeout(300);
+
+let failures = 0;
+const ok = (pass, yes, no) => { console.log(pass ? `PASS ${yes}` : `FAIL ${no}`); if (!pass) failures++; };
+
+const boxes = await page.locator(".cx-reminder").evaluateAll((els) =>
+ els.map((e) => { const r = e.getBoundingClientRect(); return [r.top, r.bottom]; }));
+const apart = boxes.length === 2 && (boxes[0][1] <= boxes[1][0] || boxes[1][1] <= boxes[0][0]);
+ok(apart, "two reminders due at the same time are stacked, not drawn over each other",
+ `the reminders at 8 overlap: ${JSON.stringify(boxes)}`);
+
+const covered = await page.evaluate(() => {
+ const now = document.querySelector(".cx-now-label")?.getBoundingClientRect();
+ if (!now) return ["no now label"];
+ return [...document.querySelectorAll(".cx-hour-labels span:not(.cx-now-label)")]
+ .filter((s) => { const r = s.getBoundingClientRect(); return r.bottom > now.top && r.top < now.bottom; })
+ .map((s) => s.textContent);
+});
+ok(covered.length === 0, "the time of now never sits over an hour's label", `now covers ${JSON.stringify(covered)}`);
+
+await b.close();
+process.exitCode = failures === 0 ? 0 : 1;
diff --git a/check.sh b/check.sh
index 288ca91..96d6412 100755
--- a/check.sh
+++ b/check.sh
@@ -36,6 +36,7 @@ step "somewhere else" node .uiverify/elsewhere.mjs
step "writing a note" node .uiverify/notes-compose.mjs
step "deleting a note" node .uiverify/notes-trash.mjs
step "uploading" node .uiverify/drive-upload.mjs
+step "calendar grids" node .uiverify/calendar.mjs
printf '\n'
if [ "$fail" -eq 0 ]; then printf '\033[32mAll checks passed.\033[0m\n'; else printf '\033[31mSome checks failed.\033[0m\n'; fi
diff --git a/src/screens/calendar/CalendarView.tsx b/src/screens/calendar/CalendarView.tsx
index e70ec85..34ae941 100644
--- a/src/screens/calendar/CalendarView.tsx
+++ b/src/screens/calendar/CalendarView.tsx
@@ -920,7 +920,9 @@ function TimeGrid({
<div className="cx-hours-body" style={{ height: `${24 * HOUR}px` }}>
<div className="cx-gutter cx-hour-labels" aria-hidden="true">
{Array.from({ length: 24 }, (_, h) =>
- h === 0 ? null : (
+ // An hour the red "now" label sits over is left out, as Calendar does, rather
+ // than drawn underneath it.
+ h === 0 || (todayColumn >= 0 && Math.abs(h * 60 - nowMinutes) < 12) ? null : (
<span key={h} style={{ top: `${h * HOUR}px` }}>
{hourLabel(h)}
</span>
@@ -982,13 +984,12 @@ function TimeGrid({
</button>
);
})}
- {reminders
- .filter((r) => r.dueAt !== null && sameDay(dateOf(r.dueAt), d))
- .map((r) => (
+ {stackReminders(reminders.filter((r) => r.dueAt !== null && sameDay(dateOf(r.dueAt), d)))
+ .map(({ reminder: r, top }) => (
<span
key={r.guid}
className={`cx-reminder${r.completedAt ? " is-done" : ""}`}
- style={{ top: `${(((dateOf(r.dueAt ?? 0).getHours() * 60 + dateOf(r.dueAt ?? 0).getMinutes()) / 60) * HOUR)}px` }}
+ style={{ top: `${top}px` }}
>
<span className="cx-ring" aria-hidden="true" />
{r.title}
@@ -1022,6 +1023,23 @@ function TimeGrid({
);
}
+/**
+ * Where each reminder sits on a day's hour grid. Two due at the same time — a morning routine
+ * set for eight — stack one under the other instead of being drawn over each other.
+ */
+export function stackReminders(list: Reminder[]): { reminder: Reminder; top: number }[] {
+ const LINE = 18;
+ const sorted = [...list].sort((a, b) => (a.dueAt ?? 0) - (b.dueAt ?? 0) || a.title.localeCompare(b.title));
+ let lastBottom = -Infinity;
+ return sorted.map((reminder) => {
+ const at = dateOf(reminder.dueAt ?? 0);
+ const wanted = ((at.getHours() * 60 + at.getMinutes()) / 60) * HOUR;
+ const top = Math.max(wanted, lastBottom);
+ lastBottom = top + LINE;
+ return { reminder, top };
+ });
+}
+
const pointOf = (el: Element): Anchor => {
const r = el.getBoundingClientRect();
return { x: r.right, y: r.top };