From 78bf87c4e6bbad5a1c39670e1f48af009b9d3ee1 Mon Sep 17 00:00:00 2001 From: Eric Bell Date: Tue, 24 Nov 2026 07:10:28 -0500 Subject: [PATCH] Update HANDOFF.md with #20 findings and pending decision (Refs #20) Co-Authored-By: Claude Sonnet 5.5 --- HANDOFF.md | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/HANDOFF.md b/HANDOFF.md index a149eb2..ece0216 100644 --- a/HANDOFF.md +++ b/HANDOFF.md @@ -1,6 +1,6 @@ # Handoff: issue #20 (save writes a 0-byte file) -Written 2026-11-23. Read `OVERVIEW.md` first for the app itself. This file covers only the open problem. +Written 2026-11-23, updated 2026-11-24. Read `OVERVIEW.md` first for the app itself. This file covers only the open problem. ## The problem @@ -17,26 +17,27 @@ After unlocking, adding `#reset=1` and erasing the secrets, the Save button (Chr - Headless Chrome with a stubbed `showSaveFilePicker` (OPFS) wrote a full file, so assemble/encrypt is fine. A real picker can't be driven headless. - The user says **saving to a thumbdrive works fine**, while every SSD location tried fails. This contradicts the theory that Chrome blocks the `file://` site as a whole (`chrome://settings/content/filesystem`). Treat that theory as unlikely. -## What was changed (commit 613f039, not pushed) +## What was changed (commit 613f039, pushed) `save()` now catches `NotAllowedError`/`SecurityError` on the write, clears `state.handle`, downloads `final-wishes.html` as a fallback and sets an explanatory status. `docs/MAINTENANCE.md` has a matching line. Tests pass (63 pass, 1 skipped). This is a workaround, not a diagnosis. Issue #20 is still open. -Also committed this session: `c480ff1` (OVERVIEW.md refresh for `?reset=1`). Neither commit is pushed. +Also committed this session: `c480ff1` (OVERVIEW.md refresh for `?reset=1`). Both are pushed to origin/master, along with the first version of this file (52ce84c). -## Open hypotheses (why the SSD fails and the thumbdrive works) +## Findings since (the app is not at fault) -1. Overwriting an existing file (thumbdrive, probably) versus creating a new one (SSD). -2. Real filesystem permissions: a folder the user doesn't own, or a read-only or odd mount. Chrome can report OS "permission denied" as this same `NotAllowedError`. -3. Chrome's blocked-folder list on Linux (home folder itself, system or config folders). +- Tried `~/Documents/final-wishes.html`: still a 0-byte file and the same error. +- A bare test page with no app code (a button calling `showSaveFilePicker`, then `createWritable`/`write`/`close`) **fails the same way on both `http://localhost` and `file://`**, even for a tiny text file. So Chrome or the desktop refuses the write; Final Wishes is not involved. (The test page lived in the session scratchpad and is gone; it is about 20 lines to rebuild.) +- Ruled out on this machine: file ownership and mounts (`~`, `~/Documents`, `~/Downloads` and the project folder are all owned by the user and writable; root is read-write ext4; no external drive was mounted), Chrome snap/flatpak sandboxing (it is the normal `.deb`, `/opt/google/chrome`, v157), enterprise policy (`/etc/opt/chrome/policies` does not exist), and stored Chrome settings (`file_system_write_guard` and `file_system_read_guard` are empty in both profiles). +- Unusual: the desktop is **COSMIC on Wayland**, and the save dialog goes through the COSMIC and GTK xdg-desktop-portal services. Best guess, **unconfirmed**: the portal-based dialog hands Chrome a file it will not let the page write to. +- Still unexplained: the user says saving to a thumbdrive works. It has not been checked how (same dialog? overwriting an existing file?) and no drive was mounted when checked. -## Next steps +## Decision pending (the user is thinking it over) -1. Ask the user for the **exact SSD path** tried, and whether it was a new filename or an existing file. Check ownership and mount options (`ls -ld`, `findmnt`, `stat`). -2. Have the user try a **new filename on the thumbdrive**. If that fails too, the problem is creating new files, not the location. -3. Have the user try a plain save (no reset) on the SSD, and check the DevTools console. -4. If the cause stays unclear, add a small diagnostic that shows the exact error name and `location.href` in the status line. -5. Fallback the user may prefer: always download instead of saving in place. A download is Chrome writing the file, so it is allowed by default. The cost is that the old file is not overwritten. -6. The user must **rebuild and carry their data across** to get the fallback. A saved file keeps the code it was saved with. Run `npm run build` (done, `dist/final-wishes.html`), then use "Open your existing Final Wishes file" on the start screen. +1. **Make download the default save.** Chrome writes the file itself, which works here. Cost: no silent overwrite, so the user replaces the old copy by hand. Chrome's "Ask where to save each file" (`chrome://settings/downloads`) lets them choose the SSD folder. Keep save-in-place only as an opt-in, so a failed in-place save does not leave a stray 0-byte file. +2. Keep the current behaviour: try in place, and on `NotAllowedError` fall back to a download (already shipped in 613f039). Cost: each failed save leaves an empty file behind. +3. Investigate more first: another browser (Firefox and Safari already use the download path), and repeat the test page on the thumbdrive with a new filename and with an existing file. + +If option 1 is chosen: change `save()` in `src/app.js`, update `docs/MAINTENANCE.md` (the Chrome/Edge bullet in "Updating" and the "Backups" wording), update `OVERVIEW.md` (the Save paragraph), and add a test only if the logic can be isolated. Then close #20. ## Housekeeping