feat(studio): typed run-flow form, file picker, copyable errors (v0.41.0)

The free-form key=value run-flow dialog produced two
unhelpful failures every time an operator hit Run:

  1. Submit empty → "step references missing value
     '\$inputs.document'" from the hub. Studio sent a zero-
     entry inputs map because nothing told the operator the
     flow declared a required input.
  2. Type `document=@/path/to/file` → "path not found".
     Dart's `File()` doesn't expand `~`, and on macOS
     sandboxed Studio can't read arbitrary paths anyway.

Both failure modes are gone. The dialog is now a typed form:

- On open, fetches `getFlowDefinition(name)` (new SDK
  v0.15.0 wrapper around the v0.10.89 hub RPC). While that
  resolves, a small spinner shows
  "Loading inputs…"; on failure, an inline `FaiErrorBox`
  with the exact RPC error and a copy button replaces the
  spinner.
- Renders one form-field per declared input. The flow
  YAML's verbatim type tag drives the widget choice:
  `bytes` / `file` → "Choose file…" button + picked-file
  readout, plain TextField for everything else. The type
  tag is shown next to the input name as a pill so a flow
  author who picks a less-common type still gets a hint.
- Bytes inputs route through `file_picker` with
  `withData: true`, which means the OS file dialog handles
  read access — sandboxed Studio gets the bytes inline
  rather than a path it can't open. Falls back to
  `File(path).readAsBytes()` on Linux configs that don't
  honour `withData` for large files; failures show a
  copyable SnackBar.
- The Run button enables only when every declared input has
  a value (text non-empty / file picked). Empty submission
  is impossible; the cryptic hub-side
  "missing value" error stops surfacing.
- The run-result dialog's error path uses `FaiErrorBox`
  instead of the previous plain `SelectableText`, so any
  hub-side flow error (permission denied, module crash,
  whatever) is one click to clipboard.

11 new ARB keys cover the form's labels, the file-picker
states, the loading / failed-definition messages, the
"This flow declares no inputs" empty state, and the
run-error dialog title.

`file_picker: ^8.0.0` added to pubspec.yaml.

Signed-off-by: flemming-it <stefan.a.flemming@googlemail.com>
This commit is contained in:
flemming-it 2026-05-09 10:18:08 +02:00
parent 63e19974c0
commit f90d8cc7a7
10 changed files with 508 additions and 105 deletions

View file

@ -389,8 +389,23 @@
"flowsNoneHint": "Flow speichern mit `fai admin flows save <name> <flow.yaml>`, dann taucht er hier auf.",
"flowsRunDialogTitle": "{name} ausführen",
"@flowsRunDialogTitle": { "placeholders": { "name": { "type": "String" } } },
"flowsRunDialogBody": "Eingaben als key=value, eine pro Zeile. Klartext-Werte landen als Text. Wert mit `@` voranstellen liest die Datei als Bytes — wie `fai run --input document=@/pfad/zu/datei.pdf`.",
"flowsInputsHint": "name=Welt\ndocument=@/Users/ich/Dokumente/beispiel.pdf\nstil=drei Stichpunkte",
"flowsRunDialogBody": "Pro deklariertem Input ein Feld. Bytes-Inputs öffnen einen Datei-Picker; alle anderen sind Klartext. Der Starten-Button aktiviert sich, wenn alle Pflichtfelder gefüllt sind.",
"flowsLoadingDefinition": "Inputs werden geladen…",
"flowsDefinitionFailed": "Flow-Definition konnte nicht geladen werden",
"flowsNoInputs": "Dieser Flow deklariert keine Inputs. Starten klicken, um loszulegen.",
"flowsTypeBytesPick": "Datei wählen…",
"flowsTypeBytesChange": "Datei ändern",
"flowsTypeBytesNoFile": "Keine Datei ausgewählt",
"flowsTypeBytesSize": "{n} Bytes",
"@flowsTypeBytesSize": { "placeholders": { "n": { "type": "int" } } },
"flowsRunErrorTitle": "Flow-Lauf fehlgeschlagen",
"flowsFileReadFailed": "„{path}\" konnte nicht gelesen werden: {error}",
"@flowsFileReadFailed": {
"placeholders": {
"path": { "type": "String" },
"error": { "type": "String" }
}
},
"flowsRunButton": "Starten",
"flowsRunningTitle": "{name} läuft",
"@flowsRunningTitle": { "placeholders": { "name": { "type": "String" } } },

View file

@ -390,8 +390,23 @@
"flowsNoneHint": "Save a flow with `fai admin flows save <name> <flow.yaml>` and it shows up here.",
"flowsRunDialogTitle": "Run {name}",
"@flowsRunDialogTitle": { "placeholders": { "name": { "type": "String" } } },
"flowsRunDialogBody": "Inputs as key=value, one per line. Plain values send as text. Prefix the value with `@` to read a file as bytes — same as `fai run --input document=@/path/to/file.pdf`.",
"flowsInputsHint": "name=World\ndocument=@/Users/me/Documents/sample.pdf\nstyle=three bullet points",
"flowsRunDialogBody": "One field per declared input. Pick a file for bytes-shaped inputs; type plain text for the rest. The Run button enables when every required input is set.",
"flowsLoadingDefinition": "Loading inputs…",
"flowsDefinitionFailed": "Could not load flow definition",
"flowsNoInputs": "This flow declares no inputs. Click Run to start.",
"flowsTypeBytesPick": "Choose file…",
"flowsTypeBytesChange": "Change file",
"flowsTypeBytesNoFile": "No file selected",
"flowsTypeBytesSize": "{n} bytes",
"@flowsTypeBytesSize": { "placeholders": { "n": { "type": "int" } } },
"flowsRunErrorTitle": "Flow run failed",
"flowsFileReadFailed": "Could not read \"{path}\": {error}",
"@flowsFileReadFailed": {
"placeholders": {
"path": { "type": "String" },
"error": { "type": "String" }
}
},
"flowsRunButton": "Run",
"flowsRunningTitle": "Running {name}",
"@flowsRunningTitle": { "placeholders": { "name": { "type": "String" } } },

View file

@ -1823,14 +1823,62 @@ abstract class AppLocalizations {
/// No description provided for @flowsRunDialogBody.
///
/// In en, this message translates to:
/// **'Inputs as key=value, one per line. Plain values send as text. Prefix the value with `@` to read a file as bytes — same as `fai run --input document=@/path/to/file.pdf`.'**
/// **'One field per declared input. Pick a file for bytes-shaped inputs; type plain text for the rest. The Run button enables when every required input is set.'**
String get flowsRunDialogBody;
/// No description provided for @flowsInputsHint.
/// No description provided for @flowsLoadingDefinition.
///
/// In en, this message translates to:
/// **'name=World\ndocument=@/Users/me/Documents/sample.pdf\nstyle=three bullet points'**
String get flowsInputsHint;
/// **'Loading inputs…'**
String get flowsLoadingDefinition;
/// No description provided for @flowsDefinitionFailed.
///
/// In en, this message translates to:
/// **'Could not load flow definition'**
String get flowsDefinitionFailed;
/// No description provided for @flowsNoInputs.
///
/// In en, this message translates to:
/// **'This flow declares no inputs. Click Run to start.'**
String get flowsNoInputs;
/// No description provided for @flowsTypeBytesPick.
///
/// In en, this message translates to:
/// **'Choose file…'**
String get flowsTypeBytesPick;
/// No description provided for @flowsTypeBytesChange.
///
/// In en, this message translates to:
/// **'Change file'**
String get flowsTypeBytesChange;
/// No description provided for @flowsTypeBytesNoFile.
///
/// In en, this message translates to:
/// **'No file selected'**
String get flowsTypeBytesNoFile;
/// No description provided for @flowsTypeBytesSize.
///
/// In en, this message translates to:
/// **'{n} bytes'**
String flowsTypeBytesSize(int n);
/// No description provided for @flowsRunErrorTitle.
///
/// In en, this message translates to:
/// **'Flow run failed'**
String get flowsRunErrorTitle;
/// No description provided for @flowsFileReadFailed.
///
/// In en, this message translates to:
/// **'Could not read \"{path}\": {error}'**
String flowsFileReadFailed(String path, String error);
/// No description provided for @flowsRunButton.
///

View file

@ -1025,11 +1025,40 @@ class AppLocalizationsDe extends AppLocalizations {
@override
String get flowsRunDialogBody =>
'Eingaben als key=value, eine pro Zeile. Klartext-Werte landen als Text. Wert mit `@` voranstellen liest die Datei als Bytes — wie `fai run --input document=@/pfad/zu/datei.pdf`.';
'Pro deklariertem Input ein Feld. Bytes-Inputs öffnen einen Datei-Picker; alle anderen sind Klartext. Der Starten-Button aktiviert sich, wenn alle Pflichtfelder gefüllt sind.';
@override
String get flowsInputsHint =>
'name=Welt\ndocument=@/Users/ich/Dokumente/beispiel.pdf\nstil=drei Stichpunkte';
String get flowsLoadingDefinition => 'Inputs werden geladen…';
@override
String get flowsDefinitionFailed =>
'Flow-Definition konnte nicht geladen werden';
@override
String get flowsNoInputs =>
'Dieser Flow deklariert keine Inputs. Starten klicken, um loszulegen.';
@override
String get flowsTypeBytesPick => 'Datei wählen…';
@override
String get flowsTypeBytesChange => 'Datei ändern';
@override
String get flowsTypeBytesNoFile => 'Keine Datei ausgewählt';
@override
String flowsTypeBytesSize(int n) {
return '$n Bytes';
}
@override
String get flowsRunErrorTitle => 'Flow-Lauf fehlgeschlagen';
@override
String flowsFileReadFailed(String path, String error) {
return '$path\" konnte nicht gelesen werden: $error';
}
@override
String get flowsRunButton => 'Starten';

View file

@ -1040,11 +1040,39 @@ class AppLocalizationsEn extends AppLocalizations {
@override
String get flowsRunDialogBody =>
'Inputs as key=value, one per line. Plain values send as text. Prefix the value with `@` to read a file as bytes — same as `fai run --input document=@/path/to/file.pdf`.';
'One field per declared input. Pick a file for bytes-shaped inputs; type plain text for the rest. The Run button enables when every required input is set.';
@override
String get flowsInputsHint =>
'name=World\ndocument=@/Users/me/Documents/sample.pdf\nstyle=three bullet points';
String get flowsLoadingDefinition => 'Loading inputs…';
@override
String get flowsDefinitionFailed => 'Could not load flow definition';
@override
String get flowsNoInputs =>
'This flow declares no inputs. Click Run to start.';
@override
String get flowsTypeBytesPick => 'Choose file…';
@override
String get flowsTypeBytesChange => 'Change file';
@override
String get flowsTypeBytesNoFile => 'No file selected';
@override
String flowsTypeBytesSize(int n) {
return '$n bytes';
}
@override
String get flowsRunErrorTitle => 'Flow run failed';
@override
String flowsFileReadFailed(String path, String error) {
return 'Could not read \"$path\": $error';
}
@override
String get flowsRunButton => 'Run';