Merge lane-d: open stage sections as their own pane
Combine the local list-scroll/covered-edge and hoisted pane wiring work with lane-d's Section pane level, sectionKey persistence, three-way back descriptions and single-Column CollapsibleSectionBody. Both intents survive: conflicts in README, PipelinesApp, StageDetailPane, PaneState, Sections and their tests were resolved by composing both sides, without conflict markers. Build: ./gradlew :app:assembleDebug Tests: ./gradlew :app:testDebugUnitTest (322 tests, 0 failures)
This commit is contained in:
+108
-1
@@ -3556,7 +3556,6 @@ native 2208x1840 @420 at the end.
|
||||
returned `HTTP/1.1 200 OK`, `Content-Type: application/vnd.android.package-archive`,
|
||||
`Content-Length: 17928873`.
|
||||
|
||||
|
||||
## Remembering the list scroll position (16 Oct 2026)
|
||||
|
||||
Returning from a pipeline or a run now restores the list to exactly where the
|
||||
@@ -3754,3 +3753,111 @@ review stages, and the device policy for this brief keeps the implementation to
|
||||
the build and the unit tests. Four levels are also unreachable in the app itself
|
||||
(`MasterPane.List/Detail/Stage`, `MAX_PANE_DEPTH = 2`), so the four-level fold is
|
||||
covered by the pure `coveredEdgesDp` cases rather than by a screenshot.
|
||||
|
||||
## Stage sections open as their own pane, not inline (16 Oct 2026)
|
||||
|
||||
The reported stage-screen defect was real and, once reproduced, exactly as
|
||||
described: expanding a section stacked its rows at the top of the section. It is
|
||||
fixed by opening every stage section as its own pane and by laying a collapsible
|
||||
body out in one column. `android/` only; nothing in the Pipelines server, its Go
|
||||
source, the Docker/compose files or the installer was touched, no run was started
|
||||
from the app, no dependency was added, and every `adb`/emulator command targeted
|
||||
`emulator-5554` only (never `emulator-5556` or the attached Pixel).
|
||||
|
||||
- **The defect and its cause.** Expanding `Stage definition` on the stage screen
|
||||
drew its fields stacked at the top: the last field's card (`Memory`) sat
|
||||
directly under the header and every other row (`Type`, `Prompt`, `Outcomes`,
|
||||
`Model`, …) was hidden underneath it. The section's content lambda emitted one
|
||||
composable per field (`definition.forEach { StageFieldRow(it) }`) straight into
|
||||
`CollapsibleSectionBody`'s `AnimatedVisibility`, which lays out a *single*
|
||||
child: several children were placed on top of each other (all at the section's
|
||||
origin) instead of one below the next, so the body had the height of its tallest
|
||||
single row and showed only the last one. Reproduced on the pre-change tree
|
||||
(below).
|
||||
- **Sections are panes.** A stage section is no longer expanded in place. The
|
||||
stage screen keeps a **compact list** of section rows (`Artifacts`, `Output`,
|
||||
`Input`, `This run`, `Stage definition`) and tapping one opens that section as
|
||||
the next pane of the stack — a full-window screen on a narrow window, a panel
|
||||
to the right of the stage pane on a wide one — with its own `Scaffold`/
|
||||
`TopAppBar` named for the section, its own scroll and its own top spacing.
|
||||
Back (the app bar, the gesture or a peek) returns exactly one level, to the
|
||||
stage screen. `MasterPane` gained the `Section` level (`MAX_PANE_DEPTH = 3`)
|
||||
and `PaneSelection.sectionKey` (a primitive saved with the pane selection), so
|
||||
the open section survives rotation and process death and the wide covered peeks
|
||||
fold (`"2 more"`) as the fourth pane is added.
|
||||
- **No trivial inline exceptions.** None of the five sections is kept inline.
|
||||
Each can hold an arbitrarily long value — the definition's prompt/output
|
||||
contract, the input/output maps, the run evidence and the artifacts gallery —
|
||||
so an inline body would both risk the layout with many rows and push the
|
||||
operator's run context off screen; one uniform rule keeps the screen
|
||||
predictable.
|
||||
- **The shared body fix.** `CollapsibleSectionBody` now lays its content out in a
|
||||
single full-width `Column`, so *any* collapsible section with more than one row
|
||||
(it also backs the run/pipeline detail `collapsibleSection` lists) stacks its
|
||||
rows under the header instead of overlapping them.
|
||||
- **Semantics kept.** Sections start collapsed; the operator's choice (which
|
||||
section is open, and the visit) is saved with the pane selection; and each
|
||||
section's content is derived from the same `stageSectionSpecs`
|
||||
(`runStepFields`, `stageDefinitionFields`, `ArtifactsSection`) as before, so
|
||||
nothing shown changed — the stage screen just lists the sections and the
|
||||
section pane shows one.
|
||||
- **Shared derivation.** `stageSectionSpecs(stageKey, graph, runSteps,
|
||||
visitIndex, runContext)` is the one pure list of sections (key, title, fields,
|
||||
artifacts) the stage screen and the section pane both read, so the two can
|
||||
never disagree; `StageVisitTabs` is the one visit tab row both use; and
|
||||
`StageSectionPane`/`StageSectionBody` render a section (the artifacts section
|
||||
keeps the shared `ArtifactSelectionScaffold`, so its gallery retains
|
||||
long-press selection, the contextual bar and Back-leaves-selection-first).
|
||||
|
||||
Evidence (macOS, Homebrew JDK 17 `openjdk@17`, Gradle 9.7.1,
|
||||
`ANDROID_HOME=~/Library/Android/sdk`, `--offline`):
|
||||
|
||||
- `gradle :app:assembleDebug :app:testDebugUnitTest --offline --console=plain` →
|
||||
`BUILD SUCCESSFUL`; the 30 result XMLs aggregate to **262 tests, 0 failures, 0
|
||||
errors, 0 skipped** (the updated `PaneStateTest` section-level/`backStep`/
|
||||
`popTo` cases and the `StageDetailSheetTest` `stageSectionSpecs` cases
|
||||
included). `app/build/outputs/apk/debug/app-debug.apk` is **18,011,393 bytes**,
|
||||
sha256 `5912d38fef80aa8aad53132ac5bb1e05fd42fdb9d0ae778e7dc0a1af732e4019`.
|
||||
- `gradle :app:lintDebug --offline` → the same **2 pre-existing** `NewApi` errors
|
||||
for `android:windowLightNavigationBar` in `res/values/themes.xml` and
|
||||
`res/values-night/themes.xml` (unchanged by this pass); no error is attributed
|
||||
to a changed file.
|
||||
- On `emulator-5554` only (fold AVD; wide `wm size reset` = 2076x2152 / 390dpi ≈
|
||||
852dp, narrow `wm size 1080x1920` / `wm density 480` ≈ 360dp; never the
|
||||
attached Pixel, never `emulator-5556`) against the live server, driving run
|
||||
145's `implementer` from a Timeline row; every frame was captured and validated
|
||||
with `scripts/capture_png.sh -s emulator-5554` into
|
||||
`~/.local/share/pipelines/data/artifacts/144/1/`:
|
||||
- **Before** (the pre-change tree rebuilt from `HEAD`): `before-wide-stage-sections.png`
|
||||
then `before-wide-definition-inline.png` — tapping `Stage definition` shows the
|
||||
overlap defect (the `Memory` card under the header, the other rows hidden).
|
||||
- **After**: `after-wide-stage-sections.png` (the compact list, every row
|
||||
chevron-right/collapsed), `after-wide-section-opened.png` (the `Stage
|
||||
definition` panel to the right of the stage pane, peeks `Back to run`/
|
||||
`Back to stage`), `after-wide-artifacts-opened.png` (the `Artifacts` pane from
|
||||
the same list), `after-narrow-section-opened.png` (full-window `Stage
|
||||
definition`, its own title/scroll/spacing) and `after-narrow-stage-sections.png`
|
||||
(Back returned to the compact stage screen). The narrow section pane was
|
||||
reached by opening it wide and folding the window, which exercises the saved
|
||||
section surviving the configuration change.
|
||||
- `adb -s emulator-5554 shell input keyevent 4` from the section pane returned to
|
||||
the stage screen (the compact rows reappear, no `Back to stage` strip); no run
|
||||
was started from the app; `wm size`/`density` were reset afterwards.
|
||||
- **APK publish.** `app-debug.apk` copied to
|
||||
`~/.local/share/pipelines/data/artifacts/144/1/pipelines-debug-wip-c700b28.apk`
|
||||
(`c700b28` = `git rev-parse --short HEAD`; the working tree is uncommitted WIP on
|
||||
top of it). `curl -I
|
||||
http://10.0.0.249:8080/artifacts/144/1/pipelines-debug-wip-c700b28.apk` returned
|
||||
`HTTP/1.1 200 OK`, `Content-Type: application/vnd.android.package-archive`,
|
||||
`Content-Length: 18011393`; a streamed `GET | shasum -a 256` returned the same
|
||||
`5912d38f…`. At 17.2 MiB it exceeds the 8 MiB per-file inventory cap, so it is
|
||||
served by direct URL only.
|
||||
|
||||
Not verified in this pass: a clean `logcat` sweep was not conclusive because the
|
||||
emulator was shared — installs this pass did not issue appeared in the log during
|
||||
the sweep and the UI moved between commands. The one `FATAL EXCEPTION` present was
|
||||
the `uiautomator` dump tool itself (`com.android.commands.uiautomator`), never
|
||||
`net.awan.pipelines`. The artifacts section was captured for a visit that recorded
|
||||
none (`Artifacts · not recorded for this visit`) rather than the populated
|
||||
gallery (the same gallery branch is covered by the run-summary grid); the wide
|
||||
fold indicator (`"2 more"`) was present but is not separately cropped.
|
||||
|
||||
@@ -4,26 +4,26 @@ import androidx.compose.runtime.saveable.Saver
|
||||
|
||||
/**
|
||||
* Which pane of the sliding stack is showing: the list (level 0), the selected
|
||||
* item's detail (level 1) and, when a stage/node is open, the stage pane
|
||||
* (level 2). On a wide window the panes stack left to right and share a fixed
|
||||
* peek budget; on a narrow window only the topmost pane is visible and it fills
|
||||
* the window.
|
||||
* item's detail (level 1), the stage/node pane (level 2) and, when a stage
|
||||
* section is opened, that section's pane (level 3). On a wide window the panes
|
||||
* stack left to right and share a fixed peek budget; on a narrow window only the
|
||||
* topmost pane is visible and it fills the window.
|
||||
*/
|
||||
enum class MasterPane { List, Detail, Stage }
|
||||
enum class MasterPane { List, Detail, Stage, Section }
|
||||
|
||||
/**
|
||||
* The declared bound on the stack: list (0), detail (1), stage (2). The stack can
|
||||
* never grow deeper than this; selecting a different stage or list item replaces
|
||||
* the rightmost pane instead of pushing a new level.
|
||||
* The declared bound on the stack: list (0), detail (1), stage (2), section (3).
|
||||
* The stack can never grow deeper than this; selecting a different stage, list
|
||||
* item or section replaces the rightmost pane instead of pushing a new level.
|
||||
*/
|
||||
const val MAX_PANE_DEPTH = 2
|
||||
const val MAX_PANE_DEPTH = 3
|
||||
|
||||
/**
|
||||
* The saved pane-stack selection: which pane is rightmost, which item (0 = none),
|
||||
* its pipeline/run version, which detail section (page) is showing, and which
|
||||
* stage/visit the stage pane is on. Every field is a primitive, so the state
|
||||
* round-trips through a Bundle cheaply and survives rotation, configuration
|
||||
* change and process death.
|
||||
* its pipeline/run version, which detail section (page) is showing, which
|
||||
* stage/visit the stage pane is on and, when a stage section is open, its key.
|
||||
* Every field is a primitive, so the state round-trips through a Bundle cheaply
|
||||
* and survives rotation, configuration change and process death.
|
||||
*
|
||||
* Geometry (peek width, insets, measured pane widths) is deliberately *not* part
|
||||
* of this model; it is derived from layout so nothing is hardcoded here.
|
||||
@@ -35,13 +35,15 @@ data class PaneSelection(
|
||||
val sectionIndex: Int = 0,
|
||||
val stageKey: String? = null,
|
||||
val stageVisit: Int = 0,
|
||||
val sectionKey: String? = null,
|
||||
) {
|
||||
/** How many panes are stacked: 0 list, 1 detail, 2 stage. */
|
||||
/** How many panes are stacked: 0 list, 1 detail, 2 stage, 3 section. */
|
||||
val depth: Int
|
||||
get() = when (pane) {
|
||||
MasterPane.List -> 0
|
||||
MasterPane.Detail -> 1
|
||||
MasterPane.Stage -> 2
|
||||
MasterPane.Section -> 3
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,29 +57,39 @@ sealed interface BackResult {
|
||||
}
|
||||
|
||||
/**
|
||||
* Exactly one pane level of Back. Inside the stage pane it steps back to the
|
||||
* detail; inside the detail it steps back to the list; at the list it leaves the
|
||||
* app. Sections are navigated only by their own tab row/pager, never by Back, so
|
||||
* the peek tap and the Back button/gesture always pop the same single level.
|
||||
* Exactly one pane level of Back. Inside a stage section it steps back to the
|
||||
* stage pane; inside the stage pane it steps back to the detail; inside the
|
||||
* detail it steps back to the list; at the list it leaves the app. The peek tap
|
||||
* and the Back button/gesture therefore always pop the same single level.
|
||||
*/
|
||||
fun backStep(selection: PaneSelection): BackResult = when (selection.pane) {
|
||||
MasterPane.List -> BackResult.Exit
|
||||
MasterPane.Detail -> BackResult.Show(PaneSelection(pane = MasterPane.List))
|
||||
MasterPane.Stage -> BackResult.Show(
|
||||
selection.copy(pane = MasterPane.Detail, stageKey = null, stageVisit = 0),
|
||||
selection.copy(pane = MasterPane.Detail, stageKey = null, stageVisit = 0, sectionKey = null),
|
||||
)
|
||||
MasterPane.Section -> BackResult.Show(
|
||||
selection.copy(pane = MasterPane.Stage, sectionKey = null),
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* The selection after tapping the peek of the pane at [level]: every pane to its
|
||||
* right is closed. Level 0 (the list) shows a bare list; level 1 shows the same
|
||||
* item's detail with no stage; a [level] at or beyond the current depth is a
|
||||
* no-op (there is nothing to its right). Peeks exist only on a wide window;
|
||||
* narrow windows use Back/gesture for the same one-level step.
|
||||
* item's detail with no stage; level 2 shows the same item's stage with no
|
||||
* section; a [level] at or beyond the current depth is a no-op (there is nothing
|
||||
* to its right). Peeks exist only on a wide window; narrow windows use
|
||||
* Back/gesture for the same one-level step.
|
||||
*/
|
||||
fun popTo(selection: PaneSelection, level: Int): PaneSelection = when {
|
||||
level <= 0 -> PaneSelection()
|
||||
level == 1 -> selection.copy(pane = MasterPane.Detail, stageKey = null, stageVisit = 0)
|
||||
level == 1 -> selection.copy(
|
||||
pane = MasterPane.Detail,
|
||||
stageKey = null,
|
||||
stageVisit = 0,
|
||||
sectionKey = null,
|
||||
)
|
||||
level == 2 -> selection.copy(pane = MasterPane.Stage, sectionKey = null)
|
||||
else -> selection
|
||||
}
|
||||
|
||||
@@ -92,6 +104,7 @@ internal fun encodePaneSelection(selection: PaneSelection): List<Any> = listOf(
|
||||
selection.sectionIndex,
|
||||
selection.stageKey ?: "",
|
||||
selection.stageVisit,
|
||||
selection.sectionKey ?: "",
|
||||
)
|
||||
|
||||
/** Restores a [PaneSelection] encoded by [encodePaneSelection]. */
|
||||
@@ -102,6 +115,7 @@ internal fun decodePaneSelection(encoded: List<Any>): PaneSelection = PaneSelect
|
||||
sectionIndex = encoded[3] as Int,
|
||||
stageKey = (encoded[4] as String).takeIf { it.isNotEmpty() },
|
||||
stageVisit = encoded[5] as Int,
|
||||
sectionKey = (encoded[6] as String).takeIf { it.isNotEmpty() },
|
||||
)
|
||||
|
||||
/**
|
||||
|
||||
@@ -367,7 +367,13 @@ private fun PipelineDestination(
|
||||
onPopTo = { level -> onSelectionChange(popTo(selection, level)) },
|
||||
compactLabel = "Pipelines",
|
||||
compactIcon = Icons.Filled.AccountTree,
|
||||
backContentDescription = { level -> if (level == 0) "Back to pipelines" else "Back to pipeline" },
|
||||
backContentDescription = { level ->
|
||||
when (level) {
|
||||
0 -> "Back to pipelines"
|
||||
1 -> "Back to pipeline"
|
||||
else -> "Back to stage"
|
||||
}
|
||||
},
|
||||
pane = { level, covered, paneModifier ->
|
||||
when (level) {
|
||||
0 -> PipelineListScreen(
|
||||
@@ -413,6 +419,32 @@ private fun PipelineDestination(
|
||||
pipelineId = itemId,
|
||||
version = version,
|
||||
stageKey = key,
|
||||
openSection = null,
|
||||
onOpenSection = { sectionKey ->
|
||||
onSelectionChange(
|
||||
selection.copy(pane = MasterPane.Section, sectionKey = sectionKey),
|
||||
)
|
||||
},
|
||||
onBack = onBack,
|
||||
wide = wide,
|
||||
modifier = paneModifier,
|
||||
covered = covered,
|
||||
)
|
||||
}
|
||||
3 -> rememberPaneContent(
|
||||
selection.sectionKey?.let {
|
||||
Triple(selection.itemId, it, selection.stageKey)
|
||||
},
|
||||
)?.let { (itemId, sectionKey, key) ->
|
||||
// A closing section pane keeps the identity that opened it, so
|
||||
// it renders its content until it is fully off-screen.
|
||||
PipelineStagePane(
|
||||
vm = vm,
|
||||
pipelineId = itemId,
|
||||
version = selection.itemVersion,
|
||||
stageKey = key.orEmpty(),
|
||||
openSection = sectionKey,
|
||||
onOpenSection = {},
|
||||
onBack = onBack,
|
||||
wide = wide,
|
||||
modifier = paneModifier,
|
||||
@@ -465,7 +497,13 @@ private fun RunsDestination(
|
||||
onPopTo = { level -> onSelectionChange(popTo(selection, level)) },
|
||||
compactLabel = "Runs",
|
||||
compactIcon = Icons.Filled.History,
|
||||
backContentDescription = { level -> if (level == 0) "Back to runs" else "Back to run" },
|
||||
backContentDescription = { level ->
|
||||
when (level) {
|
||||
0 -> "Back to runs"
|
||||
1 -> "Back to run"
|
||||
else -> "Back to stage"
|
||||
}
|
||||
},
|
||||
pane = { level, covered, paneModifier ->
|
||||
when (level) {
|
||||
0 -> RunHistoryScreen(
|
||||
@@ -505,6 +543,34 @@ private fun RunsDestination(
|
||||
runId = itemId,
|
||||
stageKey = key,
|
||||
visitIndex = visit,
|
||||
openSection = null,
|
||||
onOpenSection = { sectionKey ->
|
||||
onSelectionChange(
|
||||
selection.copy(pane = MasterPane.Section, sectionKey = sectionKey),
|
||||
)
|
||||
},
|
||||
onVisitChange = { onSelectionChange(selection.copy(stageVisit = it)) },
|
||||
onBack = onBack,
|
||||
wide = wide,
|
||||
modifier = paneModifier,
|
||||
covered = covered,
|
||||
)
|
||||
}
|
||||
3 -> rememberPaneContent(
|
||||
selection.sectionKey?.let {
|
||||
Triple(selection.itemId, it, selection.stageKey)
|
||||
},
|
||||
)?.let { (itemId, sectionKey, key) ->
|
||||
// A closing section pane keeps the identity that opened it, so
|
||||
// it renders its content until it is fully off-screen.
|
||||
RunStagePane(
|
||||
vm = vm,
|
||||
runId = itemId,
|
||||
stageKey = key.orEmpty(),
|
||||
visitIndex = selection.stageVisit,
|
||||
openSection = sectionKey,
|
||||
onOpenSection = {},
|
||||
onVisitChange = { onSelectionChange(selection.copy(stageVisit = it)) },
|
||||
onBack = onBack,
|
||||
wide = wide,
|
||||
modifier = paneModifier,
|
||||
|
||||
@@ -115,6 +115,13 @@ fun SectionHeader(
|
||||
* section does no work and the resting layout is the collapsed header alone.
|
||||
* With animations disabled Compose maps the platform animator duration scale
|
||||
* onto the specs, so the body is at its final state at once.
|
||||
*
|
||||
* [content] is laid out in a single full-width [Column]: [AnimatedVisibility]
|
||||
* measures *one* child, so several composables emitted straight into the body
|
||||
* would be stacked on top of each other at the section's top instead of under
|
||||
* their header (the "renders oddly at the top of the section" defect). The
|
||||
* wrapper gives the transition exactly one child and lets a section hold any
|
||||
* number of rows.
|
||||
*/
|
||||
@Composable
|
||||
fun CollapsibleSectionBody(
|
||||
@@ -130,7 +137,7 @@ fun CollapsibleSectionBody(
|
||||
fadeOut(animationSpec = MotionQuick.spec()),
|
||||
modifier = modifier,
|
||||
) {
|
||||
content()
|
||||
Column(Modifier.fillMaxWidth()) { content() }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,16 +17,14 @@ import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.IconButton
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.PrimaryScrollableTabRow
|
||||
import androidx.compose.material3.Scaffold
|
||||
import androidx.compose.material3.Tab
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TopAppBar
|
||||
import androidx.compose.material3.TopAppBarDefaults
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableIntStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.saveable.rememberSaveable
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.semantics.heading
|
||||
import androidx.compose.ui.semantics.semantics
|
||||
@@ -41,15 +39,12 @@ import net.awan.pipelines.data.protocol.Stage
|
||||
import net.awan.pipelines.data.protocol.edges
|
||||
import net.awan.pipelines.ui.AppViewModel
|
||||
import net.awan.pipelines.ui.components.CodeBlock
|
||||
import net.awan.pipelines.ui.components.CollapsibleSectionBody
|
||||
import net.awan.pipelines.ui.components.DetailTabBody
|
||||
import net.awan.pipelines.ui.components.KeyValueRow
|
||||
import net.awan.pipelines.ui.components.LabelChip
|
||||
import net.awan.pipelines.ui.components.PaneIdentity
|
||||
import net.awan.pipelines.ui.components.SectionExpansionState
|
||||
import net.awan.pipelines.ui.components.SectionHeader
|
||||
import net.awan.pipelines.ui.components.paneSafeArea
|
||||
import net.awan.pipelines.ui.components.rememberSectionExpansion
|
||||
import net.awan.pipelines.ui.displayMap
|
||||
import net.awan.pipelines.ui.fileChangeLine
|
||||
import net.awan.pipelines.ui.fileChangesSummary
|
||||
@@ -184,24 +179,16 @@ internal const val STAGE_DEFINITION_TITLE = "Stage definition"
|
||||
@Composable
|
||||
internal fun paneContainerColor() = MaterialTheme.colorScheme.surfaceContainer
|
||||
|
||||
/**
|
||||
* Whether the stage-definition section starts expanded. It is the only content of
|
||||
* a pane opened without a run context (a pipeline's own stage definition, see
|
||||
* [PipelineStagePane]), and starts collapsed in a run pane, where the run's
|
||||
* results lead and the definition sits at the bottom. An operator's own
|
||||
* expand/collapse choice is still remembered on top of this default.
|
||||
*/
|
||||
internal fun definitionStartsExpanded(runContext: Boolean): Boolean = !runContext
|
||||
|
||||
/**
|
||||
* One run-side result section of the stage pane. The order is the operator's
|
||||
* stated preference: the artifacts gallery first, then the output the stage
|
||||
* produced for that visit, then the input it received.
|
||||
* produced for that visit, then the input it received. [title] is the section's
|
||||
* own visible name (its pane's title and its row on the stage screen).
|
||||
*/
|
||||
internal enum class StageResultSection(val key: String) {
|
||||
Artifacts("artifacts"),
|
||||
Output("output"),
|
||||
Input("input"),
|
||||
internal enum class StageResultSection(val key: String, val title: String) {
|
||||
Artifacts("artifacts", "Artifacts"),
|
||||
Output("output", "Output"),
|
||||
Input("input", "Input"),
|
||||
}
|
||||
|
||||
/** The run-side result sections, in display order (the artifacts gallery first). */
|
||||
@@ -211,6 +198,74 @@ internal val STAGE_RESULT_SECTIONS: List<StageResultSection> = listOf(
|
||||
StageResultSection.Input,
|
||||
)
|
||||
|
||||
/** The evidence section key/title ("This run" holds the remaining run evidence). */
|
||||
internal const val STAGE_EVIDENCE_KEY = "run"
|
||||
internal const val STAGE_EVIDENCE_TITLE = "This run"
|
||||
|
||||
/**
|
||||
* One section of the stage screen: its stable [key] (what the pane selection and
|
||||
* the section pane address it by), its own [title], the [fields] it shows when it
|
||||
* is a plain field section, and [artifacts] when it is the per-visit gallery
|
||||
* (which renders the shared [ArtifactsSection] instead of [fields]).
|
||||
*/
|
||||
internal data class StageSectionSpec(
|
||||
val key: String,
|
||||
val title: String,
|
||||
val fields: List<StageField> = emptyList(),
|
||||
val artifacts: Boolean = false,
|
||||
)
|
||||
|
||||
/**
|
||||
* The ordered sections of the stage screen for one stage and visit: a run pane
|
||||
* leads with the visit's Artifacts gallery, then Output, Input and the remaining
|
||||
* evidence (`This run`); the stage's own definition is the last section in both
|
||||
* contexts and the only section when there is no run. Blank field sections are
|
||||
* skipped; the artifacts section always shows for a reached visit, even when the
|
||||
* visit recorded none, so the operator always finds the gallery. Pure, so the
|
||||
* compact stage screen's list and the section pane's content are derived from
|
||||
* exactly the same spec.
|
||||
*/
|
||||
internal fun stageSectionSpecs(
|
||||
stageKey: String,
|
||||
graph: Graph,
|
||||
runSteps: List<RunStep>,
|
||||
visitIndex: Int,
|
||||
runContext: Boolean,
|
||||
): List<StageSectionSpec> {
|
||||
val specs = ArrayList<StageSectionSpec>()
|
||||
val stage = graph.stages.firstOrNull { it.key == stageKey }
|
||||
val definition = stage?.let(::stageDefinitionFields) ?: terminalFields(graph, stageKey)
|
||||
val selectedStep = runSteps.getOrNull(clampVisitIndex(visitIndex, runSteps.size))
|
||||
if (runContext && selectedStep != null) {
|
||||
val runFields = runStepFields(selectedStep)
|
||||
STAGE_RESULT_SECTIONS.forEach { section ->
|
||||
when (section) {
|
||||
StageResultSection.Artifacts -> specs += StageSectionSpec(
|
||||
key = section.key,
|
||||
title = section.title,
|
||||
artifacts = true,
|
||||
)
|
||||
StageResultSection.Output -> {
|
||||
val fields = runFields.filter { it.label == "Output" }
|
||||
if (fields.isNotEmpty()) specs += StageSectionSpec(section.key, section.title, fields)
|
||||
}
|
||||
StageResultSection.Input -> {
|
||||
val fields = runFields.filter { it.label == "Input" }
|
||||
if (fields.isNotEmpty()) specs += StageSectionSpec(section.key, section.title, fields)
|
||||
}
|
||||
}
|
||||
}
|
||||
val evidence = evidenceFields(runFields)
|
||||
if (evidence.isNotEmpty()) {
|
||||
specs += StageSectionSpec(STAGE_EVIDENCE_KEY, STAGE_EVIDENCE_TITLE, evidence)
|
||||
}
|
||||
}
|
||||
if (definition.isNotEmpty()) {
|
||||
specs += StageSectionSpec(STAGE_DEFINITION_KEY, STAGE_DEFINITION_TITLE, definition)
|
||||
}
|
||||
return specs
|
||||
}
|
||||
|
||||
/**
|
||||
* The pure run view of one [RunStep] for the selected stage: status, outcome,
|
||||
* duration, visit against the control's max_visits, target, session id,
|
||||
@@ -300,17 +355,19 @@ internal fun clampVisitIndex(index: Int, visitCount: Int): Int =
|
||||
internal fun showVisitTabs(visitCount: Int): Boolean = visitCount > 1
|
||||
|
||||
/**
|
||||
* The stage pane's content: opened as the rightmost level of the sliding stack
|
||||
* from a timeline entry or a graph node, exactly like the list and detail panes,
|
||||
* so there is no popup anywhere. It carries its own Scaffold/[TopAppBar] with a
|
||||
* back arrow that pops one level (the same step as the peek tap and system Back).
|
||||
* The stage screen: the pane shown when no section is open. It carries its own
|
||||
* Scaffold/[TopAppBar] with a back arrow that pops one level (the same step as
|
||||
* the peek tap and system Back), leads with the run-side headline, and keeps a
|
||||
* **compact list of the stage's sections**: tapping a section opens it as its own
|
||||
* pane ([StageSectionPane]) rather than growing this screen inline.
|
||||
*
|
||||
* [runSteps] is every recorded visit of the stage in order; when there is more
|
||||
* than one the pane shows a visit tab row (visit 1..N) and starts on
|
||||
* [initialVisitIndex] (the tapped timeline entry, or the most recent visit when
|
||||
* opened from the graph). A stage the run never reached has no run section; the
|
||||
* identity heading and type always show, so a freshly opened pane never reads as
|
||||
* empty.
|
||||
* than one the pane shows a visit tab row (visit 1..N) and reports the chosen
|
||||
* visit through [onVisitIndexChange]. The selection is owned by the caller (part
|
||||
* of the saved pane selection), so this screen and the section pane always agree
|
||||
* and it survives rotation. A stage the run never reached lists only its
|
||||
* definition; the identity heading and type always show, so a freshly opened
|
||||
* pane never reads as empty.
|
||||
*/
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
@@ -318,9 +375,9 @@ fun StageDetailPane(
|
||||
stageKey: String,
|
||||
graph: Graph,
|
||||
runSteps: List<RunStep> = emptyList(),
|
||||
initialVisitIndex: Int = 0,
|
||||
configuredServerUrl: String = "",
|
||||
fetchArtifactBytes: suspend (String) -> ByteArray? = { null },
|
||||
visitIndex: Int = 0,
|
||||
onVisitIndexChange: (Int) -> Unit = {},
|
||||
onOpenSection: (String) -> Unit = {},
|
||||
onBack: () -> Unit,
|
||||
wide: Boolean = false,
|
||||
modifier: Modifier = Modifier,
|
||||
@@ -339,32 +396,10 @@ fun StageDetailPane(
|
||||
)
|
||||
return
|
||||
}
|
||||
|
||||
// The selected visit is owned here so the selection's copy/share actions in
|
||||
// the top bar and the body's per-visit artifacts section read the same step.
|
||||
// Reset when the stage changes; saved across configuration.
|
||||
var visitIndex by rememberSaveable(stageKey) {
|
||||
mutableIntStateOf(clampVisitIndex(initialVisitIndex, runSteps.size))
|
||||
}
|
||||
val clampedVisit = clampVisitIndex(visitIndex, runSteps.size)
|
||||
val selectedStep = runSteps.getOrNull(clampedVisit)
|
||||
val visitArtifacts = remember(selectedStep) { selectedStep?.artifacts.orEmpty() }
|
||||
|
||||
// The artifact selection for this visit: a long-press enters it, a tap
|
||||
// toggles. Keyed on the visit, so switching visits leaves selection mode; it
|
||||
// restores fully (or not at all) after rotation.
|
||||
val selectionState = rememberArtifactSelection(stageKey, clampedVisit)
|
||||
|
||||
// The shared selection host owns the selection, the contextual bar, the bulk
|
||||
// copy/share actions and Back-leaves-selection-first; the two artifact
|
||||
// surfaces go through it so they can never drift.
|
||||
ArtifactSelectionScaffold(
|
||||
selectionState = selectionState,
|
||||
candidates = visitArtifacts,
|
||||
configuredServerUrl = configuredServerUrl,
|
||||
fetchArtifactBytes = fetchArtifactBytes,
|
||||
Scaffold(
|
||||
modifier = modifier,
|
||||
containerColor = paneContainerColor(),
|
||||
contentWindowInsets = paneSafeArea(),
|
||||
topBar = {
|
||||
TopAppBar(
|
||||
title = { Text(GraphSemantics.nodeLabel(stageKey)) },
|
||||
@@ -377,68 +412,47 @@ fun StageDetailPane(
|
||||
colors = TopAppBarDefaults.topAppBarColors(containerColor = paneContainerColor()),
|
||||
)
|
||||
},
|
||||
) { selection, onSelectionChange, padding ->
|
||||
) { padding ->
|
||||
StageDetailBody(
|
||||
stageKey = stageKey,
|
||||
graph = graph,
|
||||
runSteps = runSteps,
|
||||
selectedStep = selectedStep,
|
||||
visitIndex = clampedVisit,
|
||||
onVisitIndexChange = { visitIndex = it },
|
||||
configuredServerUrl = configuredServerUrl,
|
||||
fetchArtifactBytes = fetchArtifactBytes,
|
||||
visitIndex = visitIndex,
|
||||
onVisitIndexChange = onVisitIndexChange,
|
||||
onOpenSection = onOpenSection,
|
||||
wide = wide,
|
||||
runContext = runContext,
|
||||
selection = selection,
|
||||
onSelectionChange = onSelectionChange,
|
||||
modifier = Modifier.padding(padding),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/** The stage detail's content, wrapped by [StageDetailPane]. */
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
/** The stage screen's content, wrapped by [StageDetailPane]. */
|
||||
@Composable
|
||||
private fun StageDetailBody(
|
||||
stageKey: String,
|
||||
graph: Graph,
|
||||
runSteps: List<RunStep>,
|
||||
selectedStep: RunStep?,
|
||||
visitIndex: Int,
|
||||
onVisitIndexChange: (Int) -> Unit,
|
||||
configuredServerUrl: String,
|
||||
fetchArtifactBytes: suspend (String) -> ByteArray?,
|
||||
onOpenSection: (String) -> Unit,
|
||||
wide: Boolean,
|
||||
runContext: Boolean,
|
||||
selection: ArtifactSelection,
|
||||
onSelectionChange: (ArtifactSelection) -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
val text = pipelinesText()
|
||||
val stage = graph.stages.firstOrNull { it.key == stageKey }
|
||||
val definition = remember(stage, graph, stageKey) {
|
||||
stage?.let(::stageDefinitionFields) ?: terminalFields(graph, stageKey)
|
||||
}
|
||||
val typeLabel = if (stage != null) effectiveStageType(stage.type) else "terminal"
|
||||
|
||||
val clampedVisit = clampVisitIndex(visitIndex, runSteps.size)
|
||||
// Derived once per selected step, not per recomposition. Only the run-side
|
||||
// facts lead the pane; the stage's own configs stay in the definition section.
|
||||
val selectedStep = runSteps.getOrNull(clampedVisit)
|
||||
// The run-side headline: always visible, never behind a section, so a freshly
|
||||
// opened screen never reads as empty.
|
||||
val runFields = remember(selectedStep) { selectedStep?.let(::runStepFields).orEmpty() }
|
||||
val headline = headlineFields(runFields)
|
||||
val inputFields = remember(runFields) { runFields.filter { it.label == "Input" } }
|
||||
val outputFields = remember(runFields) { runFields.filter { it.label == "Output" } }
|
||||
val evidence = evidenceFields(runFields)
|
||||
// The stage definition is the only content of a pane without a run context,
|
||||
// so it starts expanded there and collapsed at the bottom of a run pane.
|
||||
val expansion = rememberSectionExpansion(
|
||||
stageKey,
|
||||
initiallyExpanded = if (definitionStartsExpanded(runContext)) {
|
||||
setOf(STAGE_DEFINITION_KEY)
|
||||
} else {
|
||||
emptySet()
|
||||
},
|
||||
)
|
||||
val sections = remember(stageKey, graph, runSteps, clampedVisit, runContext) {
|
||||
stageSectionSpecs(stageKey, graph, runSteps, clampedVisit, runContext)
|
||||
}
|
||||
|
||||
DetailTabBody(wide, modifier) { columnModifier ->
|
||||
Column(
|
||||
@@ -453,106 +467,235 @@ private fun StageDetailBody(
|
||||
modifier = Modifier.semantics { heading() },
|
||||
)
|
||||
StageTypeChip(typeLabel)
|
||||
if (showVisitTabs(runSteps.size)) {
|
||||
PrimaryScrollableTabRow(
|
||||
selectedTabIndex = clampedVisit,
|
||||
edgePadding = 0.dp,
|
||||
containerColor = paneContainerColor(),
|
||||
modifier = Modifier.fillMaxWidth().padding(top = SPACING_S),
|
||||
) {
|
||||
runSteps.forEachIndexed { index, _ ->
|
||||
Tab(
|
||||
selected = index == clampedVisit,
|
||||
onClick = { onVisitIndexChange(index) },
|
||||
text = { Text("visit ${index + 1}", maxLines = 1) },
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Identity and result: always visible, never behind a collapse, so a
|
||||
// freshly opened pane never reads as empty.
|
||||
StageVisitTabs(runSteps.size, clampedVisit, onVisitIndexChange)
|
||||
headline.forEach { field -> StageFieldRow(field) }
|
||||
if (headline.isEmpty() && selectedStep == null && stage == null && definition.isEmpty()) {
|
||||
if (headline.isEmpty() && selectedStep == null && stage == null && sections.isEmpty()) {
|
||||
Text("No details recorded for this node.", style = text.meta)
|
||||
}
|
||||
|
||||
// A run pane leads with the run's results: the artifacts gallery
|
||||
// first, then the output and the input, then the remaining evidence.
|
||||
if (runContext && selectedStep != null) {
|
||||
STAGE_RESULT_SECTIONS.forEach { section ->
|
||||
when (section) {
|
||||
StageResultSection.Artifacts -> StageSection(expansion, section.key) {
|
||||
ArtifactsSection(
|
||||
step = selectedStep,
|
||||
configuredServerUrl = configuredServerUrl,
|
||||
fetchArtifactBytes = fetchArtifactBytes,
|
||||
selection = selection,
|
||||
onSelectionChange = onSelectionChange,
|
||||
)
|
||||
}
|
||||
StageResultSection.Output -> if (outputFields.isNotEmpty()) {
|
||||
StageSection(expansion, section.key) {
|
||||
outputFields.forEach { StageFieldRow(it) }
|
||||
}
|
||||
}
|
||||
StageResultSection.Input -> if (inputFields.isNotEmpty()) {
|
||||
StageSection(expansion, section.key) {
|
||||
inputFields.forEach { StageFieldRow(it) }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (evidence.isNotEmpty()) {
|
||||
StageSection(expansion, "run", "This run") {
|
||||
evidence.forEach { field -> StageFieldRow(field) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// The stage's own definition sits in one clearly named section: it is
|
||||
// the pane's only content without a run context (so it starts
|
||||
// expanded) and the collapsed last section of a run pane.
|
||||
if (definition.isNotEmpty()) {
|
||||
StageSection(expansion, STAGE_DEFINITION_KEY, STAGE_DEFINITION_TITLE) {
|
||||
definition.forEach { field -> StageFieldRow(field) }
|
||||
}
|
||||
// The compact list of sections: each row is the section's own header,
|
||||
// and tapping it opens that section as its own pane instead of growing
|
||||
// this screen inline (which stacked a section's several rows at the
|
||||
// top of its header).
|
||||
sections.forEach { section ->
|
||||
SectionHeader(
|
||||
title = section.title,
|
||||
expanded = false,
|
||||
onToggle = { onOpenSection(section.key) },
|
||||
containerColor = paneContainerColor(),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* One collapsible section of the stage pane: its header toggles [expansion]
|
||||
* under [key] and its body animates open/closed with the shared
|
||||
* [CollapsibleSectionBody], so the content and the chevron move together. The
|
||||
* title defaults to the capitalised key (e.g. `artifacts` → `Artifacts`), so the
|
||||
* pane names every section the same way.
|
||||
* The shared visit tab row: rendered only when [visitCount] is more than one, so
|
||||
* a single-visit stage never shows a pointless one-tab row. Both the stage screen
|
||||
* and a run-section pane use it, so a visit always reads the same way.
|
||||
*/
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
private fun StageSection(
|
||||
expansion: SectionExpansionState,
|
||||
key: String,
|
||||
title: String = key.capitalized(),
|
||||
content: @Composable () -> Unit,
|
||||
internal fun StageVisitTabs(
|
||||
visitCount: Int,
|
||||
selectedIndex: Int,
|
||||
onSelect: (Int) -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
val expanded = expansion.isExpanded(key)
|
||||
SectionHeader(
|
||||
title,
|
||||
expanded,
|
||||
{ expansion.toggle(key) },
|
||||
if (!showVisitTabs(visitCount)) return
|
||||
PrimaryScrollableTabRow(
|
||||
selectedTabIndex = selectedIndex,
|
||||
edgePadding = 0.dp,
|
||||
containerColor = paneContainerColor(),
|
||||
)
|
||||
CollapsibleSectionBody(expanded) { content() }
|
||||
modifier = modifier.fillMaxWidth().padding(top = SPACING_S),
|
||||
) {
|
||||
repeat(visitCount) { index ->
|
||||
Tab(
|
||||
selected = index == selectedIndex,
|
||||
onClick = { onSelect(index) },
|
||||
text = { Text("visit ${index + 1}", maxLines = 1) },
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** The stage pane hosted directly by the run destination, reading the run detail. */
|
||||
/**
|
||||
* One stage section opened as its own pane: its own Scaffold/[TopAppBar] titled
|
||||
* with the section's own name, its own scroll and its own top spacing, so the
|
||||
* content always sits cleanly under its header. It is the section level of the
|
||||
* sliding stack (a full-window screen over the stage on a narrow window, a panel
|
||||
* to the stage pane's right on a wide one); Back — the app bar, system Back or
|
||||
* the peek — pops exactly one level, back to the stage.
|
||||
*
|
||||
* The artifacts section keeps the shared [ArtifactSelectionScaffold], so its
|
||||
* gallery retains long-press selection, the contextual bar and
|
||||
* Back-leaves-selection-first; every other section is plain fields. The visited
|
||||
* section is derived from the same [stageSectionSpecs] the stage screen lists, so
|
||||
* the two can never disagree.
|
||||
*/
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun StageSectionPane(
|
||||
stageKey: String,
|
||||
sectionKey: String,
|
||||
graph: Graph,
|
||||
runSteps: List<RunStep> = emptyList(),
|
||||
visitIndex: Int = 0,
|
||||
onVisitIndexChange: (Int) -> Unit = {},
|
||||
configuredServerUrl: String = "",
|
||||
fetchArtifactBytes: suspend (String) -> ByteArray? = { null },
|
||||
onBack: () -> Unit,
|
||||
wide: Boolean = false,
|
||||
modifier: Modifier = Modifier,
|
||||
covered: Boolean = false,
|
||||
runContext: Boolean = false,
|
||||
) {
|
||||
val clampedVisit = clampVisitIndex(visitIndex, runSteps.size)
|
||||
val selectedStep = runSteps.getOrNull(clampedVisit)
|
||||
val spec = remember(stageKey, graph, runSteps, clampedVisit, runContext, sectionKey) {
|
||||
stageSectionSpecs(stageKey, graph, runSteps, clampedVisit, runContext)
|
||||
.firstOrNull { it.key == sectionKey }
|
||||
}
|
||||
val title = spec?.title ?: sectionKey
|
||||
if (covered) {
|
||||
PaneIdentity(
|
||||
title = title,
|
||||
subtitle = GraphSemantics.nodeLabel(stageKey),
|
||||
modifier = modifier.fillMaxSize(),
|
||||
)
|
||||
return
|
||||
}
|
||||
val bar: @Composable () -> Unit = {
|
||||
TopAppBar(
|
||||
title = { Text(title) },
|
||||
navigationIcon = {
|
||||
IconButton(onClick = onBack) {
|
||||
Icon(Icons.AutoMirrored.Filled.ArrowBack, contentDescription = "Back")
|
||||
}
|
||||
},
|
||||
windowInsets = paneSafeArea().only(WindowInsetsSides.Top + WindowInsetsSides.Horizontal),
|
||||
colors = TopAppBarDefaults.topAppBarColors(containerColor = paneContainerColor()),
|
||||
)
|
||||
}
|
||||
if (spec?.artifacts == true) {
|
||||
// The gallery keeps the one selection host (long-press selection, the
|
||||
// contextual bar and Back-leaves-selection-first) it had inline.
|
||||
val selectionState = rememberArtifactSelection(stageKey, clampedVisit)
|
||||
ArtifactSelectionScaffold(
|
||||
selectionState = selectionState,
|
||||
candidates = selectedStep?.artifacts.orEmpty(),
|
||||
configuredServerUrl = configuredServerUrl,
|
||||
fetchArtifactBytes = fetchArtifactBytes,
|
||||
modifier = modifier,
|
||||
containerColor = paneContainerColor(),
|
||||
topBar = bar,
|
||||
) { selection, onSelectionChange, padding ->
|
||||
StageSectionBody(
|
||||
stageKey = stageKey,
|
||||
spec = spec,
|
||||
step = selectedStep,
|
||||
runSteps = runSteps,
|
||||
visitIndex = clampedVisit,
|
||||
onVisitIndexChange = onVisitIndexChange,
|
||||
configuredServerUrl = configuredServerUrl,
|
||||
fetchArtifactBytes = fetchArtifactBytes,
|
||||
selection = selection,
|
||||
onSelectionChange = onSelectionChange,
|
||||
wide = wide,
|
||||
modifier = Modifier.padding(padding),
|
||||
)
|
||||
}
|
||||
} else {
|
||||
Scaffold(
|
||||
modifier = modifier,
|
||||
containerColor = paneContainerColor(),
|
||||
contentWindowInsets = paneSafeArea(),
|
||||
topBar = bar,
|
||||
) { padding ->
|
||||
StageSectionBody(
|
||||
stageKey = stageKey,
|
||||
spec = spec,
|
||||
step = selectedStep,
|
||||
runSteps = runSteps,
|
||||
visitIndex = clampedVisit,
|
||||
onVisitIndexChange = onVisitIndexChange,
|
||||
configuredServerUrl = configuredServerUrl,
|
||||
fetchArtifactBytes = fetchArtifactBytes,
|
||||
selection = ArtifactSelection(),
|
||||
onSelectionChange = {},
|
||||
wide = wide,
|
||||
modifier = Modifier.padding(padding),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* One section's content: its own single scroll, a context line naming the stage,
|
||||
* its own top spacing, and — for a visit's result section — the visit tab row,
|
||||
* so the operator can switch visits in place. The stage definition skips the tab
|
||||
* row (it does not change per visit). Plain sections render their rows; the
|
||||
* artifacts section renders the shared [ArtifactsSection] gallery.
|
||||
*/
|
||||
@Composable
|
||||
private fun StageSectionBody(
|
||||
stageKey: String,
|
||||
spec: StageSectionSpec?,
|
||||
step: RunStep?,
|
||||
runSteps: List<RunStep>,
|
||||
visitIndex: Int,
|
||||
onVisitIndexChange: (Int) -> Unit,
|
||||
configuredServerUrl: String,
|
||||
fetchArtifactBytes: suspend (String) -> ByteArray?,
|
||||
selection: ArtifactSelection,
|
||||
onSelectionChange: (ArtifactSelection) -> Unit,
|
||||
wide: Boolean,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
val text = pipelinesText()
|
||||
DetailTabBody(wide, modifier) { columnModifier ->
|
||||
Column(
|
||||
modifier = columnModifier
|
||||
.verticalScroll(rememberScrollState())
|
||||
.padding(horizontal = SPACING_L, vertical = SPACING_L),
|
||||
verticalArrangement = Arrangement.spacedBy(SPACING_XS),
|
||||
) {
|
||||
Text(GraphSemantics.nodeLabel(stageKey), style = text.meta)
|
||||
if (spec != null && spec.key != STAGE_DEFINITION_KEY) {
|
||||
StageVisitTabs(runSteps.size, visitIndex, onVisitIndexChange)
|
||||
}
|
||||
when {
|
||||
spec == null -> Text("This section is not recorded for this stage.", style = text.meta)
|
||||
spec.artifacts -> if (step != null) {
|
||||
ArtifactsSection(
|
||||
step = step,
|
||||
configuredServerUrl = configuredServerUrl,
|
||||
fetchArtifactBytes = fetchArtifactBytes,
|
||||
selection = selection,
|
||||
onSelectionChange = onSelectionChange,
|
||||
)
|
||||
}
|
||||
else -> spec.fields.forEach { field -> StageFieldRow(field) }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The run-side stage level: with no [openSection] it is the compact stage screen
|
||||
* ([StageDetailPane]); with one it is that section's pane ([StageSectionPane]).
|
||||
* Both read the same run detail and derive the stage's visits the same way, so
|
||||
* the two levels can never disagree and no state is read twice.
|
||||
*/
|
||||
@Composable
|
||||
fun RunStagePane(
|
||||
vm: AppViewModel,
|
||||
runId: Long,
|
||||
stageKey: String,
|
||||
visitIndex: Int,
|
||||
openSection: String?,
|
||||
onOpenSection: (String) -> Unit,
|
||||
onVisitChange: (Int) -> Unit,
|
||||
onBack: () -> Unit,
|
||||
wide: Boolean,
|
||||
modifier: Modifier = Modifier,
|
||||
@@ -564,28 +707,55 @@ fun RunStagePane(
|
||||
val steps = run?.steps.orEmpty()
|
||||
// One aggregation per step-list change; the stage's visits are read from it.
|
||||
val timeline = remember(steps) { runTimeline(steps) }
|
||||
StageDetailPane(
|
||||
stageKey = stageKey,
|
||||
graph = run?.graph ?: Graph(),
|
||||
runSteps = timeline.visitsByStage[stageKey].orEmpty(),
|
||||
initialVisitIndex = visitIndex,
|
||||
configuredServerUrl = configuredServerUrl,
|
||||
fetchArtifactBytes = vm::fetchArtifactBytes,
|
||||
onBack = onBack,
|
||||
wide = wide,
|
||||
modifier = modifier,
|
||||
covered = covered,
|
||||
runContext = true,
|
||||
)
|
||||
val runSteps = remember(timeline, stageKey) { timeline.visitsByStage[stageKey].orEmpty() }
|
||||
val graph = run?.graph ?: Graph()
|
||||
if (openSection == null) {
|
||||
StageDetailPane(
|
||||
stageKey = stageKey,
|
||||
graph = graph,
|
||||
runSteps = runSteps,
|
||||
visitIndex = visitIndex,
|
||||
onVisitIndexChange = onVisitChange,
|
||||
onOpenSection = onOpenSection,
|
||||
onBack = onBack,
|
||||
wide = wide,
|
||||
modifier = modifier,
|
||||
covered = covered,
|
||||
runContext = true,
|
||||
)
|
||||
} else {
|
||||
StageSectionPane(
|
||||
stageKey = stageKey,
|
||||
sectionKey = openSection,
|
||||
graph = graph,
|
||||
runSteps = runSteps,
|
||||
visitIndex = visitIndex,
|
||||
onVisitIndexChange = onVisitChange,
|
||||
configuredServerUrl = configuredServerUrl,
|
||||
fetchArtifactBytes = vm::fetchArtifactBytes,
|
||||
onBack = onBack,
|
||||
wide = wide,
|
||||
modifier = modifier,
|
||||
covered = covered,
|
||||
runContext = true,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/** The stage pane hosted by the pipeline destination; a definition has no run. */
|
||||
/**
|
||||
* The pipeline-side stage level: with no [openSection] it is the stage screen
|
||||
* (a definition has no run, so it lists just that section); with one it is the
|
||||
* definition section's pane. The two share the stage screen and the section pane
|
||||
* with the run side.
|
||||
*/
|
||||
@Composable
|
||||
fun PipelineStagePane(
|
||||
vm: AppViewModel,
|
||||
pipelineId: Long,
|
||||
version: Int,
|
||||
stageKey: String,
|
||||
openSection: String?,
|
||||
onOpenSection: (String) -> Unit,
|
||||
onBack: () -> Unit,
|
||||
wide: Boolean,
|
||||
modifier: Modifier = Modifier,
|
||||
@@ -593,14 +763,28 @@ fun PipelineStagePane(
|
||||
) {
|
||||
val state by vm.pipelineDetail.collectAsStateWithLifecycle()
|
||||
val detail = state.data?.takeIf { it.id == pipelineId && it.version == version }
|
||||
StageDetailPane(
|
||||
stageKey = stageKey,
|
||||
graph = detail?.graph ?: Graph(),
|
||||
onBack = onBack,
|
||||
wide = wide,
|
||||
modifier = modifier,
|
||||
covered = covered,
|
||||
)
|
||||
val graph = detail?.graph ?: Graph()
|
||||
if (openSection == null) {
|
||||
StageDetailPane(
|
||||
stageKey = stageKey,
|
||||
graph = graph,
|
||||
onOpenSection = onOpenSection,
|
||||
onBack = onBack,
|
||||
wide = wide,
|
||||
modifier = modifier,
|
||||
covered = covered,
|
||||
)
|
||||
} else {
|
||||
StageSectionPane(
|
||||
stageKey = stageKey,
|
||||
sectionKey = openSection,
|
||||
graph = graph,
|
||||
onBack = onBack,
|
||||
wide = wide,
|
||||
modifier = modifier,
|
||||
covered = covered,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/** One field as either the shared code card (blocks) or a key/value row. */
|
||||
@@ -618,7 +802,3 @@ internal fun StageFieldRow(field: StageField) {
|
||||
internal fun StageTypeChip(label: String) {
|
||||
LabelChip(label, STAGE_CHIP_PAD_H, SPACING_XS)
|
||||
}
|
||||
|
||||
/** A section key as its visible title ("definition" → "Definition"). */
|
||||
private fun String.capitalized(): String =
|
||||
replaceFirstChar { if (it.isLowerCase()) it.titlecase() else it.toString() }
|
||||
|
||||
@@ -44,11 +44,38 @@ class PaneStateTest {
|
||||
assertEquals(1, result.selection.depth)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun backInsideSectionReturnsToTheStageKeepingTheStage() {
|
||||
val section = PaneSelection(
|
||||
pane = MasterPane.Section,
|
||||
itemId = 7L,
|
||||
itemVersion = 3,
|
||||
sectionIndex = 1,
|
||||
stageKey = "planner",
|
||||
stageVisit = 2,
|
||||
sectionKey = "artifacts",
|
||||
)
|
||||
val result = backStep(section) as BackResult.Show
|
||||
// Exactly one level: section -> stage, keeping the stage and its visit,
|
||||
// clearing only the open section.
|
||||
assertEquals(MasterPane.Stage, result.selection.pane)
|
||||
assertEquals(7L, result.selection.itemId)
|
||||
assertEquals(3, result.selection.itemVersion)
|
||||
assertEquals("planner", result.selection.stageKey)
|
||||
assertEquals(2, result.selection.stageVisit)
|
||||
assertEquals(null, result.selection.sectionKey)
|
||||
assertEquals(2, result.selection.depth)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun depthIsBoundedByTheDeclaredMaximum() {
|
||||
assertEquals(0, PaneSelection(MasterPane.List).depth)
|
||||
assertEquals(1, PaneSelection(MasterPane.Detail, itemId = 1L).depth)
|
||||
assertEquals(2, PaneSelection(MasterPane.Stage, itemId = 1L, stageKey = "s").depth)
|
||||
assertEquals(
|
||||
3,
|
||||
PaneSelection(MasterPane.Section, itemId = 1L, stageKey = "s", sectionKey = "artifacts").depth,
|
||||
)
|
||||
// Every pane's depth is within the bound; the stack can never grow deeper.
|
||||
MasterPane.entries.forEach { pane ->
|
||||
assertTrue(PaneSelection(pane = pane).depth <= MAX_PANE_DEPTH)
|
||||
@@ -65,18 +92,26 @@ class PaneStateTest {
|
||||
stageKey = "s",
|
||||
stageVisit = 3,
|
||||
)
|
||||
val section = stage.copy(pane = MasterPane.Section, sectionKey = "artifacts")
|
||||
// Level 0 (list): everything closes.
|
||||
assertEquals(PaneSelection(), popTo(stage, 0))
|
||||
// Level 1 (detail): only the stage closes, the item is kept.
|
||||
val detail = popTo(stage, 1)
|
||||
assertEquals(PaneSelection(), popTo(section, 0))
|
||||
// Level 1 (detail): the stage and its section close, the item is kept.
|
||||
val detail = popTo(section, 1)
|
||||
assertEquals(MasterPane.Detail, detail.pane)
|
||||
assertEquals(9L, detail.itemId)
|
||||
assertEquals(2, detail.itemVersion)
|
||||
assertEquals(1, detail.sectionIndex)
|
||||
assertEquals(null, detail.stageKey)
|
||||
assertEquals(null, detail.sectionKey)
|
||||
// Level 2 (stage): only the section closes, the stage is kept.
|
||||
val stageAgain = popTo(section, 2)
|
||||
assertEquals(MasterPane.Stage, stageAgain.pane)
|
||||
assertEquals("s", stageAgain.stageKey)
|
||||
assertEquals(null, stageAgain.sectionKey)
|
||||
// A level at or beyond the current depth is a no-op.
|
||||
assertEquals(stage, popTo(stage, 2))
|
||||
assertEquals(stage, popTo(stage, 5))
|
||||
assertEquals(section, popTo(section, 3))
|
||||
assertEquals(section, popTo(section, 5))
|
||||
assertEquals(PaneSelection(MasterPane.Detail, 4L), popTo(PaneSelection(MasterPane.Detail, 4L), 3))
|
||||
}
|
||||
|
||||
@@ -95,6 +130,15 @@ class PaneStateTest {
|
||||
stageKey = "planner",
|
||||
stageVisit = 3,
|
||||
),
|
||||
PaneSelection(
|
||||
pane = MasterPane.Section,
|
||||
itemId = 8L,
|
||||
itemVersion = 2,
|
||||
sectionIndex = 4,
|
||||
stageKey = "planner",
|
||||
stageVisit = 3,
|
||||
sectionKey = "artifacts",
|
||||
),
|
||||
)
|
||||
cases.forEach { selection ->
|
||||
val saved = with(PaneSelectionSaver) { scope.save(selection) }
|
||||
@@ -105,7 +149,7 @@ class PaneStateTest {
|
||||
@Test
|
||||
fun encodedPayloadIsPrimitivesOnly() {
|
||||
// Process-death restoration stays small: only Strings, ints and a long,
|
||||
// with a null stage key encoded as an empty string.
|
||||
// with a null stage or section key encoded as an empty string.
|
||||
val encoded = encodePaneSelection(
|
||||
PaneSelection(
|
||||
pane = MasterPane.Stage,
|
||||
@@ -116,14 +160,25 @@ class PaneStateTest {
|
||||
stageVisit = 4,
|
||||
),
|
||||
)
|
||||
assertEquals(listOf("Stage", 9L, 2, 1, "planner", 4), encoded)
|
||||
assertEquals(listOf("Stage", 9L, 2, 1, "planner", 4, ""), encoded)
|
||||
assertEquals(
|
||||
PaneSelection(MasterPane.Stage, 9L, 2, 1, "planner", 4),
|
||||
decodePaneSelection(encoded),
|
||||
)
|
||||
assertEquals(
|
||||
listOf("Detail", 9L, 2, 1, "", 0),
|
||||
listOf("Detail", 9L, 2, 1, "", 0, ""),
|
||||
encodePaneSelection(PaneSelection(MasterPane.Detail, 9L, 2, 1)),
|
||||
)
|
||||
val section = PaneSelection(
|
||||
pane = MasterPane.Section,
|
||||
itemId = 9L,
|
||||
itemVersion = 2,
|
||||
sectionIndex = 1,
|
||||
stageKey = "planner",
|
||||
stageVisit = 4,
|
||||
sectionKey = "artifacts",
|
||||
)
|
||||
assertEquals(listOf("Section", 9L, 2, 1, "planner", 4, "artifacts"), encodePaneSelection(section))
|
||||
assertEquals(section, decodePaneSelection(encodePaneSelection(section)))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -195,11 +195,49 @@ class StageDetailSheetTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun theDefinitionStartsExpandedOnlyWithoutARunContext() {
|
||||
// A pipeline's stage definition is the pane's only content, so it starts
|
||||
// expanded; a run pane leads with results and collapses the definition.
|
||||
assertTrue(definitionStartsExpanded(runContext = false))
|
||||
assertFalse(definitionStartsExpanded(runContext = true))
|
||||
fun theStageScreenListsItsSectionsInOrderAndTheDefinitionLast() {
|
||||
val stage = Stage(key = "implementer", type = "model", prompt = "do", output = "done")
|
||||
val graph = Graph(stages = listOf(stage))
|
||||
val step = RunStep(
|
||||
status = "succeeded",
|
||||
outcome = "success",
|
||||
target = "reviewer",
|
||||
input = mapOf("prompt" to JsonPrimitive("do it")),
|
||||
output = mapOf("result" to JsonPrimitive("done")),
|
||||
diagnostic = "why",
|
||||
)
|
||||
val specs = stageSectionSpecs("implementer", graph, listOf(step), visitIndex = 0, runContext = true)
|
||||
// The run's results lead (artifacts first) and the stage's own definition
|
||||
// is the last section, named with its own visible title.
|
||||
assertEquals(listOf("artifacts", "output", "input", "run", "definition"), specs.map { it.key })
|
||||
assertEquals(
|
||||
listOf("Artifacts", "Output", "Input", "This run", "Stage definition"),
|
||||
specs.map { it.title },
|
||||
)
|
||||
// The artifacts section is the gallery (no fields); the definition keeps
|
||||
// the stage's own fields.
|
||||
assertTrue(specs.first().artifacts)
|
||||
assertTrue(specs.first().fields.isEmpty())
|
||||
assertTrue(specs.first { it.key == "definition" }.fields.isNotEmpty())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun aDefinitionOnlyStageListsJustItsDefinition() {
|
||||
val graph = Graph(stages = listOf(Stage(key = "planner", type = "model", prompt = "do")))
|
||||
// No run context (a pipeline stage): only the definition section.
|
||||
val specs = stageSectionSpecs("planner", graph, emptyList(), visitIndex = 0, runContext = false)
|
||||
assertEquals(listOf("definition"), specs.map { it.key })
|
||||
}
|
||||
|
||||
@Test
|
||||
fun aVisitThatRecordedNoOutputOrInputListsArtifactsAndTheDefinition() {
|
||||
val graph = Graph(stages = listOf(Stage(key = "s", type = "model")))
|
||||
val step = RunStep(status = "succeeded")
|
||||
val specs = stageSectionSpecs("s", graph, listOf(step), visitIndex = 0, runContext = true)
|
||||
// The artifacts gallery always shows for a reached visit; empty
|
||||
// output/input/evidence sections are omitted rather than listed blank.
|
||||
assertEquals(listOf("artifacts", "definition"), specs.map { it.key })
|
||||
assertTrue(specs.none { !it.artifacts && it.fields.isEmpty() })
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user