Repository navigation
Conversation
`openlogi_permissions::udev` probed `/.flatpak-info` itself. The agent's autostart is about to branch on the same question, so the probe moves to `openlogi_core::sandbox::is_flatpak` before a second copy appears, with an ast-grep guard against probing the file anywhere else.
…ortal Inside the Flatpak the toggle never worked. The systemd arm ran `systemctl --user enable`, which the sandbox does not have, and wrote its unit into the sandbox's `$XDG_DATA_HOME` (`~/.var/app/<id>/data`), which the host's systemd never reads. In a Flatpak the agent now asks the XDG Background portal instead: `RequestBackground` with `autostart` and the agent as `commandline`, which has the host write (or, with `autostart` cleared, remove) `~/.config/autostart/org.openlogi.OpenLogi.desktop`. It shares the systemd arm's enablement claim, so a disabled setting only talks to the portal to withdraw an autostart this app asked for, and a user who never enabled it is never shown a background-permission prompt. Only the request is awaited. The user's answer is logged from a helper thread, which also keeps the bus connection open until then, since the portal cancels a request whose sender leaves the bus.
Confidence Score: 4/5
[Medium impact] The behavior change is limited to Linux launch-at-login, mainly for Flatpak users. The code addresses the marker-loss bug, but the required regression-test counter-proof remains outstanding before merge.
|
…s removal The portal route dropped the enablement marker as soon as the removal request was accepted. A removal the portal then refused, failed, or never answered left autostart on with no claim, so no later reconcile withdrew it. The withdraw step now reports Done, Failed, or Pending, and a pending removal keeps the claim. The portal's requests live in one Requests state (Idle, Pending with a request id, Confirmed) that reconcile and the response thread change under one lock. The answer to the latest request alone settles it: a confirmed removal drops the claim, a refusal returns to Idle so the next reconcile asks again, and an answer to a superseded request changes nothing. Reconcile's Flatpak dispatch goes through reconcile_in, which takes the sandbox answer and both routes as arguments, so tests now cover the routing, the withdrawal outcomes, and the portal state transitions. Reverting the dispatch or the deferred marker clear fails them.
This branch has not been deployed
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.
Summary
Settings → General → Launch at login does nothing in the Flatpak. The agent's Linux autostart runs
systemctl --user enable, which the sandbox doesn't have:It also writes the unit to the sandbox's
$XDG_DATA_HOME(~/.var/app/org.openlogi.OpenLogi/data/systemd/user/), which the host's systemd never reads. So the setting is saved as on, but the agent is never started at login.In a Flatpak, the agent now asks the XDG Background portal instead.
RequestBackgroundwithautostart: trueand the agent ascommandlinemakes the host write~/.config/autostart/org.openlogi.OpenLogi.desktop(flatpak run --command=/app/bin/openlogi-agent org.openlogi.OpenLogi). Withautostart: false, the host removes that file.Changes
openlogi_core::sandbox::is_flatpak()(behind thefsfeature) is now the one place that checks for/.flatpak-info. A new ast-grep guard (core-flatpak-sandbox-owner) flags any other check.udev::rules_managercallsis_flatpak()instead of checking the file itself.autostart::linux::reconcilesends Flatpak builds to a newautostart/linux/portal.rs, throughreconcile_in, which takes the sandbox answer and both routes as arguments so the routing is testable.claim_enablement_at/withdraw_enablement_at), so the portal path uses the same ownership rules. When the setting is off, the agent only contacts the portal to remove an autostart it created. A user who never turned it on never sees a background-permission prompt.Done,FailedorPending, and onlyDonedrops the marker. A portal removal isPendinguntil the portal confirms it, so a removal that is refused, fails, or is never answered keeps the marker and is asked for again.reconcileruns at agent startup and insidereload_config, neither of which can wait for the user. The portal'sResponseis handled on a helper thread. That thread also keeps the bus connection open until the answer arrives, because xdg-desktop-portal cancels a request when its sender leaves the bus.Requestsstate (Idle,Pendingwith a request id,Confirmed). Reconcile and the response thread change it under one lock. Only the answer to the latest request settles it: a confirmed removal clears the marker, a refusal goes back toIdle, and an answer to a superseded request changes nothing.INSTALL-linux.mdcovers the Flatpak in its Flatpak and Autostart sections.Like Windows, this is login launch only: there is no equivalent of
Restart=on-failure.Testing
On Fedora 45 aarch64, KDE Plasma 6.8, xdg-desktop-portal 1.22.1 + xdg-desktop-portal-kde 6.8.4:
cargo fmt --all -- --checkRUSTFLAGS="-D warnings" cargo clippy --workspace --exclude openlogi-ui --exclude openlogi-desktop --exclude openlogi-overlay --all-targets -- -D warningsRUSTFLAGS="-D warnings" cargo test --workspace --exclude openlogi-ui --exclude openlogi-desktop --exclude openlogi-overlayRUSTDOCFLAGS="-D warnings" cargo doc --workspace --no-deps --document-private-items --exclude openlogi-ui --exclude openlogi-desktop --exclude openlogi-overlay --exclude openlogi-agentast-grep scanpasses. Reverting theudev.rscall site makes the new guard fail.freetype-sys, so CI's lanes for those crates are the check. They only gain an extrapub modinopenlogi-core.The follow-up commit (marker kept until the portal confirms) was checked with
cargo fmt,cargo clippy -p openlogi-agent --all-targets -- -D warnings,cargo test -p openlogi-agent --bin openlogi-agent autostart(46 pass), andast-grep scan.New regression tests, none needing a session bus:
a_flatpak_reconciles_through_the_portal_and_not_systemd: the Flatpak case reaches only the portal, the other case only systemd.disabling_without_a_claim_sends_nothing,enabling_claims_and_asks_for_the_agent_at_login: the portal path keeps the claim rules.a_withdrawn_claim_is_dropped_only_once_the_portal_confirms,a_refused_removal_is_asked_for_again,a_pending_request_is_not_repeated,a_stale_removal_answer_keeps_the_newer_claim: the request state and marker transitions.withdrawing_without_a_claim_runs_nothing,a_claim_is_dropped_only_by_a_completed_withdrawal,only_a_completed_uncontradicted_response_is_granted.Counter-proof: with the Flatpak branch disabled in
reconcile_in,a_flatpak_reconciles_through_the_portal_and_not_systemdfails. With a pending portal removal counted as done (the original marker bug),a_withdrawn_claim_is_dropped_only_once_the_portal_confirmsanda_refused_removal_is_asked_for_againfail.Runtime: built
openlogi-agentforaarch64-unknown-linux-musland ran it inside the installed v0.9.0 Flatpak (flatpak run --filesystem=… --command=…/openlogi-agent org.openlogi.OpenLogi). This was before the follow-up commit:launch_at_login = true: KDE granted the request without a dialog, and the agent loggedBackground portal answered requested=true autostart=Some(true).~/.config/autostart/org.openlogi.OpenLogi.desktopappeared withX-Flatpak=org.openlogi.OpenLogi, and theautostart.enabledmarker was recorded.launch_at_login = false: the portal answeredautostart=Some(false), the autostart file was removed, and the marker was cleared.launch_at_login = falsewith no marker: the agent made no portal call and loggedautostart enablement was not made by OpenLogi; leaving it alone.Not tested yet: an actual login on a real
.flatpakbundle, GNOME's first-run "allow background" dialog, and a runtime pass of the follow-up commit.