feat(studio): channel switcher, autostart toggle, Store redesign (v0.18.0)

UI parity for operators who never touch a CLI, plus a Store
that reads more like an app store.

Settings dialog:
- Channel rows gain a popup menu: Connect / Make active /
  Enable autostart / Disable autostart. "Connect" still
  re-points Studio's wire; "Make active" actually writes
  ~/.fai/current-channel via `fai channel switch`.
- Inline output panel surfaces the spawned binary's stdout
  on success or stderr on failure, so operators see what
  happened without opening a terminal.

Store page rewrite:
- Big top search bar with a clear button. Live filter on
  every keystroke.
- Horizontal category strip auto-populated from the index;
  segmented status row (All / Published / Alpha / Planned),
  Installed-only chip, result count.
- Grid of cards that reflows to fit the viewport — replaces
  the previous single-column list. Each card shows
  category-aware icon, version, status, tagline preview, and
  a one-click Install (or Details for installed / planned).
- Per-module detail sheet renders the full bilingual
  description with a DE/EN toggle, separate Required-
  capabilities + Required-host-services sections, repo link,
  Read-docs button. Install + Uninstall live at the bottom.
- StoreItem and HubService.searchStore now carry the German
  tagline + description so the locale toggle has something
  to switch to.

SystemActions extended with `faiChannelSwitch`,
`faiDaemonEnable`, `faiDaemonDisable` so Settings can spawn
the right CLI without each call site reimplementing the
`fai` resolution rules.

Signed-off-by: flemming-it <stefan.a.flemming@googlemail.com>
This commit is contained in:
flemming-it 2026-05-07 18:52:48 +02:00
parent 73e394b39f
commit 93926741b1
6 changed files with 1053 additions and 270 deletions

View file

@ -6,6 +6,7 @@ import 'package:fai_dart_sdk/fai_dart_sdk.dart';
import 'package:flutter/material.dart';
import '../data/hub.dart';
import '../data/system_actions.dart';
import '../theme/theme.dart';
import '../theme/tokens.dart';
import 'fai_pill.dart';
@ -33,6 +34,7 @@ class _FaiSettingsDialogState extends State<FaiSettingsDialog> {
bool _secure = false;
bool _saving = false;
String? _error;
String? _channelToast;
ChannelStatusSnapshot? _channels;
SystemAiStatus? _aiStatus;
@ -69,6 +71,40 @@ class _FaiSettingsDialogState extends State<FaiSettingsDialog> {
}
}
Future<void> _switchChannel(String name) async {
setState(() {
_saving = true;
_channelToast = null;
});
final r = await SystemActions.faiChannelSwitch(name);
if (!mounted) return;
setState(() {
_saving = false;
_channelToast = r.ok
? 'Switched active channel to "$name". Daemon restarted.\n${r.stdout.trim()}'
: 'Channel switch failed: ${r.stderr.isEmpty ? r.stdout : r.stderr}';
});
if (r.ok) await _loadChannels();
}
Future<void> _runDaemon(
String label,
Future<({bool ok, String stdout, String stderr})> Function() action,
) async {
setState(() {
_saving = true;
_channelToast = null;
});
final r = await action();
if (!mounted) return;
setState(() {
_saving = false;
_channelToast = r.ok
? 'OK · $label\n${r.stdout.trim()}'
: 'Failed · $label\n${(r.stderr.isEmpty ? r.stdout : r.stderr).trim()}';
});
}
Future<void> _connectToChannel(ChannelInfo ch) async {
setState(() {
_host.text = '127.0.0.1';
@ -227,13 +263,49 @@ class _FaiSettingsDialogState extends State<FaiSettingsDialog> {
fontSize: 10,
),
),
const SizedBox(height: 4),
const SizedBox(height: 2),
Text(
'Switch hub channel (writes ~/.fai/current-channel and '
'restarts the daemon). Connect just changes Studio\'s wire.',
style: theme.textTheme.bodySmall?.copyWith(
color: theme.colorScheme.onSurfaceVariant,
),
),
const SizedBox(height: FaiSpace.sm),
for (final ch in _channels!.channels)
_ChannelRow(
channel: ch,
active: ch.name == _channels!.active,
onConnect: _saving ? null : () => _connectToChannel(ch),
onSwitch: _saving ? null : () => _switchChannel(ch.name),
onEnableAutostart: _saving ? null : () => _runDaemon(
'enable autostart',
() => SystemActions.faiDaemonEnable(ch.name),
),
onDisableAutostart: _saving ? null : () => _runDaemon(
'disable autostart',
() => SystemActions.faiDaemonDisable(ch.name),
),
),
if (_channelToast != null) ...[
const SizedBox(height: FaiSpace.sm),
Container(
width: double.infinity,
padding: const EdgeInsets.all(FaiSpace.sm),
decoration: BoxDecoration(
color: theme.colorScheme.surfaceContainerHigh,
borderRadius: BorderRadius.circular(FaiRadius.sm),
border: Border.all(color: theme.colorScheme.outlineVariant),
),
child: SelectableText(
_channelToast!,
style: FaiTheme.mono(
size: 11,
color: theme.colorScheme.onSurface,
),
),
),
],
],
if (_aiStatus != null) ...[
const SizedBox(height: FaiSpace.lg),
@ -285,18 +357,27 @@ class _ChannelRow extends StatelessWidget {
final ChannelInfo channel;
final bool active;
final VoidCallback? onConnect;
/// Switches the active channel pointer (`fai channel switch`).
/// Distinct from [onConnect], which only re-points Studio's
/// gRPC wire at a different running daemon.
final VoidCallback? onSwitch;
final VoidCallback? onEnableAutostart;
final VoidCallback? onDisableAutostart;
const _ChannelRow({
required this.channel,
required this.active,
required this.onConnect,
required this.onSwitch,
required this.onEnableAutostart,
required this.onDisableAutostart,
});
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
return Padding(
padding: const EdgeInsets.symmetric(vertical: 2),
padding: const EdgeInsets.symmetric(vertical: 4),
child: Row(
children: [
Icon(
@ -337,18 +418,64 @@ class _ChannelRow extends StatelessWidget {
),
),
if (active)
Padding(
padding: const EdgeInsets.only(right: FaiSpace.sm),
child: Text(
'active',
style: theme.textTheme.labelSmall?.copyWith(
color: theme.colorScheme.primary,
const Padding(
padding: EdgeInsets.only(right: FaiSpace.sm),
child: FaiPill(label: 'active', tone: FaiPillTone.success),
),
PopupMenuButton<String>(
tooltip: 'Channel actions',
icon: const Icon(Icons.more_vert, size: 18),
onSelected: (v) {
switch (v) {
case 'connect':
onConnect?.call();
break;
case 'switch':
onSwitch?.call();
break;
case 'enable':
onEnableAutostart?.call();
break;
case 'disable':
onDisableAutostart?.call();
break;
}
},
itemBuilder: (_) => [
PopupMenuItem(
value: 'connect',
enabled: channel.running && onConnect != null,
child: const _MenuRow(
icon: Icons.link,
text: 'Connect Studio to this channel',
),
),
),
TextButton(
onPressed: channel.running ? onConnect : null,
child: const Text('Connect'),
PopupMenuItem(
value: 'switch',
enabled: !active && onSwitch != null,
child: const _MenuRow(
icon: Icons.swap_horiz,
text: 'Make this the active channel',
),
),
const PopupMenuDivider(),
PopupMenuItem(
value: 'enable',
enabled: onEnableAutostart != null,
child: const _MenuRow(
icon: Icons.play_circle_outline,
text: 'Enable autostart at login',
),
),
PopupMenuItem(
value: 'disable',
enabled: onDisableAutostart != null,
child: const _MenuRow(
icon: Icons.pause_circle_outline,
text: 'Disable autostart',
),
),
],
),
],
),
@ -356,6 +483,23 @@ class _ChannelRow extends StatelessWidget {
}
}
class _MenuRow extends StatelessWidget {
final IconData icon;
final String text;
const _MenuRow({required this.icon, required this.text});
@override
Widget build(BuildContext context) {
return Row(
children: [
Icon(icon, size: 14),
const SizedBox(width: FaiSpace.sm),
Text(text),
],
);
}
}
class _SystemAiPanel extends StatelessWidget {
final SystemAiStatus status;
final VoidCallback onEdit;