Artifacts: runner-internal turn files move to a Debugging files group
Each recorded artifact now carries a server group (deliverable or debug). public/ files are deliverables; input/memory/history/output.md, session exports and private/ scratch are debugging files. The app's Artifacts tab lists deliverables and the Debug toggle reveals a separate Debugging files group (older servers fall back to the filename rule); the TUI lists deliverables first and marks debug rows; artifact search excludes debug files unless include_debug / --debug-files is set.
This commit is contained in:
@@ -15,6 +15,20 @@ const List<String> systemArtifactNames = <String>[
|
||||
'session.html',
|
||||
];
|
||||
|
||||
/// The server's `group` value for a runner-internal debugging file.
|
||||
const String debugArtifactGroup = 'debug';
|
||||
|
||||
/// The server's `group` value for a file the stage published.
|
||||
const String deliverableArtifactGroup = 'deliverable';
|
||||
|
||||
/// Whether [name] is a runner-internal debugging file by name alone. This is
|
||||
/// the fallback for a server that records no `group`: the turn documents, the
|
||||
/// full `history.md`, and the visit's `private/` scratch.
|
||||
bool isDebugArtifactName(String name) =>
|
||||
isSystemArtifactName(name) ||
|
||||
name == 'history.md' ||
|
||||
name.startsWith('private/');
|
||||
|
||||
/// One recorded artifact of a stage visit.
|
||||
///
|
||||
/// The server is the authority: [name], [url], [contentType] and [sizeBytes]
|
||||
@@ -63,6 +77,15 @@ class ArtifactRecord {
|
||||
bool get isSystem => isSystemArtifactName(name);
|
||||
bool get isPublicName => name.startsWith('public/');
|
||||
|
||||
/// Whether this is a runner-internal debugging file rather than a stage
|
||||
/// deliverable. The server's recorded `group` decides; an older server that
|
||||
/// records none falls back to [isDebugArtifactName].
|
||||
bool get isDebug {
|
||||
final group = raw['group'];
|
||||
if (group is String && group.isNotEmpty) return group == debugArtifactGroup;
|
||||
return isDebugArtifactName(name);
|
||||
}
|
||||
|
||||
static String _text(dynamic value) => value == null ? '' : '$value';
|
||||
|
||||
static int _intOf(dynamic value) {
|
||||
|
||||
@@ -36,7 +36,7 @@ List<ArtifactRecord> presentedArtifacts(Iterable<ArtifactRecord> artifacts) {
|
||||
];
|
||||
}
|
||||
|
||||
/// A visit's stage-produced artifacts: everything except the turn-owned files
|
||||
/// A visit's deliverables: everything except runner-internal debugging files
|
||||
/// and repaired session exports. Order is preserved.
|
||||
List<ArtifactRecord> stageArtifactsFrom(
|
||||
Iterable<ArtifactRecord> artifacts, {
|
||||
@@ -44,18 +44,19 @@ List<ArtifactRecord> stageArtifactsFrom(
|
||||
}) {
|
||||
return <ArtifactRecord>[
|
||||
for (final artifact in presentedArtifacts(artifacts))
|
||||
if (!artifact.isSystem && !repairs.contains(artifact.name)) artifact,
|
||||
if (!artifact.isDebug && !repairs.contains(artifact.name)) artifact,
|
||||
];
|
||||
}
|
||||
|
||||
/// A visit's system files and repaired exports, in recorded order.
|
||||
/// A visit's debugging files (turn documents, history.md, private/ scratch)
|
||||
/// and repaired exports, in recorded order.
|
||||
List<ArtifactRecord> systemArtifactsFrom(
|
||||
Iterable<ArtifactRecord> artifacts, {
|
||||
Set<String> repairs = const <String>{},
|
||||
}) {
|
||||
return <ArtifactRecord>[
|
||||
for (final artifact in presentedArtifacts(artifacts))
|
||||
if (artifact.isSystem || repairs.contains(artifact.name)) artifact,
|
||||
if (artifact.isDebug || repairs.contains(artifact.name)) artifact,
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,10 @@ import '../domain/artifact_groups.dart';
|
||||
import 'artifact_record_row.dart';
|
||||
import 'artifact_row_labels.dart';
|
||||
|
||||
/// The gallery's label for a visit's runner-internal files (turn documents,
|
||||
/// history.md, private/ scratch, session exports), shown only while Debug is on.
|
||||
const String debuggingFilesTitle = 'Debugging files';
|
||||
|
||||
/// One visit's turn documents, shown below its stage artifacts.
|
||||
///
|
||||
/// A recorded document is a normal gallery row with its recorded name, MIME and
|
||||
@@ -21,8 +25,13 @@ class ArtifactDocumentSection extends StatelessWidget {
|
||||
this.selectedIdentity,
|
||||
this.onSelected,
|
||||
this.showHeader = true,
|
||||
this.title = 'Turn documents',
|
||||
});
|
||||
|
||||
/// The section label: the Session page names the turn documents; the gallery
|
||||
/// names every runner-internal file it lists as debugging files.
|
||||
final String title;
|
||||
|
||||
/// False when a collapsible title above already names the section.
|
||||
final bool showHeader;
|
||||
|
||||
@@ -54,7 +63,7 @@ class ArtifactDocumentSection extends StatelessWidget {
|
||||
container: true,
|
||||
header: true,
|
||||
child: Text(
|
||||
'Turn documents',
|
||||
title,
|
||||
style: cupertino ? SectionHeadingStyle.of(context).title : null,
|
||||
),
|
||||
),
|
||||
|
||||
@@ -124,7 +124,7 @@ class _ArtifactGalleryPageState extends State<ArtifactGalleryPage> {
|
||||
for (final document in group.documents) {
|
||||
final record = document.record;
|
||||
if (record == null || record.url != url) continue;
|
||||
// A turn document is listed only while the debug toggle shows them.
|
||||
// A debugging file is listed only while the debug toggle shows them.
|
||||
_showTurnDocuments = true;
|
||||
_opening = (group: group, artifact: record);
|
||||
}
|
||||
@@ -556,7 +556,7 @@ class _ArtifactGalleryPageState extends State<ArtifactGalleryPage> {
|
||||
|
||||
Widget _debugToggle(BuildContext context) {
|
||||
final showing = _showTurnDocuments;
|
||||
final label = showing ? 'Hide turn documents' : 'Show turn documents';
|
||||
final label = showing ? 'Hide debugging files' : 'Show debugging files';
|
||||
// Cupertino's bundled icon font has no bug glyph; retain the universally
|
||||
// recognisable Material bug icon inside its native Cupertino button.
|
||||
final icon = showing ? Icons.bug_report : Icons.bug_report_outlined;
|
||||
|
||||
@@ -211,7 +211,7 @@ class _ArtifactVisitListState extends State<ArtifactVisitList> {
|
||||
group: group,
|
||||
selectedIdentity: widget.selectedIdentity,
|
||||
onSelected: widget.onSelected,
|
||||
showHeader: false,
|
||||
title: debuggingFilesTitle,
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/features/artifacts/domain/artifact_record.dart';
|
||||
import 'package:pipelines_app/features/artifacts/domain/artifact_selection.dart';
|
||||
|
||||
import 'artifact_fixtures.dart';
|
||||
|
||||
List<String> _names(List<ArtifactRecord> records) => [
|
||||
for (final record in records) record.name,
|
||||
];
|
||||
|
||||
void main() {
|
||||
test('the server group decides deliverable versus debugging file', () {
|
||||
final records = [
|
||||
ArtifactRecord.fromJson(
|
||||
artifact('notes.md', extra: const {'group': 'debug'}),
|
||||
),
|
||||
ArtifactRecord.fromJson(
|
||||
artifact('history.md', extra: const {'group': 'deliverable'}),
|
||||
),
|
||||
ArtifactRecord.fromJson(
|
||||
artifact('public/report.png', extra: const {'group': 'deliverable'}),
|
||||
),
|
||||
];
|
||||
expect(_names(stageArtifactsFrom(records)), [
|
||||
'history.md',
|
||||
'public/report.png',
|
||||
]);
|
||||
expect(_names(systemArtifactsFrom(records)), ['notes.md']);
|
||||
});
|
||||
|
||||
test('an older server without groups falls back to the filename rule', () {
|
||||
final records = [
|
||||
for (final name in [
|
||||
'input.md',
|
||||
'memory.md',
|
||||
'history.md',
|
||||
'output.md',
|
||||
'session.html',
|
||||
'private/shot.png',
|
||||
'public/report.html',
|
||||
'legacy-report.txt',
|
||||
])
|
||||
ArtifactRecord.fromJson(artifact(name)),
|
||||
];
|
||||
expect(_names(stageArtifactsFrom(records)), [
|
||||
'public/report.html',
|
||||
'legacy-report.txt',
|
||||
]);
|
||||
expect(_names(systemArtifactsFrom(records)), [
|
||||
'input.md',
|
||||
'memory.md',
|
||||
'history.md',
|
||||
'output.md',
|
||||
'session.html',
|
||||
'private/shot.png',
|
||||
]);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
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/artifacts/ui/artifact_gallery_page.dart';
|
||||
import 'package:pipelines_app/features/artifacts/ui/artifact_viewer_fetch.dart';
|
||||
|
||||
import '../domain/artifact_fixtures.dart';
|
||||
|
||||
enum _Platform { material, cupertino }
|
||||
|
||||
JsonMap _file(String name, String group) => artifact(
|
||||
name,
|
||||
contentType: 'text/markdown',
|
||||
sizeBytes: 10,
|
||||
extra: <String, dynamic>{'group': group},
|
||||
);
|
||||
|
||||
/// One turn visit as the current server records it: a public deliverable plus
|
||||
/// runner-internal files, including history.md and a private capture.
|
||||
List<JsonMap> _steps() => <JsonMap>[
|
||||
step(
|
||||
stage: 'build',
|
||||
sequence: 1,
|
||||
visit: 1,
|
||||
artifacts: [
|
||||
_file('input.md', 'debug'),
|
||||
_file('memory.md', 'debug'),
|
||||
_file('history.md', 'debug'),
|
||||
_file('output.md', 'debug'),
|
||||
_file('private/scratch.md', 'debug'),
|
||||
_file('public/report.md', 'deliverable'),
|
||||
],
|
||||
),
|
||||
];
|
||||
|
||||
Future<void> _pump(WidgetTester tester, _Platform platform) async {
|
||||
tester.view.physicalSize = const Size(900, 2600);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.resetPhysicalSize);
|
||||
addTearDown(tester.view.resetDevicePixelRatio);
|
||||
final page = ArtifactGalleryPage(
|
||||
steps: _steps(),
|
||||
configuredEndpoint: 'ws://127.0.0.1:8081/connect',
|
||||
openExternal: (_) async => true,
|
||||
fetch: (_) async =>
|
||||
ArtifactFetchResult(status: 200, bytes: Uint8List.fromList([35])),
|
||||
markdownBuilder: (context, value) => Text(value),
|
||||
);
|
||||
await tester.pumpWidget(
|
||||
platform == _Platform.material
|
||||
? MaterialApp(home: page)
|
||||
: CupertinoApp(home: page),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
|
||||
void main() {
|
||||
for (final platform in _Platform.values) {
|
||||
testWidgets('${platform.name}: only deliverables show until Debugging '
|
||||
'files is revealed', (tester) async {
|
||||
await _pump(tester, platform);
|
||||
expect(find.text('public/report.md'), findsOneWidget);
|
||||
for (final name in [
|
||||
'history.md',
|
||||
'memory.md',
|
||||
'input.md',
|
||||
'private/scratch.md',
|
||||
]) {
|
||||
expect(find.text(name), findsNothing, reason: name);
|
||||
}
|
||||
expect(find.text('Debugging files'), findsNothing);
|
||||
|
||||
await tester.tap(find.byKey(const Key('artifact-debug-toggle')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Debugging files'), findsOneWidget);
|
||||
for (final name in [
|
||||
'history.md',
|
||||
'memory.md',
|
||||
'input.md',
|
||||
'output.md',
|
||||
'private/scratch.md',
|
||||
]) {
|
||||
expect(find.text(name), findsOneWidget, reason: name);
|
||||
}
|
||||
expect(find.text('public/report.md'), findsOneWidget);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -99,9 +99,9 @@ void main() {
|
||||
await _pump(tester, platform);
|
||||
expect(find.text('input.md'), findsNothing);
|
||||
expect(find.textContaining('Turn documents'), findsNothing);
|
||||
expect(find.byTooltip('Show turn documents'), findsOneWidget);
|
||||
expect(find.byTooltip('Show debugging files'), findsOneWidget);
|
||||
await _showTurnDocuments(tester);
|
||||
expect(find.byTooltip('Hide turn documents'), findsOneWidget);
|
||||
expect(find.byTooltip('Hide debugging files'), findsOneWidget);
|
||||
expect(find.text('input.md'), findsNWidgets(2));
|
||||
expect(find.text('output.md'), findsNWidgets(2));
|
||||
expect(find.text('session.html'), findsNWidgets(2));
|
||||
|
||||
@@ -83,6 +83,15 @@ JsonMap probeRunDetail() => {
|
||||
'size_bytes': 4096,
|
||||
'url': '/artifacts/7/2/release-dashboard.html',
|
||||
},
|
||||
if (_turnFiles)
|
||||
for (final name in _turnFileNames)
|
||||
{
|
||||
'name': name,
|
||||
'content_type': 'text/markdown',
|
||||
'size_bytes': 640,
|
||||
'url': '/artifacts/7/2/',
|
||||
'group': 'debug',
|
||||
},
|
||||
],
|
||||
'file_changes': _probeChanges([
|
||||
'lib/release/train.dart',
|
||||
@@ -138,6 +147,18 @@ int _fillerStepCount = 0;
|
||||
/// serves its bytes from the build directory (see notes/artifact-fullscreen.md).
|
||||
bool _htmlArtifact = false;
|
||||
|
||||
/// `?turn=1` adds the runner-internal turn files the server records for a model
|
||||
/// visit (group `debug`) to run 7's build visit, so the Artifacts tab's hidden
|
||||
/// Debugging files group can be reviewed.
|
||||
bool _turnFiles = false;
|
||||
const List<String> _turnFileNames = [
|
||||
'input.md',
|
||||
'memory.md',
|
||||
'history.md',
|
||||
'output.md',
|
||||
'private/build-log.md',
|
||||
];
|
||||
|
||||
List<JsonMap> _fillerSteps() => [
|
||||
for (var i = 0; i < _fillerStepCount; i++)
|
||||
{
|
||||
@@ -618,6 +639,7 @@ class _FixtureSink implements WebSocketSink {
|
||||
/// `?runs=200` / `?steps=60` append filler runs / run-7 steps for scroll
|
||||
/// performance captures;
|
||||
/// `?html=1` adds an HTML artifact to run 7 (`release-dashboard.html`);
|
||||
/// `?turn=1` adds run 7's debug turn files (input/memory/history/output.md);
|
||||
/// `?q=release` types that query into Search once its field is shown;
|
||||
/// `?platform=cupertino` renders the Cupertino host (`material`, the
|
||||
/// default, renders Material as browsers do);
|
||||
@@ -650,6 +672,7 @@ void main() {
|
||||
_fillerStepCount = int.tryParse(params['steps'] ?? '') ?? 0;
|
||||
probeUsage = params['usage'] == '1';
|
||||
_htmlArtifact = params['html'] == '1';
|
||||
_turnFiles = params['turn'] == '1';
|
||||
final cupertino = params['platform'] == 'cupertino';
|
||||
final route = params['route'];
|
||||
final opensRoute = route != null && route.startsWith('/');
|
||||
|
||||
Reference in New Issue
Block a user