Artifacts: badge counts deliverables only; debugging files as a secondary section
The Artifacts badge counted every recorded turn document (input, memory, output, session.html) while the tab lists only deliverables, so a run whose visits recorded only debugging files (the Caplens ticket runs) badged dozens of artifacts and opened to an empty tab. The badge and the header now count deliverables only; the tab stays reachable when only debugging files exist and ends with a collapsed 'Show debugging files' entry naming their count. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -15,17 +15,28 @@ String artifactsEmptyMessage(bool executing) => executing
|
||||
? 'Artifacts · $artifactCapturePending'
|
||||
: 'No artifacts recorded for this run.';
|
||||
|
||||
/// How many deliverables the run recorded: the stage-published files the
|
||||
/// gallery lists by default, each shared `public/` file counted once. The run
|
||||
/// detail's Artifacts badge and the gallery header both use this count, so a
|
||||
/// run whose visits recorded only debugging files never advertises them.
|
||||
int runDeliverableCount(List<JsonMap> steps) => artifactGroups(
|
||||
steps,
|
||||
).fold<int>(0, (sum, group) => sum + group.artifacts.length);
|
||||
|
||||
/// How many debugging files the run recorded (turn documents, history,
|
||||
/// private scratch, session exports): the gallery's secondary section.
|
||||
int debugFileCount(List<JsonMap> steps) =>
|
||||
steps.fold<int>(0, (sum, step) => sum + systemArtifacts(step).length);
|
||||
|
||||
/// The run summary's Artifacts section header.
|
||||
///
|
||||
/// The recorded count is the number of recorded entries [galleryGroups] yields:
|
||||
/// stage files plus the turn documents the server actually recorded, never an
|
||||
/// absent slot. The title takes its singular form for one. A run whose capture is
|
||||
/// unavailable says so instead of claiming that nothing was recorded. Partial
|
||||
/// capture is flagged when any visit excluded or omitted files.
|
||||
/// The recorded count is the run's deliverables ([runDeliverableCount]);
|
||||
/// debugging files are not counted as artifacts. The title takes its singular
|
||||
/// form for one. A run whose capture is unavailable says so instead of claiming
|
||||
/// that nothing was recorded. Partial capture is flagged when any visit
|
||||
/// excluded or omitted files.
|
||||
String artifactsHeader(List<JsonMap> steps, {required bool executing}) {
|
||||
final recorded = galleryGroups(
|
||||
steps,
|
||||
).fold<int>(0, (sum, group) => sum + group.recordedCount);
|
||||
final recorded = runDeliverableCount(steps);
|
||||
if (recorded == 0) {
|
||||
if (executing) return artifactsEmptyMessage(true);
|
||||
final unavailable = steps.any(
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../ui/text/plural.dart';
|
||||
|
||||
/// The gallery's secondary, collapsed entry for a run's debugging files.
|
||||
///
|
||||
/// It follows the deliverables (or stands alone when there are none), so a
|
||||
/// run that recorded only runner-internal files says how many there are and
|
||||
/// opens them in place instead of leaving the page apparently empty.
|
||||
class ArtifactDebugReveal extends StatelessWidget {
|
||||
const ArtifactDebugReveal({
|
||||
super.key,
|
||||
required this.count,
|
||||
required this.showing,
|
||||
required this.onToggle,
|
||||
});
|
||||
|
||||
/// The recorded debugging files the section holds.
|
||||
final int count;
|
||||
|
||||
/// Whether the debugging files are currently listed.
|
||||
final bool showing;
|
||||
|
||||
final VoidCallback onToggle;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Material(
|
||||
type: MaterialType.transparency,
|
||||
child: ListTile(
|
||||
key: const Key('artifact-debug-reveal'),
|
||||
leading: Icon(showing ? Icons.bug_report : Icons.bug_report_outlined),
|
||||
title: Text(showing ? 'Hide debugging files' : 'Show debugging files'),
|
||||
subtitle: Text(
|
||||
'${countLabel(count, 'file')}: turn documents, history and '
|
||||
'private scratch',
|
||||
),
|
||||
trailing: Icon(showing ? Icons.expand_less : Icons.expand_more),
|
||||
onTap: onToggle,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@ import 'package:flutter/material.dart';
|
||||
import '../../../core/api_gateway.dart';
|
||||
import '../../../core/transport/pipelines_client.dart';
|
||||
import '../domain/artifact_chat_context.dart';
|
||||
import '../domain/artifact_groups.dart';
|
||||
import '../domain/artifact_summary.dart';
|
||||
import 'artifact_external_open.dart';
|
||||
import 'artifact_gallery_page.dart';
|
||||
|
||||
@@ -34,11 +34,14 @@ List<JsonMap> runDetailArtifactSteps(JsonMap run) {
|
||||
bool showRunArtifactsAction(JsonMap run) =>
|
||||
runDetailArtifactSteps(run).isNotEmpty;
|
||||
|
||||
/// How many recorded entries the run's gallery lists (stage files plus
|
||||
/// recorded turn documents), as the gallery header counts them.
|
||||
int runArtifactCount(JsonMap run) => galleryGroups(
|
||||
runDetailArtifactSteps(run),
|
||||
).fold<int>(0, (sum, group) => sum + group.recordedCount);
|
||||
/// How many deliverables the run's gallery lists by default, as its header
|
||||
/// counts them. Debugging files are not artifacts and are never badged.
|
||||
int runArtifactCount(JsonMap run) =>
|
||||
runDeliverableCount(runDetailArtifactSteps(run));
|
||||
|
||||
/// How many debugging files the gallery's secondary section holds.
|
||||
int runDebugFileCount(JsonMap run) =>
|
||||
debugFileCount(runDetailArtifactSteps(run));
|
||||
|
||||
/// Whether the run is still executing, so the page can say capture pending
|
||||
/// instead of claiming nothing was recorded.
|
||||
|
||||
@@ -16,6 +16,7 @@ import '../domain/artifact_selection.dart';
|
||||
import '../domain/artifact_summary.dart';
|
||||
import '../domain/artifact_url.dart';
|
||||
import '../domain/artifact_chat_context.dart';
|
||||
import 'artifact_debug_reveal.dart';
|
||||
import 'artifact_external_open.dart';
|
||||
import 'artifact_selection_facts.dart';
|
||||
import 'artifact_viewer_content.dart';
|
||||
@@ -572,12 +573,28 @@ class _ArtifactGalleryPageState extends State<ArtifactGalleryPage> {
|
||||
_summary(groups),
|
||||
action: widget.embedded ? _debugToggle(context) : null,
|
||||
);
|
||||
// Debugging files are a secondary section after the deliverables, never
|
||||
// counted as artifacts, so a run with only those still shows where they are.
|
||||
final debugCount = groups.fold<int>(
|
||||
0,
|
||||
(sum, group) =>
|
||||
sum + group.documents.where((doc) => doc.record != null).length,
|
||||
);
|
||||
final footer = debugCount == 0
|
||||
? null
|
||||
: ArtifactDebugReveal(
|
||||
count: debugCount,
|
||||
showing: _showTurnDocuments,
|
||||
onToggle: () =>
|
||||
setState(() => _showTurnDocuments = !_showTurnDocuments),
|
||||
);
|
||||
// Header, status and rows share one scroll view: the page never splits a
|
||||
// fixed header from a shrinking list, so a long header always stays usable.
|
||||
final body = visibleGroups.isEmpty
|
||||
? ListView(children: [header])
|
||||
? ListView(children: [header, ?footer])
|
||||
: ArtifactVisitList(
|
||||
header: header,
|
||||
footer: footer,
|
||||
groups: visibleGroups,
|
||||
selectedIdentity: _selectedIdentity,
|
||||
onSelected: _select,
|
||||
|
||||
@@ -39,6 +39,7 @@ class ArtifactVisitList extends StatefulWidget {
|
||||
super.key,
|
||||
required this.groups,
|
||||
this.header,
|
||||
this.footer,
|
||||
this.selectedIdentity,
|
||||
this.onSelected,
|
||||
this.configuredEndpoint = '',
|
||||
@@ -51,6 +52,10 @@ class ArtifactVisitList extends StatefulWidget {
|
||||
|
||||
final Widget? header;
|
||||
|
||||
/// Follows the last group in the same scroll view (the gallery's secondary
|
||||
/// Debugging files entry).
|
||||
final Widget? footer;
|
||||
|
||||
final List<ArtifactGroup> groups;
|
||||
|
||||
final String? selectedIdentity;
|
||||
@@ -226,6 +231,7 @@ class _ArtifactVisitListState extends State<ArtifactVisitList> {
|
||||
slivers: [
|
||||
const SliverTopBarClearance(),
|
||||
...slivers,
|
||||
if (widget.footer != null) SliverToBoxAdapter(child: widget.footer),
|
||||
const SliverFloatingBarClearance(),
|
||||
],
|
||||
);
|
||||
|
||||
@@ -403,9 +403,12 @@ class _RunDetailTabsState extends State<RunDetailTabs> {
|
||||
if (runFindings(run).isNotEmpty) RunDetailTab.findings,
|
||||
];
|
||||
|
||||
/// Artifacts stays in place but disabled while the run recorded none.
|
||||
/// Artifacts stays in place but disabled while the run recorded no file at
|
||||
/// all. A run with only debugging files keeps it open (badged `0`) so its
|
||||
/// secondary Debugging files section stays reachable.
|
||||
Set<RunDetailTab> _disabledTabs(JsonMap run) => {
|
||||
if (runArtifactCount(run) == 0) RunDetailTab.artifacts,
|
||||
if (runArtifactCount(run) == 0 && runDebugFileCount(run) == 0)
|
||||
RunDetailTab.artifacts,
|
||||
};
|
||||
|
||||
@override
|
||||
|
||||
Reference in New Issue
Block a user