feat(flatpak): let the user choose which installation to act on

The same application can be present twice — in the user installation
and system-wide, or from two remotes or two branches — and flatpak then
refuses to act on the application id alone: "Multiple installed refs
match 'com.hoptodesk.HopToDesk'". Removing either copy was impossible
from the app.

A row now stands for the application and carries the copies it is made
of, so the details panel lists them and Remove opens one checkbox per
copy; the provider gets back the exact target it listed, and naming a
ref plus its installation is what makes the call unambiguous. Update
gains the same resolution, since it hit the very same refusal, and
removing one copy of two no longer takes the other one's launcher entry
away with it.

The listing that feeds it now asks flatpak for the ref, the branch and
the installation, and reads those columns by position: a branch
installed from a subdirectory has no version, and dropping that empty
column shifted every field after it.
This commit is contained in:
BlackAngelTV committed 2026-09-27 21:33:41 +02:00
1 parent f1fbd3cd8a
commit eb39905bf5
14 files changed
+559 -20

No files matched your search

+30
View File
@@ -7,6 +7,22 @@
#include <algorithm>
#include <cctype>
// One *installation* of a package. The same application can be present several
// times over — flatpak installs one copy in the user installation and another
// system-wide, or two different remotes or branches of the same id — and acting
// on "the package" is then ambiguous: flatpak refuses ("Multiple installed refs
// match …"). A provider that can have several fills `instances` so the view can
// list them and the user can choose the ones to act on.
struct PackageInstance {
// What the user reads: "utilisateur · flathub · stable".
std::string label;
// What the provider needs to act on exactly that one, in its own syntax
// ("user:com.example.App/x86_64/stable" for flatpak). The provider is the
// only one that understands it, which is why it is never shown and never
// rebuilt by the view.
std::string target;
};
// Information about a single package
struct PackageInfo {
std::string name;
@@ -22,6 +38,10 @@ struct PackageInfo {
// Every provider offering this package, after duplicate rows have been
// merged (used for display). The routing id stays in `provider`.
std::vector<std::string> providers;
// Every installation of this package, when the provider can have more than
// one (see PackageInstance). Empty means a single installation, which is
// what every provider but flatpak reports.
std::vector<PackageInstance> instances;
bool installed = false;
bool updateAvailable = false;
// Cleanup classification, filled by providers that report maintainable
@@ -62,6 +82,16 @@ inline void mergeProviderDuplicates(std::vector<PackageInfo>& packages) {
const PackageInfo& dup = packages[i];
first.installed = first.installed || dup.installed;
first.updateAvailable = first.updateAvailable || dup.updateAvailable;
// The installations of both rows belong to the merged one: that is how a
// package installed system-wide *and* per-user still shows the two
// copies the user can choose from.
for (const PackageInstance& instance : dup.instances) {
bool known = false;
for (const PackageInstance& existing : first.instances) {
if (existing.target == instance.target) { known = true; break; }
}
if (!known) first.instances.push_back(instance);
}
if (!dup.provider.empty()) {
bool known = false;
for (const auto& p : first.providers) {