Swappable inline YAML editor for F∆I Studio flows.
Find a file
flemming-it 9d21bd5318 feat(editor): empty-graph CTA + fit-to-screen button
Two polishing tweaks on the graph tab:

 - When the active flow has no steps, the canvas would have
   rendered as a near-empty grid (just inputs / outputs
   sidebars). Overlay a centred call-to-action with the
   graph icon, the "No steps yet" / "Noch keine Schritte"
   heading, a one-liner explainer, and a primary Add Step
   button that opens the capability picker directly.
 - Auto-fit zoom on first open of each flow + a floating
   "Fit to screen" button (bottom-right corner of the
   canvas viewport). The auto-fit re-runs only when the
   flow name changes, so the operator's manual pan / zoom
   on the current flow is preserved. The fit math expands
   the bounding box to include inputs + outputs pseudo-
   nodes too, so wide flows zoom out enough to show every
   port at once.

Fit math:
 - Walk every step's stored position + height; merge with
   the inputs sidebar's known position.
 - Compute scale that makes the bounding box fit the
   viewport with 80 px padding on each side.
 - Clamp to [0.4, 2.0] — InteractiveViewer's own bounds.
 - Translate so the box centres in the viewport.

`flutter analyze` clean, all 11 tests still pass.

Signed-off-by: flemming-it <sf@flemming.it>
2026-06-01 01:51:11 +02:00
lib feat(editor): empty-graph CTA + fit-to-screen button 2026-06-01 01:51:11 +02:00
test feat(editor): live step status on the graph during runs 2026-06-01 01:47:30 +02:00
.gitignore feat: initial scaffold — swappable flow editor 2026-05-30 14:33:03 +02:00
pubspec.yaml feat(model): FlowGraph + LayoutStore foundation for WYSIWYG editor 2026-06-01 00:37:19 +02:00
README.md feat: initial scaffold — swappable flow editor 2026-05-30 14:33:03 +02:00

fai_studio_flow_editor

Swappable inline YAML editor for F∆I Studio flows.

Public surface

import 'package:fai_studio_flow_editor/fai_studio_flow_editor.dart';

// Studio embeds the page as one of its destinations:
FlowEditorPage(
  initialFlowName: 'hello',                       // optional
  locale: FlowEditorLocale.de,                    // or .en
  onRun: (name) =>                                // optional callback
      HubService.instance.runSavedFlow(name: name),
)
  • initialFlowName — when set, the page loads that flow from ~/.fai/data/flows/<name>.yaml on first build. Used by Studio's Flows-page pencil → editor route push.
  • locale — picks EN or DE for the editor's internal string table. Studio passes its active locale through.
  • onRun — async callback that runs the named flow against the host hub and returns the typed outputs map. When null, the Run button is disabled (e.g. when the editor is embedded in a context without hub access).

Behaviour

  • File browser (left, 240 px) lists *.yaml in ~/.fai/data/flows/.
  • Code field (right) ships YAML syntax highlighting via flutter_code_editor + the highlight package's yaml grammar.
  • Save writes directly to disk via dart:io; the hub picks up the change on its next ListFlows / RunSavedFlow call.
  • Cmd+S / Ctrl+S — save. Cmd+Enter / Ctrl+Enter — run.

Swap it

Studio depends on this package via pubspec.yaml git reference:

dependencies:
  fai_studio_flow_editor:
    git:
      url: https://git.flemming.ai/fai/studio-flow-editor
      ref: main

To use a different editor:

  1. Fork this repo (or write your own from scratch).
  2. Keep the FlowEditorPage constructor signature (initialFlowName, locale, onRun) — that's the stable host contract.
  3. Point Studio's pubspec at your fork (or local-path during development):
    fai_studio_flow_editor:
      git:
        url: https://your-host/your/flow-editor
        ref: main
    
  4. Rebuild Studio. Done.

The contract is intentionally minimal: a single page widget with three parameters. The package brings its own tokens, its own empty/error widgets, its own l10n table, so the host doesn't have to share internals. The trade-off is visual drift if Studio's design tokens change — that's the deal you accept for a swappable module.

Develop

flutter pub get
flutter analyze
flutter test

The package's own widget tests live in test/. End-to-end tests against a live hub stay in the host repo (Studio).

License

Apache-2.0. Same as the rest of the F∆I platform.