Repository navigation
fix(flatpak): a helper that cannot lock keeps a newer background answer - #114
Merged
Merged
Conversation
When the request helper cannot take its lock, it reads the counter when it writes its failure, and does not replace an answer in background.json whose generation is at least that counter. An older failure could hide a newer answer, and the Settings row 'Desktop permission' then stayed on 'Asking the desktop…' (ADR-0033). Fixes #112
A helper that could not take the lock wrote its failure to background.json, so it could replace a newer answer and leave the Settings row on "Asking the desktop…" (issue #112). It now writes background-failure-<generation>.json beside the answer, and removes the failures below its generation. A helper that did take the lock removes, after it wrote its answer, the failures up to its generation. The shell reads the answer and the failures, and shows the newer of the two; an answer wins a tie. The helper's lock failure has Go tests in internal/packagecheck, and the shell's choice has Rust unit tests. ADR-0033 and the design doc say so.
A failure that could not be written still removed the failures of lower generations, so the shell lost the last message it had. The unlocked path now removes them only after write_outcome wrote its own failure. A Go test makes the write fail: the failure's path is a directory. The docs say the order too.
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.
Fixes #112 (plan 0008, G2 follow-up).
The bug. When
frostnotes-request-backgroundcannot takebackground.lock, it wrote its failure tobackground.jsonwithout the lock. An older failure could replace a newer helper's answer, and the Settings row "Desktop permission" then stayed on "Asking the desktop…" until Settings closed.The fix. An unlocked failure never writes
background.json:background-gen) when it writes, and writesbackground-failure-<generation>.jsonatomically in the same directory. It removes failures of lower generations.background.rs,state()) reads the answer and the failure of the highest number, and shows the newer one; an answer wins a tie. Only the exact namebackground-failure-<digits>.jsoncounts.So no writer without the lock can replace a newer message. (A first version checked the answer before it replaced it; the cross-review showed that check-then-replace still raced. This commit replaces it.)
Tests.
internal/packagecheck/background_helper_test.goruns the real helper withpython3and a lock path that is a directory:background.jsonstays byte for byte, the failure file has the current counter, and lower failures go. Rust unit tests inbackground.rscover the choice and the exact name.Docs.
docs/design/app.md(The Flatpak, Background activity) and ADR-0033 (Proposed, edited in place).Checks.
make checkpasses locally. The Rust compiles and runs only in CI (App shelljob): there is no nsl machine on the agents' host.