Native iCloud apps for Windows and Linux, built in Rust. Notes, Reminders, Calendar, Contacts, Drive and Photos, offline and in sync with your iPhone.
Rust apple-notesapple-reminderscloudkitcrdtdesktop-appicloudicloud-calendaricloud-driveicloud-notesicloud-photosiphonelinuxlinux-desktoplocal-firstoffline-firstprivacyrusttauritauri-appwindows
Drive: sort by Name, Date, Kind or Size, as icloud.com offers it — Finder's name order, folders on top, remembered
Yashwanth Kamireddi8f0101ab20f4
diff --git a/.uiverify/drive-sort.mjs b/.uiverify/drive-sort.mjsnew file mode 100644index 0000000..f4983bc--- /dev/null+++ b/.uiverify/drive-sort.mjs@@ -0,0 +1,54 @@+// Drive's "by Name" menu: Name as Finder orders it ("File 2" before "File 10"), Date and+// Size newest and largest first, folders kept at the top; remembered across visits.+import { engine } from "./engine.mjs";+import { SERVICES, installStub, openScreen } from "./stub.mjs";++const b = await engine.launch();+const ctx = await b.newContext({ viewport: { width: 1200, height: 800 } });+await ctx.addInitScript(installStub, { screen: "library", services: SERVICES, twoFactor: null, driveFixture: true });+await ctx.addInitScript(() => {+ const wrap = () => {+ const t = window.__TAURI_INTERNALS__;+ if (!t || t.__more) return;+ const inner = t.invoke;+ const file = (id, name, size, at) => ({ drivewsid: `FILE::${id}`, parentId: null, name, extension: "txt",+ kind: "FILE", size, childCount: null, createdAt: at, modifiedAt: at, etag: null });+ t.invoke = async (cmd, args) => {+ const out = await inner(cmd, args);+ if (cmd === "drive_children" && Array.isArray(out))+ return [file("z10", "File 10", 10, 1789000000), ...out, file("z2", "File 2", 5000000, 1700000000)];+ return out;+ };+ t.__more = true;+ };+ wrap(); document.addEventListener("DOMContentLoaded", wrap);+});+const page = await ctx.newPage();+await page.goto("http://localhost:4173", { waitUntil: "networkidle" });+await openScreen(page, "iCloud Drive");+await page.waitForTimeout(400);+let failures = 0;+const ok = (p, m) => { console.log(`${p ? "PASS" : "FAIL"} ${m}`); if (!p) failures++; };+const names = () => page.locator(".drive-rows .drive-name").allInnerTexts();+const files = async () => (await names()).filter((n) => !["Downloads", "Keynote", "Shortcuts"].includes(n));+const pick = async (label) => {+ await page.getByRole("button", { name: /Sort by/ }).click();+ await page.getByRole("option", { name: `by ${label}` }).click();+ await page.waitForTimeout(200);+};++const byName = await files();+ok(JSON.stringify(byName) === JSON.stringify(["File 2.txt", "File 10.txt", "Semester Plan.pdf"]), `by Name, as Finder counts ${JSON.stringify(byName)}`);+ok((await names())[0] === "Downloads", "folders stay at the top");+await pick("Size");+const bySize = await files();+ok(JSON.stringify(bySize) === JSON.stringify(["File 2.txt", "Semester Plan.pdf", "File 10.txt"]), `by Size, largest first ${JSON.stringify(bySize)}`);+await pick("Date");+const byDate = await files();+ok(JSON.stringify(byDate) === JSON.stringify(["File 10.txt", "Semester Plan.pdf", "File 2.txt"]), `by Date, newest first ${JSON.stringify(byDate)}`);+await page.reload({ waitUntil: "networkidle" });+await openScreen(page, "iCloud Drive");+await page.waitForTimeout(400);+ok(JSON.stringify(await files()) === JSON.stringify(byDate), "the order chosen is remembered");+await b.close();+process.exitCode = failures ? 1 : 0;diff --git a/check.sh b/check.shindex 97c8caf..b2c5ead 100755--- a/check.sh+++ b/check.sh@@ -52,6 +52,7 @@ step "calendar keys" node .uiverify/calendar-keys.mjsstep "reminders instant" node .uiverify/reminders-instant.mjsstep "calendar instant" node .uiverify/calendar-instant.mjsstep "notes instant" node .uiverify/notes-instant.mjs+step "drive sort" node .uiverify/drive-sort.mjs# The same screens in WebKit, the engine Quince draws in. Chromium above catches most things;# this catches what only WebKit does — pointer capture, blur on removal, its own layout.diff --git a/src/screens/DriveView.tsx b/src/screens/DriveView.tsxindex a412a7d..720516d 100644--- a/src/screens/DriveView.tsx+++ b/src/screens/DriveView.tsx@@ -16,6 +16,36 @@ import {import { ActionGlyph, FileGlyph } from "../components/FileGlyph";import { UploadTray } from "../components/UploadTray";import { listen } from "@tauri-apps/api/event";+import { Picker } from "../components/Picker";++/** iCloud Drive's own four orders, as its "by Name" menu offers them. */+const SORTS = [+ { key: "name", label: "Name" },+ { key: "date", label: "Date" },+ { key: "kind", label: "Kind" },+ { key: "size", label: "Size" },+] as const;+type SortKey = (typeof SORTS)[number]["key"];+const SORT_KEY = "quince.drive.sort";++/**+ * Names compare as Finder compares them — "File 2" before "File 10", case ignored; dates and+ * sizes newest and largest first. Folders keep together at the top under every order but+ * Kind, which is itself the grouping.+ */+const collator = new Intl.Collator(undefined, { numeric: true, sensitivity: "base" });+function sortItems(rows: DriveItem[], by: SortKey): DriveItem[] {+ const name = (a: DriveItem, b: DriveItem) => collator.compare(a.name, b.name);+ const folderFirst = (a: DriveItem, b: DriveItem) => Number(isContainer(b)) - Number(isContainer(a));+ const kindOf = (i: DriveItem) => (isContainer(i) ? " " : (i.extension ?? "").toLowerCase());+ const order: Record<SortKey, (a: DriveItem, b: DriveItem) => number> = {+ name: (a, b) => folderFirst(a, b) || name(a, b),+ date: (a, b) => folderFirst(a, b) || (b.modifiedAt ?? b.createdAt ?? 0) - (a.modifiedAt ?? a.createdAt ?? 0) || name(a, b),+ kind: (a, b) => collator.compare(kindOf(a), kindOf(b)) || name(a, b),+ size: (a, b) => folderFirst(a, b) || (b.size ?? 0) - (a.size ?? 0) || name(a, b),+ };+ return [...rows].sort(order[by]);+}const KB = 1024;@@ -46,6 +76,22 @@ type Crumb = { id: string; name: string };export function DriveView() {const [trail, setTrail] = useState<Crumb[]>([{ id: DRIVE_ROOT, name: "iCloud Drive" }]);const [items, setItems] = useState<DriveItem[]>([]);+ const [sortBy, setSortBy] = useState<SortKey>(() => {+ try {+ const saved = window.localStorage.getItem(SORT_KEY);+ return SORTS.some((o) => o.key === saved) ? (saved as SortKey) : "name";+ } catch {+ return "name";+ }+ });+ const chooseSort = (key: SortKey) => {+ setSortBy(key);+ try {+ window.localStorage.setItem(SORT_KEY, key);+ } catch {+ // Sorted for now; forgotten on restart.+ }+ };const [loading, setLoading] = useState(false);const [loaded, setLoaded] = useState(false);const [error, setError] = useState<string | null>(null);@@ -408,6 +454,13 @@ export function DriveView() {))}</nav><div className="cal-actions">+ <Picker+ className="drive-sort"+ label="Sort by"+ value={sortBy}+ onChange={(v) => chooseSort(v as SortKey)}+ options={SORTS.map((o) => ({ value: o.key, label: `by ${o.label}` }))}+ /><buttonclassName="quiet with-glyph"onClick={() => setCreatingFolder(true)}@@ -506,7 +559,7 @@ export function DriveView() {</li>)}- {items.filter((item) => !gone.has(item.drivewsid)).map((item) => {+ {sortItems(items.filter((item) => !gone.has(item.drivewsid)), sortBy).map((item) => {const container = isContainer(item);const busy = busyGuid === item.drivewsid;return (