feat(studio): swap built-in flow editor for fai_studio_flow_editor package (v0.51.0)
Some checks failed
Security / Security check (push) Failing after 2s

The flow editor was internal to Studio (lib/pages/flow_editor.dart).
Per Stefan's review feedback ("austauschbar wäre schöner"),
extract it into its own Forgejo repo so the host can swap
the implementation without touching Studio.

New repo: https://git.flemming.ai/fai/studio-flow-editor

Studio's pubspec.yaml now references the package by git URL:

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

To swap the editor:
  1. Fork (or write a new) fai/studio-flow-editor.
  2. Keep the FlowEditorPage(initialFlowName, locale, onRun)
     constructor signature — the stable host contract.
  3. Point the pubspec at your fork.
  4. Rebuild Studio.

Adapter pattern: _FlowEditorAdapter in main.dart resolves the
package's runtime dependencies (locale via Localizations,
onRun via HubService) from the BuildContext, then constructs
the package's FlowEditorPage. Same pattern in flows.dart for
the pencil → editor route push, so a future operator-side
locale switch propagates correctly.

The package brings its own copies of FaiSpace tokens, minimal
FaiEmptyState/FaiErrorBox widgets, and an inline EN+DE l10n
table — accepting a small amount of visual drift in exchange
for true package independence. flutter_code_editor +
highlight move from Studio's pubspec to the package's.

Deleted:
  lib/pages/flow_editor.dart  → package's lib/src/flow_editor_page.dart
  test/flow_editor_test.dart  → package's test/ (next commit there)

Bumped:
  pubspec.yaml version 0.50.0 → 0.51.0
  main.dart kStudioVersion 0.50.0 → 0.51.0
Signed-off-by: flemming-it <stefan.a.flemming@googlemail.com>
This commit is contained in:
flemming-it 2026-05-30 14:36:54 +02:00
parent e522267ec1
commit 0183771689
6 changed files with 54 additions and 919 deletions

View file

@ -5,8 +5,8 @@
import 'dart:async';
import 'package:fai_studio_flow_editor/fai_studio_flow_editor.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'data/hub.dart';
@ -16,7 +16,6 @@ import 'l10n/app_localizations.dart';
import 'pages/approvals.dart';
import 'pages/audit.dart';
import 'pages/doctor.dart';
import 'pages/flow_editor.dart';
import 'pages/flows.dart';
import 'pages/store.dart';
import 'pages/welcome.dart';
@ -28,7 +27,7 @@ import 'widgets/widgets.dart';
/// Studio's own build version. Bump on every UI commit so the
/// running app self-identifies visible in the sidebar header
/// and quick-glance proof that you're seeing the current build.
const String kStudioVersion = '0.50.0';
const String kStudioVersion = '0.51.0';
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
@ -239,7 +238,7 @@ class _StudioShellState extends State<StudioShell> {
id: 'flow-editor',
icon: Icons.code_outlined,
selectedIcon: Icons.code,
page: FlowEditorPage(),
page: _FlowEditorAdapter(),
),
_NavPage(
id: 'audit',
@ -1062,3 +1061,23 @@ class _LanguageToggle extends StatelessWidget {
);
}
}
/// Adapter that resolves the swappable FlowEditorPage's
/// runtime dependencies (locale, hub onRun callback) from
/// Studio's BuildContext. The _NavPage destination list
/// holds widgets as const-ish, so the adapter sits in
/// between to grab live data.
class _FlowEditorAdapter extends StatelessWidget {
const _FlowEditorAdapter();
@override
Widget build(BuildContext context) {
final lang = Localizations.localeOf(context).languageCode;
return FlowEditorPage(
locale: lang == 'de' ? FlowEditorLocale.de : FlowEditorLocale.en,
onRun: (name) async =>
(await HubService.instance.runSavedFlow(name: name))
.cast<String, Object>(),
);
}
}