Repository navigation
feat(flatpak): a setting keeps notesd running without a window, or not (G2) - #110
Merged
Merged
Conversation
…t (G2) Settings gains a Background section in the Flatpak: "Keep syncing when no window is open" (On by default), and what the desktop's Background portal last allowed. Off is the file $XDG_CONFIG_HOME/frostnotes/background-off: the launcher then asks the portal with --no-autostart, so the portal drops the autostart entry, and the app shell stops notesd (notesctl shutdown) when the primary instance exits. The helper writes the portal's answer to $XDG_STATE_HOME/frostnotes/background.json for the window to show. ADR-0033 (Proposed) records the decision. Plan 0008: G2 built; Phase 3's item 4 in each state is still to run on a real desktop.
…ows the new answer (cross-review) - request-background.py reads the off file itself, under an exclusive lock held until its answer is written, and asks again (at most 3 requests) when the setting changed meanwhile; no --no-autostart argument. - frostnotes --notesd starts notesd for a window; --background, the autostart's command line (also of older entries), starts none while the off file exists. - Settings shows "Asking the desktop…" and reads background.json every second, at most 30 s, until a new answer is in.
…hile open (cross-review) background_set names each change (FROSTNOTES_BACKGROUND_REQUEST), the helper writes that name into background.json, and Settings says "Asking the desktop…" until the answer to its own change is in. While the dialog is open it reads the answer every 2 s with no limit, so a late answer, the launcher's included, shows; no old answer returns after a timeout.
…s-review) The shell writes the setting, then notes the time (since); each helper notes askedMs under the lock just before it reads the setting. An answer with askedMs > since read the new setting, whichever helper wrote it, so a later helper's answer no longer leaves Settings asking forever.
…s included (cross-review) The shell bumps background-gen after it writes the setting; each helper reads it under the lock just before it reads the setting, and every outcome, a failure's included, carries it. Settings waits for an answer with generation >= its change's, so neither a clock that moves backward nor a helper that fails early leaves the row asking forever.
bketelsen
approved these changes
Oct 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Plan 0008, gap G2 (Brian's day line 7, T377a).
What. In the Flatpak, Settings gains a Background section:
How (ADR-0033, Proposed):
$XDG_CONFIG_HOME/frostnotes/background-off. The shell (app/src-tauri/src/background.rs, commandsbackground_get,background_set) writes it.frostnotes-request-background) reads the file itself, under an exclusive lock onbackground.lock, and asks the portal for autostart only while it is absent; it asks again (at most 3 requests) if the setting changed meanwhile. It writes the answer atomically to$XDG_STATE_HOME/frostnotes/background.json.frostnotes --background(the autostart command line, also of older entries) starts no notesd while the off file exists. A window's launcher starts notesd with the newfrostnotes --notesd.notesctl shutdown(bounded at 35 s) onRunEvent::Exit. A second launch exits in tauri-plugin-single-instance's setup before the app's setup marks the primary, so it never stops notesd.background-gen) after each change; each helper reads it under the lock before it reads the setting, and every answer, failures included, carries it. Settings polls every 2 s while open and ends "Asking the desktop…" on an answer with a generation at or above its change's.serde_jsonbecomes a direct dependency (already locked at 1.0.151;cargo-sources.jsonunchanged).Tests. Rust unit tests (paths, the off file, the counter, the answer's parse); Vitest (the section, each portal state, the polling and generations); the Flatpak smoke test (the helper is started with no arguments; window spawns use
--notesd;--backgroundwith the off file starts no notesd).Known limit (accepted by Brian, T394c): when a helper cannot take
background.lock(for example, a read-only state directory), it writes its failure without the lock and can replace a newer answer, so "Desktop permission" can stay on "Asking the desktop…" until Settings closes. Off itself is not affected. Tracked in #112.Not done here. Plan 0008 Phase 3, item 4 in each state, on a real desktop (the build sandbox has no portal).
Review. Cross-review by openai/gpt-6.1-sol: 1 review, 3 re-reviews and 1 extra re-review authorized by Brian (T394a); every blocking point fixed except the known limit above.
Coder: deepseek/deepseek-flash (subagent); parent: Irulan.