session export: write only session.html, retire the markdown export

A stage's session was exported twice, as session.md and session.html, and both
files were presented. It is now one html file; the markdown export is retired.

- internal/stage/session_export.go: ExportSession renders and writes exactly one
  file, session.html, via writeSessionFile; renderSessionMarkdown and its helpers
  are gone; SessionExportResult carries HTML/HTMLBytes only. The source read, the
  8 MiB source / 2 MiB rendered bounds, the truncation banner, the
  never-overwrite rule and the honest empty-session handling are unchanged.
- internal/protocol/runs.go: SessionExport drops markdown/markdown_bytes (a
  record written before the change still decodes; unknown fields are ignored),
  and adds LegacySessionMarkdownArtifact with RunStep.PresentedArtifacts(), the
  one Go rule that hides the retired session.md from every artifact listing.
- internal/server/runner.go: evidence.Markdown/MarkdownBytes are no longer copied.
- internal/tui: the artifacts panel, the recorded count and the per-visit summary
  derive from PresentedArtifacts(), so the terminal never lists session.md.
- web/src/app.js: the spike's renderArtifacts applies the same filter.
- android: the Session section is the html export alone in a WebView — SessionView,
  the Markdown/HTML toggle and the session markdown path are removed;
  presentedArtifacts(step) filters the retired session.md out of the per-visit
  gallery, the run gallery and its count, the verdict/selection lists and the
  timeline indicator; data/protocol SessionExport drops the markdown fields.
- Tests pin the single html file, prove no session.md is written and that a
  pre-existing one is neither overwritten nor presented, and prove a legacy
  export record still loads and its session.md is hidden.

The legacy session.md of an older run stays on disk (dated evidence); it is only
no longer produced and no longer presented.

Checks (macOS, Go 1.24, Android Gradle 8.11.1, 18 Oct 2026): gofmt -l . prints
nothing; go build ./... && go vet ./... clean; go test ./internal/... ./cmd/...
-> 19 packages ok, 0 failures; node --check web/src/app.js ok and node --test
web/test -> 20/20; gradle --offline --no-daemon :app:assembleDebug
:app:testDebugUnitTest -> BUILD SUCCESSFUL.

Packaged references checked: internal/author/skill/references/delivery.md and
operations.md both described the session.md+session.html pair, so both are
updated here to describe the single session.html export and the retired, hidden
session.md. README.md and internal/author/skill/SKILL.md carry no session.md
reference and install.go's managed inventory is unchanged (no reference added or
removed). docs/notes/session-html-only.md records the remaining stale shared
documentation (docs/stage-artifacts.md, docs/app-integration-verification.md) for
the docs-fold writer; shared docs are not edited by this item.
This commit is contained in:
2026-10-18 10:06:49 +01:00
parent 5a4cfc2e9c
commit 95362134aa
25 changed files with 666 additions and 571 deletions
+6 -3
View File
@@ -29,8 +29,11 @@ type artifactVisit struct {
// order the run produced them: stages in first-appearance order and each
// stage's visits by sequence. The display visit number is the recorded control
// visit when present, else the position within the stage (mirroring the app's
// runTimeline/runArtifactGroups). Pure, O(n), and it never dedupes steps, so a
// repeated stage's visits stay distinct.
// runTimeline/runArtifactGroups). A visit carries the step's presented
// artifacts (protocol.RunStep.PresentedArtifacts), so the retired session
// markdown is never listed beside the session html, exactly as the app hides it.
// Pure, O(n), and it never dedupes steps, so a repeated stage's visits stay
// distinct.
func runArtifactVisits(steps []protocol.RunStep) []artifactVisit {
order := make([]string, 0)
index := map[string]int{}
@@ -54,7 +57,7 @@ func runArtifactVisits(steps []protocol.RunStep) []artifactVisit {
if step.Control != nil && step.Control.Visit > 0 {
visit = step.Control.Visit
}
visits = append(visits, artifactVisit{stage: stage, visit: visit, step: step, artifacts: step.Artifacts})
visits = append(visits, artifactVisit{stage: stage, visit: visit, step: step, artifacts: step.PresentedArtifacts()})
}
}
return visits
+47
View File
@@ -155,6 +155,53 @@ func TestArtifactsViewEmptyRun(t *testing.T) {
}
}
// A run recorded before the HTML-only change still lists session.md among its
// stored artifacts. It is dated evidence that must never be presented beside the
// session html, so the panel, its recorded count and its summary all hide it,
// exactly as the app does.
func TestArtifactsViewHidesLegacySessionMarkdown(t *testing.T) {
m := New(context.Background(), "ws://127.0.0.1:8080/connect")
m.width, m.height = 120, 24
m.runDetail = &protocol.RunDetail{
RunSummary: protocol.RunSummary{ID: 344, Status: "succeeded"},
Steps: []protocol.RunStep{{Sequence: 1, Stage: "committer", Status: "completed",
Artifacts: []protocol.StageArtifact{
{Name: "session.md", SizeBytes: 62370, ContentType: "text/markdown", URL: "/artifacts/344/1/session.md"},
{Name: "session.html", SizeBytes: 68813, ContentType: "text/html", URL: "/artifacts/344/1/session.html"},
}}},
}
view := ansi.Strip(m.artifactsView(20))
if strings.Contains(view, "session.md") {
t.Fatalf("legacy session markdown presented beside the html:\n%s", view)
}
for _, want := range []string{"session.html", "Artifacts · run #344 · 1 recorded · 1 visits"} {
if !strings.Contains(view, want) {
t.Fatalf("artifacts view missing %q:\n%s", want, view)
}
}
// The step's own stored record is untouched: only the presentation filters.
if len(m.runDetail.Steps[0].Artifacts) != 2 {
t.Fatalf("presentation mutated the stored artifact record: %d", len(m.runDetail.Steps[0].Artifacts))
}
}
func TestArtifactsSummaryAndNotesHideLegacySessionMarkdown(t *testing.T) {
legacy := protocol.RunStep{Status: "completed", ArtifactsSkipped: 1,
Artifacts: []protocol.StageArtifact{{Name: "session.md", URL: "/artifacts/344/1/session.md"}}}
if got, want := artifactsSummary(legacy), "Artifacts · not recorded for this visit"; got != want {
t.Fatalf("summary = %q, want %q", got, want)
}
if notes := artifactCaptureNotes(legacy); len(notes) != 0 {
t.Fatalf("legacy-only visit still produced capture notes: %v", notes)
}
presented := protocol.RunStep{Status: "completed", Artifacts: []protocol.StageArtifact{
{Name: "session.md"}, {Name: "session.html"},
}}
if got, want := artifactsSummary(presented), "Artifacts · 1 recorded"; got != want {
t.Fatalf("summary = %q, want %q", got, want)
}
}
func artifactsScrollFixture() (Model, []string) {
m := New(context.Background(), "ws://127.0.0.1:8080/connect")
m.width, m.height = 80, 14
+4 -3
View File
@@ -31,13 +31,14 @@ func fileChangesSummary(step protocol.RunStep) string {
}
func artifactsSummary(step protocol.RunStep) string {
if len(step.Artifacts) == 0 {
artifacts := step.PresentedArtifacts()
if len(artifacts) == 0 {
if step.Status == "running" {
return "Artifacts · capture pending"
}
return "Artifacts · not recorded for this visit"
}
label := fmt.Sprintf("Artifacts · %d recorded", len(step.Artifacts))
label := fmt.Sprintf("Artifacts · %d recorded", len(artifacts))
if step.ArtifactsSkipped > 0 || step.ArtifactsTruncated > 0 {
label += " · partial capture"
}
@@ -64,7 +65,7 @@ func HumanBytes(size int64) string {
// complete. A visit with no recorded artifacts yields no notes, mirroring the
// app's artifactCaptureNotes, so notes never accompany an empty-state summary.
func artifactCaptureNotes(step protocol.RunStep) []string {
if len(step.Artifacts) == 0 {
if len(step.PresentedArtifacts()) == 0 {
return nil
}
var notes []string