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: Repeat in the event editor — Never, every day, week, month or year — read from Apple on open and written only when changed; a repeat is the series', so changing it from an occurrence is for all of it; verified live

Yashwanth Kamireddi60f1dfc2fec3
diff --git a/.uiverify/calendar-repeat.mjs b/.uiverify/calendar-repeat.mjs
index 16dbfaa..bcbf13f 100644
--- a/.uiverify/calendar-repeat.mjs
+++ b/.uiverify/calendar-repeat.mjs
@@ -53,5 +53,27 @@ await page.getByRole("button", { name: "All Events", exact: true }).click();
await page.waitForTimeout(300);
const all = await page.evaluate(() => window.__eventSaves?.at(-1));
ok(all?.scope === "all", `and "all events" sends the change for the series ${JSON.stringify({ s: all?.scope })}`);
+// Repeat: an occurrence shows its series' repeat; a one-off can be made to repeat.
+await page.locator(".cx-block", { hasText: "Weekly" }).first().click();
+await page.waitForTimeout(300);
+ok(/Every Week/.test(await page.getByRole("button", { name: "Repeat", exact: true }).innerText()), "an occurrence shows how its series repeats");
+await page.keyboard.press("Escape");
+await page.locator(".cx-block", { hasText: "Dentist" }).first().click();
+await page.waitForTimeout(300);
+await page.getByRole("button", { name: "Repeat", exact: true }).click();
+await page.getByRole("option", { name: "Every Day" }).click();
+await page.locator('input[placeholder="New Event"]').first().press("Enter");
+await page.waitForTimeout(300);
+const daily = await page.evaluate(() => window.__eventSaves?.at(-1));
+ok(daily?.repeatChanged === true && daily?.repeat?.freq === "daily" && !daily?.scope, `a one-off made to repeat every day ${JSON.stringify({ r: daily?.repeat, c: daily?.repeatChanged })}`);
+// Stopping a series from repeating is a change to all of it — no question needed.
+await page.locator(".cx-block", { hasText: "Weekly" }).first().click();
+await page.waitForTimeout(300);
+await page.getByRole("button", { name: "Repeat", exact: true }).click();
+await page.getByRole("option", { name: "Never" }).click();
+await page.locator('input[placeholder="New Event"]').first().press("Enter");
+await page.waitForTimeout(300);
+const never = await page.evaluate(() => window.__eventSaves?.at(-1));
+ok(never?.scope === "all" && never?.repeat === null && (await page.getByRole("alertdialog").count()) === 0, `a series set to Never, for all of it ${JSON.stringify({ s: never?.scope, r: never?.repeat })}`);
await b.close();
process.exitCode = failures ? 1 : 0;
diff --git a/.uiverify/stub.mjs b/.uiverify/stub.mjs
index fa406a6..a603c1b 100644
--- a/.uiverify/stub.mjs
+++ b/.uiverify/stub.mjs
@@ -144,6 +144,7 @@ export function installStub({ screen, services, twoFactor, calendarFixture, note
.sort((a, b) => a.startsAt - b.startsAt);
}
case "calendar_list": return calendars;
+ case "event_repeat": return String(args.guid).startsWith("SERIES__") ? { freq: "weekly", interval: 1, count: null } : null;
case "event_alerts": return args.guid === "e2" ? [15] : [];
case "event_save": (window.__eventSaves ??= []).push(args.draft); return "E-new";
case "event_delete": (window.__eventDeletes ??= []).push(args); return null;
diff --git a/crates/quince-icloud/src/calendar.rs b/crates/quince-icloud/src/calendar.rs
index a4d8fd8..de146cf 100644
--- a/crates/quince-icloud/src/calendar.rs
+++ b/crates/quince-icloud/src/calendar.rs
@@ -669,6 +669,27 @@ impl<'a> CalendarClient<'a> {
.and_then(event_of))
}
+ /// How an event repeats, as Apple holds it, or `None` for a one-off.
+ pub async fn repeat_of(&self, event: &Event) -> Result<Option<EventRepeat>> {
+ let day = day_of(event.starts_at, event_zone(event).as_deref());
+ let Some(body) = self.event_detail_body(event, &day).await? else {
+ return Ok(None);
+ };
+ Ok(body
+ .get("Recurrence")
+ .and_then(Value::as_array)
+ .into_iter()
+ .flatten()
+ .find(|r| belongs_to(r, &event.guid))
+ .and_then(|r| {
+ Some(EventRepeat {
+ freq: r.get("freq")?.as_str()?.to_string(),
+ interval: r.get("interval").and_then(Value::as_i64).unwrap_or(1),
+ count: r.get("count").and_then(Value::as_i64),
+ })
+ }))
+ }
+
/// An event's alerts as Apple holds them: minutes before its start, `0` at its time.
pub async fn alerts(&self, event: &Event) -> Result<Vec<i64>> {
let day = day_of(event.starts_at, event_zone(event).as_deref());
diff --git a/crates/quince-icloud/src/sync.rs b/crates/quince-icloud/src/sync.rs
index 8f43ccc..b7caa1c 100644
--- a/crates/quince-icloud/src/sync.rs
+++ b/crates/quince-icloud/src/sync.rs
@@ -156,10 +156,11 @@ pub async fn save_event(
ctag: Option<&str>,
event: &quince_core::calendar::Event,
) -> Result<Vec<quince_core::calendar::Event>> {
- save_event_with_alerts(http, root, params, ctag, event, None, None).await
+ save_event_with_alerts(http, root, params, ctag, event, None, None, None).await
}
/// [`save_event`], with the event's alerts set to `alerts` when given.
+#[allow(clippy::too_many_arguments)]
pub async fn save_event_with_alerts(
http: &reqwest::Client,
root: &str,
@@ -167,11 +168,12 @@ pub async fn save_event_with_alerts(
ctag: Option<&str>,
event: &quince_core::calendar::Event,
alerts: Option<&[i64]>,
+ repeat: Option<Option<&crate::calendar::EventRepeat>>,
scope: Option<crate::calendar::Scope>,
) -> Result<Vec<quince_core::calendar::Event>> {
let client = CalendarClient::new(http, root, params);
let answer = client
- .put_event_full(event, ctag, alerts, None, scope)
+ .put_event_full(event, ctag, alerts, repeat, scope)
.await?;
// What goes into the library is what Apple holds, never what was sent. Measured: a save
// to the account answers with an empty list, and storing the sent copy instead kept an
diff --git a/probe/examples/calendar_repeat_off.rs b/probe/examples/calendar_repeat_off.rs
new file mode 100644
index 0000000..04c7b3d
--- /dev/null
+++ b/probe/examples/calendar_repeat_off.rs
@@ -0,0 +1,89 @@
+//! Live, throwaway event only: a weekly series set to Never from one of its occurrences,
+//! counted before and after, then deleted.
+use anyhow::{anyhow, Result};
+use serde_json::Value;
+#[tokio::main]
+async fn main() -> Result<()> {
+ 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("calendar")
+ .ok_or_else(|| anyhow!("no calendar"))?;
+ let (http, p) = (client.http().clone(), client.service_params());
+ let cal = quince_icloud::calendar::CalendarClient::new(&http, &root, p.clone());
+ let snap = cal
+ .startup("2026-10-01", "2026-10-31", "Asia/Kolkata")
+ .await?;
+ let home = snap
+ .calendars
+ .iter()
+ .find(|c| c.writable)
+ .ok_or_else(|| anyhow!("no writable calendar"))?;
+ let event = quince_core::calendar::Event {
+ guid: uuid::Uuid::new_v4().to_string().to_uppercase(),
+ calendar_guid: home.guid.clone(),
+ title: "Quince never test".into(),
+ starts_at: 1_793_000_000,
+ ends_at: 1_793_003_600,
+ timezone: Some("Asia/Kolkata".into()),
+ ..Default::default()
+ };
+ let rule = quince_icloud::calendar::EventRepeat {
+ freq: "weekly".into(),
+ interval: 1,
+ count: Some(3),
+ };
+ cal.put_event_full(&event, None, None, Some(Some(&rule)), None)
+ .await?;
+ let count = || async {
+ let mut q = p.clone();
+ for (k, v) in [
+ ("clientVersion", "5.1"),
+ ("requestID", "4"),
+ ("lang", "en-us"),
+ ("usertz", "Asia/Kolkata"),
+ ("startDate", "2026-10-26"),
+ ("endDate", "2026-11-25"),
+ ] {
+ q.push((k.into(), v.into()));
+ }
+ let b: Value = http
+ .get(format!("{}/ca/events", root.trim_end_matches('/')))
+ .query(&q)
+ .send()
+ .await?
+ .json()
+ .await?;
+ Ok::<usize, anyhow::Error>(
+ b["Event"]
+ .as_array()
+ .into_iter()
+ .flatten()
+ .filter(|e| {
+ e["title"]
+ .as_str()
+ .is_some_and(|t| t.starts_with("Quince never test"))
+ })
+ .count(),
+ )
+ };
+ println!("before: {} occurrences", count().await?);
+ let mut first = event.clone();
+ first.guid = format!("{}__20261026T073300Z", event.guid);
+ cal.put_event_full(
+ &first,
+ None,
+ None,
+ Some(None),
+ Some(quince_icloud::calendar::Scope::All),
+ )
+ .await?;
+ println!("after Never: {} occurrence(s)", count().await?);
+ cal.delete_event(&event, None).await.ok();
+ println!("left after delete: {}", count().await?);
+ Ok(())
+}
diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs
index 0568d25..0dab3a9 100644
--- a/src-tauri/src/main.rs
+++ b/src-tauri/src/main.rs
@@ -376,6 +376,12 @@ struct EventDraft {
/// For one occurrence of a repeating event: which events the change is for.
#[serde(default)]
scope: Option<quince_icloud::calendar::Scope>,
+ /// Set the repeat to this — `None` for never — when `repeat_changed`; otherwise the event
+ /// keeps the repeat Apple holds.
+ #[serde(default)]
+ repeat: Option<quince_icloud::calendar::EventRepeat>,
+ #[serde(default)]
+ repeat_changed: bool,
}
/// Everything an event write needs from the session, with the auth lock released first.
@@ -415,6 +421,25 @@ async fn event_alerts(
.map_err(|e| e.to_string())
}
+/// How an event repeats, as Apple holds it.
+#[tauri::command]
+async fn event_repeat(
+ guid: String,
+ auth: State<'_, Auth>,
+ data: State<'_, Data>,
+) -> UiResult<Option<quince_icloud::calendar::EventRepeat>> {
+ let event = {
+ let library = data.0.lock().await;
+ library.event(&guid).map_err(|e| e.to_string())?
+ };
+ let Some(event) = event else { return Ok(None) };
+ let (http, root, params) = calendar_context(&auth).await?;
+ quince_icloud::calendar::CalendarClient::new(&http, &root, params)
+ .repeat_of(&event)
+ .await
+ .map_err(|e| e.to_string())
+}
+
#[tauri::command]
async fn event_save(
draft: EventDraft,
@@ -463,6 +488,7 @@ async fn event_save(
ctag.as_deref(),
&event,
draft.alerts.as_deref(),
+ draft.repeat_changed.then_some(draft.repeat.as_ref()),
draft.scope,
)
.await
@@ -2449,6 +2475,7 @@ fn main() {
calendar_events,
event_save,
event_alerts,
+ event_repeat,
event_delete,
calendar_list,
calendar_search,
diff --git a/src/lib/ipc.ts b/src/lib/ipc.ts
index 12c7464..133f462 100644
--- a/src/lib/ipc.ts
+++ b/src/lib/ipc.ts
@@ -75,6 +75,7 @@ export const api = {
eventSave: (draft: EventWrite) => invoke<string>("event_save", { draft }),
eventAlerts: (guid: string) => invoke<number[]>("event_alerts", { guid }),
+ eventRepeat: (guid: string) => invoke<EventRepeat | null>("event_repeat", { guid }),
eventDelete: (guid: string, scope?: "this" | "all") => invoke<void>("event_delete", { guid, scope: scope ?? null }),
calendarSync: (from: string, to: string, timezone: string) =>
invoke<SyncSummary>("calendar_sync", { from, to, timezone }),
@@ -228,10 +229,16 @@ export type EventWrite = {
/** Set the alerts to exactly these minutes before the start (0 at the time); left out,
* the event keeps the alerts Apple holds. */
alerts?: number[];
+ /** Set the repeat to this (null: never) when `repeatChanged`; otherwise it is left as it is. */
+ repeat?: EventRepeat | null;
+ repeatChanged?: boolean;
/** For one occurrence of a repeating event: whether the change is for it alone or the series. */
scope?: "this" | "all";
};
+/** How an event repeats, in icloud.com's words. */
+export type EventRepeat = { freq: "daily" | "weekly" | "monthly" | "yearly"; interval: number; count: number | null };
+
export type CalendarEvent = {
guid: string;
calendarGuid: string;
diff --git a/src/screens/calendar/CalendarView.tsx b/src/screens/calendar/CalendarView.tsx
index 0bab93f..cae8b99 100644
--- a/src/screens/calendar/CalendarView.tsx
+++ b/src/screens/calendar/CalendarView.tsx
@@ -4,6 +4,7 @@ import { TimeField } from "../../components/TimeField";
import { Search } from "lucide-react";
import { createContext, Fragment, useCallback, useContext, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
import {
+ type EventRepeat,
api,
defaultCalendar,
messageOf,
@@ -32,6 +33,24 @@ import {
const ZONE = Intl.DateTimeFormat().resolvedOptions().timeZone || "UTC";
+const REPEATS = [
+ { value: "never", label: "Never" },
+ { value: "daily", label: "Every Day" },
+ { value: "weekly", label: "Every Week" },
+ { value: "monthly", label: "Every Month" },
+ { value: "yearly", label: "Every Year" },
+];
+function repeatKey(r: EventRepeat | null): string {
+ if (!r) return "never";
+ return r.interval === 1 && r.count === null ? r.freq : "custom";
+}
+function repeatText(r: EventRepeat | null): string {
+ if (!r) return "Never";
+ const unit = { daily: "day", weekly: "week", monthly: "month", yearly: "year" }[r.freq];
+ const every = r.interval === 1 ? `Every ${unit}` : `Every ${r.interval} ${unit}s`;
+ return r.count ? `${every}, ${r.count} times` : every;
+}
+
/** icloud.com's alert presets, minutes before the start; an all-day event's are by the day. */
const ALERTS = [
{ minutes: 0, label: "At time of event" },
@@ -113,6 +132,9 @@ type Draft = {
alerts?: number[];
/** Whether the alerts were changed here, and so are to be written. */
alertsChanged?: boolean;
+ /** How it repeats; `undefined` until read from Apple, `null` for never. */
+ repeat?: EventRepeat | null;
+ repeatChanged?: boolean;
};
/**
@@ -390,7 +412,8 @@ export function CalendarView() {
const save = useCallback(
async (d: Draft) => {
const occurrence = Boolean(d.guid && d.guid.includes("__"));
- const scope = occurrence ? await whichEvents("change") : null;
+ // A repeat belongs to the series, so changing it is a change to all of it.
+ const scope = occurrence ? (d.repeatChanged ? "all" : await whichEvents("change")) : null;
if (occurrence && !scope) return false;
return write(async () => {
await api.eventSave({
@@ -406,6 +429,7 @@ export function CalendarView() {
notes: d.notes.trim() || null,
url: d.url?.trim() || null,
...(d.alertsChanged && d.alerts ? { alerts: d.alerts } : {}),
+ ...(d.repeatChanged ? { repeat: d.repeat ?? null, repeatChanged: true } : {}),
});
}, (rows) => {
// Shown where it now sits at once; a new one is drawn by its draft until Apple names it.
@@ -457,7 +481,7 @@ export function CalendarView() {
}, [undo]);
const openDraft = (d: Draft, at: Anchor) => {
- setDraft(d.guid ? d : { ...d, alerts: [] });
+ setDraft(d.guid ? d : { ...d, alerts: [], repeat: null });
setAnchor(at);
const guid = d.guid;
if (guid && !guid.startsWith("quince:")) {
@@ -465,6 +489,10 @@ export function CalendarView() {
(alerts) => setDraft((cur) => (cur && cur.guid === guid && !cur.alertsChanged ? { ...cur, alerts } : cur)),
() => {},
);
+ api.eventRepeat(guid).then(
+ (repeat) => setDraft((cur) => (cur && cur.guid === guid && !cur.repeatChanged ? { ...cur, repeat } : cur)),
+ () => {},
+ );
}
};
const newAt = (startsAt: number, endsAt: number, allDay: boolean, at: Anchor) => {
@@ -1852,6 +1880,24 @@ function EventPopover({
</div>
);
})}
+ {/* Repeat, icloud.com's simple choices; a schedule it has no name for is shown as is. */}
+ <div className="cx-pop-row cal-field">
+ <span>repeat</span>
+ <Picker
+ label="Repeat"
+ value={draft.repeat === undefined ? "loading" : repeatKey(draft.repeat)}
+ disabled={!editable || draft.repeat === undefined}
+ onChange={(v) => set({ repeat: v === "never" ? null : { freq: v as EventRepeat["freq"], interval: 1, count: null }, repeatChanged: true })}
+ options={
+ draft.repeat === undefined
+ ? [{ value: "loading", label: "…" }]
+ : [
+ ...REPEATS,
+ ...(repeatKey(draft.repeat) === "custom" ? [{ value: "custom", label: repeatText(draft.repeat) }] : []),
+ ]
+ }
+ />
+ </div>
</div>
<input
className="cx-pop-line"