413c923e77
Tapping or pressing Enter on a stage in the pipeline or run graph (inline and full screen) opens a card anchored to the node: type, config chips, tools, collapsed permissions, the prompt clamped with Show all (commands, gate or operator instructions by type), limits and routes, and for runs the status, visits, time, verdict, handoff and failure. Open definition keeps the old tap target; Open visit the old run tap. It follows pan and zoom, closes on outside tap, Escape or the same node, and opens as a bottom sheet on a narrow viewport. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
154 lines
4.6 KiB
Dart
154 lines
4.6 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
import '../../../core/api_gateway.dart';
|
|
import '../domain/graph_definition.dart';
|
|
import '../domain/stage_summary.dart';
|
|
import '../layout/layout_models.dart';
|
|
import '../painting/graph_edge_layer.dart';
|
|
import '../painting/stage_edges_highlight.dart';
|
|
import '../routing/route_models.dart';
|
|
import 'graph_canvas_style.dart';
|
|
import 'graph_edge_hover.dart';
|
|
import 'graph_stage_node.dart';
|
|
import 'graph_stage_popover.dart';
|
|
import 'stage_popover_card.dart';
|
|
|
|
/// The measured definition canvas at any viewport size and selection.
|
|
///
|
|
/// Used by both the inline [GraphViewport] and the expanded presentation: the
|
|
/// passive edge layer paints behind the native nodes and outcome labels.
|
|
/// Tapping a node opens its stage popover (the declaration at a glance); the
|
|
/// popover's "Open definition" reports the node through [onSelected].
|
|
class DefinitionGraphCanvas extends StatelessWidget {
|
|
const DefinitionGraphCanvas({
|
|
super.key,
|
|
required this.graph,
|
|
required this.nodes,
|
|
required this.layout,
|
|
required this.routing,
|
|
required this.style,
|
|
required this.selectedStage,
|
|
required this.onSelected,
|
|
});
|
|
|
|
/// The definition the nodes came from, for each stage's declaration.
|
|
final JsonMap graph;
|
|
final List<GraphNode> nodes;
|
|
final GraphLayout layout;
|
|
final GraphRouting routing;
|
|
final GraphCanvasStyle style;
|
|
final String? selectedStage;
|
|
final ValueChanged<String> onSelected;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final nodesByKey = <String, GraphNode>{
|
|
for (final node in nodes) node.key: node,
|
|
};
|
|
final size = Size(routing.width, routing.height);
|
|
return GraphStagePopover(
|
|
nodeRects: {
|
|
for (final box in layout.nodes)
|
|
box.key: Rect.fromLTWH(box.x, box.y, box.width, box.height),
|
|
},
|
|
cardBuilder: (context, stage, close) => StagePopoverCard(
|
|
label: nodesByKey[stage]?.label ?? stage,
|
|
summary: stageSummaryFor(graph, stage),
|
|
onClose: close,
|
|
onOpenDefinition: () {
|
|
close();
|
|
onSelected(stage);
|
|
},
|
|
),
|
|
builder: (context, open, toggle) => GraphEdgeHover(
|
|
layout: layout,
|
|
routing: routing,
|
|
describe: describeGraphEdge,
|
|
builder: (context, highlighted, select) => _canvas(
|
|
context,
|
|
nodesByKey,
|
|
size,
|
|
highlighted,
|
|
select,
|
|
open,
|
|
toggle,
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget _canvas(
|
|
BuildContext context,
|
|
Map<String, GraphNode> nodesByKey,
|
|
Size size,
|
|
int? highlighted,
|
|
ValueChanged<int> select,
|
|
String? open,
|
|
ValueChanged<String> toggle,
|
|
) {
|
|
return Stack(
|
|
clipBehavior: Clip.none,
|
|
children: [
|
|
// The passive layer comes first so every edge paints behind the native
|
|
// nodes and labels without taking their input.
|
|
Positioned.fill(
|
|
child: GraphEdgeLayer(
|
|
routes: routing.routes,
|
|
canvasSize: size,
|
|
color: style.edgeColor,
|
|
strokeWidth: style.edgeWidth,
|
|
),
|
|
),
|
|
Positioned.fill(
|
|
child: graphStageEdgesHighlight(
|
|
context: context,
|
|
routing: routing,
|
|
stage: open,
|
|
edgeWidth: style.edgeWidth,
|
|
),
|
|
),
|
|
Positioned.fill(
|
|
child: graphEdgeHighlight(
|
|
context: context,
|
|
layout: layout,
|
|
routing: routing,
|
|
highlighted: highlighted,
|
|
edgeWidth: style.edgeWidth,
|
|
),
|
|
),
|
|
for (final box in layout.nodes)
|
|
Positioned(
|
|
left: box.x,
|
|
top: box.y,
|
|
width: box.width,
|
|
height: box.height,
|
|
child: GraphStageNode(
|
|
node: nodesByKey[box.key]!,
|
|
selected: box.key == selectedStage || box.key == open,
|
|
onSelected: toggle,
|
|
),
|
|
),
|
|
for (final label in routing.labels)
|
|
Positioned(
|
|
left: label.x,
|
|
top: label.y,
|
|
child: graphEdgeLabel(
|
|
context: context,
|
|
highlighted: label.edgeId == highlighted,
|
|
description: describeGraphEdge(routing.routeFor(label.edgeId)!),
|
|
onSelect: () => select(label.edgeId),
|
|
child: Text(
|
|
routing.routeFor(label.edgeId)!.label,
|
|
style: graphEdgeLabelStyle(
|
|
context,
|
|
style.labelStyle,
|
|
highlighted: label.edgeId == highlighted,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
}
|