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: Download a Copy for folders and selections, shown in one calm line
Yashwanth Kamireddi4f68cebf8026
diff --git a/.uiverify/drive-download-model.test.mjs b/.uiverify/drive-download-model.test.mjsnew file mode 100644index 0000000..0361cda--- /dev/null+++ b/.uiverify/drive-download-model.test.mjs@@ -0,0 +1,111 @@+// How a download into Downloads is counted for the tray: one line for a whole folder, the+// words it shows at each step, what can be gone on with, and a hundred thousand files counted+// without a row each.+import { test } from "node:test";+import assert from "node:assert/strict";+import { NAMED, apply, finish, heading, newLine, pausedLine, view } from "../src/lib/downloadModel.ts";++const ev = (id, state, extra = {}) => ({ id: `b:${id}`, batch: "b", name: `${id}.jpg`, within: "Photos", sent: 0, total: 100, state, folder: false, error: null, ...extra });+const tally = (state, files, bytes) => ({ id: `b:${state}`, batch: "b", name: "", within: "", sent: files, total: bytes, state, folder: true, error: null });+const report = (extra = {}) => ({ key: "k1", saved: ["/home/me/Downloads/Photos"], failed: [], moreFailed: 0, cancelled: false, problem: null, resumable: false, ...extra });+const items = [{ drivewsid: "FOLDER::z::photos", name: "Photos", kind: "FOLDER" }];++test("a folder is one line: counted while it is read, then to a total that will not move", () => {+ const line = newLine("b", "Photos", items);+ assert.equal(view(line).status, "Preparing…");+ apply(line, tally("found", 2, 200));+ assert.equal(view(line).status, "Preparing… 2 found");+ assert.equal(view(line).percent, null, "no total yet, so no percent");+ apply(line, tally("planned", 2, 2_000_000));+ apply(line, ev("big", "downloading", { sent: 500_000, total: 1_000_000 }));+ assert.equal(view(line).status, "0 of 2");+ assert.equal(view(line).percent, 25);+ apply(line, ev("big", "done", { sent: 1_000_000 }));+ apply(line, ev("small", "done", { sent: 1_000_000 }));+ assert.equal(view(line).status, "2 of 2");+ assert.equal(view(line).percent, 100);+ assert.equal(heading([view(line)]), "Downloading Photos");+ finish(line, report(), null);+ const v = view(line);+ assert.equal(v.status, "Downloaded");+ assert.equal(v.tone, "done");+ assert.equal(v.reveal, "/home/me/Downloads/Photos");+ assert.equal(v.again, null, "nothing to go on with");+ assert.equal(heading([v]), "Photos downloaded");+});++test("a late report for a finished file changes nothing", () => {+ const line = newLine("b", "Photos", items);+ apply(line, ev(0, "downloading", { sent: 90 }));+ apply(line, ev(0, "done", { sent: 100 }));+ apply(line, ev(0, "downloading", { sent: 10 }));+ assert.equal(line.done, 1);+ assert.equal(line.inflight.size, 0);+ assert.equal(line.bytesDone, 100);+});++test("what did not download is named, with why; the rest are counted", () => {+ const line = newLine("b", "3 items", items);+ apply(line, ev(0, "failed", { error: "its path is too long for this computer" }));+ apply(line, { ...ev("x", "failed", { error: "iCloud Drive is busy" }), id: "b:x:0", folder: true, name: "Broken", within: "Photos" });+ finish(line, report({ resumable: true }), null);+ const v = view(line);+ assert.equal(v.status, "2 didn’t download");+ assert.equal(v.tone, "failed");+ assert.deepEqual(v.failures.map((f) => f.path), ["Photos/0.jpg", "Photos/Broken"]);+ assert.equal(v.again, "Resume", "it can be gone on with");+ assert.equal(v.forgettable, "k1");+ assert.equal(heading([v]), "Some downloads didn’t finish");+ const many = newLine("c", "Big", items);+ for (let i = 0; i < NAMED + 50; i++) apply(many, { ...ev(i, "failed", { error: "no" }), batch: "c" });+ finish(many, report(), null);+ assert.equal(view(many).failures.length, NAMED);+ assert.equal(view(many).unnamed, 50);+});++test("cancelled, out of room, connection lost, sign-in lapsed: each said as itself, and offered again", () => {+ const cancelled = newLine("b", "Photos", items);+ apply(cancelled, ev(0, "done", { sent: 100 }));+ finish(cancelled, report({ cancelled: true, resumable: true }), null);+ assert.equal(view(cancelled).status, "Cancelled after 1");+ assert.equal(view(cancelled).again, "Resume");+ assert.equal(heading([view(cancelled)]), "Download cancelled");++ const full = newLine("b", "Photos", items);+ finish(full, report({ saved: [], problem: "There isn’t room in Downloads for this: it needs 3.2 GB and 1.1 GB is free." }), null);+ assert.equal(view(full).status, "Stopped");+ assert.match(view(full).note, /isn’t room/);+ assert.equal(view(full).reveal, null, "nothing to show");+ assert.equal(view(full).again, "Try Again", "nothing to resume, so it starts again");++ const lost = newLine("b", "Photos", items);+ apply(lost, ev(0, "done", { sent: 100 }));+ finish(lost, report({ problem: "The connection to iCloud was lost, so the download paused.", resumable: true }), null);+ assert.equal(view(lost).status, "1 downloaded");+ assert.equal(view(lost).again, "Resume");++ const lapsed = newLine("b", "Photos", items);+ finish(lapsed, null, "this needs a fresh sign-in");+ assert.equal(view(lapsed).status, "Didn’t download");+ assert.equal(view(lapsed).note, "this needs a fresh sign-in");+});++test("a download left unfinished last time is offered again, with what of it is there", () => {+ const v = view(pausedLine("k9", "Archive", items, ["/home/me/Downloads/Archive"]));+ assert.equal(v.status, "Paused");+ assert.equal(v.again, "Resume");+ assert.equal(v.reveal, "/home/me/Downloads/Archive");+ assert.equal(v.forgettable, "k9");+ assert.equal(v.running, false);+ assert.equal(heading([v]), "A download didn’t finish");+});++test("a hundred thousand files are counts, not rows", () => {+ const line = newLine("b", "Archive", items);+ apply(line, tally("planned", 100_000, 100_000));+ for (let i = 0; i < 100_000; i++) apply(line, ev(i, "done", { sent: 1, total: 1 }));+ assert.equal(line.inflight.size, 0);+ assert.equal(line.ended.size, 0, "small files leave nothing behind");+ assert.equal(line.done, 100_000);+ assert.equal(view(line).percent, 100);+});diff --git a/.uiverify/drive-download.mjs b/.uiverify/drive-download.mjsnew file mode 100644index 0000000..273598b--- /dev/null+++ b/.uiverify/drive-download.mjs@@ -0,0 +1,200 @@+// A whole folder — or several things chosen together — downloaded from Drive into Downloads:+// offered in the menu and by the keys alone, shown as one calm line however many files are in+// it, cancellable, its failures named, and Show in Folder once it is there. A single file+// still downloads the way it always has.+import { engine } from "./engine.mjs";+import { SERVICES, installStub } from "./stub.mjs";++const b = await engine.launch();+const ctx = await b.newContext({ viewport: { width: 1280, height: 800 } });+await ctx.addInitScript(installStub, { screen: "library", services: SERVICES, twoFactor: null, driveFixture: true });+const page = await ctx.newPage();+const errors = [];+page.on("pageerror", (e) => errors.push(String(e)));+await page.goto(process.env.BASE ?? process.env.URL ?? "http://localhost:4173", { waitUntil: "networkidle" });+await page.locator(".nav-item", { hasText: "Drive" }).click();+await page.waitForSelector(".drive-row-hit");+await page.waitForTimeout(300);++let failures = 0;+const ok = (pass, what) => { console.log(`${pass ? "PASS" : "FAIL"} ${what}`); if (!pass) failures++; };+const row = (name) => page.locator(".drive-row-hit", { hasText: name });+const tray = page.locator(".download-tray");+const got = (key) => page.evaluate((key) => window[key] ?? [], key);+const lastBatch = async () => (await got("__downloadItems")).at(-1)?.batch;+const say = (batch, e) => page.evaluate(([batch, e]) => window.__emit("quince://download", {+ batch, within: "Downloads", sent: 0, total: 1000, folder: false, error: null, ...e, id: `${batch}:${e.id}` }), [batch, e]);+const end = (batch, report) => page.evaluate(([batch, report]) => window.__downloadEnd[batch]({+ key: "k", saved: [], failed: [], moreFailed: 0, cancelled: false, problem: null, resumable: false, ...report }), [batch, report]);+const settle = () => page.waitForTimeout(250);++// ── A folder, from its menu ────────────────────────────────────────────────────────────────+await row("Downloads").click({ button: "right" });+const entries = await page.getByRole("menuitem").allInnerTexts();+ok(entries.some((t) => t.includes("Open")) && entries.some((t) => t.includes("Download a Copy")),+ `a folder's menu offers to download it ${JSON.stringify(entries)}`);+await page.getByRole("menuitem", { name: "Download a Copy" }).click();+await settle();+let asked = (await got("__downloadItems")).at(-1);+ok(asked?.items?.length === 1 && asked.items[0].drivewsid === "FOLDER::a", `the folder itself is asked for ${JSON.stringify(asked?.items?.map((i) => i.drivewsid))}`);+ok(asked?.title === "Downloads", `under its own name, to resume by [${asked?.title}]`);+ok((await got("__singleDownloads")).length === 0, "a folder is not sent to the one-file download");+ok(await tray.isVisible(), "the downloads tray appears at once");+ok((await tray.locator(".upload-tray-title").innerText()) === "Downloading Downloads", `its head names the folder [${await tray.locator(".upload-tray-title").innerText()}]`);+ok(/Preparing…/.test(await tray.locator(".upload-row").innerText()), "before anything is found it is preparing");++let batch = asked.batch;+for (const n of [1, 2, 3]) await say(batch, { id: "found", name: "", folder: true, sent: n, total: n * 1000, state: "found" });+await settle();+ok(/Preparing… 3 found/.test(await tray.locator(".upload-row").innerText()), `while the tree is counted it says what it has found [${await tray.locator(".upload-row").innerText()}]`);+await say(batch, { id: "planned", name: "", folder: true, sent: 3, total: 3000, state: "planned" });+await say(batch, { id: 0, name: "photo 0.jpg", state: "downloading", sent: 500 });+await settle();+const rows = await tray.locator(".upload-row").count();+ok(rows === 1, `a folder of many files is one line, not a row per file [${rows}]`);+ok(/0 of 3/.test(await tray.locator(".upload-row").innerText()), "once everything is found it counts to the total");+ok((await tray.locator(".upload-tray-percent").innerText()) === "16%", `the head says how far, by bytes [${await tray.locator(".upload-tray-percent").innerText()}]`);+await say(batch, { id: 0, name: "photo 0.jpg", state: "done", sent: 1000 });+// A report overtaken on its way: the bar never slides back.+await say(batch, { id: 0, name: "photo 0.jpg", state: "downloading", sent: 100 });+await settle();+ok(/1 of 3/.test(await tray.locator(".upload-row").innerText()), "each file that lands is counted");+ok((await tray.locator(".upload-tray-percent").innerText()) === "33%", "a late report does not take it backwards");+for (const n of [1, 2]) await say(batch, { id: n, name: `photo ${n}.jpg`, state: "done", sent: 1000 });+await end(batch, { saved: ["/home/test/Downloads/Downloads 2"] });+await settle();+ok((await tray.locator(".upload-tray-title").innerText()) === "Downloads downloaded", `finished, the head says so [${await tray.locator(".upload-tray-title").innerText()}]`);+ok((await tray.getByLabel("Downloaded").count()) === 1, "and the line is ticked");+const show = tray.getByRole("button", { name: "Show in Folder" });+ok((await show.count()) === 1, "it offers Show in Folder");+await show.click();+await settle();+ok(JSON.stringify(await got("__revealed")) === JSON.stringify(["/home/test/Downloads/Downloads 2"]), `Show in Folder shows the folder it made ${JSON.stringify(await got("__revealed"))}`);+await page.waitForTimeout(4500);+ok(await tray.isVisible(), "it stays until it is closed: Show in Folder is what it is for");+await tray.getByRole("button", { name: "Close downloads" }).click();+await settle();+ok((await tray.count()) === 0, "Done closes it");++// ── A selection of files and folders ────────────────────────────────────────────────────────+const mod = process.platform === "darwin" ? "Meta" : "Control";+await row("Semester Plan").click();+await row("Downloads").click({ modifiers: [mod] });+await row("Downloads").click({ button: "right" });+ok((await page.getByRole("menuitem", { name: "Download 2 Copies" }).count()) === 1, "a selection with a folder in it can be downloaded");+await page.getByRole("menuitem", { name: "Download 2 Copies" }).click();+await settle();+asked = (await got("__downloadItems")).at(-1);+ok(asked.items.map((i) => i.drivewsid).sort().join() === "FILE::d,FOLDER::a", `every item chosen goes, in one download ${JSON.stringify(asked.items.map((i) => i.drivewsid))}`);+ok((await tray.locator(".upload-tray-title").innerText()) === "Downloading 2 items", "one line for the whole selection");+batch = asked.batch;+await say(batch, { id: 0, name: "Semester Plan.pdf", within: "", state: "downloading", sent: 10 });+await say(batch, { id: 1, name: "secret.key", within: "Downloads", state: "failed", error: "its path is too long for this computer" });+await say(batch, { id: "x:0", name: "Broken", within: "Downloads", folder: true, state: "failed", error: "iCloud Drive is busy right now — try this one again in a minute." });+await say(batch, { id: "planned", name: "", folder: true, sent: 2, total: 2000, state: "planned" });+await say(batch, { id: 0, name: "Semester Plan.pdf", within: "", state: "done", sent: 1000 });+await end(batch, { saved: ["/home/test/Downloads/Semester Plan 2.pdf", "/home/test/Downloads/Downloads 3"], failed: ["Downloads/secret.key: its path is too long for this computer", "Downloads/Broken: busy"] });+await settle();+ok(/2 didn’t download/.test(await tray.locator(".upload-row").innerText()), `what did not arrive is counted [${await tray.locator(".upload-row").innerText()}]`);+ok((await tray.locator(".upload-tray-title").innerText()) === "Some downloads didn’t finish", "and the head says not all of it finished");+await tray.getByRole("button", { name: "Show what didn’t download" }).click();+const why = await tray.locator(".upload-failures").innerText();+ok(/Downloads\/secret\.key/.test(why) && /too long/.test(why) && /Downloads\/Broken/.test(why), `each is named with why [${why.replace(/\s+/g, " ")}]`);+ok((await tray.getByRole("button", { name: "Show in Folder" }).count()) === 1, "what did arrive can still be shown");+await tray.getByRole("button", { name: "Close downloads" }).click();+await settle();++// ── Cancel ──────────────────────────────────────────────────────────────────────────────────+await row("Downloads").click();+await row("Downloads").click({ button: "right" });+await page.getByRole("menuitem", { name: "Download a Copy" }).click();+await settle();+batch = await lastBatch();+await say(batch, { id: 0, name: "a.jpg", state: "done", sent: 1000 });+await say(batch, { id: 1, name: "b.jpg", state: "downloading", sent: 10 });+await settle();+ok((await tray.getByRole("button", { name: /^Cancel / }).count()) === 0, "one download has one Cancel, not two");+await tray.getByRole("button", { name: "Cancel", exact: true }).click();+await settle();+const cancels = await got("__downloadCancels");+ok(cancels.length === 1 && cancels[0].batch === batch, `Cancel stops that download ${JSON.stringify(cancels)}`);+ok(/Cancelled after 1/.test(await tray.locator(".upload-row").innerText()), `then it says it was cancelled, and after how many [${await tray.locator(".upload-row").innerText()}]`);+// Cancelled is not the end of it: it can be gone on with, where it was.+const resume = tray.getByRole("button", { name: "Resume" });+ok((await resume.count()) === 1, "a cancelled download offers to Resume");+await resume.click();+await settle();+const again = (await got("__downloadItems")).at(-1);+ok(again.batch !== batch && again.items[0].drivewsid === "FOLDER::a" && again.title === "Downloads", "Resume asks for the same download again — the backend goes on where it was");+ok((await tray.locator(".upload-row").count()) === 1 && /Downloading Downloads/.test(await tray.locator(".upload-tray-title").innerText()), "in place of the cancelled line, not beside it");+await end(again.batch, { saved: ["/home/test/Downloads/Downloads 2"] });+await settle();+ok((await tray.locator(".upload-tray-title").innerText()) === "Downloads downloaded", "and then finishes");+await tray.getByRole("button", { name: "Close downloads" }).click();+await settle();++// ── By the keys alone ───────────────────────────────────────────────────────────────────────+for (const key of ["Shift+F10", "ContextMenu"]) {+ await row("Downloads").click();+ const before = (await got("__downloadItems")).length;+ await page.keyboard.press(key);+ await settle();+ ok((await page.locator(".row-menu").count()) === 1, `${key} opens the selection's menu`);+ // Type-select, as a menu takes it, then Return.+ await page.keyboard.type("Dow");+ await page.keyboard.press("Enter");+ await settle();+ const after = await got("__downloadItems");+ ok(after.length === before + 1 && after.at(-1).items[0].drivewsid === "FOLDER::a", `${key}, then Download a Copy, downloads the folder`);+ await page.evaluate((b) => window.__downloadEnd[b]({ saved: [], failed: [], moreFailed: 0, cancelled: true, problem: null }), after.at(-1).batch);+ await settle();+ if (await tray.count()) await tray.getByRole("button", { name: "Close downloads" }).click();+}++// ── One file, as before ─────────────────────────────────────────────────────────────────────+await row("Semester Plan").click({ button: "right" });+await page.getByRole("menuitem", { name: "Download a Copy" }).click();+await settle();+ok(JSON.stringify(await got("__singleDownloads")) === JSON.stringify(["FILE::d"]), "one file still goes the one-file way");+ok((await tray.count()) === 0, "with its notice, not the tray");++// ── Downloads and uploads at once: stacked, never over each other ──────────────────────────+await row("Downloads").click();+await row("Downloads").click({ button: "right" });+await page.getByRole("menuitem", { name: "Download a Copy" }).click();+await settle();+await page.evaluate(() => window.__emit("quince://upload", { id: "u:0", batch: "u", name: "notes.txt", within: "", sent: 10, total: 100, state: "sending", folder: false, error: null }));+await settle();+const boxes = await page.locator(".upload-tray").evaluateAll((els) => els.map((e) => e.getBoundingClientRect().toJSON()));+const apart = boxes.length === 2 && (boxes[0].bottom <= boxes[1].top || boxes[1].bottom <= boxes[0].top);+const inside = boxes.every((r) => r.top >= 0 && r.bottom <= 800 && r.right <= 1280);+ok(apart && inside, `the two trays sit one above the other, on screen ${JSON.stringify(boxes.map((r) => [Math.round(r.top), Math.round(r.bottom)]))}`);++// ── Left unfinished last time: offered again when Drive opens ──────────────────────────────+const later = await b.newContext({ viewport: { width: 1280, height: 800 } });+await later.addInitScript(installStub, { screen: "library", services: SERVICES, twoFactor: null, driveFixture: true });+await later.addInitScript(() => {+ window.__unfinished = [{ key: "0123456789abcdef0123456789abcdef", title: "Archive",+ items: [{ drivewsid: "FOLDER::archive", parentId: null, name: "Archive", extension: null, kind: "FOLDER",+ size: null, childCount: null, createdAt: null, modifiedAt: null, etag: null }],+ saved: ["/home/test/Downloads/Archive"] }];+});+const next = await later.newPage();+next.on("pageerror", (e) => errors.push(String(e)));+await next.goto(process.env.BASE ?? process.env.URL ?? "http://localhost:4173", { waitUntil: "networkidle" });+await next.locator(".nav-item", { hasText: "Drive" }).click();+await next.waitForTimeout(500);+const offered = next.locator(".download-tray");+ok((await offered.count()) === 1 && /Archive/.test(await offered.innerText()) && /Paused/.test(await offered.innerText()),+ `a download left unfinished is offered again [${(await offered.innerText().catch(() => "")).replace(/\s+/g, " ")}]`);+ok((await offered.locator(".upload-tray-title").innerText()) === "A download didn’t finish", "its head says so plainly");+ok((await offered.getByRole("button", { name: "Show in Folder" }).count()) === 1, "what of it is there can be shown");+await offered.getByRole("button", { name: "Forget Archive" }).click();+await next.waitForTimeout(250);+ok(JSON.stringify(await next.evaluate(() => window.__forgotten ?? [])) === JSON.stringify(["0123456789abcdef0123456789abcdef"]), "it can be let go of");+ok((await offered.count()) === 0, "and then it is no longer offered");+await later.close();++ok(errors.length === 0, `no page errors ${JSON.stringify(errors)}`);+await b.close();+process.exitCode = failures ? 1 : 0;diff --git a/.uiverify/drive-info.mjs b/.uiverify/drive-info.mjsindex a9eb904..6ee1a18 100644--- a/.uiverify/drive-info.mjs+++ b/.uiverify/drive-info.mjs@@ -23,7 +23,7 @@ ok((await page.locator(".info-sheet").count()) === 0, "Escape closes it");await page.locator(".drive-row", { hasText: "Downloads" }).click({ button: "right" });await page.waitForTimeout(150);const offered = await page.getByRole("menuitem").allInnerTexts();-ok(JSON.stringify(offered) === JSON.stringify(["Open", "Get Info", "Rename", "Move to Folder", "Delete"]),+ok(JSON.stringify(offered) === JSON.stringify(["Open", "Download a Copy", "Get Info", "Rename", "Move to Folder", "Delete"]),`a right-click on a folder offers its menu ${JSON.stringify(offered)}`);await page.keyboard.press("Escape");await page.locator(".drive-row", { hasText: "Semester Plan" }).click({ button: "right" });diff --git a/.uiverify/stub.mjs b/.uiverify/stub.mjsindex 79e792a..ead8b17 100644--- a/.uiverify/stub.mjs+++ b/.uiverify/stub.mjs@@ -1117,7 +1117,22 @@ export function installStub({ screen, services, twoFactor, calendarFixture, note// A folder deleted on another device: the backend forgets it and says so.if (args.folderId === window.__driveGone) throw "This folder was deleted or moved on another device.";return driveItems.length;- case "drive_download": return "/home/user/Downloads/file.pdf";+ case "drive_download": (window.__singleDownloads ??= []).push(args.drivewsid); return "/home/user/Downloads/file.pdf";+ // A folder, or a selection, into Downloads (folder_download.rs): kept going until the+ // test says how it ended — `window.__downloadEnd[batch](report)` — playing its progress+ // in with __emit("quince://download", …) meanwhile. Cancel ends it as cancelled.+ case "drive_download_items": {+ (window.__downloadItems ??= []).push(args);+ return await new Promise((resolve) => { (window.__downloadEnd ??= {})[args.batch] = resolve; });+ }+ case "drive_download_cancel": {+ (window.__downloadCancels ??= []).push(args);+ window.__downloadEnd?.[args.batch]?.({ key: "k", saved: [], failed: [], moreFailed: 0, cancelled: true, problem: null, resumable: true });+ return null;+ }+ // Downloads left unfinished last time (`window.__unfinished`), and those let go of.+ case "drive_downloads_unfinished": return window.__unfinished ?? [];+ case "drive_download_forget": (window.__forgotten ??= []).push(args.key); return null;case "download_reveal": (window.__revealed ??= []).push(args.path); return null;case "drive_move": (window.__moves ??= []).push(args); await new Promise((r) => setTimeout(r, 600)); return null;case "drive_create_folder": case "drive_rename": {diff --git a/check.sh b/check.shindex 92fe272..17592fe 100755--- a/check.sh+++ b/check.sh@@ -103,6 +103,7 @@ step "pending writes" node .uiverify/pending-writes.mjsstep "row hover" node .uiverify/row-hover.mjsstep "reminders switch" node .uiverify/reminders-switch.mjsstep "upload cancel" node .uiverify/drive-upload-cancel.mjs+step "folder download" node .uiverify/drive-download.mjsstep "notes tables" node .uiverify/notes-table.mjsstep "reminder menu" node .uiverify/reminders-context.mjsstep "notes media" node .uiverify/notes-media.mjs@@ -166,6 +167,7 @@ step "webkit: failing" env ENGINE=webkit node .uiverify/boundary.mjsstep "webkit: back" env ENGINE=webkit node .uiverify/resume.mjsstep "webkit: occasions" env ENGINE=webkit node .uiverify/occasions.mjsstep "webkit: drive nav" env ENGINE=webkit node .uiverify/drive-nav.mjs+step "webkit: download" env ENGINE=webkit node .uiverify/drive-download.mjsstep "sign-in keyring" node .uiverify/signin-keyring.mjsstep "lapse reason" node .uiverify/lapse-reason.mjsstep "device approval" node .uiverify/device-approval.mjsdiff --git a/src/components/DownloadTray.tsx b/src/components/DownloadTray.tsxnew file mode 100644index 0000000..d7a35b4--- /dev/null+++ b/src/components/DownloadTray.tsx@@ -0,0 +1,158 @@+import { useEffect, useRef, useState } from "react";+import { Progress } from "./Spinner";+import { FileGlyph } from "./FileGlyph";+import { toast } from "./Toast";+import { api, messageOf } from "../lib/ipc";+import { heading, view } from "../lib/downloadModel";+import {+ cancelDownload,+ dismissFinished,+ downloadAgain,+ forgetDownload,+ offerUnfinished,+ useDownloads,+} from "../lib/downloads";++/**+ * Downloads into Downloads, in the corner where uploads are shown and in the same shape: one+ * line for each folder or selection, however many files are in it, with its progress, and —+ * once it is there — Show in Folder. One that stopped short says why and offers to Resume+ * where it was; one left unfinished when Skykeep was last closed is offered again. A line+ * opens to say what in it did not download, and why. It stays until it is closed: Show in+ * Folder is what it is for.+ */+export function DownloadTray() {+ const lines = useDownloads();+ const [open, setOpen] = useState<string | null>(null);+ useEffect(() => {+ void offerUnfinished();+ }, []);+ // Progress only ever moves forward: four files arrive at once and report out of step, and a+ // bar that slid back on every report read as broken.+ const highest = useRef<Map<string, number>>(new Map());+ const forward = (key: string, value: number | null) => {+ if (value === null) return null;+ const now = Math.max(highest.current.get(key) ?? 0, value);+ highest.current.set(key, now);+ return now;+ };+ if (lines.length === 0) {+ highest.current.clear();+ return null;+ }+ const views = lines.map(view);+ const active = views.some((v) => v.running);+ const one = views.length === 1 ? views[0] : null;+ const headPercent = one?.running ? forward(`head:${one.batch}`, one.percent) : null;+ const reveal = (path: string) =>+ void api.downloadReveal(path).catch((e) => toast({ message: messageOf(e), tone: "error" }));++ return (+ <section className="upload-tray download-tray" aria-label="Downloads" aria-live="polite">+ <header className="upload-tray-head">+ <span className="upload-tray-title">{heading(views)}</span>+ {active ? (+ <span className="upload-tray-actions">+ {headPercent !== null && <span className="upload-tray-percent">{headPercent}%</span>}+ <button+ className="quiet upload-tray-close"+ onClick={() => views.filter((v) => v.running).forEach((v) => void cancelDownload(v.batch))}+ >+ Cancel+ </button>+ </span>+ ) : (+ <button className="quiet upload-tray-close" onClick={dismissFinished} aria-label="Close downloads">+ Done+ </button>+ )}+ </header>+ {active && one && <Progress value={headPercent === null ? null : headPercent / 100} className="upload-bar" />}+ <ul className="upload-rows">+ {views.map((v) => {+ const p = forward(v.batch, v.percent);+ const unfolds = v.failures.length > 0 && !v.running;+ return (+ <li key={v.batch} className={`upload-row is-${v.tone}`}>+ <div className="upload-line">+ <span className="upload-glyph" aria-hidden="true">+ <FileGlyph kind="FOLDER" extension={null} />+ </span>+ <span className="upload-text">+ <span className="upload-name">{v.title}</span>+ {v.running && views.length > 1 && (+ <Progress value={p === null ? null : p / 100} className="upload-bar small" />+ )}+ {v.note && <span className="upload-where" title={v.note}>{v.note}</span>}+ </span>+ <span className="upload-state">+ {v.tone === "done" ? <span aria-label="Downloaded">✓</span> : v.status}+ </span>+ <span className="download-actions">+ {v.again && (+ <button className="quiet download-show" onClick={() => void downloadAgain(v.batch)}>+ {v.again}+ </button>+ )}+ {v.reveal && (+ <button className="quiet download-show" onClick={() => reveal(v.reveal!)}>+ Show in Folder+ </button>+ )}+ </span>+ {unfolds ? (+ <button+ className="icon-button small round upload-stop"+ aria-expanded={open === v.batch}+ aria-label={open === v.batch ? "Hide what didn’t download" : "Show what didn’t download"}+ onClick={() => setOpen(open === v.batch ? null : v.batch)}+ >+ {open === v.batch ? "▾" : "▸"}+ </button>+ ) : v.running && views.length > 1 ? (+ // One download has one Cancel — the head's.+ <button+ className="icon-button small round upload-stop"+ aria-label={`Cancel ${v.title}`}+ title="Cancel"+ onClick={() => void cancelDownload(v.batch)}+ >+ ✕+ </button>+ ) : v.forgettable ? (+ <button+ className="icon-button small round upload-stop"+ aria-label={`Forget ${v.title}`}+ title="Don’t offer to resume this"+ onClick={() => void forgetDownload(v.batch, v.forgettable!)}+ >+ ✕+ </button>+ ) : (+ <span />+ )}+ </div>+ {open === v.batch && unfolds && (+ <ul className="upload-failures">+ {v.failures.map((f, i) => (+ <li key={`${f.path}:${i}`}>+ <b>{f.path}</b> {f.error}+ </li>+ ))}+ {v.unnamed > 0 && <li>and {v.unnamed} more</li>}+ {v.forgettable && (+ <li>+ <button className="quiet download-show" onClick={() => void forgetDownload(v.batch, v.forgettable!)}>+ Don’t Offer to Resume+ </button>+ </li>+ )}+ </ul>+ )}+ </li>+ );+ })}+ </ul>+ </section>+ );+}diff --git a/src/lib/downloadModel.ts b/src/lib/downloadModel.tsnew file mode 100644index 0000000..2587897--- /dev/null+++ b/src/lib/downloadModel.ts@@ -0,0 +1,207 @@+/**+ * A download into Downloads — a folder, or a selection of files and folders — as the tray+ * shows it: one line for the whole of it, however many files are in it.+ *+ * Kept as counts, not as a row per file: a folder of a hundred thousand files sends about as+ * many events, and each is a few additions here. Only the large files arriving right now are+ * held one by one (for their bytes), and only the first NAMED failures by name.+ */+import type { DownloadEvent, DownloadReport, DriveItem } from "./ipc";++/** How many failures a line names; past this they are counted. */+export const NAMED = 200;++export type Failure = { path: string; error: string };++export type DownloadLine = {+ batch: string;+ /** What was chosen: a folder's name, or "3 items". */+ title: string;+ /** What was chosen, to download again: that resumes it. */+ items: DriveItem[];+ /** Counted while the tree is read: files and their bytes. */+ found: number;+ done: number;+ failedCount: number;+ failures: Failure[];+ bytesDone: number;+ /** The large files arriving now, and how many of their bytes are here. */+ inflight: Map<string, number>;+ /** Large files that have finished: a late report for one is not undone. */+ ended: Set<string>;+ /** Every file in it is known: how many, and their bytes. */+ planned: { files: number; bytes: number } | null;+ finished: boolean;+ report: DownloadReport | null;+ error: string | null;+ /** An unfinished download from before Skykeep was last closed: what of it is in Downloads. */+ paused: { key: string; saved: string[] } | null;+};++export function newLine(batch: string, title: string, items: DriveItem[]): DownloadLine {+ return {+ batch,+ title,+ items,+ found: 0,+ done: 0,+ failedCount: 0,+ failures: [],+ bytesDone: 0,+ inflight: new Map(),+ ended: new Set(),+ planned: null,+ finished: false,+ report: null,+ error: null,+ paused: null,+ };+}++/** An unfinished download from before, shown so it can be gone on with. */+export function pausedLine(key: string, title: string, items: DriveItem[], saved: string[]): DownloadLine {+ return { ...newLine(`unfinished:${key}`, title, items), finished: true, paused: { key, saved } };+}++function fail(line: DownloadLine, e: DownloadEvent) {+ line.failedCount += 1;+ if (line.failures.length < NAMED) {+ line.failures.push({ path: [e.within, e.name].filter(Boolean).join("/"), error: e.error ?? "" });+ }+}++/** One event from the backend, counted into its line. */+export function apply(line: DownloadLine, e: DownloadEvent) {+ if (line.finished) return;+ if (e.state === "found") {+ line.found = e.sent;+ return;+ }+ if (e.state === "planned") {+ line.planned = { files: e.sent, bytes: e.total };+ return;+ }+ // A folder's only event is that it could not be read or made.+ if (e.folder) {+ if (e.state === "failed") fail(line, e);+ return;+ }+ // Events for one file can pass each other; a finished file never goes back.+ if (line.ended.has(e.id)) return;+ const end = () => {+ if (line.inflight.delete(e.id)) line.ended.add(e.id);+ };+ switch (e.state) {+ case "downloading":+ line.inflight.set(e.id, Math.max(line.inflight.get(e.id) ?? 0, e.sent));+ break;+ case "done":+ end();+ line.done += 1;+ line.bytesDone += Math.max(e.sent, 0);+ break;+ case "failed":+ end();+ fail(line, e);+ break;+ case "cancelled":+ end();+ break;+ default:+ break;+ }+}++/** The backend has said all it will: whatever was still arriving is closed now. */+export function finish(line: DownloadLine, report: DownloadReport | null, error: string | null) {+ line.finished = true;+ line.report = report;+ line.error = error;+ line.inflight.clear();+ if (report && report.moreFailed > 0) line.failedCount = Math.max(line.failedCount, report.failed.length + report.moreFailed);+}++export type Tone = "sending" | "done" | "failed" | "cancelled";++export type LineView = {+ batch: string;+ title: string;+ running: boolean;+ /** How far, 0–100; null while it is not known how much there is. */+ percent: number | null;+ status: string;+ tone: Tone;+ /** A sentence under the name: why it stopped, when it did. */+ note: string | null;+ failures: Failure[];+ /** Failures not named. */+ unnamed: number;+ /** What Show in Folder shows. */+ reveal: string | null;+ /** What going on with it is called: Resume where it was, or Try Again afresh. */+ again: "Resume" | "Try Again" | null;+ /** It is remembered as unfinished, and can be let go of. */+ forgettable: string | null;+};++const arrived = (line: DownloadLine) => line.bytesDone + [...line.inflight.values()].reduce((n, b) => n + b, 0);++/** How far a line has got, and what it is doing, in the fewest words that are true. */+export function view(line: DownloadLine): LineView {+ const running = !line.finished;+ let percent: number | null = null;+ if (line.planned) {+ const { bytes, files } = line.planned;+ if (bytes > 0) percent = Math.min(100, Math.floor((arrived(line) / bytes) * 100));+ else if (files > 0) percent = Math.min(100, Math.floor((line.done / files) * 100));+ else percent = running ? 0 : 100;+ }+ const failures = line.failures;+ const unnamed = Math.max(0, line.failedCount - failures.length);+ const saved = line.report?.saved ?? line.paused?.saved ?? [];+ const reveal = !running && saved.length > 0 ? saved[0] : null;+ const resumable = Boolean(line.report?.resumable || line.paused);+ const base = {+ batch: line.batch,+ title: line.title,+ running,+ failures,+ unnamed,+ reveal,+ forgettable: resumable ? (line.report?.key ?? line.paused?.key ?? null) : null,+ };+ if (running) {+ // Still counting what is in it: a count that would only grow is not a total yet.+ const status = line.planned+ ? `${line.done} of ${line.planned.files}`+ : line.found+ ? `Preparing… ${line.found} found`+ : "Preparing…";+ return { ...base, percent, status, tone: "sending", note: null, again: null };+ }+ const again = resumable ? "Resume" : "Try Again";+ if (line.paused) return { ...base, percent: null, status: "Paused", tone: "cancelled", note: null, again };+ if (line.error) return { ...base, percent: null, status: "Didn’t download", tone: "failed", note: line.error, again };+ const problem = line.report?.problem ?? null;+ if (problem) return { ...base, percent: null, status: line.done ? `${line.done} downloaded` : "Stopped", tone: "failed", note: problem, again };+ if (line.report?.cancelled) {+ return { ...base, percent: null, status: line.done ? `Cancelled after ${line.done}` : "Cancelled", tone: "cancelled", note: null, again };+ }+ if (line.failedCount > 0) {+ return { ...base, percent: null, status: `${line.failedCount} didn’t download`, tone: "failed", note: null, again };+ }+ return { ...base, percent: 100, status: "Downloaded", tone: "done", note: null, again: null };+}++/** The tray's head: what is happening, across every line. */+export function heading(views: LineView[]): string {+ const running = views.filter((v) => v.running);+ if (running.length === 1) return `Downloading ${running[0].title}`;+ if (running.length > 1) return "Downloading…";+ if (views.length > 0 && views.every((v) => v.status === "Paused")) {+ return views.length === 1 ? "A download didn’t finish" : "Some downloads didn’t finish";+ }+ if (views.some((v) => v.tone === "failed")) return "Some downloads didn’t finish";+ if (views.length > 0 && views.every((v) => v.tone === "cancelled")) return views.length === 1 ? "Download cancelled" : "Downloads cancelled";+ return views.length === 1 ? `${views[0].title} downloaded` : "Downloads finished";+}diff --git a/src/lib/downloads.ts b/src/lib/downloads.tsnew file mode 100644index 0000000..655d0a4--- /dev/null+++ b/src/lib/downloads.ts@@ -0,0 +1,122 @@+/**+ * Downloads into Downloads that are under way, just finished, or left unfinished — for the+ * whole window: kept here rather than in Drive's screen, so a download goes on being shown+ * after the screen is left and come back to, and its thousands of events never redraw the+ * file list.+ */+import { useSyncExternalStore } from "react";+import { listen } from "@tauri-apps/api/event";+import { api, DOWNLOAD, messageOf, type DownloadEvent, type DriveItem } from "./ipc";+import { apply, finish, newLine, pausedLine, type DownloadLine } from "./downloadModel";++const lines = new Map<string, DownloadLine>();+const listeners = new Set<() => void>();+let version = 0;+let flushing: number | null = null;++/**+ * Told to whoever draws it at most every 80 ms: a folder of small files sends hundreds of+ * events a second, and drawing the tray for each one was all the window did.+ */+function changed() {+ if (flushing !== null) return;+ flushing = window.setTimeout(() => {+ flushing = null;+ version += 1;+ listeners.forEach((l) => l());+ }, 80);+}++let listening: Promise<void> | null = null;+/** Heard for as long as the window is open, from before the first download begins. */+function hear(): Promise<void> {+ listening ??= listen<DownloadEvent>(DOWNLOAD, (event) => {+ const line = lines.get(event.payload.batch);+ if (!line) return;+ apply(line, event.payload);+ changed();+ }).then(+ () => undefined,+ // No event system behind the page (a plain browser): nothing will be heard.+ () => undefined,+ );+ return listening;+}++/**+ * Save `items` into Downloads as they are in Drive — or, when the same was downloaded before+ * and not finished, go on with it where it was. Never blocks the window: it is shown in the+ * tray as it goes, and what it came to stays there until the tray is closed.+ */+export async function startDownload(items: DriveItem[], title: string): Promise<void> {+ const batch = `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 7)}`;+ const line = newLine(batch, title, items);+ lines.set(batch, line);+ changed();+ await hear();+ try {+ finish(line, await api.driveDownloadItems(batch, title, items), null);+ } catch (e) {+ finish(line, null, messageOf(e));+ }+ changed();+}++/** Go on with a download that stopped short — or start it again — in place of its line. */+export function downloadAgain(batch: string): Promise<void> {+ const line = lines.get(batch);+ if (!line) return Promise.resolve();+ lines.delete(batch);+ return startDownload(line.items, line.title);+}++/** Stop a download: what has arrived stays, the rest does not begin. */+export function cancelDownload(batch: string): Promise<void> {+ return api.driveDownloadCancel([], batch).catch(() => {});+}++/** No longer offer to go on with this download; what it saved stays where it is. */+export function forgetDownload(batch: string, key: string): Promise<void> {+ lines.delete(batch);+ changed();+ return api.driveDownloadForget(key).catch(() => {});+}++/** Close the finished lines; any still running stay. */+export function dismissFinished() {+ for (const [batch, line] of lines) if (line.finished) lines.delete(batch);+ changed();+}++let looked = false;+/**+ * Downloads left unfinished when Skykeep was last closed, offered once a session so they can+ * be gone on with.+ */+export async function offerUnfinished(): Promise<void> {+ if (looked) return;+ looked = true;+ try {+ for (const u of await api.driveDownloadsUnfinished()) {+ const batch = `unfinished:${u.key}`;+ if (!lines.has(batch)) lines.set(batch, pausedLine(u.key, u.title, u.items, u.saved));+ }+ changed();+ } catch {+ // Nothing to offer.+ }+}++const subscribe = (listener: () => void) => {+ listeners.add(listener);+ return () => {+ listeners.delete(listener);+ };+};+const current = () => version;++/** Every download in the tray, oldest first; drawn again as they move. */+export function useDownloads(): DownloadLine[] {+ useSyncExternalStore(subscribe, current, current);+ return [...lines.values()];+}diff --git a/src/lib/ipc.ts b/src/lib/ipc.tsindex d85f46a..34fc527 100644--- a/src/lib/ipc.ts+++ b/src/lib/ipc.ts@@ -88,6 +88,50 @@ export type UploadEvent = {error: string | null;};+/** Where each downloading file's progress is announced (a folder, or a selection, into Downloads). */+export const DOWNLOAD = "quince://download";++/**+ * One step of a download: a file as it moves (a small one says only that it landed), a folder+ * that could not be read — or, for the batch, `found` while the tree is counted and `planned`+ * once all of it is known.+ */+export type DownloadEvent = {+ id: string;+ batch: string;+ name: string;+ /** The folders it sits in inside Downloads, as saved. */+ within: string;+ /** Bytes so far; on `found` and `planned`, how many files. */+ sent: number;+ /** Bytes in all; on `found` and `planned`, the bytes of every file. */+ total: number;+ state: "downloading" | "done" | "failed" | "cancelled" | "found" | "planned";+ /** A folder that could not be read or made, rather than a file. */+ folder: boolean;+ error: string | null;+};++/** What a download into Downloads came to. */+export type DownloadReport = {+ /** What it is known by: downloading the same again resumes it. */+ key: string;+ /** One path for each thing chosen that is there, whole or in part. */+ saved: string[];+ /** What did not arrive, one line each. */+ failed: string[];+ /** Failures past those named. */+ moreFailed: number;+ cancelled: boolean;+ /** Why it stopped short on its own: the disk full or about to be, the connection lost. */+ problem: string | null;+ /** It can be gone on with where it was left. */+ resumable: boolean;+};++/** A download that did not finish, from before — cancelled, stopped, or cut off by quitting. */+export type UnfinishedDownload = { key: string; title: string; items: DriveItem[]; saved: string[] };+/** Told whenever Skykeep's own update moves on; each window asks for its status again. */export const UPDATE = "quince://update";@@ -430,6 +474,19 @@ export const api = {driveItem: (drivewsid: string) => invoke<DriveItem | null>("drive_item", { drivewsid }),/** Saves to Downloads; returns the path it landed at. */driveDownload: (drivewsid: string, item?: DriveItem) => invoke<string>("drive_download", { drivewsid, item: item ?? null }),+ /**+ * Folders, or a selection of files and folders, into Downloads as the same tree. Progress+ * arrives as DOWNLOAD events under `batch`.+ */+ driveDownloadItems: (batch: string, title: string, items: DriveItem[]) =>+ invoke<DownloadReport>("drive_download_items", { batch, title, items }),+ /** Downloads that did not finish, oldest first: downloading one again resumes it. */+ driveDownloadsUnfinished: () => invoke<UnfinishedDownload[]>("drive_downloads_unfinished"),+ /** No longer offer to resume this download; what it saved stays. */+ driveDownloadForget: (key: string) => invoke<void>("drive_download_forget", { key }),+ /** Stop a download — a whole batch, or the batches these files are in. What arrived stays. */+ driveDownloadCancel: (ids: string[], batch?: string) =>+ invoke<void>("drive_download_cancel", { ids, batch: batch ?? null }),/** The files opened most recently, newest first. */driveRecents: () => invoke<RecentItem[]>("drive_recents"),/**diff --git a/src/screens/DriveView.tsx b/src/screens/DriveView.tsxindex 5f4dbb4..8943ac7 100644--- a/src/screens/DriveView.tsx+++ b/src/screens/DriveView.tsx@@ -25,6 +25,8 @@ import {} from "../lib/ipc";import { ActionGlyph, FileGlyph } from "../components/FileGlyph";import { UploadTray } from "../components/UploadTray";+import { DownloadTray } from "../components/DownloadTray";+import { startDownload } from "../lib/downloads";import { listen } from "@tauri-apps/api/event";import { Picker } from "../components/Picker";import { RowMenu } from "../components/RowMenu";@@ -818,6 +820,21 @@ export function DriveView() {}}, [markBusy]);+ /**+ * A copy in Downloads of what is chosen: one file as before, saved with a notice; a folder,+ * or several things, as the same tree — shown in the corner as it arrives, one line for all+ * of it, with Show in Folder once it is there.+ */+ const downloadItems = useCallback((chosen: DriveItem[]) => {+ if (chosen.length === 0) return;+ if (chosen.length === 1 && !isContainer(chosen[0])) {+ void download(chosen[0]);+ return;+ }+ setError(null);+ void startDownload(chosen, chosen.length === 1 ? driveName(chosen[0]) : `${chosen.length} items`);+ }, [download]);+const rename = useCallback(async (item: DriveItem, name: string) => {@@ -1599,6 +1616,14 @@ export function DriveView() {e.preventDefault();setPeeking(false);void removeAll(pickedItems);+ } else if ((k === "ContextMenu" || (k === "F10" && e.shiftKey && !e.ctrlKey && !e.metaKey && !e.altKey)) && primary) {+ // The menu key, or Shift-F10, as every desktop has them: the selection's own menu, under+ // its row — everything the right-click menu offers (Download among it), by the keys alone.+ e.preventDefault();+ setPeeking(false);+ const hit = listRef.current?.querySelector<HTMLElement>(`[data-id="${CSS.escape(primary.drivewsid)}"] .drive-row-hit`);+ const r = hit?.getBoundingClientRect();+ setMenu({ item: primary, x: r ? r.left + 24 : 24, y: r ? r.bottom : 24, alignRight: false });} else if (k === " " && !mod && onRows && primary) {e.preventDefault();setPeeking(true);@@ -1911,18 +1936,13 @@ export function DriveView() {{menu && (() => {// A right-click on the selection is for all of it, as Finder's menu is.const many = pickedItems.length > 1 && picked.includes(menu.item.drivewsid) ? pickedItems : null;- const files = many?.filter((i) => !isContainer(i)) ?? [];return (<RowMenuat={menu}onClose={() => setMenu(null)}entries={many ? [- ...(files.length- ? [{- label: files.length === 1 ? "Download a Copy" : `Download ${files.length} Copies`,- run: () => void (async () => { for (const f of files) await download(f); })(),- }]- : []),+ // Files and folders alike, as one download into Downloads.+ { label: `Download ${many.length} Copies`, run: () => downloadItems(many) },...(many.some(copyable) ? [{ label: "Copy", run: () => void copyItems(many) }] : []),{ label: "Move to Folder", run: () => setMoving(many) },null,@@ -1941,6 +1961,8 @@ export function DriveView() {]: []),{ label: isContainer(menu.item) ? "Open" : "Download a Copy", run: () => openItem(menu.item) },+ // A folder, whole, into Downloads.+ ...(isContainer(menu.item) ? [{ label: "Download a Copy", run: () => downloadItems([menu.item]) }] : []),{ label: "Get Info", run: () => setInfo(menu.item) },null,...(isContainer(menu.item) ? [] : [{ label: "Duplicate", run: () => void duplicate(menu.item) }]),@@ -1985,7 +2007,10 @@ export function DriveView() {<InfoSheet item={info} where={trail.map((c) => c.name).join(" › ")} thumb={thumbs[info.drivewsid]} onClose={() => setInfo(null)} />)}- <UploadTray uploads={[...uploads.values()]} onDismiss={dismissUploads} />+ <div className="trays">+ <DownloadTray />+ <UploadTray uploads={[...uploads.values()]} onDismiss={dismissUploads} />+ </div></div>);}diff --git a/src/styles/app.css b/src/styles/app.cssindex b5d352b..5fe6e97 100644--- a/src/styles/app.css+++ b/src/styles/app.css@@ -1494,6 +1494,24 @@.upload-row.is-failed .upload-state,.upload-row.is-failed .upload-where { color: var(--danger); }+/* Downloads and uploads at once: stacked in the one corner, downloads above, never over each+ other. The column takes no clicks of its own, so the list behind its gaps still does. */+.trays {+ position: fixed;+ right: 20px;+ bottom: 20px;+ z-index: 30;+ display: flex;+ flex-direction: column;+ align-items: flex-end;+ gap: 10px;+ pointer-events: none;+}+.trays > .upload-tray { position: static; pointer-events: auto; }+.trays > .upload-tray:not(:only-child) { max-height: min(320px, 40vh); }+.download-actions { display: flex; gap: 4px; }+.download-show { font-size: var(--t-11); padding: 2px 8px; white-space: nowrap; }+/* A screen that failed to draw, in place of the screen — the rest of the app carries on. */.screen-failed { max-width: 46ch; margin: 64px auto 0; text-align: center; color: var(--text-2); }.screen-failed p { margin: 0 0 12px; font-size: var(--t-13); }