merge(app): land the recorded visit pane after a retained deadline

This commit is contained in:
2026-10-22 02:05:36 +01:00
28 changed files with 2419 additions and 52 deletions
@@ -266,6 +266,39 @@ void main() {
];
expect(artifactGroups(steps).single.artifacts.length, 1);
});
test('visitArtifactGroup matches the pane group of a later visit', () {
final steps = <Map<String, dynamic>>[
step(
stage: 'a',
sequence: 1,
visit: 1,
artifacts: <Map<String, dynamic>>[
artifact('public/shared.csv'),
artifact('a.csv'),
],
),
step(
stage: 'a',
sequence: 2,
visit: 2,
artifacts: <Map<String, dynamic>>[
artifact('public/shared.csv'),
artifact('b.csv'),
],
),
];
final group = visitArtifactGroup(steps, 1)!;
expect(group.stageKey, 'a');
expect(group.visit, 2);
expect(group.artifacts.map((record) => record.name), <String>['b.csv']);
expect(
visitArtifacts(steps[1], steps).map((record) => record.name),
<String>['b.csv'],
);
expect(visitArtifactGroup(steps, 2), isNull);
expect(visitArtifactGroup(steps, -1), isNull);
});
});
group('unavailable and empty captures', () {
@@ -81,6 +81,7 @@ Future<RunsController> pumpRunDetail(
JsonMap? run,
Size size = const Size(900, 1000),
double scale = 1,
Brightness brightness = Brightness.light,
}) async {
tester.view.physicalSize = size;
tester.view.devicePixelRatio = 1;
@@ -100,10 +101,20 @@ Future<RunsController> pumpRunDetail(
).copyWith(textScaler: TextScaler.linear(scale)),
child: view,
);
// A caller that pumps a second run in one test must not inherit the previous
// detail's open tab or pane, so start from an empty tree.
await tester.pumpWidget(const SizedBox.shrink());
await tester.pumpWidget(
platform == RunDetailTestPlatform.material
? MaterialApp(home: Scaffold(body: page))
? MaterialApp(
theme: ThemeData(
brightness: brightness,
platform: TargetPlatform.android,
),
home: Scaffold(body: page),
)
: CupertinoApp(
theme: CupertinoThemeData(brightness: brightness),
home: CupertinoPageScaffold(child: SafeArea(child: page)),
),
);
@@ -4,7 +4,6 @@ import 'package:pipelines_app/features/graph/widgets/graph_stage_node.dart';
import 'package:pipelines_app/features/graph/widgets/run_graph_canvas.dart';
import 'package:pipelines_app/features/graph/widgets/run_graph_view.dart';
import 'package:pipelines_app/features/runs/ui/run_detail_tab.dart';
import 'package:pipelines_app/features/runs/ui/run_detail_timeline.dart';
import 'run_detail_graph_support.dart';
@@ -41,32 +40,25 @@ void main() {
expect(tester.takeException(), isNull);
});
testWidgets('${platform.name} stage click highlights its recorded visit', (
testWidgets('${platform.name} stage click opens its recorded visit pane', (
tester,
) async {
await pumpRunDetail(tester, platform);
await openRunDetailTab(tester, RunDetailTab.graph);
await tapGraphNode(tester, 'plan');
await tester.pumpAndSettle();
// The Graph reports the stage and the detail moves to Timeline, where the
// exact recorded visit is selected.
// exact recorded visit is open.
expect(find.byType(RunGraphView), findsNothing);
expect(
find.byKey(const Key('run-detail-tab-body-timeline')),
findsOneWidget,
);
final selected = tester.widget<RunTimelineRow>(
find.byKey(const ValueKey('run-timeline-visit-1')),
);
expect(selected.selected, isTrue);
expect(
tester
.widget<RunTimelineRow>(
find.byKey(const ValueKey('run-timeline-visit-2')),
)
.selected,
isFalse,
);
expect(find.byKey(const Key('run-visit-pane')), findsOneWidget);
expect(find.byKey(const Key('run-visit-title')), findsOneWidget);
expect(find.text('plan · visit 1'), findsOneWidget);
expect(find.textContaining('Status:'), findsOneWidget);
expect(find.textContaining('audit · visit'), findsNothing);
});
@@ -0,0 +1,187 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/features/artifacts/ui/artifact_gallery_page.dart';
import 'package:pipelines_app/features/graph/widgets/stage_definition_view.dart';
import 'package:pipelines_app/features/runs/ui/run_detail_visit_facts.dart';
import 'package:pipelines_app/features/runs/ui/run_detail_visit_sections.dart';
import 'package:pipelines_app/features/runs/ui/run_detail_visit_session_state.dart';
import 'run_detail_graph_support.dart';
import 'run_detail_visit_support.dart';
void main() {
for (final platform in RunDetailTestPlatform.values) {
testWidgets('${platform.name} tabs show recorded values and exact empty '
'wording', (tester) async {
await openVisit(tester, platform);
expect(find.textContaining('"prompt": "Ship it."'), findsOneWidget);
await openVisitTab(tester, RunVisitSection.output);
expect(find.textContaining('"result": "ok"'), findsOneWidget);
await openVisitTab(tester, RunVisitSection.artifacts);
expect(find.text('plan.csv'), findsOneWidget);
await tester.tap(find.text('plan.csv'));
await tester.pumpAndSettle();
expect(find.byType(ArtifactGalleryPage), findsOneWidget);
// The opened page lists exactly the pane's stage files: the session
// evidence file is not stage output and stays out of both.
expect(find.text('plan · visit 1'), findsOneWidget);
expect(find.text('plan.csv'), findsOneWidget);
expect(find.text('session.html'), findsNothing);
expect(find.text('Artifacts · 1 recorded'), findsOneWidget);
await tester.pageBack();
await tester.pumpAndSettle();
await openVisitTab(tester, RunVisitSection.session);
expect(find.text('Session'), findsWidgets);
expect(find.text('sess-1'), findsOneWidget);
expect(find.text('Open session.html'), findsOneWidget);
await openVisitTab(tester, RunVisitSection.definition);
expect(find.byType(StageDefinitionView), findsOneWidget);
expect(find.text('Draft the plan.'), findsOneWidget);
});
testWidgets('${platform.name} artifacts tab reports the capture state', (
tester,
) async {
final absent = visitRunFixture();
firstVisitStep(absent).remove('artifacts');
await openVisit(tester, platform, run: absent);
await openVisitTab(tester, RunVisitSection.artifacts);
expect(find.text('Artifacts · capture unavailable'), findsOneWidget);
final empty = visitRunFixture();
firstVisitStep(empty)['artifacts'] = <dynamic>[];
await openVisit(tester, platform, run: empty);
await openVisitTab(tester, RunVisitSection.artifacts);
expect(
find.text('Artifacts · not recorded for this visit'),
findsOneWidget,
);
final running = visitRunFixture();
final runningStep = firstVisitStep(running);
runningStep['status'] = 'running';
runningStep['artifacts'] = <dynamic>[];
await openVisit(tester, platform, run: running);
await openVisitTab(tester, RunVisitSection.artifacts);
expect(find.text('Artifacts · capture pending'), findsOneWidget);
});
testWidgets('${platform.name} empty sections use the exact wording', (
tester,
) async {
final run = visitRunFixture();
final step = firstVisitStep(run);
step.remove('input');
step.remove('output');
step['artifacts'] = <dynamic>[];
step.remove('session_id');
step.remove('session_export');
await openVisit(tester, platform, run: run);
expect(find.text(visitEmptyInput), findsOneWidget);
await openVisitTab(tester, RunVisitSection.output);
expect(find.text(visitEmptyOutput), findsOneWidget);
await openVisitTab(tester, RunVisitSection.artifacts);
expect(
find.text('Artifacts · not recorded for this visit'),
findsOneWidget,
);
await openVisitTab(tester, RunVisitSection.session);
// A completed model visit with no identity is a runtime error, not a
// generic "no session" claim.
expect(find.text(visitSessionNoIdentity), findsOneWidget);
});
testWidgets('${platform.name} later visit pane and opened gallery agree on '
'attributed files', (tester) async {
final run = visitRunFixture();
final steps = run['steps'] as List;
firstVisitStep(run)['artifacts'] = <dynamic>[
<String, dynamic>{
'name': 'public/shared.csv',
'url': 'https://example.test/artifacts/1/public/shared.csv',
'content_type': 'text/csv',
'size_bytes': 10,
},
<String, dynamic>{
'name': 'plan.csv',
'url': 'https://example.test/artifacts/1/plan.csv',
'content_type': 'text/csv',
'size_bytes': 42,
},
];
steps.add(<String, dynamic>{
'stage': 'plan',
'sequence': 2,
'status': 'completed',
'outcome': 'success',
'artifacts': <dynamic>[
<String, dynamic>{
'name': 'public/shared.csv',
'url': 'https://example.test/artifacts/2/public/shared.csv',
'content_type': 'text/csv',
'size_bytes': 10,
},
<String, dynamic>{
'name': 'plan-2.csv',
'url': 'https://example.test/artifacts/2/plan-2.csv',
'content_type': 'text/csv',
'size_bytes': 7,
},
],
});
await openVisit(tester, platform, run: run, sequence: 2);
expect(find.text('plan · visit 2'), findsOneWidget);
await openVisitTab(tester, RunVisitSection.artifacts);
expect(find.text('plan-2.csv'), findsOneWidget);
expect(find.text('public/shared.csv'), findsNothing);
await tester.tap(find.text('plan-2.csv'));
await tester.pumpAndSettle();
expect(find.byType(ArtifactGalleryPage), findsOneWidget);
expect(find.text('plan · visit 2'), findsOneWidget);
expect(find.text('plan-2.csv'), findsOneWidget);
expect(find.text('public/shared.csv'), findsNothing);
expect(find.text('Artifacts · 1 recorded'), findsOneWidget);
});
testWidgets('${platform.name} missing definition uses exact wording', (
tester,
) async {
await openVisit(
tester,
platform,
run: visitRunFixture(declareStage: false),
);
await openVisitTab(tester, RunVisitSection.definition);
expect(find.byType(StageDefinitionView), findsNothing);
expect(find.text(unknownStageDefinition), findsOneWidget);
expect(find.text('Draft the plan.'), findsNothing);
});
testWidgets('${platform.name} visit sections at 320 with 2x dark text', (
tester,
) async {
await openVisit(
tester,
platform,
size: const Size(320, 568),
scale: 2,
brightness: Brightness.dark,
);
expect(find.byKey(const Key('run-visit-pane')), findsOneWidget);
expect(tester.takeException(), isNull);
for (final section in RunVisitSection.values) {
await openVisitTab(tester, section);
expect(tester.takeException(), isNull, reason: section.label);
}
});
}
}
@@ -0,0 +1,147 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/features/runs/ui/run_detail_visit_sections.dart';
import 'package:pipelines_app/features/runs/ui/run_detail_visit_session.dart';
import 'package:pipelines_app/features/runs/ui/run_detail_visit_session_state.dart';
import 'run_detail_graph_support.dart';
import 'run_detail_visit_support.dart';
void main() {
for (final platform in RunDetailTestPlatform.values) {
testWidgets('${platform.name} legacy session.html stays openable', (
tester,
) async {
final run = visitRunFixture();
firstVisitStep(run).remove('session_export');
await openVisit(tester, platform, run: run);
await openVisitTab(tester, RunVisitSection.session);
expect(find.text('sess-1'), findsOneWidget);
expect(find.text('Open session.html'), findsOneWidget);
expect(
find.textContaining('not available in the artifact inventory'),
findsNothing,
);
});
testWidgets('${platform.name} running and failed model visits report '
'their session state', (tester) async {
final running = visitRunFixture();
final runningStep = firstVisitStep(running);
runningStep['status'] = 'running';
runningStep.remove('session_id');
runningStep.remove('session_export');
runningStep.remove('artifacts');
await openVisit(tester, platform, run: running);
await openVisitTab(tester, RunVisitSection.session);
expect(find.text(visitSessionStarting), findsOneWidget);
final failed = visitRunFixture();
final failedStep = firstVisitStep(failed);
failedStep['status'] = 'failed';
failedStep.remove('session_id');
failedStep.remove('session_export');
failedStep.remove('artifacts');
failedStep['diagnostic'] = 'Provider refused.';
await openVisit(tester, platform, run: failed);
await openVisitTab(tester, RunVisitSection.session);
expect(
find.text('$visitSessionFailed Provider refused.'),
findsOneWidget,
);
});
}
testWidgets('a recorded session without any export file reports its state', (
tester,
) async {
final step = firstVisitStep(visitRunFixture());
step.remove('session_export');
step['artifacts'] = <dynamic>[
<String, dynamic>{
'name': 'plan.csv',
'url': 'https://example.test/artifacts/plan.csv',
'content_type': 'text/csv',
'size_bytes': 42,
},
];
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
body: RunVisitSession(step: step, configuredEndpoint: ''),
),
),
);
expect(
find.text('Session sess-1 is recorded. Its export is not yet available.'),
findsOneWidget,
);
expect(find.textContaining('Open '), findsNothing);
step['session_export'] = <String, dynamic>{
'html': 'session.html',
'status': 'failed',
'diagnostic': 'Repair failed.',
};
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
body: RunVisitSession(step: step, configuredEndpoint: ''),
),
),
);
expect(
find.text(
'Session sess-1 is recorded. Its export is failed. Repair failed.',
),
findsOneWidget,
);
});
testWidgets('session entry opens the resolved export externally', (
tester,
) async {
Uri? opened;
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
body: RunVisitSession(
step: firstVisitStep(visitRunFixture()),
configuredEndpoint: 'ws://example.test/connect',
openExternal: (uri) async {
opened = uri;
return true;
},
),
),
),
);
await tester.tap(find.text('Open session.html'));
await tester.pumpAndSettle();
expect(opened, Uri.parse('https://example.test/artifacts/session.html'));
expect(find.text('Link opened externally.'), findsOneWidget);
});
testWidgets('session open refusal is reported', (tester) async {
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
body: RunVisitSession(
step: firstVisitStep(visitRunFixture()),
configuredEndpoint: 'ws://example.test/connect',
openExternal: (uri) async => false,
),
),
),
);
await tester.tap(find.text('Open session.html'));
await tester.pumpAndSettle();
expect(find.text('Could not open the link.'), findsOneWidget);
});
}
@@ -0,0 +1,116 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/core/api_gateway.dart';
import 'package:pipelines_app/features/runs/ui/run_detail_tab.dart';
import 'package:pipelines_app/features/runs/ui/run_detail_visit_sections.dart';
import 'run_detail_graph_support.dart';
/// plan -> build, with one rich recorded plan visit.
JsonMap visitRunFixture({
bool bothTimestamps = true,
bool providerModel = true,
bool declareStage = true,
}) => <String, dynamic>{
'id': 77,
'title': 'Visit run',
'name': 'release',
'pipeline_id': 7,
'version': 3,
'status': 'succeeded',
'graph': <String, dynamic>{
'stages': <dynamic>[
if (declareStage)
<String, dynamic>{
'key': 'plan',
'type': 'model',
'prompt': 'Draft the plan.',
'edges': <String, String?>{'success': 'build', 'error': '#'},
},
<String, dynamic>{
'key': 'build',
'type': 'model',
'edges': <String, String?>{'success': '#success'},
},
],
},
'steps': <dynamic>[
<String, dynamic>{
'stage': 'plan',
'sequence': 1,
'status': 'completed',
'outcome': 'success',
'target': 'build',
if (providerModel) 'provider': 'anthropic',
if (providerModel) 'model': 'claude-x',
if (bothTimestamps) 'started_at': '2026-10-22T00:00:00Z',
if (bothTimestamps) 'finished_at': '2026-10-22T00:02:05Z',
'diagnostic': 'Plan checked.',
'verdict': <String, dynamic>{
'option': 'approve',
'reason': 'Looks good.',
},
'input': <String, dynamic>{'prompt': 'Ship it.'},
'output': <String, dynamic>{'result': 'ok'},
'session_id': 'sess-1',
'session_export': <String, dynamic>{
'html': 'session.html',
'status': 'complete',
'messages': 3,
'html_bytes': 1234,
},
'artifacts': <dynamic>[
<String, dynamic>{
'name': 'plan.csv',
'url': 'https://example.test/artifacts/plan.csv',
'content_type': 'text/csv',
'size_bytes': 42,
},
<String, dynamic>{
'name': 'session.html',
'url': 'https://example.test/artifacts/session.html',
'content_type': 'text/html',
'size_bytes': 100,
},
],
},
],
};
/// The first recorded step of a detail fixture, for tests that change one
/// visit's recorded fields.
JsonMap firstVisitStep(JsonMap run) =>
(run['steps'] as List).first as Map<String, dynamic>;
Future<void> openVisit(
WidgetTester tester,
RunDetailTestPlatform platform, {
JsonMap? run,
int sequence = 1,
Size size = const Size(900, 1000),
double scale = 1,
Brightness brightness = Brightness.light,
}) async {
await pumpRunDetail(
tester,
platform,
run: run ?? visitRunFixture(),
size: size,
scale: scale,
brightness: brightness,
);
await openRunDetailTab(tester, RunDetailTab.timeline);
final row = find.byKey(ValueKey('run-timeline-visit-$sequence'));
await tester.ensureVisible(row);
await tester.pumpAndSettle();
await tester.tap(row);
await tester.pumpAndSettle();
}
Future<void> openVisitTab(WidgetTester tester, RunVisitSection section) async {
final tab = find.byKey(ValueKey('run-visit-tab-${section.name}'));
await tester.ensureVisible(tab);
await tester.pumpAndSettle();
await tester.tap(tab);
await tester.pumpAndSettle();
}
@@ -0,0 +1,106 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/core/api_gateway.dart';
import 'package:pipelines_app/features/runs/ui/run_detail_timeline.dart';
import 'package:pipelines_app/features/runs/ui/run_detail_visit_session.dart';
import 'package:pipelines_app/features/runs/ui/run_detail_visit_session_state.dart';
import 'run_detail_graph_support.dart';
import 'run_detail_visit_support.dart';
void main() {
for (final platform in RunDetailTestPlatform.values) {
testWidgets('${platform.name} visit shows only its recorded facts', (
tester,
) async {
await openVisit(tester, platform);
expect(find.byKey(const Key('run-visit-pane')), findsOneWidget);
expect(find.text('plan · visit 1'), findsOneWidget);
for (final value in [
'Status: completed',
'Outcome: success',
'Duration: 2m 5s',
'Provider/model: anthropic / claude-x',
'Target: build',
]) {
expect(find.textContaining(value), findsOneWidget, reason: value);
}
for (final value in ['approve', 'Looks good.', 'Plan checked.']) {
expect(find.text(value), findsOneWidget, reason: value);
}
expect(find.text('Verdict'), findsOneWidget);
expect(find.text('Diagnostic'), findsOneWidget);
});
testWidgets('${platform.name} duration hides without both timestamps', (
tester,
) async {
await openVisit(
tester,
platform,
run: visitRunFixture(bothTimestamps: false),
);
expect(find.textContaining('Duration'), findsNothing);
expect(find.textContaining('0s'), findsNothing);
expect(find.textContaining('Status: completed'), findsOneWidget);
});
testWidgets('${platform.name} absent provider/model is not invented', (
tester,
) async {
await openVisit(
tester,
platform,
run: visitRunFixture(providerModel: false),
);
expect(find.textContaining('Provider/model'), findsNothing);
expect(find.textContaining('anthropic / claude-x'), findsNothing);
});
testWidgets('${platform.name} Back closes the visit pane', (tester) async {
await openVisit(tester, platform);
await tester.tap(find.byKey(const Key('run-visit-back')));
await tester.pumpAndSettle();
expect(find.byKey(const Key('run-visit-pane')), findsNothing);
expect(find.byType(RunTimelineList), findsOneWidget);
expect(find.text('plan · visit 1'), findsOneWidget);
});
testWidgets('${platform.name} visit pane at 320 with 2x dark text', (
tester,
) async {
await openVisit(
tester,
platform,
size: const Size(320, 568),
scale: 2,
brightness: Brightness.dark,
);
expect(find.byKey(const Key('run-visit-pane')), findsOneWidget);
expect(tester.takeException(), isNull);
});
}
testWidgets('session export with no configured endpoint states the hint', (
tester,
) async {
final step = (visitRunFixture()['steps'] as List).first as JsonMap;
final artifacts = step['artifacts'] as List;
(artifacts[1] as JsonMap)['url'] = '/artifacts/session.html';
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
body: RunVisitSession(step: step, configuredEndpoint: ''),
),
),
);
expect(find.text('Open session.html'), findsNothing);
expect(find.text(visitSessionEndpointMissing), findsOneWidget);
});
}