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:
@@ -86,11 +86,11 @@ func sessionExportRunner(t *testing.T, backend string, seam func(stage.SessionEx
|
||||
return handler, store, run.ID
|
||||
}
|
||||
|
||||
// TestRunnerExportsSessionFilesIntoArtifactsAndServesThem proves the real export
|
||||
// path writes both files into the step's artifacts directory, lists them with
|
||||
// artifact URLs and serves them 200, without changing the step's status, outcome
|
||||
// or target.
|
||||
func TestRunnerExportsSessionFilesIntoArtifactsAndServesThem(t *testing.T) {
|
||||
// TestRunnerExportsTheHTMLSessionIntoArtifactsAndServesIt proves the real export
|
||||
// path writes the one html session file into the step's artifacts directory,
|
||||
// lists it with an artifact URL and serves it 200, without changing the step's
|
||||
// status, outcome or target, and produces no legacy session.md.
|
||||
func TestRunnerExportsTheHTMLSessionIntoArtifactsAndServesIt(t *testing.T) {
|
||||
sessionExportCLI(t)
|
||||
handler, store, runID := sessionExportRunner(t, "v2", nil)
|
||||
detail, err := store.GetRun(context.Background(), runID)
|
||||
@@ -110,45 +110,37 @@ func TestRunnerExportsSessionFilesIntoArtifactsAndServesThem(t *testing.T) {
|
||||
if step.SessionExport == nil || step.SessionExport.SessionID != "ses_run" || step.SessionExport.Source != "native_export" {
|
||||
t.Fatalf("export evidence missing: %+v", step.SessionExport)
|
||||
}
|
||||
if step.SessionExport.Messages != 2 || step.SessionExport.MarkdownBytes == 0 || step.SessionExport.HTMLBytes == 0 {
|
||||
if step.SessionExport.HTML != "session.html" || step.SessionExport.Messages != 2 || step.SessionExport.HTMLBytes == 0 {
|
||||
t.Fatalf("export evidence wrong: %+v", step.SessionExport)
|
||||
}
|
||||
for _, name := range []string{"session.md", "session.html"} {
|
||||
artifact, ok := artifactNamed(step.Artifacts, name)
|
||||
if !ok {
|
||||
t.Fatalf("%s not in the artifact listing: %+v", name, step.Artifacts)
|
||||
}
|
||||
wantURL := fmt.Sprintf("/artifacts/%d/1/%s", runID, name)
|
||||
if artifact.URL != wantURL || artifact.SizeBytes == 0 {
|
||||
t.Fatalf("%s listing wrong: %+v", name, artifact)
|
||||
}
|
||||
if _, ok := artifactNamed(step.Artifacts, stage.SessionMarkdownFile); ok {
|
||||
t.Fatalf("legacy session.md must not be produced: %+v", step.Artifacts)
|
||||
}
|
||||
artifact, ok := artifactNamed(step.Artifacts, "session.html")
|
||||
if !ok {
|
||||
t.Fatalf("session.html not in the artifact listing: %+v", step.Artifacts)
|
||||
}
|
||||
wantURL := fmt.Sprintf("/artifacts/%d/1/session.html", runID)
|
||||
if artifact.URL != wantURL || artifact.SizeBytes == 0 {
|
||||
t.Fatalf("session.html listing wrong: %+v", artifact)
|
||||
}
|
||||
|
||||
srv := httptest.NewServer(handler)
|
||||
defer srv.Close()
|
||||
for _, name := range []string{"session.md", "session.html"} {
|
||||
resp, err := http.Get(srv.URL + fmt.Sprintf("/artifacts/%d/1/%s", runID, name))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
body, _ := io.ReadAll(resp.Body)
|
||||
resp.Body.Close()
|
||||
if resp.StatusCode != http.StatusOK || len(body) == 0 {
|
||||
t.Fatalf("%s served %d (%d bytes)", name, resp.StatusCode, len(body))
|
||||
}
|
||||
contentType := resp.Header.Get("Content-Type")
|
||||
if name == "session.md" && !strings.HasPrefix(contentType, "text/markdown") && !strings.HasPrefix(contentType, "text/plain") {
|
||||
t.Fatalf("session.md content type = %q", contentType)
|
||||
}
|
||||
if name == "session.html" && !strings.HasPrefix(contentType, "text/html") {
|
||||
t.Fatalf("session.html content type = %q", contentType)
|
||||
}
|
||||
if name == "session.md" && !strings.Contains(string(body), "do the task") {
|
||||
t.Fatalf("served markdown missing session text")
|
||||
}
|
||||
if name == "session.html" && !strings.Contains(string(body), "output here") {
|
||||
t.Fatalf("served html missing tool output")
|
||||
}
|
||||
resp, err := http.Get(srv.URL + wantURL)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
body, _ := io.ReadAll(resp.Body)
|
||||
resp.Body.Close()
|
||||
if resp.StatusCode != http.StatusOK || len(body) == 0 {
|
||||
t.Fatalf("session.html served %d (%d bytes)", resp.StatusCode, len(body))
|
||||
}
|
||||
if contentType := resp.Header.Get("Content-Type"); !strings.HasPrefix(contentType, "text/html") {
|
||||
t.Fatalf("session.html content type = %q", contentType)
|
||||
}
|
||||
if !strings.Contains(string(body), "output here") {
|
||||
t.Fatal("served html missing tool output")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user