feat(studio): first-run UX, recovery affordances, l10n, bundled fonts

- Connection-aware Welcome: when the hub is down, show a hero with a
  primary "Start hub" CTA + install fallback instead of a dead,
  all-unchecked onboarding checklist (the first-run cliff).
- Actionable binary-not-found (file picker + install link, not a
  "set FAI_BIN" dead end) and a connect-failure banner after
  repeated failed health polls.
- Localize six hardcoded English error/toast clusters (DE+EN ARB).
- Bundle Inter + JetBrains Mono as assets; drop the runtime
  google_fonts fetch (air-gap / KRITIS safe, no font-swap flash).

Signed-off-by: flemming-it <stefan.a.flemming@googlemail.com>
This commit is contained in:
flemming-it 2026-06-11 23:52:18 +02:00
parent 7511867774
commit 5313266cc4
25 changed files with 1231 additions and 234 deletions

View file

@ -0,0 +1,95 @@
// Recovery affordance shown when Studio cannot locate the `fai`
// binary on the machine. Replaces the old CLI-jargon dead-end
// ("set FAI_BIN to its full path") with two acts a non-CLI
// operator can actually take:
//
// 1. Locate the binary with a native file picker, persisting
// the choice via SystemActions.setFaiBinaryPath.
// 2. Open the install guide in the OS browser.
import 'package:file_picker/file_picker.dart';
import 'package:flutter/material.dart';
import '../data/system_actions.dart';
import '../l10n/app_localizations.dart';
import '../theme/tokens.dart';
class FaiBinaryRecovery extends StatelessWidget {
/// Fired after the operator successfully picks a `fai` binary,
/// so the host can retry whatever action hit the missing
/// binary (e.g. re-run the daemon start / status probe).
final VoidCallback? onLocated;
const FaiBinaryRecovery({super.key, this.onLocated});
Future<void> _locate(BuildContext context) async {
final l = AppLocalizations.of(context)!;
final messenger = ScaffoldMessenger.of(context);
final picked = await FilePicker.pickFiles(
dialogTitle: l.faiBinaryPickerTitle,
);
final path = picked?.files.single.path;
if (path == null) return;
final ok = await SystemActions.setFaiBinaryPath(path);
messenger.showSnackBar(
SnackBar(
content: Text(ok ? l.faiBinarySetOk(path) : l.faiBinaryNotFound),
),
);
if (ok) onLocated?.call();
}
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
final l = AppLocalizations.of(context)!;
return Container(
width: double.infinity,
padding: const EdgeInsets.all(FaiSpace.md),
decoration: BoxDecoration(
color: theme.colorScheme.errorContainer.withValues(alpha: 0.4),
borderRadius: BorderRadius.circular(FaiRadius.sm),
border: Border.all(
color: theme.colorScheme.error.withValues(alpha: 0.4),
),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
l.faiBinaryNotFound,
style: theme.textTheme.bodyMedium?.copyWith(
fontWeight: FontWeight.w600,
color: theme.colorScheme.error,
),
),
const SizedBox(height: FaiSpace.xs),
Text(
l.faiBinaryNotFoundHint,
style: theme.textTheme.bodySmall?.copyWith(
color: theme.colorScheme.onSurfaceVariant,
),
),
const SizedBox(height: FaiSpace.md),
Wrap(
spacing: FaiSpace.sm,
runSpacing: FaiSpace.sm,
children: [
FilledButton.tonalIcon(
onPressed: () => _locate(context),
icon: const Icon(Icons.folder_open, size: 16),
label: Text(l.faiBinaryLocateButton),
),
OutlinedButton.icon(
onPressed: () =>
SystemActions.openInOs(kFaiInstallDocsUrl),
icon: const Icon(Icons.open_in_new, size: 16),
label: Text(l.faiBinaryInstallDocsButton),
),
],
),
],
),
);
}
}

View file

@ -293,11 +293,12 @@ class _FaiSettingsDialogState extends State<FaiSettingsDialog> {
});
final r = await SystemActions.faiChannelSwitch(name);
if (!mounted) return;
final l = AppLocalizations.of(context)!;
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}';
? '${l.channelSwitchOk(name)}\n${r.stdout.trim()}'
: l.channelSwitchFailed(r.stderr.isEmpty ? r.stdout : r.stderr);
});
if (r.ok) await _loadChannels();
}

View file

@ -86,6 +86,26 @@ class _ProviderPreset {
static _ProviderPreset byWire(String wire) {
return all.firstWhere((p) => p.wire == wire, orElse: () => all.first);
}
/// Localized help body for this provider. Falls back to the
/// const English [description] for any future wire that has no
/// ARB key yet.
String descriptionFor(AppLocalizations l) {
switch (wire) {
case 'ollama':
return l.providerDescOllama;
case 'openai':
return l.providerDescOpenai;
case 'lmstudio':
return l.providerDescLmstudio;
case 'vllm':
return l.providerDescVllm;
case 'custom':
return l.providerDescCustom;
default:
return description;
}
}
}
class FaiSystemAiEditor extends StatefulWidget {
@ -372,7 +392,7 @@ class _FaiSystemAiEditorState extends State<FaiSystemAiEditor> {
_ProviderDropdown(value: _preset, onChanged: _onProviderChanged),
const SizedBox(height: 4),
Text(
_preset.description,
_preset.descriptionFor(l),
style: theme.textTheme.bodySmall?.copyWith(
color: theme.colorScheme.onSurfaceVariant,
),
@ -634,10 +654,10 @@ class _TestResultPanel extends StatelessWidget {
ok ? l.systemAiReplyPrefix(result.text) : result.text,
style: FaiTheme.mono(size: 11, color: theme.colorScheme.onSurface),
),
if (!ok && result.fixHint.isNotEmpty) ...[
if (!ok && result.fixHint(l).isNotEmpty) ...[
const SizedBox(height: FaiSpace.xs),
Text(
result.fixHint,
result.fixHint(l),
style: theme.textTheme.bodySmall?.copyWith(
color: theme.colorScheme.onSurface,
),

View file

@ -4,6 +4,7 @@
// primitives directly no Material `Card` / generic `Container`
// soup in page code.
export 'fai_binary_recovery.dart';
export 'fai_card.dart';
export 'fai_data_row.dart';
export 'fai_delta_mark.dart';