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:
@@ -293,20 +293,20 @@ data class SessionEvidence(
|
||||
|
||||
/**
|
||||
* The recorded evidence of one stage's session file export, mirroring
|
||||
* internal/protocol/runs.go SessionExport exactly: the file names written under
|
||||
* the step's artifacts directory, their byte sizes, the decoded message count,
|
||||
* the source, whether the export was truncated and a sanitized diagnostic. An
|
||||
* absent (null) value means the step recorded no export (a non-OpenCode harness,
|
||||
* a failed export or a pre-export server), so no Session section is shown.
|
||||
* internal/protocol/runs.go SessionExport exactly: the html file name written
|
||||
* under the step's artifacts directory, its byte size, the decoded message
|
||||
* count, the source, whether the export was truncated and a sanitized
|
||||
* diagnostic. An absent (null) value means the step recorded no export (a
|
||||
* non-OpenCode harness, a failed export or a pre-export server), so no Session
|
||||
* section is shown. A record written before the HTML-only change also carried
|
||||
* markdown and markdown_bytes; unknown keys are ignored.
|
||||
*/
|
||||
@Serializable
|
||||
data class SessionExport(
|
||||
@SerialName("session_id") val sessionId: String = "",
|
||||
val backend: String = "",
|
||||
val source: String = "",
|
||||
val markdown: String = "",
|
||||
val html: String = "",
|
||||
@SerialName("markdown_bytes") val markdownBytes: Long = 0,
|
||||
@SerialName("html_bytes") val htmlBytes: Long = 0,
|
||||
val messages: Int = 0,
|
||||
val truncated: Boolean = false,
|
||||
|
||||
@@ -15,6 +15,25 @@ data class ArtifactGroup(
|
||||
val artifacts: List<StageArtifact>,
|
||||
)
|
||||
|
||||
/**
|
||||
* The retired markdown session export file name. Nothing writes it any more, but
|
||||
* a run recorded before the HTML-only change still has `session.md` on disk: it
|
||||
* is dated evidence that is never presented, so it is hidden from every artifact
|
||||
* listing rather than shown beside the session html.
|
||||
*/
|
||||
const val LEGACY_SESSION_MARKDOWN_ARTIFACT = "session.md"
|
||||
|
||||
/**
|
||||
* The artifacts of one visit as the operator sees them: the recorded files with
|
||||
* the retired markdown session export filtered out. Every artifact listing — the
|
||||
* per-visit summary, the run gallery, the timeline indicator and the selection
|
||||
* candidates — derives from this one function, so a stage's artifacts never show
|
||||
* a session markdown beside the session html and the recorded counts can never
|
||||
* disagree with the tiles. Pure, O(artifacts) per step.
|
||||
*/
|
||||
fun presentedArtifacts(step: RunStep): List<StageArtifact> =
|
||||
step.artifacts.orEmpty().filterNot { it.name == LEGACY_SESSION_MARKDOWN_ARTIFACT }
|
||||
|
||||
/**
|
||||
* Groups a run's artifacts by stage and visit, purely and deterministically.
|
||||
* Order follows [runTimeline]: stages in first-appearance order and each stage's
|
||||
@@ -32,7 +51,7 @@ fun runArtifactGroups(steps: List<RunStep>): List<ArtifactGroup> {
|
||||
val groups = ArrayList<ArtifactGroup>()
|
||||
timeline.visitsByStage.forEach { (stageKey, visits) ->
|
||||
visits.forEach { step ->
|
||||
val artifacts = step.artifacts.orEmpty()
|
||||
val artifacts = presentedArtifacts(step)
|
||||
if (artifacts.isNotEmpty()) {
|
||||
val visit = visitByStageSequence[stageKey to step.sequence] ?: 1
|
||||
groups += ArtifactGroup(stageKey, visit, artifacts)
|
||||
@@ -67,7 +86,7 @@ fun artifactsEmptyMessage(executing: Boolean): String =
|
||||
* disagree. Pure.
|
||||
*/
|
||||
fun runArtifactsHeader(steps: List<RunStep>, executing: Boolean): String {
|
||||
val recorded = steps.sumOf { it.artifacts.orEmpty().size }
|
||||
val recorded = steps.sumOf { presentedArtifacts(it).size }
|
||||
if (recorded == 0) return artifactsEmptyMessage(executing)
|
||||
val partial = steps.any { it.artifactsSkipped > 0 || it.artifactsTruncated > 0 }
|
||||
return buildString {
|
||||
|
||||
@@ -197,7 +197,7 @@ const val ARTIFACT_CAPTURE_PENDING = "capture pending"
|
||||
* count plus " · partial capture" when files were excluded or omitted.
|
||||
*/
|
||||
fun artifactsSummary(step: RunStep): String {
|
||||
val artifacts = step.artifacts.orEmpty()
|
||||
val artifacts = presentedArtifacts(step)
|
||||
if (artifacts.isEmpty()) {
|
||||
val state = if (step.status == "running") {
|
||||
ARTIFACT_CAPTURE_PENDING
|
||||
@@ -218,7 +218,7 @@ fun artifactsSummary(step: RunStep): String {
|
||||
* the notes never accompany the empty-state summary.
|
||||
*/
|
||||
fun artifactCaptureNotes(step: RunStep): List<String> = buildList {
|
||||
if (step.artifacts.isNullOrEmpty()) return@buildList
|
||||
if (presentedArtifacts(step).isEmpty()) return@buildList
|
||||
if (step.artifactsSkipped > 0) add("${step.artifactsSkipped} files excluded from artifact capture.")
|
||||
if (step.artifactsTruncated > 0) add("${step.artifactsTruncated} files omitted by artifact capture limits.")
|
||||
}
|
||||
|
||||
@@ -53,6 +53,7 @@ import net.awan.pipelines.ui.artifactsSummary
|
||||
import net.awan.pipelines.ui.components.copyText
|
||||
import net.awan.pipelines.ui.components.galleryGrid
|
||||
import net.awan.pipelines.ui.humanBytes
|
||||
import net.awan.pipelines.ui.presentedArtifacts
|
||||
import net.awan.pipelines.ui.theme.ARTIFACT_BADGE_DP
|
||||
import net.awan.pipelines.ui.theme.ARTIFACT_PLAY_BADGE_DP
|
||||
import net.awan.pipelines.ui.theme.ARTIFACT_TILE_ACTION_DP
|
||||
@@ -85,7 +86,7 @@ internal fun ArtifactsSection(
|
||||
) {
|
||||
val text = pipelinesText()
|
||||
// Derived once per data change, never per recomposition (performance requirement).
|
||||
val artifacts = remember(step) { step.artifacts.orEmpty() }
|
||||
val artifacts = remember(step) { presentedArtifacts(step) }
|
||||
val summary = remember(step) { artifactsSummary(step) }
|
||||
val notes = remember(step) { artifactCaptureNotes(step) }
|
||||
Column(modifier.fillMaxWidth(), verticalArrangement = Arrangement.spacedBy(SPACING_XS)) {
|
||||
|
||||
@@ -4,13 +4,10 @@ import android.webkit.WebView
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.material3.CircularProgressIndicator
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.OutlinedButton
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.DisposableEffect
|
||||
@@ -18,7 +15,6 @@ import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.saveable.rememberSaveable
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
@@ -29,115 +25,61 @@ import kotlinx.coroutines.withContext
|
||||
import net.awan.pipelines.data.protocol.GraphSemantics
|
||||
import net.awan.pipelines.data.protocol.RunStep
|
||||
import net.awan.pipelines.data.protocol.StageArtifact
|
||||
import net.awan.pipelines.ui.chat.MarkdownBlocks
|
||||
import net.awan.pipelines.ui.chat.MdBlock
|
||||
import net.awan.pipelines.ui.chat.parseMarkdown
|
||||
import net.awan.pipelines.ui.theme.SPACING_L
|
||||
import net.awan.pipelines.ui.theme.SPACING_S
|
||||
import net.awan.pipelines.ui.theme.pipelinesText
|
||||
|
||||
/**
|
||||
* The session export's files of one visit, resolved against the visit's recorded
|
||||
* artifacts. Either file may be missing (a partially exported or truncated
|
||||
* listing); a visit with neither has no export to show.
|
||||
* The html session export [step] recorded, resolved against the visit's recorded
|
||||
* artifacts, or null when the visit has no export to open. The server writes one
|
||||
* html file per session; a visit that recorded no export (a Pi harness, a failed
|
||||
* export or a pre-export server) or whose file is missing from a truncated
|
||||
* artifact listing yields null, so the stage pane lists no Session section for a
|
||||
* visit that has nothing to show. The retired `session.md` export is never named
|
||||
* by the server record and is never presented.
|
||||
*/
|
||||
internal data class SessionExportFiles(
|
||||
val markdown: StageArtifact?,
|
||||
val html: StageArtifact?,
|
||||
)
|
||||
|
||||
/**
|
||||
* The files [step]'s session export actually wrote, matched by the names the
|
||||
* server recorded in `session_export` against the step's artifact listing. Null
|
||||
* when the visit recorded no export, when it recorded only a limitation (a Pi
|
||||
* harness, `source: "unavailable"`, or a failure with a diagnostic and no file
|
||||
* names) or when the listing holds neither recorded file. The stage pane derives
|
||||
* the Session section from exactly this, so a section is never listed for a visit
|
||||
* that has no session file to open.
|
||||
*/
|
||||
internal fun sessionExportFiles(step: RunStep): SessionExportFiles? {
|
||||
internal fun sessionExportFile(step: RunStep): StageArtifact? {
|
||||
val export = step.sessionExport ?: return null
|
||||
val markdownName = export.markdown.takeIf { it.isNotBlank() }
|
||||
val htmlName = export.html.takeIf { it.isNotBlank() }
|
||||
if (markdownName == null && htmlName == null) return null
|
||||
val artifacts = step.artifacts.orEmpty()
|
||||
val markdown = markdownName?.let { name -> artifacts.firstOrNull { it.name == name } }
|
||||
val html = htmlName?.let { name -> artifacts.firstOrNull { it.name == name } }
|
||||
if (markdown == null && html == null) return null
|
||||
return SessionExportFiles(markdown = markdown, html = html)
|
||||
val name = export.html.takeIf { it.isNotBlank() } ?: return null
|
||||
return step.artifacts.orEmpty().firstOrNull { it.name == name }
|
||||
}
|
||||
|
||||
/** The two ways of reading an exported session: the rendered markdown or the html document. */
|
||||
internal enum class SessionView { Markdown, Html }
|
||||
|
||||
/**
|
||||
* The view the session section opens in: the markdown export, rendered with the
|
||||
* app's existing markdown renderer, is the default. The html export is only the
|
||||
* default when there is no markdown to render; otherwise it is reached through the
|
||||
* section's own "HTML view" toggle and shown in a WebView for fidelity.
|
||||
*/
|
||||
internal fun defaultSessionView(files: SessionExportFiles): SessionView =
|
||||
if (files.markdown != null) SessionView.Markdown else SessionView.Html
|
||||
|
||||
/** Whether the operator can switch between the two exports (both were written). */
|
||||
internal fun sessionViewToggle(files: SessionExportFiles): Boolean =
|
||||
files.markdown != null && files.html != null
|
||||
|
||||
/** The file the section shows in [view], or null when that export is missing. */
|
||||
internal fun sessionArtifact(files: SessionExportFiles, view: SessionView): StageArtifact? =
|
||||
when (view) {
|
||||
SessionView.Markdown -> files.markdown
|
||||
SessionView.Html -> files.html
|
||||
}
|
||||
|
||||
/**
|
||||
* One exported session file, loaded: its markdown parsed into the app's shared
|
||||
* blocks, its html kept as the document text, its absence a distinct error. A null
|
||||
* url means no server was configured to fetch it from.
|
||||
* One exported session file, loaded: its html kept as the document text, its
|
||||
* absence a distinct error. A null url means no server was configured to fetch
|
||||
* it from.
|
||||
*/
|
||||
internal sealed interface SessionLoad {
|
||||
data object Loading : SessionLoad
|
||||
data object Unavailable : SessionLoad
|
||||
data object Error : SessionLoad
|
||||
data class Markdown(val blocks: List<MdBlock>) : SessionLoad
|
||||
data class Html(val document: String) : SessionLoad
|
||||
}
|
||||
|
||||
/**
|
||||
* Classifies one fetched session file: a failed fetch ([bytes] null) is a distinct
|
||||
* error state, never rendered as an empty session, and a fetched file decodes to
|
||||
* its view. Pure, so the decode/parse and the failure branch are unit tested.
|
||||
* its document text. Pure (the UTF-8 decode replaces malformed sequences rather
|
||||
* than throwing), so the viewer passes it off the main thread and it is unit
|
||||
* tested.
|
||||
*/
|
||||
internal fun sessionLoad(bytes: ByteArray?, markdown: Boolean): SessionLoad =
|
||||
if (bytes == null) SessionLoad.Error else decodeSessionFile(bytes, markdown)
|
||||
|
||||
/**
|
||||
* Decodes one session file: markdown into the shared parsed blocks, html into its
|
||||
* document text. Pure (the UTF-8 decode replaces malformed sequences rather than
|
||||
* throwing), so the viewer passes it off the main thread and it is unit tested.
|
||||
*/
|
||||
internal fun decodeSessionFile(bytes: ByteArray, markdown: Boolean): SessionLoad {
|
||||
val text = bytes.toString(Charsets.UTF_8)
|
||||
return if (markdown) SessionLoad.Markdown(parseMarkdown(text)) else SessionLoad.Html(text)
|
||||
}
|
||||
internal fun sessionLoad(bytes: ByteArray?): SessionLoad =
|
||||
if (bytes == null) SessionLoad.Error else SessionLoad.Html(bytes.toString(Charsets.UTF_8))
|
||||
|
||||
/**
|
||||
* The Session section pane: the exported session of the selected visit, read like
|
||||
* the artifacts beside it. The markdown export is the default and is rendered with
|
||||
* the app's existing markdown renderer in a lazy list (one parsed block per item),
|
||||
* so a session of several hundred kilobytes scrolls without composing every block.
|
||||
* When both files were exported the section offers an "HTML view" toggle that
|
||||
* swaps in the html document in a WebView for fidelity, and switches back. The
|
||||
* context line stays pinned above the scroll, exactly as the other section panes
|
||||
* keep their chrome. On a wide window [visitTabs] renders the pinned visit row in
|
||||
* that header; on a narrow one the caller owns the visit strip below instead, so the
|
||||
* header must not double it.
|
||||
* the artifacts beside it. The one session export is html, shown in a WebView for
|
||||
* fidelity — there is no markdown view and no view toggle. The context line stays
|
||||
* pinned above the scroll, exactly as the other section panes keep their chrome.
|
||||
* On a wide window [visitTabs] renders the pinned visit row in that header; on a
|
||||
* narrow one the caller owns the visit strip below instead, so the header must not
|
||||
* double it.
|
||||
*
|
||||
* The file is fetched once per url through the app's shared artifact byte cache and
|
||||
* the fetch/parse run off the main thread, so switching views or reopening the pane
|
||||
* never re-hits the network and never blocks the pane. A missing server URL shows
|
||||
* that state, and a failed fetch shows its own error in this pane only: the stage
|
||||
* screen and every other section are unaffected.
|
||||
* the fetch runs off the main thread, so reopening the pane never re-hits the
|
||||
* network and never blocks the pane. A missing server URL shows that state, and a
|
||||
* failed fetch shows its own error in this pane only: the stage screen and every
|
||||
* other section are unaffected.
|
||||
*/
|
||||
@Composable
|
||||
internal fun SessionExportSection(
|
||||
@@ -151,46 +93,17 @@ internal fun SessionExportSection(
|
||||
visitTabs: Boolean = true,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
val text = pipelinesText()
|
||||
val files = remember(step) { sessionExportFiles(step) }
|
||||
val file = remember(step) { sessionExportFile(step) }
|
||||
Column(modifier.fillMaxSize()) {
|
||||
if (files == null) {
|
||||
if (file == null) {
|
||||
SessionHeader(stageKey, runSteps, visitIndex, onVisitIndexChange, visitTabs) {
|
||||
Text("No session was exported for this visit.", style = text.meta)
|
||||
Text("No session was exported for this visit.", style = pipelinesText().meta)
|
||||
}
|
||||
return@Column
|
||||
}
|
||||
var view by rememberSaveable(step.sequence, files.markdown?.url, files.html?.url) {
|
||||
mutableStateOf(defaultSessionView(files))
|
||||
}
|
||||
val toggle = sessionViewToggle(files)
|
||||
val artifact = sessionArtifact(files, view)
|
||||
val url = artifact?.let { resolvedArtifactUrl(it, configuredServerUrl) }
|
||||
SessionHeader(stageKey, runSteps, visitIndex, onVisitIndexChange, visitTabs) {
|
||||
Row(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.spacedBy(SPACING_S),
|
||||
) {
|
||||
Text(
|
||||
if (view == SessionView.Markdown) "Markdown" else "HTML",
|
||||
style = text.label,
|
||||
color = MaterialTheme.colorScheme.primary,
|
||||
modifier = Modifier.weight(1f),
|
||||
)
|
||||
if (toggle) {
|
||||
OutlinedButton(
|
||||
onClick = {
|
||||
view = if (view == SessionView.Markdown) SessionView.Html else SessionView.Markdown
|
||||
},
|
||||
) {
|
||||
Text(if (view == SessionView.Markdown) "HTML view" else "Markdown view")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
SessionHeader(stageKey, runSteps, visitIndex, onVisitIndexChange, visitTabs) {}
|
||||
SessionBody(
|
||||
load = rememberSessionLoad(url, view == SessionView.Markdown, fetchArtifactBytes),
|
||||
load = rememberSessionLoad(resolvedArtifactUrl(file, configuredServerUrl), fetchArtifactBytes),
|
||||
modifier = Modifier.weight(1f),
|
||||
)
|
||||
}
|
||||
@@ -198,11 +111,11 @@ internal fun SessionExportSection(
|
||||
|
||||
/**
|
||||
* The session pane's pinned header: the context line naming the stage and — on a
|
||||
* wide window — the visit row, followed by the caller's [content] (the view toggle,
|
||||
* or the missing-export notice). It stays above the session's own scroll, exactly as
|
||||
* the other section panes keep their chrome. On a narrow window [visitTabs] is false
|
||||
* and the visit selector is the caller's bottom strip instead, so the header does not
|
||||
* show it twice.
|
||||
* wide window — the visit row, followed by the caller's [content] (the
|
||||
* missing-export notice, or nothing when a session is shown). It stays above the
|
||||
* session's own scroll, exactly as the other section panes keep their chrome. On a
|
||||
* narrow window [visitTabs] is false and the visit selector is the caller's bottom
|
||||
* strip instead, so the header does not show it twice.
|
||||
*/
|
||||
@Composable
|
||||
private fun SessionHeader(
|
||||
@@ -227,9 +140,8 @@ private fun SessionHeader(
|
||||
}
|
||||
|
||||
/**
|
||||
* The loaded session file's body: the parsed markdown in a lazy list, the html in
|
||||
* a WebView, or the loading/unavailable/error notice. The one branch that draws a
|
||||
* session, so the markdown and html paths share the section's fetch and state.
|
||||
* The loaded session's body: the html document in a WebView, or the
|
||||
* loading/unavailable/error notice. The one branch that draws a session.
|
||||
*/
|
||||
@Composable
|
||||
private fun SessionBody(load: SessionLoad, modifier: Modifier = Modifier) {
|
||||
@@ -247,7 +159,6 @@ private fun SessionBody(load: SessionLoad, modifier: Modifier = Modifier) {
|
||||
message = "Couldn't load the exported session.",
|
||||
modifier = modifier,
|
||||
)
|
||||
is SessionLoad.Markdown -> MarkdownBlocks(blocks = load.blocks, modifier = modifier)
|
||||
is SessionLoad.Html -> SessionHtml(document = load.document, modifier = modifier)
|
||||
}
|
||||
}
|
||||
@@ -268,11 +179,10 @@ private fun SessionNotice(message: String, modifier: Modifier = Modifier, spinne
|
||||
}
|
||||
|
||||
/**
|
||||
* The html export in a WebView. The markdown default is rendered natively; the
|
||||
* html is the fidelity fallback for the structure the app's renderer does not
|
||||
* reproduce. The document is self-contained, so it is loaded with a null base URL
|
||||
* (no file or network origin), scripting is off, and the view is destroyed with
|
||||
* the composition.
|
||||
* The html export in a WebView, the fidelity view of the one session export. The
|
||||
* document is self-contained, so it is loaded with a null base URL (no file or
|
||||
* network origin), scripting is off, and the view is destroyed with the
|
||||
* composition.
|
||||
*/
|
||||
@Composable
|
||||
private fun SessionHtml(document: String, modifier: Modifier = Modifier) {
|
||||
@@ -296,27 +206,25 @@ private fun SessionHtml(document: String, modifier: Modifier = Modifier) {
|
||||
/**
|
||||
* Loads the resolved session [url] once and classifies it. A null url is
|
||||
* [SessionLoad.Unavailable] with no request attempted. The bytes are fetched
|
||||
* through the app's shared [ArtifactBytesCache], so re-opening the section or
|
||||
* switching views reuses them instead of loading the file a second time; the
|
||||
* decode and markdown parse run off the main thread so a large session never
|
||||
* blocks the UI. A canceled effect (the url or view changed) never publishes its
|
||||
* stale result.
|
||||
* through the app's shared [ArtifactBytesCache], so re-opening the section reuses
|
||||
* them instead of loading the file a second time; the decode runs off the main
|
||||
* thread so a large session never blocks the UI. A canceled effect (the url
|
||||
* changed) never publishes its stale result.
|
||||
*/
|
||||
@Composable
|
||||
private fun rememberSessionLoad(
|
||||
url: String?,
|
||||
markdown: Boolean,
|
||||
fetchBytes: suspend (String) -> ByteArray?,
|
||||
): SessionLoad {
|
||||
if (url == null) return SessionLoad.Unavailable
|
||||
var load by remember(url) { mutableStateOf<SessionLoad>(SessionLoad.Loading) }
|
||||
LaunchedEffect(url, markdown) {
|
||||
LaunchedEffect(url) {
|
||||
val cached = ArtifactBytesCache.get(url)
|
||||
val bytes = cached ?: runCatching {
|
||||
withContext(Dispatchers.IO) { fetchBytes(url) }
|
||||
}.getOrNull()
|
||||
if (cached == null && bytes != null) ArtifactBytesCache.put(url, bytes)
|
||||
load = withContext(Dispatchers.Default) { sessionLoad(bytes, markdown) }
|
||||
load = withContext(Dispatchers.Default) { sessionLoad(bytes) }
|
||||
}
|
||||
return load
|
||||
}
|
||||
|
||||
@@ -59,6 +59,7 @@ import net.awan.pipelines.ui.fileChangesSummary
|
||||
import net.awan.pipelines.ui.formatDuration
|
||||
import net.awan.pipelines.ui.notificationLine
|
||||
import net.awan.pipelines.ui.pendingDecision
|
||||
import net.awan.pipelines.ui.presentedArtifacts
|
||||
import net.awan.pipelines.ui.runLabel
|
||||
import net.awan.pipelines.ui.screens.runTimeline
|
||||
import net.awan.pipelines.ui.theme.SPACING_L
|
||||
@@ -259,7 +260,7 @@ internal fun stageSectionSpecs(
|
||||
// artifacts it was written with: both are the visit's recorded files, and
|
||||
// the operator reads them the same way. A visit without an export lists no
|
||||
// Session row at all, rather than an empty section.
|
||||
val session = sessionExportFiles(selectedStep) != null
|
||||
val session = sessionExportFile(selectedStep) != null
|
||||
STAGE_RESULT_SECTIONS.forEach { section ->
|
||||
when (section) {
|
||||
StageResultSection.Artifacts -> {
|
||||
@@ -553,7 +554,7 @@ private fun StageDetailBody(
|
||||
verdict = selectedStep.verdict,
|
||||
outcome = selectedStep.outcome,
|
||||
status = selectedStep.status,
|
||||
artifacts = selectedStep.artifacts.orEmpty(),
|
||||
artifacts = presentedArtifacts(selectedStep),
|
||||
configuredServerUrl = configuredServerUrl,
|
||||
fetchArtifactBytes = fetchArtifactBytes,
|
||||
)
|
||||
@@ -701,7 +702,7 @@ fun StageSectionPane(
|
||||
val selectionState = rememberArtifactSelection(stageKey, clampedVisit)
|
||||
ArtifactSelectionScaffold(
|
||||
selectionState = selectionState,
|
||||
candidates = selectedStep?.artifacts.orEmpty(),
|
||||
candidates = selectedStep?.let { presentedArtifacts(it) }.orEmpty(),
|
||||
configuredServerUrl = configuredServerUrl,
|
||||
fetchArtifactBytes = fetchArtifactBytes,
|
||||
modifier = modifier,
|
||||
|
||||
@@ -2,6 +2,7 @@ package net.awan.pipelines.ui.screens
|
||||
|
||||
import net.awan.pipelines.data.protocol.GraphSemantics
|
||||
import net.awan.pipelines.data.protocol.RunStep
|
||||
import net.awan.pipelines.ui.LEGACY_SESSION_MARKDOWN_ARTIFACT
|
||||
import net.awan.pipelines.ui.formatDuration
|
||||
|
||||
/**
|
||||
@@ -79,6 +80,9 @@ internal fun timelineDescription(step: RunStep): String {
|
||||
/**
|
||||
* Whether a visit recorded any artifacts. The single predicate behind the
|
||||
* timeline's subtle artifact indicator, so the timeline and the sheet never
|
||||
* disagree about whether a visit produced files.
|
||||
* disagree about whether a visit produced files. The retired session markdown is
|
||||
* not presented, so it never counts; the check does not allocate, unlike
|
||||
* [presentedArtifacts], and is safe to call on every recomposition.
|
||||
*/
|
||||
internal fun hasArtifacts(step: RunStep): Boolean = !step.artifacts.isNullOrEmpty()
|
||||
internal fun hasArtifacts(step: RunStep): Boolean =
|
||||
step.artifacts.orEmpty().any { it.name != LEGACY_SESSION_MARKDOWN_ARTIFACT }
|
||||
|
||||
Reference in New Issue
Block a user