desktop: Import and Export work offline; the menu toggle is reachable; errors say why
CI & Build / Build now, or wait for Android? (push) Successful in 4s
Android / Build, or is the channel already serving this? (push) Successful in 4s
CI & Build / Python lint (push) Successful in 2s
CI & Build / Web typecheck and unit tests (push) Successful in 12s
Desktop (Tauri) / Build, or is the channel already serving this? (push) Successful in 2s
CI & Build / Python tests (push) Successful in 13s
CI & Build / integration (push) Successful in 48s
CI & Build / Build & push image (push) Skipped
Desktop (Tauri) / Web tests, clippy, Rust tests and rustfmt (push) Successful in 4m26s
Desktop (Tauri) / Windows installer (cross-compiled) (push) Successful in 3m32s
Desktop (Tauri) / Tauri desktop (Linux) (push) Successful in 4m10s
Desktop (Tauri) / Update manifest (push) Successful in 4s
Android / Kotlin + Rust (APK) (push) Successful in 12m42s

Export and Import were a link to the server and a reject("needs a server") on the
desktop. Both now run in the core with no server:

- core/src/local/portable.rs builds the same zip the server writes (notes.json,
  a Markdown file per note, each attachment this device holds) and reads either
  export marker or a Google Keep Takeout zip, with the server's decompression
  budget and an all-or-nothing transaction. Export saves to Downloads (no new
  plugin) and the sidebar says where; Import takes the archive as raw IPC bytes.
- core/testdata/portable.json pins the format for both copies: the server runs
  its Keep and native readers against it (test_portable_fixture.py) and checks
  its real export's keys (test_integration.py); the core runs the same cases.
- Found on the way: both importers skipped a Keep note that is only a photo as
  "empty". It now imports, on the server and in the core.
- New dependency, approved: `zip` (deflate only) plus `flate2` on its pure-Rust
  backend, both already in the lockfile.

The AppImage applications-menu toggle moves from Account, which the desktop
never shows, to the Sync page; the first-run prompt now says so.

errorMessage (#5236) replaces the hand-rolled `.error ?? …` / `.message ?? e`
reads at the remaining catch sites, so a desktop failure shows its real reason.

Task #5170.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-07 11:36:42 -04:00
co-authored by Claude Opus 5.5
parent ac4427f834
commit 5989ffc1c6
27 changed files with 1365 additions and 88 deletions
+58
View File
@@ -874,3 +874,61 @@ async def test_a_preview_arriving_or_leaving_moves_its_note_in_the_feed(app_clie
preview_id = (await (await app_client.get(f"/api/notes/{nid}")).get_json())["previews"][0]["id"]
await app_client.delete(f"/api/notes/{nid}/previews/{preview_id}")
assert await _note_revision(app_client, nid) > arrived
# --- the export format, pinned against the shared fixture (#5170) ---------------
async def test_an_export_writes_the_keys_the_shared_fixture_names(app_client, db):
"""The desktop exports offline with the core's copy of this format, and both
copies are held to core/testdata/portable.json. This is the server's side."""
import io
import json
import zipfile
from pathlib import Path
keys = json.loads(
(Path(__file__).resolve().parents[1] / "core" / "testdata" / "portable.json").read_text(encoding="utf-8")
)["export"]
await _signed_in(app_client, "exporter")
assert (await app_client.post("/api/labels", json={"name": "travel"})).status_code == 201
nid = await _pushed_note(app_client, "exported")
raw = b"%PDF-1"
assert (await _put(app_client, str(uuid.uuid4()), nid, raw)).status_code == 201
resp = await app_client.get("/api/notes/export")
assert resp.status_code == 200
with zipfile.ZipFile(io.BytesIO(await resp.get_data())) as zf:
doc = json.loads(zf.read("notes.json"))
assert sorted(doc) == sorted(keys["document"])
assert doc["app"] == "inkwell"
[note] = doc["notes"]
assert sorted(note) == sorted(keys["note"])
assert [sorted(lb) for lb in doc["labels"]] == [sorted(keys["label"])]
[att] = note["attachments"]
assert sorted(att) == sorted(keys["attachment"])
assert zf.read(att["file"]) == raw, "the listed file is in the archive"
async def test_a_keep_note_that_is_only_a_photo_imports(app_client, db):
"""It used to be skipped as empty. The core's importer keeps it as well."""
import io
import json
import zipfile
from werkzeug.datastructures import FileStorage
await _signed_in(app_client, "keeper")
buf = io.BytesIO()
with zipfile.ZipFile(buf, "w") as zf:
zf.writestr("Takeout/Keep/Photo.json", json.dumps({"textContent": "", "attachments": [{"filePath": "p.png"}]}))
zf.writestr("Takeout/Keep/p.png", b"png bytes")
zf.writestr("Takeout/Keep/Empty.json", json.dumps({"textContent": " "}))
resp = await app_client.post(
"/api/notes/import", files={"file": FileStorage(io.BytesIO(buf.getvalue()), filename="takeout.zip")}
)
assert resp.status_code == 201
assert await resp.get_json() == {"source": "keep", "imported": 1, "skipped": 1}
[note] = (await db.scalars(select(Note))).all()
[att] = (await db.scalars(select(NoteAttachment).where(NoteAttachment.note_id == note.id))).all()
assert att.mime == "image/png"