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:
2026-12-03 17:23:33 +00:00
parent 1dc992bc27
commit 0791a4702d
10 changed files with 289 additions and 38 deletions
@@ -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(