feat(settings): multi-version uninstall picker + default_scope editor
Some checks failed
Security / Security check (push) Failing after 2s

Two operator surfaces shipped together:

**Multi-version uninstall picker** — when more than one version
of a `(provider, name)` is installed side-by-side, both the
module-sheet "Uninstall" affordance and the store-detail
"Uninstall" affordance now ask the operator which version to
remove before calling the RPC. The hub's wire-level support for
this (UninstallModuleRequest.version) was already there; Studio
just wasn't using it. Picker pre-selects the highest version so
single-version flows still take one click.

  - `HubService.installedVersions(name)` enumerates the installed
    versions via the capabilities list.
  - `HubService.uninstallModule(name, version: ...)` forwards
    the version into the RPC.
  - `_UninstallVersionPickerDialog` (module sheet) and
    `_StoreUninstallVersionPickerDialog` (store) host the
    picker — separate widgets so each surface can evolve copy
    independently. Uses `RadioGroup<String>` for Flutter
    3.32+ deprecation compliance.

**Default scope editor** — new DEFAULT SCOPE panel in Settings
that calls the freshly-added HubAdmin RPCs
`GetDefaultScope` / `SetDefaultScope`. Operators can:

  - reorder publisher segments with up/down buttons
    (first match wins in the bare-form resolver),
  - delete entries (hub still rejects empty list — Studio
    surfaces the constraint inline),
  - add arbitrary entries via the text field,
  - add catalog-known publishers via suggestion chips
    (sorted alphabetically, populated from the catalog).

Every change persists to `~/.fai/config.yaml` via the hub
and hot-swaps the in-memory copy without a daemon restart.

Bumped pubspec to 0.48.0. dart analyze clean (No issues
found!); flutter test green (11 tests).

Signed-off-by: flemming-it <stefan.a.flemming@googlemail.com>
This commit is contained in:
flemming-it 2026-05-29 00:21:51 +02:00
parent 327bc0fea2
commit 1903babc5a
10 changed files with 750 additions and 7 deletions

View file

@ -2029,6 +2029,24 @@ class _StoreDetailSheetState extends State<_StoreDetailSheet> {
Future<void> _uninstall() async {
final l = AppLocalizations.of(context)!;
// Multi-version aware: ask which version to remove when
// more than one is installed side-by-side. Otherwise the
// hub picks "highest version" and the operator can be
// surprised by what disappeared.
final versions =
await HubService.instance.installedVersions(widget.item.name);
if (!mounted) return;
String? targetVersion;
if (versions.length > 1) {
targetVersion = await showDialog<String>(
context: context,
builder: (ctx) => _StoreUninstallVersionPickerDialog(
moduleName: widget.item.name,
versions: versions,
),
);
if (targetVersion == null || !mounted) return;
}
final ok = await showDialog<bool>(
context: context,
builder: (ctx) => AlertDialog(
@ -2056,7 +2074,10 @@ class _StoreDetailSheetState extends State<_StoreDetailSheet> {
_toast = null;
});
try {
final r = await HubService.instance.uninstallModule(widget.item.name);
final r = await HubService.instance.uninstallModule(
widget.item.name,
version: targetVersion ?? '',
);
if (!mounted) return;
final l2 = AppLocalizations.of(context)!;
setState(() {
@ -3398,3 +3419,80 @@ class _ProvenancePill extends StatelessWidget {
}
}
}
/// Store-side version picker. Same shape as the module-sheet
/// version picker but lives here so the Store page doesn't take
/// a dependency on the module-sheet's private widgets. The
/// duplication is small (one dialog), and keeping them
/// separate lets each surface evolve its copy independently.
class _StoreUninstallVersionPickerDialog extends StatefulWidget {
final String moduleName;
final List<String> versions;
const _StoreUninstallVersionPickerDialog({
required this.moduleName,
required this.versions,
});
@override
State<_StoreUninstallVersionPickerDialog> createState() =>
_StoreUninstallVersionPickerDialogState();
}
class _StoreUninstallVersionPickerDialogState
extends State<_StoreUninstallVersionPickerDialog> {
late String _picked;
@override
void initState() {
super.initState();
_picked = widget.versions.last;
}
@override
Widget build(BuildContext context) {
final l = AppLocalizations.of(context)!;
return AlertDialog(
title: Text(l.uninstallVersionPickerTitle),
content: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
Text(l.uninstallVersionPickerBody(widget.moduleName)),
const SizedBox(height: FaiSpace.md),
RadioGroup<String>(
groupValue: _picked,
onChanged: (val) {
if (val != null) setState(() => _picked = val);
},
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
for (final v in widget.versions)
RadioListTile<String>(
value: v,
title: Text(
'v$v',
style: const TextStyle(fontFamily: 'monospace'),
),
dense: true,
contentPadding: EdgeInsets.zero,
),
],
),
),
],
),
actions: [
TextButton(
onPressed: () => Navigator.pop(context),
child: Text(l.buttonCancel),
),
FilledButton(
onPressed: () => Navigator.pop(context, _picked),
child: Text(l.uninstallVersionPickerContinue),
),
],
);
}
}