feat(editor): persistent diagnostic strip + run-block + copyable run errors
Three connected fixes that close the loop the analyzer started:
- **Strip lives at page level, not text-tab**. Moved
_DiagnosticStrip out of _textTab and into _tabbedBody
below the TabBarView, so the same error list + quick-fix
buttons are visible on Graph + Text + Run. The Graph-tab
operator now sees both the pulsing node AND the message
explaining what's broken, without flipping tabs. One strip,
one source of truth.
- **Run button disabled when there are analyzer errors**.
FlowEditorController.analyzerErrorCount counts `IssueType.error`
issues; the action strip's Run button + the RunTab's Start
button both check it. When > 0:
· button greys out + icon flips to Icons.block
· tooltip names the count ('2 errors prevent the run')
· the Run tab grows an inline red explanation next to
the disabled Start so the operator isn't left guessing
Warnings (orange) do NOT block — they're nudges. Operators
who want to run a half-broken flow during dev can still
silence the analyzer via the strip.
- **Run failures are copyable everywhere**. New
_CopyableErrorBox replaces both the per-run failure detail
and the per-step failure suffix in the RunTab. Selectable
monospace + explicit Copy button with 'Copied' feedback.
Scrollbar-capped at 220 px so the box doesn't push outputs
off-screen. Mirrors the operator-visible contract:
'every error is copyable, always.'
Closes the operator-reported regression where a failed run
showed 'Lauf fehlgeschlagen' as plain Text, leaving the
operator unable to paste it into a bug report.
Bumped to 0.19.0.
Signed-off-by: flemming-it <sf@flemming.it>
This commit is contained in:
parent
efdfa7dd79
commit
b6bb8741a9
4 changed files with 230 additions and 82 deletions
|
|
@ -22,9 +22,9 @@
|
|||
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
import '../editor_controller.dart';
|
||||
import '../l10n.dart';
|
||||
|
|
@ -165,17 +165,7 @@ class _RunTabState extends State<RunTab> {
|
|||
for (final entry in graph.inputs.entries)
|
||||
_inputField(theme, entry.key, entry.value),
|
||||
const SizedBox(height: FaiSpace.md),
|
||||
FilledButton.icon(
|
||||
onPressed: _running || widget.driver == null ? null : _start,
|
||||
icon: _running
|
||||
? const SizedBox(
|
||||
width: 14,
|
||||
height: 14,
|
||||
child: CircularProgressIndicator(strokeWidth: 2),
|
||||
)
|
||||
: const Icon(Icons.play_arrow, size: 18),
|
||||
label: Text(strings.runStart),
|
||||
),
|
||||
_startButtonRow(theme, strings),
|
||||
if (_liveSteps.isNotEmpty || _running) ...[
|
||||
const SizedBox(height: FaiSpace.lg),
|
||||
_section(
|
||||
|
|
@ -193,21 +183,7 @@ class _RunTabState extends State<RunTab> {
|
|||
if (_error != null) ...[
|
||||
const SizedBox(height: FaiSpace.lg),
|
||||
_section(theme, strings.runTitleFailed),
|
||||
Container(
|
||||
padding: const EdgeInsets.all(FaiSpace.sm),
|
||||
decoration: BoxDecoration(
|
||||
color: theme.colorScheme.errorContainer,
|
||||
borderRadius: BorderRadius.circular(FaiRadius.sm),
|
||||
),
|
||||
child: Text(
|
||||
_error.toString(),
|
||||
style: TextStyle(
|
||||
fontFamily: 'monospace',
|
||||
fontSize: 12,
|
||||
color: theme.colorScheme.onErrorContainer,
|
||||
),
|
||||
),
|
||||
),
|
||||
_CopyableErrorBox(text: _error.toString()),
|
||||
],
|
||||
],
|
||||
),
|
||||
|
|
@ -338,33 +314,91 @@ class _RunTabState extends State<RunTab> {
|
|||
case _StepKind.error:
|
||||
glyph = Icons.close;
|
||||
color = theme.colorScheme.error;
|
||||
if (state.error != null && state.error!.isNotEmpty) {
|
||||
suffix = ' — ${state.error}';
|
||||
}
|
||||
case _StepKind.awaiting:
|
||||
glyph = Icons.pause_circle_outline;
|
||||
color = theme.colorScheme.tertiary;
|
||||
suffix = ' awaiting approval';
|
||||
}
|
||||
final isError = state.kind == _StepKind.error &&
|
||||
state.error != null &&
|
||||
state.error!.isNotEmpty;
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 2),
|
||||
child: Row(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Icon(glyph, size: 16, color: color),
|
||||
Row(
|
||||
children: [
|
||||
Icon(glyph, size: 16, color: color),
|
||||
const SizedBox(width: FaiSpace.sm),
|
||||
Flexible(
|
||||
child: SelectableText(
|
||||
'$id$suffix',
|
||||
style: TextStyle(
|
||||
fontFamily: 'monospace',
|
||||
fontSize: 13,
|
||||
color: color,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
if (isError) ...[
|
||||
const SizedBox(height: 4),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 24),
|
||||
child: _CopyableErrorBox(text: state.error!),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// Run button row. Disabled when the buffer carries analyzer
|
||||
/// errors — an info chip next to the button names the count
|
||||
/// and (when collapsed) the first message so the operator
|
||||
/// sees the blocker without scrolling to the bottom strip.
|
||||
Widget _startButtonRow(ThemeData theme, FlowEditorStrings strings) {
|
||||
final errors = widget.controller.analyzerErrorCount;
|
||||
final blocked = errors > 0;
|
||||
return Row(
|
||||
children: [
|
||||
Tooltip(
|
||||
message: blocked
|
||||
? '$errors error${errors == 1 ? '' : 's'} prevent the run'
|
||||
: '',
|
||||
child: FilledButton.icon(
|
||||
onPressed: _running || widget.driver == null || blocked
|
||||
? null
|
||||
: _start,
|
||||
icon: _running
|
||||
? const SizedBox(
|
||||
width: 14,
|
||||
height: 14,
|
||||
child: CircularProgressIndicator(strokeWidth: 2),
|
||||
)
|
||||
: Icon(
|
||||
blocked ? Icons.block : Icons.play_arrow,
|
||||
size: 18,
|
||||
),
|
||||
label: Text(strings.runStart),
|
||||
),
|
||||
),
|
||||
if (blocked) ...[
|
||||
const SizedBox(width: FaiSpace.sm),
|
||||
Flexible(
|
||||
child: Text(
|
||||
'$id$suffix',
|
||||
style: TextStyle(
|
||||
fontFamily: 'monospace',
|
||||
fontSize: 13,
|
||||
color: color,
|
||||
'$errors error${errors == 1 ? '' : 's'} prevent the run · '
|
||||
'check the diagnostic strip',
|
||||
style: theme.textTheme.bodySmall?.copyWith(
|
||||
color: theme.colorScheme.error,
|
||||
),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -575,3 +609,88 @@ class _StepState {
|
|||
final String? error;
|
||||
const _StepState({required this.kind, this.durationMs, this.error});
|
||||
}
|
||||
|
||||
/// Selectable error box used for the run-failure detail + the
|
||||
/// per-step failure detail. SelectableText + an explicit Copy
|
||||
/// button cover both keyboard and trackpad operators — the
|
||||
/// implicit selection gesture is too easy to miss on a long
|
||||
/// failure message. Matches the visual treatment Studio's
|
||||
/// `FaiErrorBox` uses elsewhere; kept local to this package
|
||||
/// so flow_editor doesn't depend on Studio internals.
|
||||
class _CopyableErrorBox extends StatefulWidget {
|
||||
final String text;
|
||||
const _CopyableErrorBox({required this.text});
|
||||
|
||||
@override
|
||||
State<_CopyableErrorBox> createState() => _CopyableErrorBoxState();
|
||||
}
|
||||
|
||||
class _CopyableErrorBoxState extends State<_CopyableErrorBox> {
|
||||
bool _justCopied = false;
|
||||
|
||||
Future<void> _copy() async {
|
||||
await Clipboard.setData(ClipboardData(text: widget.text));
|
||||
if (!mounted) return;
|
||||
setState(() => _justCopied = true);
|
||||
Future.delayed(const Duration(seconds: 2), () {
|
||||
if (mounted) setState(() => _justCopied = false);
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.fromLTRB(
|
||||
FaiSpace.sm,
|
||||
FaiSpace.xs,
|
||||
FaiSpace.xs,
|
||||
FaiSpace.sm,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: theme.colorScheme.errorContainer,
|
||||
borderRadius: BorderRadius.circular(FaiRadius.sm),
|
||||
border: Border.all(
|
||||
color: theme.colorScheme.error.withValues(alpha: 0.4),
|
||||
),
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
Align(
|
||||
alignment: Alignment.centerRight,
|
||||
child: Tooltip(
|
||||
message: _justCopied ? 'Copied' : 'Copy',
|
||||
child: IconButton(
|
||||
icon: Icon(
|
||||
_justCopied ? Icons.check : Icons.content_copy,
|
||||
size: 14,
|
||||
),
|
||||
visualDensity: VisualDensity.compact,
|
||||
padding: const EdgeInsets.all(4),
|
||||
constraints: const BoxConstraints(),
|
||||
onPressed: _copy,
|
||||
),
|
||||
),
|
||||
),
|
||||
ConstrainedBox(
|
||||
constraints: const BoxConstraints(maxHeight: 220),
|
||||
child: Scrollbar(
|
||||
child: SingleChildScrollView(
|
||||
child: SelectableText(
|
||||
widget.text,
|
||||
style: TextStyle(
|
||||
fontFamily: 'JetBrains Mono',
|
||||
fontSize: 12,
|
||||
color: theme.colorScheme.onErrorContainer,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue