Skip to content

feat(app): say why when a Flatpak permission is refused (plan 0008, G5) - #107

Merged
bketelsen merged 11 commits into
mainfrom
feat/g5-say-why-refused
Oct 28, 2026
Merged

bketelsen merged 11 commits into
mainfrom
feat/g5-say-why-refused

Conversation

@frostyard-machines

@frostyard-machines frostyard-machines commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Plan 0008, gap G5: with no Flatpak portal the window says only that it is reconnecting, and a vault outside a narrowed --filesystem fails with a plain file error. Now both show their cause and the fix in the window.

Case 1: no Flatpak portal

  • The launcher already appends frostnotes: notesd did not start through the Flatpak portal (flatpak-spawn); see …/notesd.log to notesd.log. This PR does not change the launcher (feat(flatpak): a new window replaces a notesd of an older build (plan 0008, G3) #106 rewrites it and keeps that line).
  • New Tauri command notesd_log (app/src-tauri/src/notesd_log.rs), in the Flatpak only: a bounded read (8 KiB) of the log's end; the log path, its last line, and whether it is the launcher's portal line. A Go test (internal/packagecheck, TestPortalFailureLineMatchesTheApp) pins the Rust constant to the launcher's line; it is not a Rust include_str! test, because the Flatpak builds and tests the crate from app/ alone.
  • Connecting shows NotesdCause once the connection is lost: for the portal case, the cause and the checks (flatpak override --user --show, --reset, systemctl --user status flatpak-portal.service); otherwise the log's last line; both with the log's path. Outside the Flatpak and in lodge's web build nothing changes.

Case 2: a vault outside the Flatpak's file access

  • New package internal/sandbox: parses [Context] filesystems= of /.flatpak-info (host, home, ~/…, absolute paths, xdg-* with subpaths, :ro/:rw/:create, ! negations) and explains a file error (ENOENT, EACCES, EPERM, EROFS) on a path the grants do not cover, or cover read-only.
  • vault.add (open and create) answers invalidParams with: Frostnotes cannot reach PATH because the Flatpak's file access does not include it; grant it with: flatpak override --user --filesystem=PATH org.frostyard.Frostnotes, then log out and in (notesd keeps its sandbox until then). For a vault to create, PATH is the folder that holds it (Flatpak mounts only paths that exist). A covered path keeps its plain error.
  • The vault manager shows that message as it is. (No "Copy command" action: the cross-review showed that extracting a command from a message that holds a folder name is unsafe.)
  • When the parser is unsure (a bad key-file escape, an unknown token, an XDG folder it cannot resolve) or the path is one Flatpak always exposes (the app's own ~/.var/app/<ID>, /app, /usr, /etc, /tmp, /run except /run/media, …), the plain error stays.

Limits

  • A vault already registered that fails its scan at notesd's start is not covered: the window shows no scan error today, so it stays in notesd.log.
  • The cause shows on the first-connect screen; a window that loses notesd later shows the status bar line only.
  • Grant matching is by path; symlinks and host-os are not followed.
  • Neither case has run in a real Flatpak yet (plan 0008, Phase 3).

Checks

  • make check passes (umask 022).
  • Rust tests (notesd_log.rs, paths.rs), Vitest and Biome run in CI only: no nsl machine on this host.

Docs: design/app.md, specs/ui.md ("Connecting", the vault manager), plan 0008 G5 status, AGENTS.md map line.

@frostyard-machines frostyard-machines added the ready-for-human Reviewed, CI green: ready for Brian to review and merge label Oct 28, 2026
@frostyard-machines

Copy link
Copy Markdown
Contributor Author

Cross-review: reviewer openai/gpt-6.1-sol; coder github-copilot/claude-sonnet-5.5 (1 CI fix by github-copilot/claude-opus-5.5). Initial review at 698f115 in 2 batches (code at 698f115; docs at 1b2ddf0): 5 blocking points (the copied command could be taken from inside a folder name, so the Copy action is removed; GLib key-file list escapes; XDG folders guessed; always-exposed paths; the cause shown after the state left "lost"), all fixed. Re-review 1 at 1b2ddf0: 2 blocking points (user-dirs.dirs shell escapes; the wrong portal service, now flatpak-portal.service), fixed. Re-review 2 at 02b1199: Ready. CI then failed in the Flatpak build: the Rust pin test read packaging/ with include_str!, which the Flatpak's app/-only build cannot see; the pin moved to a Go test (internal/packagecheck). Re-review 3 at d4767aa: Ready, Blocking: none. CI green at d4767aa. The review budget is now spent.

@bketelsen
bketelsen merged commit eafe7bc into main Oct 28, 2026
9 checks passed
@bketelsen
bketelsen deleted the feat/g5-say-why-refused branch October 28, 2026 03:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-human Reviewed, CI green: ready for Brian to review and merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants