feat(files): download from anywhere — a link box, a pasted link, the palette; the running downloads in a tray

- Files toolbar link box (paste button, Enter); a lone http(s) link pasted onto any page opens the one
  app-wide download dialog, which now names the link; the palette's "Download from a link…" focuses
  the box on its history entry.
- The download tray, bottom right on every page: what waits, runs, is paused or failed (reason +
  Retry, the queue's right-click / "…" menu), and what finished in this tab as "Done · Open" until
  closed; folds to a pill (per-account pref); closed, it stays shut — across a reload — until the
  work changes or something finishes. Back to top steps up over it, the page end keeps clear.
- A finish is announced once: "Downloaded: …", whether a phone plays it, Copy link + Open (toasts
  and notices may carry a second action).
- The inbox's ready notice opens the file in its folder: download_done carries job_id + folder_id.
- GET /api/downloads is the queue only (in flight, failed, finished in the last 10 minutes), with
  each row's source key.
This commit is contained in:
2026-10-11 16:56:13 +02:00
parent d22c64f4dd
commit 1c4f0042d2
42 changed files with 1509 additions and 162 deletions
+32
View File
@@ -506,3 +506,35 @@ def test_a_new_file_at_an_assets_path_forgets_the_old_hash(db, make_user):
asset.sha256 = "ab" * 32
asset.rel_path = "converted.mp4"
assert asset.sha256 is None
# --- the queue (the tray's poll) ------------------------------------------------------------------
def test_the_queue_is_what_is_in_flight_and_what_just_finished_not_the_library(
db, make_user, as_user
):
# The tray polls this on every page: a finished file is the library's, so it is listed only
# while the tray may still be showing it done.
from sqlalchemy import update
user = make_user()
old = _file(db, user.id, title="Old")
fresh = _file(db, user.id, title="Fresh")
waiting = _file(db, user.id, title="Waiting", status=JobStatus.QUEUED)
stuck = _file(db, user.id, title="Stuck", status=JobStatus.ERROR)
paused = _file(db, user.id, title="Paused", status=JobStatus.PAUSED)
stopped = _file(db, user.id, title="Stopped", status=JobStatus.ERROR)
dropped = _file(db, user.id, title="Dropped", status=JobStatus.CANCELED)
for job in (old, stopped, dropped):
db.execute(
update(DownloadJob)
.where(DownloadJob.id == job.id)
.values(updated_at=NOW - timedelta(hours=1))
)
db.commit()
rows = as_user(user).get("/api/downloads").json()
# An old failure still waits for the user; an old finished or cancelled job does not.
assert {row["id"] for row in rows} == {fresh.id, waiting.id, stuck.id, paused.id, stopped.id}
# The tray names where each came from, as the library does.
assert {row["source_key"] for row in rows} == {"youtube"}