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.

Drive items can be moved between folders

Yashwanth Kamireddi715508168937
diff --git a/.uiverify/a11y.mjs b/.uiverify/a11y.mjs
index 822bc11..6720bed 100644
--- a/.uiverify/a11y.mjs
+++ b/.uiverify/a11y.mjs
@@ -10,7 +10,7 @@ const SERVICES = ["account","archivews","calendar","ckdatabasews","ckdeviceservi
"premiummailsettings","push","reminders","settings","sharedlibrary",
"sharedstreams","ubiquity","uploadimagews"];
-function installStub({ screen, services, twoFactor }) {
+function installStub({ screen, services, twoFactor, driveItems = [] }) {
window.__TAURI_INTERNALS__ = {
transformCallback: (cb) => cb,
invoke: async (cmd) => {
@@ -48,7 +48,7 @@ function installStub({ screen, services, twoFactor }) {
case "contacts_list": return [];
case "contacts_last_synced": return Math.floor(Date.now() / 1000);
case "contacts_sync": return 0;
- case "drive_children": return [];
+ case "drive_children": return driveItems;
case "drive_sync_folder": return 0;
case "drive_download": return "/home/user/Downloads/file.pdf";
case "drive_create_folder": case "drive_rename": case "drive_delete": case "drive_move": return null;
@@ -93,18 +93,34 @@ const screens = [
await p.waitForSelector(".sidebar .nav-item");
await p.click(".nav-toggle"); // audit the expanded state too
} },
+ { name: "drive-move", screen: "library", driveItems: [
+ { drivewsid: "FOLDER::a", parentId: null, name: "Downloads", extension: null,
+ kind: "FOLDER", size: null, childCount: 3, createdAt: 1785000000,
+ modifiedAt: 1788000000, etag: null },
+ ], act: async (p) => {
+ await p.click('.nav-item:has-text("iCloud Drive")');
+ await p.waitForSelector(".drive-row-hit");
+ await p.hover(".drive-row.is-folder");
+ await p.click('.drive-row.is-folder .rem-list-action[aria-label^="Move"]');
+ await p.waitForSelector(".modal-sheet");
+ } },
];
const browser = await chromium.launch();
let total = 0;
for (const theme of ["light", "dark"]) {
- for (const { name, screen, act } of screens) {
+ for (const { name, screen, act, driveItems } of screens) {
const ctx = await browser.newContext({
viewport: { width: 1040, height: 800 },
colorScheme: theme,
});
- await ctx.addInitScript(installStub, { screen, services: SERVICES, twoFactor: TWO_FACTOR });
+ await ctx.addInitScript(installStub, {
+ screen,
+ services: SERVICES,
+ twoFactor: TWO_FACTOR,
+ driveItems: driveItems ?? [],
+ });
const page = await ctx.newPage();
await page.goto("http://localhost:4173", { waitUntil: "networkidle" });
if (act) await act(page);
diff --git a/.uiverify/keyboard.mjs b/.uiverify/keyboard.mjs
index 8c2eb83..c1fdd15 100644
--- a/.uiverify/keyboard.mjs
+++ b/.uiverify/keyboard.mjs
@@ -61,7 +61,11 @@ function installStub({ screen, services, twoFactor }) {
case "contacts_list": return [];
case "contacts_last_synced": return Math.floor(Date.now() / 1000);
case "contacts_sync": return 0;
- case "drive_children": return [];
+ case "drive_children": return [
+ { drivewsid: "FOLDER::a", parentId: null, name: "Downloads", extension: null,
+ kind: "FOLDER", size: null, childCount: 3, createdAt: 1785000000,
+ modifiedAt: 1788000000, etag: null },
+ ];
case "drive_sync_folder": return 0;
case "drive_download": return "/home/user/Downloads/file.pdf";
case "drive_create_folder": case "drive_rename": case "drive_delete": case "drive_move": return null;
@@ -255,6 +259,32 @@ const focused = (page) =>
await ctx.close();
}
+// --- Drive's Move dialog: Escape closes it, focus starts inside it ---
+{
+ const { ctx, page } = await open("library");
+ await page.click('.nav-item:has-text("iCloud Drive")');
+ await page.waitForSelector(".drive-row-hit");
+ await page.hover(".drive-row.is-folder");
+ await page.click('.drive-row.is-folder .rem-list-action[aria-label^="Move"]');
+ await page.waitForSelector(".modal-sheet");
+
+ // The focus move is deliberately a tick after mount (it has to win a race against the
+ // browser's own "focus the button that was clicked" behavior), so the test waits for the
+ // eventual state rather than asserting the instant after the dialog appears.
+ const startsInside = await page
+ .waitForFunction(() => document.activeElement?.closest(".modal-sheet") !== null, {
+ timeout: 1000,
+ })
+ .then(() => true)
+ .catch(() => false);
+ check("Move dialog starts with focus inside it", startsInside);
+
+ await page.keyboard.press("Escape");
+ const closed = (await page.locator(".modal-sheet").count()) === 0;
+ check("Escape closes the Move dialog", closed);
+ await ctx.close();
+}
+
await browser.close();
let failed = 0;
for (const c of checks) {
diff --git a/.uiverify/shots.mjs b/.uiverify/shots.mjs
index 246fb31..ae04713 100644
--- a/.uiverify/shots.mjs
+++ b/.uiverify/shots.mjs
@@ -272,6 +272,14 @@ const shots = [
{ name: "17-calendar-wide", screen: "library", theme: "dark", calendarFixture: true,
viewport: { width: 1920, height: 1080 },
act: async (p) => { await p.waitForSelector(".cal-grid"); } },
+ { name: "18-drive-move", screen: "library", theme: "dark", driveFixture: true,
+ act: async (p) => {
+ await p.click('.nav-item:has-text("iCloud Drive")');
+ await p.waitForSelector(".drive-row-hit");
+ await p.hover(".drive-row.is-folder");
+ await p.click('.drive-row.is-folder .rem-list-action[aria-label^="Move"]');
+ await p.waitForSelector(".modal-sheet");
+ } },
{ name: "04-library", screen: "library", theme: "light" },
{ name: "05-library-dark", screen: "library", theme: "dark" },
];
diff --git a/crates/quince-icloud/src/drive.rs b/crates/quince-icloud/src/drive.rs
index 47b2550..8899abf 100644
--- a/crates/quince-icloud/src/drive.rs
+++ b/crates/quince-icloud/src/drive.rs
@@ -379,9 +379,15 @@ pub async fn move_to(
.and_then(|i| i.etag.clone())
.or_else(|| item.etag.clone());
+ // Unlike rename and delete, moveItems 400s outright without a clientId on the item —
+ // measured against the real service, not documented anywhere.
let url = format!("{}/moveItems", root.trim_end_matches('/'));
let body = json!({
- "items": [{ "drivewsid": item.drivewsid, "etag": etag }],
+ "items": [{
+ "drivewsid": item.drivewsid,
+ "etag": etag,
+ "clientId": uuid::Uuid::new_v4().to_string(),
+ }],
"destinationDrivewsId": destination_id,
});
@@ -848,6 +854,14 @@ mod write_tests {
body["destinationDrivewsId"],
"FOLDER::com.apple.CloudDocs::DEST"
);
+ // Measured against the real service: moveItems 400s outright with no clientId on
+ // the item, unlike rename or delete, which need none.
+ assert!(
+ body["items"][0]["clientId"]
+ .as_str()
+ .is_some_and(|c| !c.is_empty()),
+ "moveItems requires a clientId per item"
+ );
}
#[tokio::test]
diff --git a/src/screens/DriveView.tsx b/src/screens/DriveView.tsx
index d5f9581..d0ba93a 100644
--- a/src/screens/DriveView.tsx
+++ b/src/screens/DriveView.tsx
@@ -53,6 +53,8 @@ export function DriveView() {
const [renaming, setRenaming] = useState<string | null>(null);
const [creatingFolder, setCreatingFolder] = useState(false);
const [newFolderName, setNewFolderName] = useState("");
+ /** The item a Move dialog is open for, if any. */
+ const [moving, setMoving] = useState<DriveItem | null>(null);
const here = trail[trail.length - 1];
@@ -166,6 +168,23 @@ export function DriveView() {
[refresh]
);
+ const move = useCallback(
+ async (item: DriveItem, destinationId: string) => {
+ setMoving(null);
+ setBusyGuid(item.drivewsid);
+ setError(null);
+ try {
+ await api.driveMove(item.drivewsid, destinationId);
+ await refresh();
+ } catch (e) {
+ setError(messageOf(e));
+ } finally {
+ setBusyGuid(null);
+ }
+ },
+ [refresh]
+ );
+
const createFolder = useCallback(async () => {
const name = newFolderName.trim();
setCreatingFolder(false);
@@ -307,6 +326,14 @@ export function DriveView() {
<span className="drive-meta">{modified(item.modifiedAt ?? item.createdAt)}</span>
</button>
<span className="drive-row-actions">
+ <button
+ className="rem-list-action"
+ aria-label={`Move ${driveName(item)}`}
+ disabled={busy}
+ onClick={() => setMoving(item)}
+ >
+ ⇥
+ </button>
<button
className="rem-list-action"
aria-label={`Rename ${driveName(item)}`}
@@ -334,6 +361,155 @@ export function DriveView() {
{loaded && items.length === 0 && !creatingFolder && !error && (
<p className="cal-empty">This folder is empty.</p>
)}
+
+ {moving && (
+ <MoveDialog
+ item={moving}
+ startingIn={here.id}
+ onCancel={() => setMoving(null)}
+ onMove={(destinationId) => void move(moving, destinationId)}
+ />
+ )}
+ </div>
+ );
+}
+
+/**
+ * Where to move something — a small folder browser of its own, in the same shape Files'
+ * own Move sheet takes: breadcrumbs, folders only, a Move button that names where it will
+ * land. You cannot navigate into the item being moved, which is what stops the one obvious
+ * way to move something inside itself.
+ */
+function MoveDialog({
+ item,
+ startingIn,
+ onCancel,
+ onMove,
+}: {
+ item: DriveItem;
+ startingIn: string;
+ onCancel: () => void;
+ onMove: (destinationId: string) => void;
+}) {
+ const [trail, setTrail] = useState<Crumb[]>([{ id: DRIVE_ROOT, name: "iCloud Drive" }]);
+ const [folders, setFolders] = useState<DriveItem[]>([]);
+ const [loading, setLoading] = useState(false);
+
+ const here = trail[trail.length - 1];
+
+ useEffect(() => {
+ let cancelled = false;
+ setLoading(true);
+ (async () => {
+ try {
+ await api.driveSyncFolder(here.id);
+ const fresh = await api.driveChildren(here.id);
+ if (!cancelled) {
+ setFolders(
+ (Array.isArray(fresh) ? fresh : []).filter(
+ (i) => isContainer(i) && i.drivewsid !== item.drivewsid
+ )
+ );
+ }
+ } catch {
+ if (!cancelled) setFolders([]);
+ } finally {
+ if (!cancelled) setLoading(false);
+ }
+ })();
+ return () => {
+ cancelled = true;
+ };
+ }, [here.id, item.drivewsid]);
+
+ const alreadyHere = here.id === startingIn;
+
+ // A sheet is modal: Escape leaves it exactly as Cancel would, and it must not be possible
+ // to tab out into the page still open underneath.
+ useEffect(() => {
+ const onKey = (e: KeyboardEvent) => {
+ if (e.key === "Escape") onCancel();
+ };
+ document.addEventListener("keydown", onKey);
+ return () => document.removeEventListener("keydown", onKey);
+ }, [onCancel]);
+
+ // JSX autoFocus loses a real race: the click that opened this dialog also gives the
+ // trigger button native focus, and that lands after React's own autoFocus handling —
+ // so a keyboard user who opened this with Enter stayed on the row behind it, in a dialog
+ // that was visually in front but not where their next Tab or Escape would act. Moving
+ // focus explicitly, one tick later, wins the race properly.
+ const cancelRef = useRef<HTMLButtonElement | null>(null);
+ useEffect(() => {
+ const id = window.setTimeout(() => cancelRef.current?.focus(), 0);
+ return () => window.clearTimeout(id);
+ }, []);
+
+ return (
+ <div className="modal-veil" onClick={onCancel}>
+ <div
+ className="modal-sheet move-sheet"
+ role="dialog"
+ aria-label={`Move ${driveName(item)}`}
+ onClick={(e) => e.stopPropagation()}
+ >
+ <h2>Move “{driveName(item)}”</h2>
+
+ <nav className="crumbs" aria-label="Destination folder">
+ {trail.map((crumb, i) => (
+ <span key={crumb.id}>
+ {i > 0 && (
+ <span className="crumb-sep" aria-hidden="true">
+ ›
+ </span>
+ )}
+ <button
+ className="crumb"
+ aria-current={i === trail.length - 1}
+ onClick={() => setTrail((t) => t.slice(0, i + 1))}
+ >
+ {crumb.name}
+ </button>
+ </span>
+ ))}
+ </nav>
+
+ <ul className="move-sheet-list">
+ {loading && <li className="cal-empty">Loading…</li>}
+ {!loading && folders.length === 0 && (
+ <li className="cal-empty">No folders here.</li>
+ )}
+ {!loading &&
+ folders.map((folder) => (
+ <li key={folder.drivewsid}>
+ <button
+ className="drive-row-hit move-sheet-row"
+ onClick={() =>
+ setTrail((t) => [...t, { id: folder.drivewsid, name: driveName(folder) }])
+ }
+ >
+ <span className="drive-badge folder" aria-hidden="true">
+ ▸
+ </span>
+ <span className="drive-name">{driveName(folder)}</span>
+ </button>
+ </li>
+ ))}
+ </ul>
+
+ <div className="cal-form-actions">
+ <button
+ className="primary"
+ disabled={alreadyHere}
+ onClick={() => onMove(here.id)}
+ >
+ Move here
+ </button>
+ <button className="quiet" ref={cancelRef} onClick={onCancel}>
+ Cancel
+ </button>
+ </div>
+ </div>
</div>
);
}
diff --git a/src/styles/app.css b/src/styles/app.css
index 840f616..e0de791 100644
--- a/src/styles/app.css
+++ b/src/styles/app.css
@@ -2081,3 +2081,67 @@ button.cal-day-item:hover { background: color-mix(in srgb, var(--sheet) 92%, var
}
.contact-kind { width: 100%; }
+
+/* ── Modal sheet ────────────────────────────────────────────────────────────────────────
+ The Move dialog is the app's first modal, so this is the shape everything after it will
+ share: a dimmed veil behind a raised sheet, in the macOS sheet's proportions rather than
+ a full-screen dialog. */
+.modal-veil {
+ position: fixed;
+ inset: 0;
+ z-index: 100;
+ display: grid;
+ place-items: center;
+ background: rgba(0, 0, 0, 0.32);
+ -webkit-backdrop-filter: blur(2px);
+ backdrop-filter: blur(2px);
+ animation: modal-veil-in 160ms var(--ease) both;
+}
+
+@keyframes modal-veil-in {
+ from { opacity: 0; }
+ to { opacity: 1; }
+}
+
+.modal-sheet {
+ width: min(440px, 92vw);
+ max-height: min(560px, 84vh);
+ display: flex;
+ flex-direction: column;
+ gap: 12px;
+ padding: 20px 22px;
+ background: var(--sheet);
+ border-radius: var(--r-window);
+ box-shadow: var(--shadow-sheet), 0 0 0 0.5px var(--glass-edge);
+ animation: modal-sheet-in 220ms var(--ease-spring) both;
+}
+
+@keyframes modal-sheet-in {
+ from { opacity: 0; transform: translateY(10px) scale(0.97); }
+ to { opacity: 1; transform: none; }
+}
+
+.modal-sheet h2 {
+ margin: 0;
+ font-size: var(--t-17);
+ font-weight: 600;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+}
+
+.move-sheet-list {
+ flex: 1;
+ min-height: 120px;
+ overflow-y: auto;
+ margin: 0;
+ padding: 0;
+ list-style: none;
+ border: 1px solid var(--separator);
+ border-radius: var(--r-plateau);
+}
+
+.move-sheet-row {
+ grid-template-columns: 28px 1fr;
+ padding: 7px 9px;
+}