feat(studio): localised + explainer-rich Add module source dialog
Some checks failed
Security / Security check (push) Failing after 1s

The previous Add-source dialog was English-only and
operator-hostile — answered 'where do I install from?' without
explaining what a private module *is*. New version, DE + EN:

  - Title + intro + button labels routed through AppLocalizations
    ("Modul-Quelle hinzufügen" / "Installation fehlgeschlagen"
    instead of raw English strings).
  - 'How private modules work' explainer block (3 sentences):
    what a module is (`module.yaml` + WASM), how to package
    it (`fai pack <dir>` → .fai bundle), where to host it
    (any URL: own Forgejo / GitHub / S3), what verification the
    hub does (sha256 + signature against trust store).
  - Honest about the Studio gap: the dialog can install URLs +
    packed bundles, but unpacked source directories still
    require `fai install --link <path>` on the CLI. The
    example command lives in its own code-style box, selectable.
  - Layout: SingleChildScrollView'd so the explainer doesn't
    push the buttons off short viewports.

Studio bumped to 0.66.0; editor path-override pulls in 0.20.0.

Signed-off-by: flemming-it <stefan.a.flemming@googlemail.com>
This commit is contained in:
flemming-it 2026-06-09 01:36:54 +02:00
parent eba7e51c7f
commit 2be7d241bf
9 changed files with 259 additions and 66 deletions

View file

@ -15,6 +15,7 @@ import 'package:flutter/material.dart';
import '../data/flow_run_driver.dart';
import '../data/hub.dart';
import '../l10n/app_localizations.dart';
class FlowsPage extends StatefulWidget {
/// Pre-load this flow when the editor first builds. Studio
@ -121,10 +122,14 @@ class _FlowsPageState extends State<FlowsPage> {
return updated;
} catch (e) {
if (mounted) {
final l = AppLocalizations.of(context);
final msg = l != null
? l.installFailed(e.toString())
: 'Install failed: $e';
ScaffoldMessenger.of(context).removeCurrentSnackBar();
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text('Install failed: $e'),
content: Text(msg),
behavior: SnackBarBehavior.floating,
),
);
@ -189,83 +194,99 @@ class _AddModuleSourceDialogState extends State<_AddModuleSourceDialog> {
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
final l = AppLocalizations.of(context)!;
return AlertDialog(
title: const Text('Add module source'),
content: SizedBox(
width: 480,
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'`${widget.capability}` is not in the public store. '
'Point the hub at a `.fai` bundle URL or a local bundle path '
'and the hub will install + verify it.',
style: theme.textTheme.bodySmall?.copyWith(
color: theme.colorScheme.onSurfaceVariant,
title: Text(l.addSourceTitle),
content: ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 520),
child: SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
l.addSourceIntro(widget.capability),
style: theme.textTheme.bodySmall?.copyWith(
color: theme.colorScheme.onSurfaceVariant,
),
),
),
const SizedBox(height: 16),
TextField(
controller: _ctrl,
autofocus: true,
onChanged: (v) => setState(() => _source = v.trim()),
decoration: const InputDecoration(
labelText: 'URL or path to .fai bundle',
hintText: 'https://example.com/foo-0.1.0.fai',
border: OutlineInputBorder(),
isDense: true,
const SizedBox(height: 16),
TextField(
controller: _ctrl,
autofocus: true,
onChanged: (v) => setState(() => _source = v.trim()),
decoration: InputDecoration(
labelText: l.addSourceField,
hintText: l.addSourceHint,
border: const OutlineInputBorder(),
isDense: true,
),
),
),
const SizedBox(height: 12),
Container(
padding: const EdgeInsets.all(10),
decoration: BoxDecoration(
color: theme.colorScheme.surfaceContainerHigh,
borderRadius: BorderRadius.circular(6),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Developing a local module?',
style: theme.textTheme.labelMedium?.copyWith(
fontWeight: FontWeight.w600,
const SizedBox(height: 12),
Container(
padding: const EdgeInsets.all(12),
decoration: BoxDecoration(
color: theme.colorScheme.surfaceContainerHigh,
borderRadius: BorderRadius.circular(6),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
l.addSourceHowItWorksTitle,
style: theme.textTheme.labelMedium?.copyWith(
fontWeight: FontWeight.w600,
),
),
),
const SizedBox(height: 4),
Text(
'Studio installs from URLs + packed bundles only. For an '
'unpacked source directory, use the CLI:',
style: theme.textTheme.bodySmall?.copyWith(
color: theme.colorScheme.onSurfaceVariant,
const SizedBox(height: 6),
Text(
l.addSourceHowItWorksBody,
style: theme.textTheme.bodySmall?.copyWith(
color: theme.colorScheme.onSurfaceVariant,
),
),
),
const SizedBox(height: 6),
SelectableText(
'fai install --link /path/to/module',
style: theme.textTheme.bodySmall?.copyWith(
fontFamily: 'JetBrains Mono',
fontSize: 11,
color: theme.colorScheme.onSurface,
const SizedBox(height: 6),
Container(
padding: const EdgeInsets.symmetric(
horizontal: 8,
vertical: 4,
),
decoration: BoxDecoration(
color: theme.colorScheme.surface,
borderRadius: BorderRadius.circular(4),
),
child: SelectableText(
l.addSourceCliExample,
style: TextStyle(
fontFamily: 'JetBrains Mono',
fontFamilyFallback: const [
'Menlo',
'Consolas',
'Courier New',
'monospace',
],
fontSize: 11,
color: theme.colorScheme.onSurface,
),
),
),
),
],
],
),
),
),
],
],
),
),
),
actions: [
TextButton(
onPressed: () => Navigator.of(context).pop(),
child: const Text('Cancel'),
child: Text(l.addSourceCancel),
),
FilledButton(
onPressed: _source.isEmpty
? null
: () => Navigator.of(context).pop(_source),
child: const Text('Install'),
child: Text(l.addSourceInstallButton),
),
],
);