From 280837882351ecc29f8c06c3fa96b7285768b4e5 Mon Sep 17 00:00:00 2001 From: Alan Silva Date: Sun, 1 Nov 2026 08:32:10 +0000 Subject: [PATCH] Keep turn documents out of the artifact viewer unless Debug is on Opening a stage artifact paged through every visit's turn documents too, although the list hides them; the viewer now pages through what the list shows. --- .../artifacts/ui/artifact_gallery_page.dart | 14 ++++++++++- .../ui/artifact_gallery_documents_test.dart | 25 +++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/app/lib/features/artifacts/ui/artifact_gallery_page.dart b/app/lib/features/artifacts/ui/artifact_gallery_page.dart index 51c127ca..e98f996c 100644 --- a/app/lib/features/artifacts/ui/artifact_gallery_page.dart +++ b/app/lib/features/artifacts/ui/artifact_gallery_page.dart @@ -216,7 +216,19 @@ class _ArtifactGalleryPageState extends State { ], ), ] - : _groups; + // A stage artifact pages through what the list shows: turn + // documents only while Debug reveals them. + : _showTurnDocuments + ? _groups + : [ + for (final group in _groups) + if (group.artifacts.isNotEmpty) + ArtifactGroup( + stageKey: group.stageKey, + visit: group.visit, + artifacts: group.artifacts, + ), + ]; final previousFocus = FocusManager.instance.primaryFocus; await Navigator.of(context).push( usesCupertinoHost(context) diff --git a/app/test/features/artifacts/ui/artifact_gallery_documents_test.dart b/app/test/features/artifacts/ui/artifact_gallery_documents_test.dart index 1c6ec0a3..f8e229cc 100644 --- a/app/test/features/artifacts/ui/artifact_gallery_documents_test.dart +++ b/app/test/features/artifacts/ui/artifact_gallery_documents_test.dart @@ -196,6 +196,31 @@ void main() { ]); }); + testWidgets('${platform.name}: a stage artifact pages only through stage ' + 'artifacts while Debug is off', (tester) async { + await _pump(tester, platform); + + // report.csv (visit 1) and notes.md (visit 2) are the only stage + // artifacts; the visits' turn documents stay out of the viewer. + await tester.tap(find.text('report.csv')); + await tester.pumpAndSettle(); + expect(find.byType(ArtifactViewerPage), findsOneWidget); + expect(find.text('1 of 2 · text/csv'), findsOneWidget); + }); + + testWidgets('${platform.name}: with Debug on, a stage artifact pages ' + 'through turn documents too', (tester) async { + await _pump(tester, platform); + await _showTurnDocuments(tester); + + await tester.tap(find.text('report.csv')); + await tester.pumpAndSettle(); + expect(find.byType(ArtifactViewerPage), findsOneWidget); + // Both stage artifacts plus the recorded viewer documents + // (session.html opens externally only). + expect(find.text('1 of 6 · text/csv'), findsOneWidget); + }); + testWidgets('${platform.name}: documents do not count as artifacts and ' 'viewer paging stays within documents', (tester) async { await _pump(