Make the Android stage detail a pane and add an artifacts gallery
Turn the stage detail into the rightmost pane of a bounded three-level stack and show every run artifact in a summary gallery. - The stage detail opens as a real level-2 pane from both entry points (a Timeline row and a graph node). StageDetailPane is wrapped in the same Scaffold/TopAppBar with a back arrow as the other panes, and its identity/result facts (status, outcome, target, duration, visit, model target) render outside any collapsible so a fresh pane is never empty. StageDetailSheet, ModalBottomSheet and RightSlidingPanel are removed. - SlidingPaneStack replaces SlidingMasterDetail: pane 0 fills the host, panes 1 and 2 overlay at peek*level, each covered pane keeps one tappable peek strip, and MasterPane/backStep/popTo/MAX_PANE_DEPTH are the pure model. The peek tap, the pane back arrow, the system Back button and the predictive-back gesture all pop exactly one level. - New pure runArtifactGroups(steps) groups a run's artifacts by stage and visit (stable order, duplicates kept, empty run -> empty) and artifactsEmptyMessage distinguishes the running "capture pending" case. ArtifactGallery renders image thumbnails (tap opens full size) and non-image rows with name, size, content type and open/copy; urls resolve through ServerUrl, never a hardcoded host. - Run Summary shows the run gallery and the stage pane shows that visit's group, keeping the existing per-visit artifacts summary and notes. - Tests updated/added (PaneStateTest, SlidingPaneStackTest, ArtifactGroupsTest, ArtifactGalleryTest, StageDetailSheetTest, refreshed DetailTabsTest/PipelinesNavTest, CollapseRemovalTest kept green) and android/README.md records the pass, evidence and not-verified list.
This commit is contained in:
+350
-18
@@ -114,18 +114,20 @@ stops it.
|
||||
- Both detail screens are tabbed via one shared `ui/components/DetailTabs.kt`:
|
||||
run detail exposes Summary, Graph, Input, Output, Evidence and Steps, pipeline
|
||||
detail Summary, Graph and Source, with Summary first and the default. Every tab
|
||||
carries a meaningful icon alongside its label. The run's six tabs scroll
|
||||
horizontally on a narrow window; on a wide window the same tabs render as a
|
||||
vertical selectable rail that **collapses to a narrow icon-only strip** and
|
||||
expands back via an accessibility-labelled "Collapse tabs"/"Expand tabs"
|
||||
control, so the content reclaims the rail's width; the collapsed strip keeps
|
||||
each icon's accurate content description and still marks the selected tab. Both
|
||||
the selection and the collapsed/expanded state are `rememberSaveable` (survive
|
||||
recomposition and configuration changes) and the tabs carry real tab semantics
|
||||
(`Role.Tab` + selected state), so selection is never conveyed by colour alone.
|
||||
Only the selected tab's body composes (`when`), each tab is a single
|
||||
`LazyColumn`, and the Graph tab keeps the full-height `WorkflowGraph` panel
|
||||
with its Fit and expand controls.
|
||||
carries a meaningful icon alongside its label. The section index stays fixed and
|
||||
visible while the sections themselves live in a `HorizontalPager`: tapping a tab
|
||||
(or swiping) slides that section's panel in, a later section entering from the
|
||||
right and an earlier one from the left, following the index order. The pager
|
||||
composes only the visible page at rest, each section is a single `LazyColumn`,
|
||||
and the Graph tab keeps the full-height `WorkflowGraph` panel with its Fit and
|
||||
expand controls. Narrow windows show a horizontally scrolling
|
||||
`PrimaryScrollableTabRow`; wide windows show an always-visible selectable rail
|
||||
(icon + label, no collapse control). `selectedIndex` is the single source of
|
||||
truth: an external change (Back) scrolls the pager and a settled pager reports
|
||||
the new index, guarded against feedback loops. The tabs carry real tab semantics
|
||||
(`Role.Tab` + selected state), so selection is never conveyed by colour alone,
|
||||
and the selected index is `rememberSaveable` (survives recomposition,
|
||||
configuration change and process death) and clamped by `clampTabIndex`.
|
||||
- The Source tab fills the whole tab area and renders the parsed definition
|
||||
instead of dumping the raw markdown: one collapsible section per stage (name ·
|
||||
type) holding labelled blocks for prompt, output, tools, configs, edges
|
||||
@@ -156,12 +158,18 @@ stops it.
|
||||
`LazyColumn`, so no scrollable nests inside a same-direction scrollable.
|
||||
- Foldable-responsive layout driven by window size (`ui/WindowSize.kt`,
|
||||
`isWideLayout(widthDp)` at a 600dp breakpoint, read from
|
||||
`LocalConfiguration.current.screenWidthDp`): a narrow window keeps the
|
||||
single-pane lists, top tabs and bottom navigation, while a wide window shows
|
||||
the pipeline list beside the selected pipeline's tabs and the run list beside
|
||||
the selected run's tabs (master pane ~360dp), with the detail tabs as a side
|
||||
rail, the text column capped at a comfortable width and the graph using the
|
||||
extra width. No material3-adaptive dependency is added.
|
||||
`LocalConfiguration.current.screenWidthDp`): both window widths use one sliding
|
||||
three-level pane stack (`ui/components/SlidingPaneStack.kt`) — pane 0 is the
|
||||
pipeline (or run) list filling the window, pane 1 the selected detail and pane
|
||||
2 the selected stage/graph node, each overlaying the one below at `peek * level`
|
||||
leaving a tappable peek strip of the pane it covers on the left; tapping a
|
||||
covered pane's peek closes every pane to its right. There is no collapse
|
||||
control, no collapsed strip and no master-pane width constant any more. The
|
||||
section index presentation does follow
|
||||
the window width: a narrow window shows the tab row across the top, a wide
|
||||
window the always-visible side rail, with the text column capped at a
|
||||
comfortable width and the graph using the extra width. No material3-adaptive
|
||||
dependency is added.
|
||||
- Both detail screens' sections are still collapsible via the shared
|
||||
`SectionHeader`: tapping a header toggles it, an animated chevron rotates with
|
||||
the state, the header sticks to the top of the list while its content scrolls
|
||||
@@ -545,4 +553,328 @@ before/after screenshots for the top inset and the collapsed sections, the
|
||||
emulator screenshots for the artifacts sheet (narrow/wide run detail) are in
|
||||
`~/.local/share/pipelines/data/artifacts/58/3/`.
|
||||
|
||||
## Sliding master/detail, right-opening sections, no collapse (15 Oct 2026)
|
||||
|
||||
> **Superseded** by the pane-stack pass below (same day): the shared host is now
|
||||
> `ui/components/SlidingPaneStack.kt` (three levels), Back no longer steps the
|
||||
> section index, and the stage detail is a pane — there is no
|
||||
> `SlidingMasterDetail.kt`, `RightSlidingPanel` or `ModalBottomSheet` in the
|
||||
> tree. The bullets and evidence here record what that pass did at the time.
|
||||
|
||||
The collapse-based master/detail interaction was replaced by a sliding one, in
|
||||
`android/` only. No Pipelines server/Go/Docker/installer file was touched, no run
|
||||
was started from the app, and colours, the graph and the information shown are
|
||||
unchanged — only the navigation model and its geometry.
|
||||
|
||||
- **Removed, not repaired.** `CollapsedListPane`, the `onTogglePane` parameter
|
||||
and the "Collapse list pane" `IconButton` on both list top bars, `LIST_PANE_WIDTH`
|
||||
(`360.dp`) and `COLLAPSED_LIST_PANE_WIDTH` (`56.dp`), and the observed-side rail
|
||||
collapse (`RailToggle`, `railWidthDp`, `COLLAPSED_RAIL_WIDTH_DP`,
|
||||
`WIDE_RAIL_WIDTH_DP` collapse branch, "Collapse tabs") are all gone; the wide
|
||||
rail is always visible as the section index. `ui/CollapseRemovalTest.kt` scans
|
||||
`src/main/java` for those identifiers and fails if any return. The old
|
||||
full-screen `pipeline/{id}/{version}` and `run/{id}` routes were removed, so
|
||||
`destinationSelected` is a plain route equality.
|
||||
- **One shared host, one slide.** `ui/components/SlidingMasterDetail.kt` is used
|
||||
by both the Pipelines and Runs destinations at both window widths: the list
|
||||
fills the window and the detail overlays it, sliding in from the right via a
|
||||
single `animateDpAsState(spring())` until a peek strip stays visible; a rapid
|
||||
run of taps only retargets that one animator, so the pane always settles fully
|
||||
open or fully closed (never half-slid). The detail width is `measuredWidth -
|
||||
peek` (never hardcoded) and the list behind is hidden from accessibility and
|
||||
made non-interactive while the detail is open, so TalkBack focus follows the
|
||||
visible pane and a tap can never select a row through the peek.
|
||||
- **The peek geometry is derived, with one named token.** `PEEK_WIDTH_DP`
|
||||
(`56.dp`) is the only new dimension literal; the actual peek is
|
||||
`peekWidthDp(minimumInteractive, startInset) = maxOf(PEEK_WIDTH_DP,
|
||||
minimumInteractive + startInset)`, so the tappable strip left after the left
|
||||
system-gesture inset is still at least `LocalMinimumInteractiveComponentSize`
|
||||
(48dp). The strip is positioned clear of the status/nav bars and the gesture
|
||||
area by offsetting/sizing it with `WindowInsets.systemBars ∪
|
||||
WindowInsets.systemGestures` (read once per layout), and it carries the content
|
||||
description "Back to list". No other numeric literals were added (the animation
|
||||
uses the default `spring()` with no literal).
|
||||
- **Sections open to the right.** `DetailTabs` keeps the index fixed in place and
|
||||
moves the section bodies into a `HorizontalPager` (compose-foundation, already
|
||||
in the BOM): a tap or a swipe slides the section in, later sections from the
|
||||
right and earlier ones from the left. Back (`ui/PaneState.kt` `backStep`) is one
|
||||
level — section > 0 → previous section, section 0 → list, list → app exit — and
|
||||
the peek tap, the detail's back arrow and the system Back button/gesture all run
|
||||
that same step. `PredictiveBackHandler` handles the gesture;
|
||||
`android:enableOnBackInvokedCallback="true"` was added to the manifest.
|
||||
- **Saved state.** `PaneSelection` (pane, item id/version, section index) is all
|
||||
primitives with a `Saver`, so the open pane and selected section survive
|
||||
rotation, configuration change and process death. `rememberPagerState` also
|
||||
saves the pager page.
|
||||
- **Secondary surface.** The wide stage-detail overlay reuses the same
|
||||
right-slide (`RightSlidingPanel`); on a narrow window it deliberately keeps its
|
||||
`ModalBottomSheet` (a right panel on a phone-width window would crowd the
|
||||
content, and the sheet is the platform-appropriate narrow surface). The overlay
|
||||
is hosted at the screen level, a sibling of the tabs, so it covers the
|
||||
whole detail pane rather than being nested inside a pager page (a pager-nested
|
||||
copy sized to zero). The pure helpers in `StageDetailSheet.kt` are unchanged, so
|
||||
no information changed.
|
||||
|
||||
Evidence obtained in this pass (macOS, JDK 17 from Homebrew `openjdk@17`, Gradle
|
||||
8.11.1 from the wrapper cache, `ANDROID_HOME=/Users/alan/Library/Android/sdk`):
|
||||
|
||||
- `:app:testDebugUnitTest` reported **112 tests, 0 failures** (new `PaneStateTest`
|
||||
— pane open, `backStep` at section > 0 / section 0 / list, section ordering and
|
||||
slide direction, `Saver` round trip and primitive payload; new
|
||||
`CollapseRemovalTest`; new `SlidingMasterDetailTest` for `peekWidthDp`;
|
||||
`DetailTabsTest` updated and `PipelinesNavTest` updated for the removed routes).
|
||||
- `:app:assembleDebug` succeeded. `:app:lintDebug` still reports only the two
|
||||
pre-existing `NewApi` errors for `android:windowLightNavigationBar` (minSdk 26)
|
||||
in `res/values/themes.xml` and `res/values-night/themes.xml`; those files were
|
||||
not modified.
|
||||
- `grep` over `app/src/main` for the banned collapse identifiers returned nothing.
|
||||
- The debug APK was installed and driven on the attached Pixel 10 Pro Fold
|
||||
(`adb -s 58281FDCG000JF`, inner display 2076x2152, density 330 ≈ 1006dp wide)
|
||||
against a live server (`ws://10.0.0.249:8080/connect`):
|
||||
- Tapping a pipeline row slid the detail in; `uiautomator dump` showed the
|
||||
"Back to list" strip at `[61,185][160,1904]` (48dp wide, offset past the ~30dp
|
||||
left gesture inset and below the status bar) with the list rows absent from
|
||||
the accessibility tree; tapping the strip's centre closed the detail and
|
||||
restored all nine rows. A tap in the gesture area (`x = 30 < 61`) selected no
|
||||
row (the list is blocked).
|
||||
- Tapping the Graph rail tab (and the narrow top tab row) changed the section
|
||||
while the rail/tab row and the strip stayed in place; the selected rail node
|
||||
exposed `selected="true"`.
|
||||
- `adb shell input swipe 5 1000 900 1000 250` (predictive-back gesture) closed
|
||||
the detail at section 0, and from Source (section 2) stepped back to Graph
|
||||
(section 1) — one level.
|
||||
- A live `wm density` change 330 → 300 → 330 kept the pane open and the section
|
||||
selected; the narrow layout (`wm size 1080x2340`, ≈524dp) showed the full-width
|
||||
list, the top tab row index and a 48dp strip, and both the section tab and the
|
||||
strip back worked there.
|
||||
- `adb logcat` for the package contained no `FATAL EXCEPTION` or
|
||||
`AndroidRuntime` error during the sweep, and no run was started from the app.
|
||||
- `:app:testDebugUnitTest` and the APK build were re-run after the final code
|
||||
change; the beats above are the final-build run.
|
||||
|
||||
- The wide sequence was captured to `captures/` (git-ignored) and mirrored to
|
||||
the run artifacts: `slide-W1-list`, `slide-W2-detail-peek` (detail slid in,
|
||||
48dp strip on the left), `slide-W3-section` (Graph tab selected, index still
|
||||
in place), `slide-W4-back-section` (strip tapped once, back to Summary) and
|
||||
`slide-W5-closed-list` (strip tapped again, list restored, byte-identical to
|
||||
`slide-W1-list`); the narrow window (`wm size 1080x2340`, ≈524dp) has the same
|
||||
set `slide-N1`…`slide-N5` (top tab row, `N3` graph, `N4` back to Summary,
|
||||
`N5` closed, identical to `N1`).
|
||||
- The wide stage-detail overlay was driven from both entry points: tapping a
|
||||
timeline row (`W8-timeline`, `W7-stage-overlay`: the panel slid in with the
|
||||
"Close stage details" strip at `[221,477][320,1838]`, the `planner` heading and
|
||||
the `Definition` section, dismissed by tapping the strip) and tapping a graph
|
||||
node (`W9-graph-stage-overlay`).
|
||||
- **APK publish.** `app/build/outputs/apk/debug/app-debug.apk` (18,184,868 bytes,
|
||||
sha256 `7942795c1d979a66e4759a0c3e3f0399d60e256b29ba4a7266dfc52142245ac8`) was
|
||||
copied to
|
||||
`~/.local/share/pipelines/data/artifacts/59/2/pipelines-debug-059c85a.apk`
|
||||
(`059c85a` = `git log -1 --format=%h -- android/`). `curl -I
|
||||
http://10.0.0.249:8080/artifacts/59/2/pipelines-debug-059c85a.apk` (LAN address
|
||||
from `python3 scripts/lan-address.py`, never `localhost`/`10.0.2.2`) returned
|
||||
`HTTP/1.1 200 OK`, `Content-Type: application/vnd.android.package-archive`,
|
||||
`Content-Length: 18184868`; a streamed `GET | shasum -a 256` returned
|
||||
`7942795c1d979a66e4759a0c3e3f0399d60e256b29ba4a7266dfc52142245ac8`, equal to the
|
||||
local file. At 17.3 MiB it exceeds the 8 MiB per-file inventory cap
|
||||
(`internal/server/artifacts.go`), so it is served by direct URL only.
|
||||
|
||||
Not verified in this pass: `onOpenRun` from a pipeline detail to a freshly
|
||||
started run cannot be exercised without starting a run, so that path is kept
|
||||
compiling and functional but untested; the predictive-back gesture's frame-by-frame
|
||||
preview is not driven through `adb`, so its behaviour (one level back) is
|
||||
verified but not its animation; a real hardware fold to the narrow cover display
|
||||
was not exercised (narrow was produced with `wm size`); the emulator
|
||||
(`emulator-5554`) was not used, the physical Pixel was.
|
||||
|
||||
|
||||
## Pane stack, click-outside back, stage pane and artifacts gallery (15 Oct 2026)
|
||||
|
||||
This pass turned the stage detail into a real pane, made the stack behave like
|
||||
Back at every level, and added an artifacts gallery to the summary.
|
||||
|
||||
- **The stage detail is a pane, not a popup.** `StageDetailSheet` and its
|
||||
`ModalBottomSheet`/`RightSlidingPanel` branches are gone. `StageDetailPane`
|
||||
(`ui/graph/StageDetailPane.kt`) is the stage level of the stack, wrapped in the
|
||||
same `Scaffold`/`TopAppBar` with a back arrow as the other panes. Both entry
|
||||
points — a Timeline row and a graph node — now set
|
||||
`PaneSelection(pane = Stage, stageKey, stageVisit)` and open it as the rightmost
|
||||
pane; the covered graph/timeline is hidden from accessibility and blocked, so
|
||||
nothing leaks through.
|
||||
- **Headline-first content.** The identity/result facts (Status, Outcome, Target,
|
||||
Duration, Visit, Model target; `STAGE_HEADLINE_LABELS`) are rendered outside any
|
||||
collapsible, so a freshly opened pane never reads as empty. Definition, Input,
|
||||
Output, Artifacts and the remaining run evidence are collapsible via the shared
|
||||
`SectionHeader` + `rememberSectionExpansion(stageKey)`. `runStepFields`,
|
||||
`stageDefinitionFields`, `StageFieldRow`, `StageTypeChip`, `controlVisitLabel`,
|
||||
`numberFields`/`terminalFields` and the visit tab row are all kept.
|
||||
- **One three-level stack.** `ui/components/SlidingPaneStack.kt` replaces
|
||||
`SlidingMasterDetail`: pane 0 fills the host, panes 1 and 2 overlay it at
|
||||
`paneOffsetDp(level, peek) = peek * level` and `paneWidthDp(hostWidth, level,
|
||||
peek) = hostWidth - peek * level` (derived from the one named `PEEK_WIDTH_DP`
|
||||
token and the measured width; no new offsets). Each covered pane keeps exactly
|
||||
one peek visible and its peek strip is tappable, calling `onPopTo(level)` to
|
||||
close every pane to its right. `MasterPane { List, Detail, Stage }`, `depth`,
|
||||
`MAX_PANE_DEPTH = 2`, `backStep` (one pane per step, no section stepping) and
|
||||
`popTo(selection, level)` are the pure model; `PaneSelection` carries
|
||||
`stageKey`/`stageVisit` and its saver encodes six primitives.
|
||||
- **Back and the outside tap agree.** `PredictiveBackHandler` is enabled for
|
||||
`depth >= 1` and the system Back button/gesture, the peek tap and the pane's
|
||||
back arrow all run the same one-level step; `backStep(Stage)` → Detail,
|
||||
`backStep(Detail)` → List, list → app exit.
|
||||
- **Artifacts gallery.** `ui/ArtifactGroups.kt` has the pure
|
||||
`runArtifactGroups(steps)` (grouped by stage then visit from `runTimeline`,
|
||||
stable order, duplicate names kept, empty run → empty) and
|
||||
`artifactsEmptyMessage(executing)`. `ArtifactGallery` (`ui/graph/Artifacts.kt`)
|
||||
renders each group's image artifacts as a non-lazy chunked grid of thumbnails
|
||||
(a tap opens the full-size dialog) and its non-images as rows with name,
|
||||
`humanBytes` size, content type and open/copy; the Summary tab shows the run
|
||||
gallery and the stage pane's Artifacts section shows that visit's group plus the
|
||||
unchanged `Artifacts · N recorded` summary and capture notes. Every url resolves
|
||||
through `ServerUrl.resolveArtifactUrl` (no hardcoded host), and
|
||||
`ArtifactImage`/`ArtifactBytesCache` remain the single loader.
|
||||
|
||||
Evidence obtained in this pass (macOS, JDK 17 from Homebrew `openjdk@17`, Gradle
|
||||
8.11.1 from the wrapper cache, `ANDROID_HOME=/Users/alan/Library/Android/sdk`,
|
||||
`--offline`):
|
||||
|
||||
- `gradle :app:testDebugUnitTest` reported **122 tests, 0 failures** (rewritten
|
||||
`PaneStateTest` — three levels, `depth`, `MAX_PANE_DEPTH`, `backStep` at each
|
||||
level, `popTo` levels and the six-primitive saver; renamed `SlidingPaneStackTest`
|
||||
— `peekWidthDp` plus `paneOffsetDp`/`paneWidthDp`; new `ArtifactGroupsTest` —
|
||||
grouping/order, duplicates kept, empty run, visit numbers vs `runTimeline`,
|
||||
running-vs-finished empty message; `StageDetailSheetTest` gained the
|
||||
headline/evidence split assertions). `CollapseRemovalTest` still passes.
|
||||
- `gradle :app:assembleDebug` succeeded (18,198,400 bytes). `gradle :app:lintDebug`
|
||||
still reports only the two pre-existing `NewApi` errors for
|
||||
`android:windowLightNavigationBar` in `res/values/themes.xml` and
|
||||
`res/values-night/themes.xml`.
|
||||
- `rg -n 'ModalBottomSheet|StageDetailSheet' android/app/src/main` and
|
||||
`rg -n 'https?://' android/app/src/main/java/net/awan/pipelines/ui/graph` both
|
||||
return nothing; `git diff --stat` shows no change under `android/gradle` or the
|
||||
`build.gradle.kts` dependency blocks.
|
||||
- On `emulator-5554` (2076x2152, density 390 ≈ 851dp wide; **never** the attached
|
||||
Pixel) against the live server `ws://10.0.0.75:8080/connect` (LAN address from
|
||||
`python3 -c` importing `scripts/lan-address.py`; the script has no `__main__`,
|
||||
so it prints nothing when run directly):
|
||||
- Summary of run 58 showed the grouped gallery (`reviewer · visit 1` header, then
|
||||
a grid of `Preview of …png`); tapping a thumbnail opened the full-size dialog
|
||||
(`02_sheet_ui_reviewer_top.png`); a non-image row showed `EVIDENCE.md`,
|
||||
`3.0 KiB · text/plain; charset=utf-8`, `Open`/`Copy` `enabled="true"`.
|
||||
- Tapping the Timeline row `reviewer · visit 1` opened the stage pane as level 2
|
||||
with two peeks visible (`Back to runs` at `[73,165][190,1859]`, `Back to run`
|
||||
at `[190,165][380,1859]`) and the headline facts shown unexpanded
|
||||
(`reviewer`/`model`, `Status completed`, `Outcome rejected`, `Duration 7m 41s`,
|
||||
`Visit 1 / 3`, `Target implementer`); Definition/Input/Output/Artifacts/This run
|
||||
were collapsed. Tapping the graph node `Stage reviewer` opened the same pane
|
||||
(`Status completed`, `Outcome success`, `Visit 2 / 3`, `Target ui_reviewer`).
|
||||
- Tapping the detail peek (`285 1000`) → depth 1 (`Back to runs` only); tapping
|
||||
the list peek (`130 1000`) → depth 0 (list, no strips). `input keyevent 4` at
|
||||
depth 2 → depth 1, at depth 1 → depth 0; the predictive-back swipe
|
||||
`input swipe 5 1000 900 1000 250` at depth 2 → depth 1.
|
||||
- `settings put system user_rotation 1` (config change) kept depth 2 and the
|
||||
`reviewer`/visit 1 selection; after `am kill net.awan.pipelines` (verified
|
||||
`pidof` empty) the relaunch restored the same depth and selection.
|
||||
- The stage pane's Artifacts section expanded to `Artifacts · 6 recorded` plus
|
||||
the visit's thumbnails; run 60 (executing) showed the run empty state
|
||||
`Artifacts · capture pending`.
|
||||
- `adb logcat -d | grep -c 'FATAL EXCEPTION'` and `… | grep -c 'E AndroidRuntime'`
|
||||
both returned 0; no run was started from the app.
|
||||
- **APK publish.** `app/build/outputs/apk/debug/app-debug.apk` was copied to
|
||||
`…/artifacts/60/2/pipelines-debug-059c85a.apk` (`059c85a` =
|
||||
`git log -1 --format=%h -- android/`); `shasum -a 256` matched. `curl -I
|
||||
http://10.0.0.75:8080/artifacts/60/2/pipelines-debug-059c85a.apk` returned 200
|
||||
with `Content-Type: application/vnd.android.package-archive` and a
|
||||
`Content-Length`; a streamed `GET | shasum -a 256` equalled the local file. At
|
||||
17.3 MiB it exceeds the server's 8 MiB per-file inventory cap, so it is served
|
||||
by direct URL only.
|
||||
|
||||
Not verified in this pass: a different graph node tapped *while the stage pane is
|
||||
open* is not reachable because the covered graph is intentionally blocked, so the
|
||||
"selection replaces the rightmost pane at depth 2" invariant is covered by the
|
||||
`PaneStateTest` bound/`popTo` tests rather than by a device tap; the unconfigured
|
||||
(disabled open/copy) gallery row and the finished-run "no artifacts recorded" empty
|
||||
state were not exercised (only the running "capture pending" one); the
|
||||
predictive-back animation frames and pinch-zoom were not driven through `adb`; the
|
||||
narrow layout was not separately exercised (the stage pane no longer branches on
|
||||
width); the physical Pixel was not touched.
|
||||
|
||||
### Follow-up fix: narrow-window gallery (15 Oct 2026)
|
||||
|
||||
A review of the pane-stack pass found the gallery grid used a fixed 96dp tile
|
||||
(`ARTIFACT_TILE_DP`) in three columns, so the row overflowed a narrow (phone)
|
||||
pane and clipped the third thumbnail. Fixed in `ui/graph/Artifacts.kt`:
|
||||
|
||||
- **Derived tile size.** `ArtifactGallery` now measures the row once with
|
||||
`BoxWithConstraints` and calls the pure `artifactTileDp(availableWidth, columns,
|
||||
spacing, preferred)` (the widest that fits, capped at the preferred
|
||||
`ARTIFACT_TILE_DP`), so three tiles and their gaps always fit the pane. The only
|
||||
new named token is `ARTIFACT_TILE_SPACING_DP` (`8.dp`), shared by the row
|
||||
arrangement and the fitting; no magic offsets.
|
||||
- **Dead code removed.** `ArtifactRow` no longer carries an unreachable image
|
||||
branch (the gallery passes it only non-image artifacts); it renders the file
|
||||
glyph, name and `artifactMetaLine` with open/copy.
|
||||
- **No duplicated derivation.** `runArtifactGroups` reuses `runTimeline`'s display
|
||||
visit number (`entries` → `(stage, sequence) → visit`) instead of re-deriving
|
||||
`control.visit ?: index + 1`.
|
||||
- **Docs corrected.** The current-architecture bullet and the superseded
|
||||
`SlidingMasterDetail`/`RightSlidingPanel`/`ModalBottomSheet` references above were
|
||||
updated; the previous pass's section is marked superseded.
|
||||
- New unit test `ui/graph/ArtifactGalleryTest`: narrow width shrinks the tile so
|
||||
the row never overflows, a width that fits keeps the preferred tile, exact fit
|
||||
and degenerate inputs.
|
||||
|
||||
Evidence obtained in this follow-up (macOS, JDK 17 from Homebrew `openjdk@17`,
|
||||
Gradle 8.11.1 from the wrapper cache, `ANDROID_HOME=/Users/alan/Library/Android/sdk`,
|
||||
`--offline`):
|
||||
|
||||
- `gradle :app:testDebugUnitTest` reported **127 tests, 0 failures, 0 errors**
|
||||
(the 5 new `ArtifactGalleryTest` cases included); `CollapseRemovalTest` still
|
||||
passes. `gradle :app:assembleDebug` succeeded (17,830,569 bytes).
|
||||
`gradle :app:lintDebug` still reports only the two pre-existing `NewApi` errors
|
||||
for `android:windowLightNavigationBar` in `res/values/themes.xml` and
|
||||
`res/values-night/themes.xml`.
|
||||
- `rg -n 'ModalBottomSheet|StageDetailSheet|RightSlidingPanel|SlidingMasterDetail'
|
||||
android/app/src/main` and `rg -n 'https?://'
|
||||
android/app/src/main/java/net/awan/pipelines/ui/graph` both return nothing;
|
||||
`git diff --stat` shows no change under `android/gradle` or the
|
||||
`build.gradle.kts` dependency blocks.
|
||||
- On `emulator-5554` (never the attached Pixel) against the live server
|
||||
`ws://10.0.0.75:8080/connect`:
|
||||
- Run 58 Summary showed the gallery grouped by stage/visit; at the wide
|
||||
(851dp, density 390) size the tiles measured 234px (96dp).
|
||||
- Setting `wm size 1080x1920` + `wm density 480` (360dp): the Summary gallery's
|
||||
three tiles measured 78dp and the third's right edge (`[798,492][1032,582]`
|
||||
→ x=1032) coincided with the pane content edge — no clipping. In the depth-2
|
||||
stage pane (`Artifacts, expanded`) the three tiles measured 52dp
|
||||
(`[516,796][672,952]`, `[696,…][852,…]`, `[876,…][1032,…]`) and also reached
|
||||
the pane edge exactly; the non-image `emulator.log` row showed
|
||||
`10.8 KiB · text/plain; charset=utf-8` with enabled `Open`/`Copy`.
|
||||
- Timeline row → stage pane (depth 2, two peeks) and graph node → stage pane both
|
||||
opened with the headline facts visible (`reviewer`/`model`, `Status completed`,
|
||||
`Outcome rejected`/`success`, `Duration`, `Visit`, `Target`) and every other
|
||||
section collapsed. Detail peek (`285 1000`) → depth 1; list peek (`131 1000`)
|
||||
→ depth 0; `input keyevent 4` at depth 2 → depth 1 and at depth 1 → depth 0;
|
||||
the predictive-back swipe `input swipe 5 1000 900 1000 250` at depth 2 →
|
||||
depth 1.
|
||||
- A `wm density` 480 → 440 change kept depth 2 with the `reviewer` visit-1
|
||||
selection and the expanded Artifacts section; after `am kill net.awan.pipelines`
|
||||
(verified `pidof` empty) and relaunch, the same depth and selection returned.
|
||||
- `adb -s emulator-5554 logcat -d` contained 0 `FATAL EXCEPTION` and 0
|
||||
`E AndroidRuntime` lines; no run was started from the app.
|
||||
- **APK publish.** `app/build/outputs/apk/debug/app-debug.apk` (17,830,569 bytes,
|
||||
sha256 `6ac6004e9d4bc29d30457cc99009c226df7157dae2b41f07fa7c8a7a46a40498`) was
|
||||
copied to `…/artifacts/60/4/pipelines-debug-059c85a.apk` (`059c85a` =
|
||||
`git log -1 --format=%h -- android/`); `shasum -a 256` matched. `curl -I
|
||||
http://10.0.0.75:8080/artifacts/60/4/pipelines-debug-059c85a.apk` returned
|
||||
`HTTP/1.1 200 OK`, `Content-Type: application/vnd.android.package-archive`,
|
||||
`Content-Length: 17830569`; a streamed `GET | shasum -a 256` equalled the local
|
||||
file.
|
||||
|
||||
Not verified in this follow-up: a different graph node tapped *while the stage pane
|
||||
is open* (the covered graph stays blocked, so the replace-the-rightmost invariant
|
||||
is covered by the `PaneStateTest` bound/`popTo` tests only); the explicit gallery
|
||||
empty states (the run 60 card already carried artifacts during this sweep, so
|
||||
neither the "capture pending" nor the finished "no artifacts recorded" message was
|
||||
seen on device — both are covered by `ArtifactGroupsTest`/`artifactsEmptyMessage`);
|
||||
the unconfigured (disabled open/copy) gallery row; the predictive-back animation
|
||||
frames and pinch-zoom (adb cannot drive a two-finger pinch).
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:enableOnBackInvokedCallback="true"
|
||||
android:name=".PipelinesApplication"
|
||||
android:icon="@drawable/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
package net.awan.pipelines.ui
|
||||
|
||||
import net.awan.pipelines.data.protocol.RunStep
|
||||
import net.awan.pipelines.data.protocol.StageArtifact
|
||||
import net.awan.pipelines.ui.screens.runTimeline
|
||||
|
||||
/**
|
||||
* Every artifact one visit of one stage recorded, in the order the visit's
|
||||
* artifacts were reported. Duplicate names are tolerated (kept, not deduped): an
|
||||
* artifact's identity is its recorded url, not its name.
|
||||
*/
|
||||
data class ArtifactGroup(
|
||||
val stageKey: String,
|
||||
val visit: Int,
|
||||
val artifacts: List<StageArtifact>,
|
||||
)
|
||||
|
||||
/**
|
||||
* Groups a run's artifacts by stage and visit, purely and deterministically.
|
||||
* Order follows [runTimeline]: stages in first-appearance order and each stage's
|
||||
* visits by sequence, with the same display visit number (the recorded control
|
||||
* visit, else the position within the stage). Only visits that recorded at least
|
||||
* one artifact produce a group, so an empty/absent capture never yields an empty
|
||||
* group and an artifact-less run yields an empty list. O(steps), single pass.
|
||||
*/
|
||||
fun runArtifactGroups(steps: List<RunStep>): List<ArtifactGroup> {
|
||||
if (steps.isEmpty()) return emptyList()
|
||||
val timeline = runTimeline(steps)
|
||||
// Reuse runTimeline's display visit number rather than re-deriving it: the
|
||||
// entries already carry (stage, sequence) -> visit. O(steps), built once.
|
||||
val visitByStageSequence = timeline.entries.associate { (it.stageKey to it.step.sequence) to it.visit }
|
||||
val groups = ArrayList<ArtifactGroup>()
|
||||
timeline.visitsByStage.forEach { (stageKey, visits) ->
|
||||
visits.forEach { step ->
|
||||
val artifacts = step.artifacts.orEmpty()
|
||||
if (artifacts.isNotEmpty()) {
|
||||
val visit = visitByStageSequence[stageKey to step.sequence] ?: 1
|
||||
groups += ArtifactGroup(stageKey, visit, artifacts)
|
||||
}
|
||||
}
|
||||
}
|
||||
return groups
|
||||
}
|
||||
|
||||
/**
|
||||
* The explicit message shown where the run's artifacts gallery would be when
|
||||
* there are none: while the run is executing it uses the same "capture pending"
|
||||
* wording as a running visit, otherwise it says plainly that nothing was
|
||||
* recorded.
|
||||
*/
|
||||
fun artifactsEmptyMessage(executing: Boolean): String =
|
||||
if (executing) {
|
||||
"Artifacts · $ARTIFACT_CAPTURE_PENDING"
|
||||
} else {
|
||||
"No artifacts recorded for this run."
|
||||
}
|
||||
@@ -110,6 +110,12 @@ fun humanBytes(size: Long): String {
|
||||
/** Whether an artifact's content type is an image the sheet can preview. */
|
||||
fun isImageContentType(contentType: String): Boolean = contentType.startsWith("image/")
|
||||
|
||||
/**
|
||||
* The "capture pending" wording shared by a running visit's summary and the
|
||||
* run-level empty state, so the two never spell it differently.
|
||||
*/
|
||||
const val ARTIFACT_CAPTURE_PENDING = "capture pending"
|
||||
|
||||
/**
|
||||
* The artifacts summary label, mirroring internal/tui/file_changes.go
|
||||
* artifactsSummary: "capture pending" while the visit runs, "not recorded for
|
||||
@@ -119,7 +125,11 @@ fun isImageContentType(contentType: String): Boolean = contentType.startsWith("i
|
||||
fun artifactsSummary(step: RunStep): String {
|
||||
val artifacts = step.artifacts.orEmpty()
|
||||
if (artifacts.isEmpty()) {
|
||||
val state = if (step.status == "running") "capture pending" else "not recorded for this visit"
|
||||
val state = if (step.status == "running") {
|
||||
ARTIFACT_CAPTURE_PENDING
|
||||
} else {
|
||||
"not recorded for this visit"
|
||||
}
|
||||
return "Artifacts · $state"
|
||||
}
|
||||
var label = "Artifacts · ${artifacts.size} recorded"
|
||||
|
||||
@@ -0,0 +1,112 @@
|
||||
package net.awan.pipelines.ui
|
||||
|
||||
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). The panes stack left to right and each leaves a peek of the pane it
|
||||
* covers.
|
||||
*/
|
||||
enum class MasterPane { List, Detail, Stage }
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
const val MAX_PANE_DEPTH = 2
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* Geometry (peek width, insets, measured pane widths) is deliberately *not* part
|
||||
* of this model; it is derived from layout so nothing is hardcoded here.
|
||||
*/
|
||||
data class PaneSelection(
|
||||
val pane: MasterPane = MasterPane.List,
|
||||
val itemId: Long = 0L,
|
||||
val itemVersion: Int = 0,
|
||||
val sectionIndex: Int = 0,
|
||||
val stageKey: String? = null,
|
||||
val stageVisit: Int = 0,
|
||||
) {
|
||||
/** How many panes are stacked: 0 list, 1 detail, 2 stage. */
|
||||
val depth: Int
|
||||
get() = when (pane) {
|
||||
MasterPane.List -> 0
|
||||
MasterPane.Detail -> 1
|
||||
MasterPane.Stage -> 2
|
||||
}
|
||||
}
|
||||
|
||||
/** The result of one Back step: show a new selection, or leave the app. */
|
||||
sealed interface BackResult {
|
||||
/** The list is showing, so Back leaves the app (no pane to close). */
|
||||
data object Exit : BackResult
|
||||
|
||||
/** Show [selection] (exactly one pane level back). */
|
||||
data class Show(val selection: PaneSelection) : 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.
|
||||
*/
|
||||
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),
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 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).
|
||||
*/
|
||||
fun popTo(selection: PaneSelection, level: Int): PaneSelection = when {
|
||||
level <= 0 -> PaneSelection()
|
||||
level == 1 -> selection.copy(pane = MasterPane.Detail, stageKey = null, stageVisit = 0)
|
||||
else -> selection
|
||||
}
|
||||
|
||||
/**
|
||||
* Encodes a [PaneSelection] as Bundle-able primitives (a small `List<Any>`), so
|
||||
* the saved state stays tiny. Paired with [decodePaneSelection].
|
||||
*/
|
||||
internal fun encodePaneSelection(selection: PaneSelection): List<Any> = listOf(
|
||||
selection.pane.name,
|
||||
selection.itemId,
|
||||
selection.itemVersion,
|
||||
selection.sectionIndex,
|
||||
selection.stageKey ?: "",
|
||||
selection.stageVisit,
|
||||
)
|
||||
|
||||
/** Restores a [PaneSelection] encoded by [encodePaneSelection]. */
|
||||
internal fun decodePaneSelection(encoded: List<Any>): PaneSelection = PaneSelection(
|
||||
pane = MasterPane.valueOf(encoded[0] as String),
|
||||
itemId = encoded[1] as Long,
|
||||
itemVersion = encoded[2] as Int,
|
||||
sectionIndex = encoded[3] as Int,
|
||||
stageKey = (encoded[4] as String).takeIf { it.isNotEmpty() },
|
||||
stageVisit = encoded[5] as Int,
|
||||
)
|
||||
|
||||
/**
|
||||
* Saves/restores a [PaneSelection] across configuration change and process
|
||||
* death. The save payload is primitives only (see [encodePaneSelection]).
|
||||
*/
|
||||
val PaneSelectionSaver: Saver<PaneSelection, List<Any>> = Saver(
|
||||
save = { encodePaneSelection(it) },
|
||||
restore = { decodePaneSelection(it) },
|
||||
)
|
||||
@@ -1,5 +1,6 @@
|
||||
package net.awan.pipelines.ui
|
||||
|
||||
import androidx.activity.compose.PredictiveBackHandler
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
@@ -7,33 +8,25 @@ import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.WindowInsets
|
||||
import androidx.compose.foundation.layout.consumeWindowInsets
|
||||
import androidx.compose.foundation.layout.fillMaxHeight
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.navigationBars
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.layout.statusBars
|
||||
import androidx.compose.foundation.layout.width
|
||||
import androidx.compose.foundation.layout.windowInsetsPadding
|
||||
import androidx.compose.foundation.selection.selectable
|
||||
import androidx.compose.foundation.shape.CircleShape
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.automirrored.filled.KeyboardArrowLeft
|
||||
import androidx.compose.material.icons.automirrored.filled.KeyboardArrowRight
|
||||
import androidx.compose.material.icons.filled.AccountTree
|
||||
import androidx.compose.material.icons.filled.History
|
||||
import androidx.compose.material.icons.filled.Settings
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.IconButton
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Scaffold
|
||||
import androidx.compose.material3.Surface
|
||||
import androidx.compose.material3.VerticalDivider
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableIntStateOf
|
||||
import androidx.compose.runtime.mutableLongStateOf
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.saveable.rememberSaveable
|
||||
import androidx.compose.runtime.setValue
|
||||
@@ -46,15 +39,19 @@ import androidx.compose.ui.platform.LocalConfiguration
|
||||
import androidx.compose.ui.semantics.Role
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import androidx.navigation.NavType
|
||||
import androidx.navigation.compose.NavHost
|
||||
import androidx.navigation.compose.composable
|
||||
import androidx.navigation.compose.currentBackStackEntryAsState
|
||||
import androidx.navigation.compose.rememberNavController
|
||||
import androidx.navigation.navArgument
|
||||
import kotlinx.coroutines.flow.collect
|
||||
import net.awan.pipelines.data.transport.ConnectionState
|
||||
import net.awan.pipelines.ui.components.ConnectionBanner
|
||||
import net.awan.pipelines.ui.components.EmptyState
|
||||
import net.awan.pipelines.ui.components.SlidingPaneStack
|
||||
import net.awan.pipelines.ui.components.clampTabIndex
|
||||
import net.awan.pipelines.ui.components.pipelineDetailTabs
|
||||
import net.awan.pipelines.ui.components.runDetailTabs
|
||||
import net.awan.pipelines.ui.graph.PipelineStagePane
|
||||
import net.awan.pipelines.ui.graph.RunStagePane
|
||||
import net.awan.pipelines.ui.screens.PipelineDetailScreen
|
||||
import net.awan.pipelines.ui.screens.PipelineListScreen
|
||||
import net.awan.pipelines.ui.screens.RunDetailScreen
|
||||
@@ -70,14 +67,23 @@ private val destinations = listOf(
|
||||
)
|
||||
|
||||
/**
|
||||
* Whether [route]'s destination is the current one. A detail route
|
||||
* (`pipeline/…`/`run/…`) belongs to its list destination, so the floating pill
|
||||
* keeps the right destination selected while a detail is open.
|
||||
* Whether [route] is the current destination. Detail panes are no longer
|
||||
* separate routes (they are saved state inside a destination), so this is a
|
||||
* plain equality check.
|
||||
*/
|
||||
internal fun destinationSelected(currentRoute: String?, route: String): Boolean =
|
||||
currentRoute == route ||
|
||||
(route == "pipelines" && currentRoute?.startsWith("pipeline/") == true) ||
|
||||
(route == "runs" && currentRoute?.startsWith("run/") == true)
|
||||
currentRoute == route
|
||||
|
||||
/**
|
||||
* One Back step as a selection update. The peek tap, the detail's top-bar back
|
||||
* button and the system Back button/gesture all call through here, so a section
|
||||
* never disagrees with the pane.
|
||||
*/
|
||||
private fun backFrom(selection: PaneSelection): PaneSelection =
|
||||
when (val result = backStep(selection)) {
|
||||
is BackResult.Show -> result.selection
|
||||
BackResult.Exit -> selection
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun PipelinesApp(vm: AppViewModel) {
|
||||
@@ -86,10 +92,16 @@ fun PipelinesApp(vm: AppViewModel) {
|
||||
val currentRoute = backStackEntry?.destination?.route
|
||||
val connectionState by vm.connectionState.collectAsStateWithLifecycle()
|
||||
val configuredUrl by vm.configuredServerUrl.collectAsStateWithLifecycle()
|
||||
// Window-size driven (never a hardcoded device): a foldable's narrow cover
|
||||
// display stays single-pane, its wide inner display shows list + detail.
|
||||
// Window-size driven (never a hardcoded device): the same sliding pane works at
|
||||
// every width; only the section index presentation (tab row vs rail) changes.
|
||||
val wide = isWideLayout(LocalConfiguration.current.screenWidthDp)
|
||||
|
||||
// The Runs destination's selection is hoisted here so the Pipelines detail can
|
||||
// jump to a freshly started run (there is no longer a run route to navigate to).
|
||||
var runSelection by rememberSaveable(stateSaver = PaneSelectionSaver) {
|
||||
mutableStateOf(PaneSelection())
|
||||
}
|
||||
|
||||
val onNavigate: (TopDestination) -> Unit = { destination ->
|
||||
if (currentRoute != destination.route) {
|
||||
navController.navigate(destination.route) {
|
||||
@@ -134,47 +146,24 @@ fun PipelinesApp(vm: AppViewModel) {
|
||||
),
|
||||
) {
|
||||
composable("pipelines") {
|
||||
if (wide) {
|
||||
WidePipelinePane(
|
||||
vm = vm,
|
||||
onOpenRun = { runId -> navController.navigate("run/$runId") },
|
||||
)
|
||||
} else {
|
||||
PipelineListScreen(vm, onOpen = { id, version ->
|
||||
navController.navigate("pipeline/$id/$version")
|
||||
})
|
||||
}
|
||||
}
|
||||
composable(
|
||||
route = "pipeline/{id}/{version}",
|
||||
arguments = listOf(
|
||||
navArgument("id") { type = NavType.LongType },
|
||||
navArgument("version") { type = NavType.IntType },
|
||||
),
|
||||
) { entry ->
|
||||
PipelineDetailScreen(
|
||||
PipelineDestination(
|
||||
vm = vm,
|
||||
pipelineId = entry.arguments?.getLong("id") ?: 0L,
|
||||
version = entry.arguments?.getInt("version") ?: 0,
|
||||
onBack = { navController.popBackStack() },
|
||||
onOpenRun = { runId -> navController.navigate("run/$runId") },
|
||||
wide = wide,
|
||||
onOpenRun = { runId ->
|
||||
runSelection = PaneSelection(
|
||||
pane = MasterPane.Detail,
|
||||
itemId = runId,
|
||||
)
|
||||
navController.navigate("runs") { launchSingleTop = true }
|
||||
},
|
||||
)
|
||||
}
|
||||
composable("runs") {
|
||||
if (wide) {
|
||||
WideRunPane(vm)
|
||||
} else {
|
||||
RunHistoryScreen(vm, onOpenRun = { runId -> navController.navigate("run/$runId") })
|
||||
}
|
||||
}
|
||||
composable(
|
||||
route = "run/{id}",
|
||||
arguments = listOf(navArgument("id") { type = NavType.LongType }),
|
||||
) { entry ->
|
||||
RunDetailScreen(
|
||||
RunsDestination(
|
||||
vm = vm,
|
||||
runId = entry.arguments?.getLong("id") ?: 0L,
|
||||
onBack = { navController.popBackStack() },
|
||||
wide = wide,
|
||||
selection = runSelection,
|
||||
onSelectionChange = { runSelection = it },
|
||||
)
|
||||
}
|
||||
composable("settings") {
|
||||
@@ -195,6 +184,138 @@ fun PipelinesApp(vm: AppViewModel) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The Pipelines destination: one sliding pane stack whose pane 0 is the pipeline
|
||||
* list, pane 1 is the selected pipeline (Summary/Graph/Source) and pane 2 is the
|
||||
* stage pane for a graph node. The saved [PaneSelection] survives rotation,
|
||||
* configuration change and process death. Back (gesture/button) and the nearest
|
||||
* peek tap both step back exactly one level via [backFrom]; tapping a lower peek
|
||||
* closes every pane to its right via [popTo].
|
||||
*/
|
||||
@Composable
|
||||
private fun PipelineDestination(vm: AppViewModel, wide: Boolean, onOpenRun: (Long) -> Unit) {
|
||||
var selection by rememberSaveable(stateSaver = PaneSelectionSaver) {
|
||||
mutableStateOf(PaneSelection())
|
||||
}
|
||||
val depth = selection.depth
|
||||
val onBack: () -> Unit = { selection = backFrom(selection) }
|
||||
|
||||
PredictiveBackHandler(enabled = depth >= 1) { progress ->
|
||||
// Consume the gesture; on completion perform exactly one Back step.
|
||||
progress.collect { }
|
||||
onBack()
|
||||
}
|
||||
|
||||
SlidingPaneStack(
|
||||
depth = depth,
|
||||
onPopTo = { level -> selection = popTo(selection, level) },
|
||||
backContentDescription = { level -> if (level == 0) "Back to pipelines" else "Back to pipeline" },
|
||||
pane = { level, paneModifier ->
|
||||
when (level) {
|
||||
0 -> PipelineListScreen(
|
||||
vm = vm,
|
||||
onOpen = { id, version ->
|
||||
selection = PaneSelection(MasterPane.Detail, id, version)
|
||||
},
|
||||
modifier = paneModifier,
|
||||
selectedId = selection.itemId.takeIf { depth >= 1 },
|
||||
)
|
||||
1 -> if (selection.itemId != 0L) {
|
||||
PipelineDetailScreen(
|
||||
vm = vm,
|
||||
pipelineId = selection.itemId,
|
||||
version = selection.itemVersion,
|
||||
onBack = onBack,
|
||||
onOpenRun = onOpenRun,
|
||||
selectedSection = clampTabIndex(selection.sectionIndex, pipelineDetailTabs.size),
|
||||
onSelectSection = { selection = selection.copy(sectionIndex = it) },
|
||||
modifier = paneModifier,
|
||||
wide = wide,
|
||||
onOpenStage = { key ->
|
||||
selection = selection.copy(pane = MasterPane.Stage, stageKey = key, stageVisit = 0)
|
||||
},
|
||||
)
|
||||
}
|
||||
2 -> selection.stageKey?.let { key ->
|
||||
PipelineStagePane(
|
||||
vm = vm,
|
||||
pipelineId = selection.itemId,
|
||||
version = selection.itemVersion,
|
||||
stageKey = key,
|
||||
onBack = onBack,
|
||||
wide = wide,
|
||||
modifier = paneModifier,
|
||||
)
|
||||
}
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* The Runs destination: the same shared pane stack with the run list, the
|
||||
* selected run's tabs and the stage pane. Its selection is owned by
|
||||
* [PipelinesApp] so the Pipelines detail can open a run it just started.
|
||||
*/
|
||||
@Composable
|
||||
private fun RunsDestination(
|
||||
vm: AppViewModel,
|
||||
wide: Boolean,
|
||||
selection: PaneSelection,
|
||||
onSelectionChange: (PaneSelection) -> Unit,
|
||||
) {
|
||||
val depth = selection.depth
|
||||
val onBack: () -> Unit = { onSelectionChange(backFrom(selection)) }
|
||||
|
||||
PredictiveBackHandler(enabled = depth >= 1) { progress ->
|
||||
progress.collect { }
|
||||
onBack()
|
||||
}
|
||||
|
||||
SlidingPaneStack(
|
||||
depth = depth,
|
||||
onPopTo = { level -> onSelectionChange(popTo(selection, level)) },
|
||||
backContentDescription = { level -> if (level == 0) "Back to runs" else "Back to run" },
|
||||
pane = { level, paneModifier ->
|
||||
when (level) {
|
||||
0 -> RunHistoryScreen(
|
||||
vm = vm,
|
||||
onOpenRun = { runId -> onSelectionChange(PaneSelection(MasterPane.Detail, runId)) },
|
||||
modifier = paneModifier,
|
||||
selectedRunId = selection.itemId.takeIf { depth >= 1 },
|
||||
)
|
||||
1 -> if (selection.itemId != 0L) {
|
||||
RunDetailScreen(
|
||||
vm = vm,
|
||||
runId = selection.itemId,
|
||||
onBack = onBack,
|
||||
selectedSection = clampTabIndex(selection.sectionIndex, runDetailTabs.size),
|
||||
onSelectSection = { onSelectionChange(selection.copy(sectionIndex = it)) },
|
||||
modifier = paneModifier,
|
||||
wide = wide,
|
||||
onOpenStage = { key, visit ->
|
||||
onSelectionChange(
|
||||
selection.copy(pane = MasterPane.Stage, stageKey = key, stageVisit = visit),
|
||||
)
|
||||
},
|
||||
)
|
||||
}
|
||||
2 -> selection.stageKey?.let { key ->
|
||||
RunStagePane(
|
||||
vm = vm,
|
||||
runId = selection.itemId,
|
||||
stageKey = key,
|
||||
visitIndex = selection.stageVisit,
|
||||
onBack = onBack,
|
||||
wide = wide,
|
||||
modifier = paneModifier,
|
||||
)
|
||||
}
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* The Pipelines/Runs/Settings destinations as a floating rounded pill at the
|
||||
* bottom right: the three destinations as icons, inset from the bottom/right
|
||||
@@ -258,124 +379,6 @@ private fun DestinationPill(
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Wide Pipelines destination: the pipeline list beside the selected pipeline's
|
||||
* tabs. The selection is remembered across config changes and Back inside the
|
||||
* detail clears it (rather than popping a route that is not on the stack). The
|
||||
* list pane collapses to a narrow strip (remembered/saved across configuration
|
||||
* changes); the freed width goes to the detail.
|
||||
*/
|
||||
@Composable
|
||||
private fun WidePipelinePane(vm: AppViewModel, onOpenRun: (Long) -> Unit) {
|
||||
var selectedId by rememberSaveable { mutableStateOf<Long?>(null) }
|
||||
var selectedVersion by rememberSaveable { mutableIntStateOf(0) }
|
||||
var paneExpanded by rememberSaveable { mutableStateOf(true) }
|
||||
Row(Modifier.fillMaxSize()) {
|
||||
if (paneExpanded) {
|
||||
Box(Modifier.width(LIST_PANE_WIDTH).fillMaxHeight()) {
|
||||
PipelineListScreen(
|
||||
vm,
|
||||
onOpen = { id, version ->
|
||||
selectedId = id
|
||||
selectedVersion = version
|
||||
},
|
||||
selectedId = selectedId,
|
||||
onTogglePane = { paneExpanded = false },
|
||||
)
|
||||
}
|
||||
VerticalDivider()
|
||||
} else {
|
||||
CollapsedListPane(paneExpanded = false, onToggle = { paneExpanded = true })
|
||||
VerticalDivider()
|
||||
}
|
||||
Box(Modifier.weight(1f).fillMaxHeight()) {
|
||||
val id = selectedId
|
||||
if (id == null) {
|
||||
EmptyState("Select a pipeline to see its Summary, Graph and Source.")
|
||||
} else {
|
||||
PipelineDetailScreen(
|
||||
vm = vm,
|
||||
pipelineId = id,
|
||||
version = selectedVersion,
|
||||
onBack = { selectedId = null },
|
||||
onOpenRun = onOpenRun,
|
||||
wide = true,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Wide Runs destination: the run list beside the selected run's tabs. The
|
||||
* selection is remembered across config changes and Back inside the detail clears
|
||||
* it instead of popping. The list pane collapses to a narrow strip exactly like
|
||||
* the pipelines pane.
|
||||
*/
|
||||
@Composable
|
||||
private fun WideRunPane(vm: AppViewModel) {
|
||||
var selectedRunId by rememberSaveable { mutableLongStateOf(0L) }
|
||||
var paneExpanded by rememberSaveable { mutableStateOf(true) }
|
||||
Row(Modifier.fillMaxSize()) {
|
||||
if (paneExpanded) {
|
||||
Box(Modifier.width(LIST_PANE_WIDTH).fillMaxHeight()) {
|
||||
RunHistoryScreen(
|
||||
vm,
|
||||
onOpenRun = { selectedRunId = it },
|
||||
selectedRunId = selectedRunId,
|
||||
onTogglePane = { paneExpanded = false },
|
||||
)
|
||||
}
|
||||
VerticalDivider()
|
||||
} else {
|
||||
CollapsedListPane(paneExpanded = false, onToggle = { paneExpanded = true })
|
||||
VerticalDivider()
|
||||
}
|
||||
Box(Modifier.weight(1f).fillMaxHeight()) {
|
||||
if (selectedRunId == 0L) {
|
||||
EmptyState("Select a run to see its Summary, Graph, Input, Output, Evidence and Timeline.")
|
||||
} else {
|
||||
RunDetailScreen(
|
||||
vm = vm,
|
||||
runId = selectedRunId,
|
||||
onBack = { selectedRunId = 0L },
|
||||
wide = true,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The collapsed list pane: a narrow strip holding only the control that restores
|
||||
* the pane, with an accurate accessibility label. Reuses the tab rail's
|
||||
* chevron-toggle idiom.
|
||||
*/
|
||||
@Composable
|
||||
private fun CollapsedListPane(paneExpanded: Boolean, onToggle: () -> Unit) {
|
||||
Column(
|
||||
modifier = Modifier.width(COLLAPSED_LIST_PANE_WIDTH).fillMaxHeight(),
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
) {
|
||||
IconButton(onClick = onToggle, modifier = Modifier.padding(top = 8.dp)) {
|
||||
Icon(
|
||||
imageVector = if (paneExpanded) {
|
||||
Icons.AutoMirrored.Filled.KeyboardArrowLeft
|
||||
} else {
|
||||
Icons.AutoMirrored.Filled.KeyboardArrowRight
|
||||
},
|
||||
contentDescription = if (paneExpanded) "Collapse list pane" else "Expand list pane",
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Width of the master list pane in the wide two-pane layout. */
|
||||
private val LIST_PANE_WIDTH = 360.dp
|
||||
|
||||
/** Width of the collapsed master list pane (its restore control only). */
|
||||
private val COLLAPSED_LIST_PANE_WIDTH = 56.dp
|
||||
|
||||
/** Bottom space reserved for the floating destination pill, so content is never
|
||||
* permanently hidden behind it (pill height + its margins + a small gap). */
|
||||
private val DESTINATION_PILL_RESERVE = 88.dp
|
||||
|
||||
@@ -12,13 +12,13 @@ import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.layout.width
|
||||
import androidx.compose.foundation.layout.widthIn
|
||||
import androidx.compose.foundation.pager.HorizontalPager
|
||||
import androidx.compose.foundation.pager.rememberPagerState
|
||||
import androidx.compose.foundation.selection.selectable
|
||||
import androidx.compose.foundation.selection.selectableGroup
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.automirrored.filled.FactCheck
|
||||
import androidx.compose.material.icons.automirrored.filled.Input
|
||||
import androidx.compose.material.icons.automirrored.filled.KeyboardArrowLeft
|
||||
import androidx.compose.material.icons.automirrored.filled.KeyboardArrowRight
|
||||
import androidx.compose.material.icons.automirrored.filled.List
|
||||
import androidx.compose.material.icons.automirrored.filled.Send
|
||||
import androidx.compose.material.icons.filled.Code
|
||||
@@ -26,19 +26,21 @@ import androidx.compose.material.icons.filled.Hub
|
||||
import androidx.compose.material.icons.filled.Info
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.IconButton
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.PrimaryScrollableTabRow
|
||||
import androidx.compose.material3.Tab
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.VerticalDivider
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.Stable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.rememberUpdatedState
|
||||
import androidx.compose.runtime.saveable.Saver
|
||||
import androidx.compose.runtime.saveable.rememberSaveable
|
||||
import androidx.compose.runtime.snapshotFlow
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
@@ -47,12 +49,12 @@ import androidx.compose.ui.graphics.vector.ImageVector
|
||||
import androidx.compose.ui.semantics.Role
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.unit.dp
|
||||
import kotlinx.coroutines.flow.distinctUntilChanged
|
||||
import net.awan.pipelines.ui.theme.pipelinesText
|
||||
|
||||
/**
|
||||
* A named detail page tab: [key] is stable for `when` dispatch, [title] is shown,
|
||||
* and [icon] is the tab's glyph (used on the wide rail, always alongside the
|
||||
* label when expanded and alone when it is collapsed).
|
||||
* and [icon] is the tab's glyph on the wide rail.
|
||||
*/
|
||||
data class DetailTab(val key: String, val title: String, val icon: ImageVector)
|
||||
|
||||
@@ -81,15 +83,19 @@ fun clampTabIndex(index: Int, tabCount: Int): Int =
|
||||
if (tabCount <= 0) 0 else index.coerceIn(0, tabCount - 1)
|
||||
|
||||
/**
|
||||
* A tab host that renders the tab strip and *only* the selected tab's content
|
||||
* (the caller's `when`), so switching tabs never composes every tab at once.
|
||||
* The section index + its panel, open to the right. On narrow windows the index
|
||||
* is a horizontally scrolling Material 3 [PrimaryScrollableTabRow]; on wide
|
||||
* windows it is an always-visible selectable rail. Both stay fixed and visible
|
||||
* while the sections themselves live in a [HorizontalPager], so tapping a
|
||||
* section slides its panel in from the right (and a later section enters from the
|
||||
* right, an earlier one from the left as the pager follows the index order);
|
||||
* swiping switches sections too.
|
||||
*
|
||||
* Narrow windows get a horizontally scrolling Material 3 [PrimaryScrollableTabRow]
|
||||
* (the run detail's six tabs scroll on a cover display); wide windows get a
|
||||
* vertical selectable rail that collapses to a narrow icon-only strip and expands
|
||||
* back to icons with labels, remembered across configuration changes. Both carry
|
||||
* real tab semantics (`Role.Tab` + selected state), so selection is never
|
||||
* conveyed by colour alone.
|
||||
* The pager composes only the visible page at rest (the default
|
||||
* `beyondViewportPageCount`), preserving the previous laziness. `selectedIndex`
|
||||
* is the single source of truth: a change from outside (e.g. Back) scrolls the
|
||||
* pager, and a settled pager (a tap or a swipe) reports the new index through
|
||||
* [onSelect]. The two are guarded against feedback loops.
|
||||
*/
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
@@ -101,34 +107,50 @@ fun DetailTabs(
|
||||
modifier: Modifier = Modifier,
|
||||
content: @Composable (DetailTab, Modifier) -> Unit,
|
||||
) {
|
||||
val selected = clampTabIndex(selectedIndex, tabs.size)
|
||||
if (tabs.isEmpty()) return
|
||||
val selected = clampTabIndex(selectedIndex, tabs.size)
|
||||
val pagerState = rememberPagerState(initialPage = selected, pageCount = { tabs.size })
|
||||
|
||||
// External selection (Back, or a restored index) moves the pager; skip while
|
||||
// a finger is down so a swipe is never fought mid-gesture.
|
||||
LaunchedEffect(selected, tabs.size) {
|
||||
if (!pagerState.isScrollInProgress && pagerState.settledPage != selected) {
|
||||
pagerState.animateScrollToPage(selected)
|
||||
}
|
||||
}
|
||||
// A settled pager (tab tap or swipe) reports the section up. Keyed only on the
|
||||
// pager so it is never restarted; the callback is read through a fresh state.
|
||||
val report by rememberUpdatedState(onSelect)
|
||||
LaunchedEffect(pagerState) {
|
||||
snapshotFlow { pagerState.settledPage }
|
||||
.distinctUntilChanged()
|
||||
.collect { report(it) }
|
||||
}
|
||||
|
||||
val page: @Composable (Int) -> Unit = { index ->
|
||||
content(tabs[clampTabIndex(index, tabs.size)], Modifier.fillMaxSize())
|
||||
}
|
||||
|
||||
if (wide) {
|
||||
// Remembered/saved so the collapsed or expanded rail survives
|
||||
// recomposition and configuration changes.
|
||||
var railExpanded by rememberSaveable { mutableStateOf(true) }
|
||||
Row(modifier.fillMaxSize()) {
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.width(railWidthDp(railExpanded).dp)
|
||||
.width(WIDE_RAIL_WIDTH_DP.dp)
|
||||
.fillMaxHeight()
|
||||
.padding(vertical = 8.dp),
|
||||
) {
|
||||
RailToggle(expanded = railExpanded, onToggle = { railExpanded = !railExpanded })
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.weight(1f)
|
||||
.fillMaxWidth()
|
||||
.selectableGroup()
|
||||
.padding(top = 4.dp, bottom = 8.dp),
|
||||
.padding(top = 8.dp, bottom = 8.dp),
|
||||
verticalArrangement = Arrangement.spacedBy(4.dp),
|
||||
) {
|
||||
tabs.forEachIndexed { index, tab ->
|
||||
RailTab(
|
||||
tab = tab,
|
||||
selected = index == selected,
|
||||
expanded = railExpanded,
|
||||
onClick = { onSelect(index) },
|
||||
)
|
||||
}
|
||||
@@ -136,7 +158,9 @@ fun DetailTabs(
|
||||
}
|
||||
VerticalDivider()
|
||||
Box(Modifier.weight(1f).fillMaxHeight()) {
|
||||
content(tabs[selected], Modifier.fillMaxSize())
|
||||
HorizontalPager(state = pagerState, modifier = Modifier.fillMaxSize()) { index ->
|
||||
page(index)
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -150,41 +174,22 @@ fun DetailTabs(
|
||||
)
|
||||
}
|
||||
}
|
||||
Box(Modifier.weight(1f).fillMaxWidth()) {
|
||||
content(tabs[selected], Modifier.fillMaxSize())
|
||||
HorizontalPager(
|
||||
state = pagerState,
|
||||
modifier = Modifier.weight(1f).fillMaxWidth(),
|
||||
) { index ->
|
||||
page(index)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** The accessibility-labelled control that collapses/expands the wide rail. */
|
||||
@Composable
|
||||
private fun RailToggle(expanded: Boolean, onToggle: () -> Unit) {
|
||||
Row(
|
||||
modifier = Modifier.fillMaxWidth().padding(horizontal = 4.dp),
|
||||
horizontalArrangement = if (expanded) Arrangement.End else Arrangement.Center,
|
||||
) {
|
||||
IconButton(onClick = onToggle) {
|
||||
Icon(
|
||||
imageVector = if (expanded) {
|
||||
Icons.AutoMirrored.Filled.KeyboardArrowLeft
|
||||
} else {
|
||||
Icons.AutoMirrored.Filled.KeyboardArrowRight
|
||||
},
|
||||
contentDescription = if (expanded) "Collapse tabs" else "Expand tabs",
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* One wide-rail tab. Expanded it is an icon+label row; collapsed it is an
|
||||
* icon-only tile whose icon carries the [DetailTab.title] as its content
|
||||
* description. Selection is conveyed by the tab semantics (Role.Tab + selected)
|
||||
* and the container colour, not colour alone.
|
||||
* One wide-rail tab: an icon+label row. Selection is conveyed by the tab
|
||||
* semantics (Role.Tab + selected) and the container colour, not colour alone.
|
||||
*/
|
||||
@Composable
|
||||
private fun RailTab(tab: DetailTab, selected: Boolean, expanded: Boolean, onClick: () -> Unit) {
|
||||
private fun RailTab(tab: DetailTab, selected: Boolean, onClick: () -> Unit) {
|
||||
val text = pipelinesText()
|
||||
val contentColor = if (selected) {
|
||||
MaterialTheme.colorScheme.onSecondaryContainer
|
||||
@@ -198,31 +203,24 @@ private fun RailTab(tab: DetailTab, selected: Boolean, expanded: Boolean, onClic
|
||||
.background(
|
||||
if (selected) MaterialTheme.colorScheme.secondaryContainer else Color.Transparent,
|
||||
)
|
||||
.padding(horizontal = if (expanded) 16.dp else 0.dp, vertical = 12.dp),
|
||||
.padding(horizontal = 16.dp, vertical = 12.dp),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = if (expanded) {
|
||||
Arrangement.spacedBy(12.dp)
|
||||
} else {
|
||||
Arrangement.Center
|
||||
},
|
||||
horizontalArrangement = Arrangement.spacedBy(12.dp),
|
||||
) {
|
||||
Icon(
|
||||
imageVector = tab.icon,
|
||||
// When expanded the label names the tab, so the glyph is decorative;
|
||||
// collapsed the glyph is the only visible affordance and names it.
|
||||
contentDescription = if (expanded) null else tab.title,
|
||||
// The label names the tab, so the glyph is decorative.
|
||||
contentDescription = null,
|
||||
tint = contentColor,
|
||||
modifier = Modifier.size(24.dp),
|
||||
)
|
||||
if (expanded) {
|
||||
Text(
|
||||
text = tab.title,
|
||||
style = text.cardTitle,
|
||||
color = contentColor,
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
)
|
||||
}
|
||||
Text(
|
||||
text = tab.title,
|
||||
style = text.cardTitle,
|
||||
color = contentColor,
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -281,12 +279,8 @@ fun rememberSectionExpansion(vararg inputs: Any?): SectionExpansionState {
|
||||
return remember(expanded) { SectionExpansionState(expanded) }
|
||||
}
|
||||
|
||||
/** The always-visible wide section rail's width (icons with labels). */
|
||||
private const val WIDE_RAIL_WIDTH_DP = 200
|
||||
private const val COLLAPSED_RAIL_WIDTH_DP = 64
|
||||
|
||||
/** Rail width in dp: icons with labels when expanded, icon-only when collapsed. */
|
||||
internal fun railWidthDp(expanded: Boolean): Int =
|
||||
if (expanded) WIDE_RAIL_WIDTH_DP else COLLAPSED_RAIL_WIDTH_DP
|
||||
|
||||
/** Comfortable max text width for a tab body on a wide window. */
|
||||
const val DETAIL_MAX_WIDTH_DP = 840
|
||||
|
||||
@@ -0,0 +1,175 @@
|
||||
package net.awan.pipelines.ui.components
|
||||
|
||||
import androidx.compose.animation.core.animateDpAsState
|
||||
import androidx.compose.animation.core.spring
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.BoxWithConstraints
|
||||
import androidx.compose.foundation.layout.WindowInsets
|
||||
import androidx.compose.foundation.layout.asPaddingValues
|
||||
import androidx.compose.foundation.layout.fillMaxHeight
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.offset
|
||||
import androidx.compose.foundation.layout.systemBars
|
||||
import androidx.compose.foundation.layout.systemGestures
|
||||
import androidx.compose.foundation.layout.union
|
||||
import androidx.compose.foundation.layout.width
|
||||
import androidx.compose.material3.LocalMinimumInteractiveComponentSize
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.input.pointer.PointerEventPass
|
||||
import androidx.compose.ui.input.pointer.pointerInput
|
||||
import androidx.compose.ui.platform.LocalLayoutDirection
|
||||
import androidx.compose.ui.semantics.Role
|
||||
import androidx.compose.ui.semantics.clearAndSetSemantics
|
||||
import androidx.compose.ui.semantics.contentDescription
|
||||
import androidx.compose.ui.semantics.role
|
||||
import androidx.compose.ui.semantics.semantics
|
||||
import androidx.compose.ui.unit.Dp
|
||||
import androidx.compose.ui.unit.dp
|
||||
import net.awan.pipelines.ui.MAX_PANE_DEPTH
|
||||
|
||||
/**
|
||||
* The one named minimum width of the visible peek strip left of an open pane.
|
||||
* The actual peek is derived from this and the platform's minimum interactive
|
||||
* size, widened further by the left system-gesture inset so the *tappable* strip
|
||||
* (after that inset) is still at least the minimum interactive size.
|
||||
*/
|
||||
private val PEEK_WIDTH_DP = 56.dp
|
||||
|
||||
/**
|
||||
* The visible peek width: at least [PEEK_WIDTH_DP], and always wide enough that
|
||||
* the tappable strip left after [startInset] is at least [minimumInteractive].
|
||||
* Pure so the geometry is unit-testable without a device.
|
||||
*/
|
||||
internal fun peekWidthDp(minimumInteractive: Dp, startInset: Dp = 0.dp): Dp =
|
||||
maxOf(PEEK_WIDTH_DP, minimumInteractive + startInset)
|
||||
|
||||
/**
|
||||
* The x offset of pane [level] when it is open: one peek per level, so each
|
||||
* covered pane keeps exactly one peek visible. Derived, never a magic offset.
|
||||
*/
|
||||
internal fun paneOffsetDp(level: Int, peek: Dp): Dp = peek * level
|
||||
|
||||
/**
|
||||
* The width of pane [level]: the measured host width minus the peeks it leaves
|
||||
* visible to its left. Derived from the measured width, never hardcoded.
|
||||
*/
|
||||
internal fun paneWidthDp(hostWidth: Dp, level: Int, peek: Dp): Dp =
|
||||
maxOf(0.dp, hostWidth - peek * level)
|
||||
|
||||
/**
|
||||
* The one shared sliding pane stack: pane 0 (the list) fills the host and each
|
||||
* deeper pane overlays the one below, sliding in from the right until a peek
|
||||
* strip of the pane it covers stays visible on the left. Both the Pipelines and
|
||||
* Runs destinations use this, so the motion and geometry live in exactly one
|
||||
* place, and the stage pane is the same third level as the detail.
|
||||
*
|
||||
* [depth] is the number of visible panes minus one (0..[MAX_PANE_DEPTH]);
|
||||
* [pane] composes the level's content and is expected to render nothing for a
|
||||
* level whose selection is empty (so a closing pane simply slides back out).
|
||||
* Tapping a covered pane's peek calls [onPopTo] with that pane's level, closing
|
||||
* every pane to its right; [backContentDescription] names each strip.
|
||||
*
|
||||
* Every pane is always composed and each level has its own long-lived
|
||||
* [animateDpAsState], so opening slides in and closing slides back out with no
|
||||
* first-frame hack, and a rapid run of taps only retargets an existing animator
|
||||
* (never half-slid). A covered pane is hidden from accessibility and made
|
||||
* non-interactive so TalkBack focus follows the top pane and a tap can never leak
|
||||
* through to a covered one; only its peek strip stays tappable.
|
||||
*/
|
||||
@Composable
|
||||
fun SlidingPaneStack(
|
||||
depth: Int,
|
||||
onPopTo: (Int) -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
backContentDescription: (Int) -> String = { "Back" },
|
||||
pane: @Composable (level: Int, modifier: Modifier) -> Unit,
|
||||
) {
|
||||
BoxWithConstraints(modifier.fillMaxSize()) {
|
||||
// Measured once per layout. The insets are read once here and applied to
|
||||
// the strip node's geometry (not via a padding modifier, which would
|
||||
// shrink the pointer node to nothing once the gesture insets are wide).
|
||||
val hostWidth = maxWidth
|
||||
val insetPadding = WindowInsets.systemBars.union(WindowInsets.systemGestures)
|
||||
.asPaddingValues()
|
||||
val direction = LocalLayoutDirection.current
|
||||
val startInset = insetPadding.calculateLeftPadding(direction)
|
||||
val topInset = insetPadding.calculateTopPadding()
|
||||
val bottomInset = insetPadding.calculateBottomPadding()
|
||||
val peek = peekWidthDp(LocalMinimumInteractiveComponentSize.current, startInset)
|
||||
|
||||
// Pane 0 fills the host; it is blocked as soon as anything covers it.
|
||||
pane(
|
||||
0,
|
||||
Modifier
|
||||
.fillMaxSize()
|
||||
.then(if (depth >= 1) Modifier.blockPointerInput() else Modifier),
|
||||
)
|
||||
|
||||
// Panes 1..MAX are always composed (the animator stays warm); a level
|
||||
// beyond the depth sits off-screen and the caller renders nothing.
|
||||
for (level in 1..MAX_PANE_DEPTH) {
|
||||
val covered = level - 1
|
||||
if (covered < depth) {
|
||||
// The covered pane's tappable peek: clear of the status/nav bars,
|
||||
// of the left gesture area (startInset) and, via the peek
|
||||
// derivation, at least the minimum interactive size. Tapping it
|
||||
// closes every pane to its right.
|
||||
val stripOffset = if (covered == 0) startInset else peek * covered
|
||||
val stripWidth = if (covered == 0) peek - startInset else peek
|
||||
Box(
|
||||
Modifier
|
||||
.align(Alignment.TopStart)
|
||||
.offset(x = stripOffset, y = topInset)
|
||||
.width(maxOf(0.dp, stripWidth))
|
||||
.height(maxOf(0.dp, maxHeight - topInset - bottomInset))
|
||||
.clickable(
|
||||
role = Role.Button,
|
||||
onClickLabel = backContentDescription(covered),
|
||||
onClick = { onPopTo(covered) },
|
||||
)
|
||||
.semantics {
|
||||
contentDescription = backContentDescription(covered)
|
||||
role = Role.Button
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
val offset by animateDpAsState(
|
||||
targetValue = if (level <= depth) paneOffsetDp(level, peek) else hostWidth,
|
||||
animationSpec = spring(),
|
||||
label = "pane-slide-$level",
|
||||
)
|
||||
Box(
|
||||
Modifier
|
||||
.offset(x = offset)
|
||||
.width(paneWidthDp(hostWidth, level, peek))
|
||||
.fillMaxHeight()
|
||||
.then(if (level < depth) Modifier.blockPointerInput() else Modifier),
|
||||
) {
|
||||
pane(level, Modifier.fillMaxSize())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears a pane's semantics and consumes every pointer event, so a covered pane
|
||||
* is neither reachable by TalkBack nor tappable through the peek strip above it.
|
||||
* Consuming in the Initial pass stops the pane's own rows (which would otherwise
|
||||
* handle the event first, bottom-up); a peek strip is a separate, higher sibling
|
||||
* and is the only node hit where it sits, so its tap is never affected.
|
||||
*/
|
||||
private fun Modifier.blockPointerInput(): Modifier = this
|
||||
.clearAndSetSemantics { }
|
||||
.pointerInput(Unit) {
|
||||
awaitPointerEventScope {
|
||||
while (true) {
|
||||
awaitPointerEvent(PointerEventPass.Initial).changes.forEach { it.consume() }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import android.net.Uri
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.BoxWithConstraints
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
@@ -16,7 +17,6 @@ import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.automirrored.filled.InsertDriveFile
|
||||
import androidx.compose.material.icons.automirrored.filled.OpenInNew
|
||||
import androidx.compose.material.icons.filled.ContentCopy
|
||||
import androidx.compose.material.icons.filled.Image
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.IconButton
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
@@ -34,11 +34,13 @@ import androidx.compose.ui.platform.LocalClipboardManager
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.text.AnnotatedString
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.unit.Dp
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.window.Dialog
|
||||
import net.awan.pipelines.data.protocol.RunStep
|
||||
import net.awan.pipelines.data.protocol.StageArtifact
|
||||
import net.awan.pipelines.data.transport.ServerUrl
|
||||
import net.awan.pipelines.ui.ArtifactGroup
|
||||
import net.awan.pipelines.ui.artifactCaptureNotes
|
||||
import net.awan.pipelines.ui.artifactMetaLine
|
||||
import net.awan.pipelines.ui.artifactsSummary
|
||||
@@ -46,10 +48,11 @@ import net.awan.pipelines.ui.isImageContentType
|
||||
import net.awan.pipelines.ui.theme.pipelinesText
|
||||
|
||||
/**
|
||||
* The per-visit artifacts section for the stage detail sheet: the summary line
|
||||
* (matching the TUI's empty/partial wording), one row per file, and the
|
||||
* partial-capture notes. The single artifacts rendering path; it resolves each
|
||||
* url against the configured server URL and never hardcodes a host.
|
||||
* The per-visit artifacts section for the stage pane: the summary line (matching
|
||||
* the TUI's empty/partial wording), the capture notes, and the visit's own
|
||||
* artifacts rendered through the shared [ArtifactGallery]. The single artifacts
|
||||
* rendering path; it resolves each url against the configured server URL and
|
||||
* never hardcodes a host.
|
||||
*
|
||||
* When no server URL is configured the rows still show (name/size/type) but the
|
||||
* open/copy actions are disabled and a hint is shown.
|
||||
@@ -74,19 +77,136 @@ internal fun ArtifactsSection(
|
||||
style = text.meta,
|
||||
)
|
||||
}
|
||||
artifacts.forEach { artifact ->
|
||||
ArtifactRow(artifact, configuredServerUrl, fetchArtifactBytes)
|
||||
}
|
||||
notes.forEach { note -> Text(note, style = text.meta) }
|
||||
if (artifacts.isNotEmpty()) {
|
||||
// The section is already scoped to this visit, so no group header.
|
||||
val visit = step.control?.visit?.takeIf { it > 0 } ?: 1
|
||||
ArtifactGallery(
|
||||
groups = listOf(ArtifactGroup(step.stage, visit, artifacts)),
|
||||
configuredServerUrl = configuredServerUrl,
|
||||
fetchArtifactBytes = fetchArtifactBytes,
|
||||
showHeaders = false,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** One artifact: a type thumbnail (or inline preview), name, size/type, actions. */
|
||||
/**
|
||||
* The artifacts gallery: one group per (stage, visit) with a header, the group's
|
||||
* image artifacts as a grid of thumbnails (a tap opens the full-size view) and
|
||||
* its non-image artifacts as rows with name, size, content type and open/copy.
|
||||
* Every url is resolved with [ServerUrl.resolveArtifactUrl], so nothing here
|
||||
* hardcodes a host. The grid is built from non-lazy chunked [Row]s, so it never
|
||||
* nests a scrollable inside the Summary [LazyColumn] or the pane's scroll.
|
||||
*
|
||||
* The tile side is derived from the measured width (one [BoxWithConstraints]):
|
||||
* a fixed tile would overflow a narrow phone pane, so each tile is the widest
|
||||
* that fits the row up to the preferred [ARTIFACT_TILE_DP].
|
||||
*/
|
||||
@Composable
|
||||
internal fun ArtifactGallery(
|
||||
groups: List<ArtifactGroup>,
|
||||
configuredServerUrl: String,
|
||||
fetchArtifactBytes: suspend (String) -> ByteArray?,
|
||||
modifier: Modifier = Modifier,
|
||||
showHeaders: Boolean = true,
|
||||
) {
|
||||
val text = pipelinesText()
|
||||
BoxWithConstraints(modifier.fillMaxWidth()) {
|
||||
val tile = artifactTileDp(
|
||||
availableWidth = maxWidth,
|
||||
columns = ARTIFACT_GRID_COLUMNS,
|
||||
spacing = ARTIFACT_TILE_SPACING_DP,
|
||||
preferred = ARTIFACT_TILE_DP,
|
||||
)
|
||||
Column(Modifier.fillMaxWidth(), verticalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||
groups.forEach { group ->
|
||||
if (showHeaders) {
|
||||
Text(
|
||||
"${group.stageKey} · visit ${group.visit}",
|
||||
style = text.sectionHeader,
|
||||
)
|
||||
}
|
||||
val images = group.artifacts.filter { isImageContentType(it.contentType) }
|
||||
val others = group.artifacts.filterNot { isImageContentType(it.contentType) }
|
||||
images.chunked(ARTIFACT_GRID_COLUMNS).forEach { rowArtifacts ->
|
||||
Row(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
horizontalArrangement = Arrangement.spacedBy(ARTIFACT_TILE_SPACING_DP),
|
||||
) {
|
||||
rowArtifacts.forEach { artifact ->
|
||||
ArtifactTile(artifact, configuredServerUrl, fetchArtifactBytes, tile)
|
||||
}
|
||||
// Keep a partial last row's tiles aligned to the grid.
|
||||
repeat(ARTIFACT_GRID_COLUMNS - rowArtifacts.size) {
|
||||
Box(Modifier.size(tile))
|
||||
}
|
||||
}
|
||||
}
|
||||
others.forEach { artifact ->
|
||||
ArtifactRow(artifact, configuredServerUrl)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The side of one square gallery tile: the widest that fits [columns] tiles and
|
||||
* their gaps in [availableWidth], capped at the preferred [preferred] so a wide
|
||||
* window keeps compact thumbnails and a narrow one keeps every tile fully on
|
||||
* screen. Pure, so the fitting is unit-tested without a device.
|
||||
*/
|
||||
internal fun artifactTileDp(availableWidth: Dp, columns: Int, spacing: Dp, preferred: Dp): Dp {
|
||||
if (columns <= 0) return preferred
|
||||
val fit = (availableWidth - spacing * (columns - 1)) / columns
|
||||
return fit.coerceIn(0.dp, preferred)
|
||||
}
|
||||
|
||||
/** One image artifact as a square thumbnail that opens the full-size view. */
|
||||
@Composable
|
||||
private fun ArtifactTile(
|
||||
artifact: StageArtifact,
|
||||
configuredServerUrl: String,
|
||||
fetchArtifactBytes: suspend (String) -> ByteArray?,
|
||||
tile: Dp,
|
||||
) {
|
||||
// Resolve once per (url, configuration), not on every recomposition.
|
||||
val resolved = remember(artifact.url, configuredServerUrl) {
|
||||
ServerUrl.resolveArtifactUrl(configuredServerUrl, artifact.url)
|
||||
}
|
||||
var showFull by remember(artifact.url) { mutableStateOf(false) }
|
||||
|
||||
Box(
|
||||
Modifier
|
||||
.size(tile)
|
||||
.clip(RoundedCornerShape(12.dp))
|
||||
.clickable(enabled = resolved != null) { showFull = true },
|
||||
) {
|
||||
ArtifactImage(
|
||||
url = resolved ?: artifact.url,
|
||||
contentDescription = "Preview of ${artifact.name}",
|
||||
maxDim = THUMBNAIL_MAX_DIM,
|
||||
fetchBytes = fetchArtifactBytes,
|
||||
size = tile,
|
||||
)
|
||||
}
|
||||
|
||||
if (showFull && resolved != null) {
|
||||
FullSizeArtifactDialog(
|
||||
url = resolved,
|
||||
name = artifact.name,
|
||||
fetchBytes = fetchArtifactBytes,
|
||||
onDismiss = { showFull = false },
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/** One non-image artifact: a file glyph, name, size/type and open/copy actions. */
|
||||
@Composable
|
||||
private fun ArtifactRow(
|
||||
artifact: StageArtifact,
|
||||
configuredServerUrl: String,
|
||||
fetchArtifactBytes: suspend (String) -> ByteArray?,
|
||||
) {
|
||||
val text = pipelinesText()
|
||||
val context = LocalContext.current
|
||||
@@ -95,9 +215,7 @@ private fun ArtifactRow(
|
||||
val resolved = remember(artifact.url, configuredServerUrl) {
|
||||
ServerUrl.resolveArtifactUrl(configuredServerUrl, artifact.url)
|
||||
}
|
||||
val isImage = remember(artifact.contentType) { isImageContentType(artifact.contentType) }
|
||||
val metaLine = remember(artifact) { artifactMetaLine(artifact) }
|
||||
var showFull by remember(artifact.url) { mutableStateOf(false) }
|
||||
|
||||
Surface(
|
||||
shape = RoundedCornerShape(12.dp),
|
||||
@@ -109,25 +227,15 @@ private fun ArtifactRow(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.spacedBy(12.dp),
|
||||
) {
|
||||
val thumbModifier = Modifier
|
||||
.size(56.dp)
|
||||
.clip(RoundedCornerShape(8.dp))
|
||||
if (isImage && resolved != null) {
|
||||
ArtifactImage(
|
||||
url = resolved,
|
||||
contentDescription = "Preview of ${artifact.name}",
|
||||
maxDim = THUMBNAIL_MAX_DIM,
|
||||
fetchBytes = fetchArtifactBytes,
|
||||
modifier = thumbModifier.clickable { showFull = true },
|
||||
Box(
|
||||
Modifier.size(56.dp).clip(RoundedCornerShape(8.dp)),
|
||||
contentAlignment = Alignment.Center,
|
||||
) {
|
||||
Icon(
|
||||
imageVector = Icons.AutoMirrored.Filled.InsertDriveFile,
|
||||
contentDescription = null,
|
||||
tint = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
)
|
||||
} else {
|
||||
Box(thumbModifier, contentAlignment = Alignment.Center) {
|
||||
Icon(
|
||||
imageVector = if (isImage) Icons.Default.Image else Icons.AutoMirrored.Filled.InsertDriveFile,
|
||||
contentDescription = null,
|
||||
tint = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
)
|
||||
}
|
||||
}
|
||||
Column(Modifier.weight(1f), verticalArrangement = Arrangement.spacedBy(2.dp)) {
|
||||
Text(
|
||||
@@ -157,15 +265,6 @@ private fun ArtifactRow(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (showFull && resolved != null) {
|
||||
FullSizeArtifactDialog(
|
||||
url = resolved,
|
||||
name = artifact.name,
|
||||
fetchBytes = fetchArtifactBytes,
|
||||
onDismiss = { showFull = false },
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/** The explicit full-resolution view, opened by tapping an image thumbnail. */
|
||||
@@ -216,3 +315,12 @@ private const val THUMBNAIL_MAX_DIM = 160
|
||||
|
||||
/** Fixed box for the full-size preview. */
|
||||
private const val FULL_SIZE_PREVIEW_DP = 320
|
||||
|
||||
/** Preferred side of one square gallery thumbnail tile (the named size token). */
|
||||
private val ARTIFACT_TILE_DP = 96.dp
|
||||
|
||||
/** Gap between gallery thumbnails; shared by the row arrangement and the fitting. */
|
||||
private val ARTIFACT_TILE_SPACING_DP = 8.dp
|
||||
|
||||
/** Image thumbnails per gallery row. */
|
||||
private const val ARTIFACT_GRID_COLUMNS = 3
|
||||
|
||||
+224
-66
@@ -1,33 +1,35 @@
|
||||
package net.awan.pipelines.ui.graph
|
||||
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.widthIn
|
||||
import androidx.compose.foundation.rememberScrollState
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.foundation.verticalScroll
|
||||
import androidx.compose.material3.BottomSheetDefaults
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.automirrored.filled.ArrowBack
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.IconButton
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.ModalBottomSheet
|
||||
import androidx.compose.material3.PrimaryScrollableTabRow
|
||||
import androidx.compose.material3.Scaffold
|
||||
import androidx.compose.material3.Surface
|
||||
import androidx.compose.material3.Tab
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.rememberModalBottomSheetState
|
||||
import androidx.compose.material3.TopAppBar
|
||||
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.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.semantics.heading
|
||||
import androidx.compose.ui.semantics.semantics
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import net.awan.pipelines.data.protocol.ControlEvidence
|
||||
import net.awan.pipelines.data.protocol.Graph
|
||||
import net.awan.pipelines.data.protocol.GraphSemantics
|
||||
@@ -35,25 +37,29 @@ import net.awan.pipelines.data.protocol.Protocol
|
||||
import net.awan.pipelines.data.protocol.RunStep
|
||||
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.DETAIL_MAX_WIDTH_DP
|
||||
import net.awan.pipelines.ui.components.DetailTabBody
|
||||
import net.awan.pipelines.ui.components.KeyValueRow
|
||||
import net.awan.pipelines.ui.components.SectionHeader
|
||||
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
|
||||
import net.awan.pipelines.ui.formatDuration
|
||||
import net.awan.pipelines.ui.notificationLine
|
||||
import net.awan.pipelines.ui.screens.runTimeline
|
||||
import net.awan.pipelines.ui.theme.pipelinesText
|
||||
|
||||
/**
|
||||
* The effective stage type, mirroring internal/stage.EffectiveType: a blank type
|
||||
* is the model stage. Kept pure so the sheet chip and the node description share
|
||||
* is the model stage. Kept pure so the pane chip and the node description share
|
||||
* one derivation.
|
||||
*/
|
||||
internal fun effectiveStageType(type: String?): String =
|
||||
if (type.isNullOrBlank()) "model" else type
|
||||
|
||||
/** One labelled row/block of stage detail, rendered by the sheet. */
|
||||
/** One labelled row/block of stage detail, rendered by the pane. */
|
||||
internal data class StageField(
|
||||
val label: String,
|
||||
val value: String,
|
||||
@@ -64,7 +70,7 @@ internal data class StageField(
|
||||
/**
|
||||
* The pure definition view of a [stage]: key + type title, prompt, output, edges
|
||||
* with their outcomes and resolved terminals, configs, tools, limits and memory
|
||||
* sources. Only non-blank fields are emitted, so the sheet never shows an empty
|
||||
* sources. Only non-blank fields are emitted, so the pane never shows an empty
|
||||
* row and no protocol field is invented.
|
||||
*/
|
||||
internal fun stageDefinitionFields(stage: Stage): List<StageField> {
|
||||
@@ -117,7 +123,7 @@ internal fun stageDefinitionFields(stage: Stage): List<StageField> {
|
||||
|
||||
/**
|
||||
* The shared visit label for a step's control evidence, e.g. `3 / 5 (limit
|
||||
* reached)` (or just `3` when no max is recorded). Used by the sheet and the run
|
||||
* reached)` (or just `3` when no max is recorded). Used by the pane and the run
|
||||
* steps timeline so the two never spell a visit differently.
|
||||
*/
|
||||
internal fun controlVisitLabel(control: ControlEvidence): String {
|
||||
@@ -129,6 +135,27 @@ internal fun controlVisitLabel(control: ControlEvidence): String {
|
||||
return base + if (control.limitReached) " (limit reached)" else ""
|
||||
}
|
||||
|
||||
/**
|
||||
* The identity/result labels that must be visible the moment the stage pane is
|
||||
* opened, before anything is expanded: the stage's status and outcome, its
|
||||
* target, duration, visit and model target. Everything else lives in a
|
||||
* collapsible section.
|
||||
*/
|
||||
internal val STAGE_HEADLINE_LABELS: Set<String> =
|
||||
setOf("Status", "Outcome", "Target", "Duration", "Visit", "Model target")
|
||||
|
||||
/** The always-visible identity/result fields of a step's recorded evidence. */
|
||||
internal fun headlineFields(fields: List<StageField>): List<StageField> =
|
||||
fields.filter { it.label in STAGE_HEADLINE_LABELS }
|
||||
|
||||
/**
|
||||
* The remaining run evidence (diagnostic, transcript, session/agent, file
|
||||
* changes, notifications) that belongs in a collapsible section: the headline
|
||||
* facts and the input/output blocks are surfaced elsewhere.
|
||||
*/
|
||||
internal fun evidenceFields(fields: List<StageField>): List<StageField> =
|
||||
fields.filter { it.label !in STAGE_HEADLINE_LABELS && it.label != "Input" && it.label != "Output" }
|
||||
|
||||
/**
|
||||
* The pure run view of one [RunStep] for the selected stage: status, outcome,
|
||||
* duration, visit against the control's max_visits, target, session id,
|
||||
@@ -180,7 +207,7 @@ internal fun runStepFields(step: RunStep): List<StageField> {
|
||||
return fields
|
||||
}
|
||||
|
||||
/** Incoming routes into a terminal node, for the sheet opened on a terminal. */
|
||||
/** Incoming routes into a terminal node, for the pane opened on a terminal. */
|
||||
internal fun terminalFields(graph: Graph, key: String): List<StageField> {
|
||||
val lines = graph.edges()
|
||||
.filter { it.target == key }
|
||||
@@ -218,34 +245,75 @@ internal fun clampVisitIndex(index: Int, visitCount: Int): Int =
|
||||
internal fun showVisitTabs(visitCount: Int): Boolean = visitCount > 1
|
||||
|
||||
/**
|
||||
* The one reusable stage-detail overlay, opened when a node in [WorkflowGraph]
|
||||
* is tapped or a timeline entry is tapped. It is a Material 3
|
||||
* [ModalBottomSheet] that opens near full height (`skipPartiallyExpanded`), is
|
||||
* scrollable, and dismisses by swipe, back or tapping outside. On a wide window
|
||||
* it reuses the screens' responsive centring (the shared [DETAIL_MAX_WIDTH_DP])
|
||||
* instead of stretching one narrow column. It is an overlay on the current
|
||||
* screen; no navigation route is added.
|
||||
* 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).
|
||||
*
|
||||
* [runSteps] is every recorded visit of the stage in order; when there is more
|
||||
* than one the sheet shows a visit tab row (visit 1..N) and starts on
|
||||
* 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.
|
||||
* 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.
|
||||
*/
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun StageDetailSheet(
|
||||
fun StageDetailPane(
|
||||
stageKey: String,
|
||||
graph: Graph,
|
||||
runSteps: List<RunStep> = emptyList(),
|
||||
initialVisitIndex: Int = 0,
|
||||
configuredServerUrl: String = "",
|
||||
fetchArtifactBytes: suspend (String) -> ByteArray? = { null },
|
||||
onDismiss: () -> Unit,
|
||||
onBack: () -> Unit,
|
||||
wide: Boolean = false,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
Scaffold(
|
||||
modifier = modifier,
|
||||
topBar = {
|
||||
TopAppBar(
|
||||
title = { Text(GraphSemantics.nodeLabel(stageKey)) },
|
||||
navigationIcon = {
|
||||
IconButton(onClick = onBack) {
|
||||
Icon(Icons.AutoMirrored.Filled.ArrowBack, contentDescription = "Back")
|
||||
}
|
||||
},
|
||||
)
|
||||
},
|
||||
) { padding ->
|
||||
StageDetailBody(
|
||||
stageKey = stageKey,
|
||||
graph = graph,
|
||||
runSteps = runSteps,
|
||||
initialVisitIndex = initialVisitIndex,
|
||||
configuredServerUrl = configuredServerUrl,
|
||||
fetchArtifactBytes = fetchArtifactBytes,
|
||||
wide = wide,
|
||||
modifier = Modifier.padding(padding),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/** The stage detail's content, wrapped by [StageDetailPane]. */
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
private fun StageDetailBody(
|
||||
stageKey: String,
|
||||
graph: Graph,
|
||||
runSteps: List<RunStep>,
|
||||
initialVisitIndex: Int,
|
||||
configuredServerUrl: String,
|
||||
fetchArtifactBytes: suspend (String) -> ByteArray?,
|
||||
wide: Boolean,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
val text = pipelinesText()
|
||||
val sheetState = rememberModalBottomSheetState(skipPartiallyExpanded = true)
|
||||
val stage = graph.stages.firstOrNull { it.key == stageKey }
|
||||
val definition = stage?.let(::stageDefinitionFields) ?: terminalFields(graph, stageKey)
|
||||
val definition = remember(stage, graph, stageKey) {
|
||||
stage?.let(::stageDefinitionFields) ?: terminalFields(graph, stageKey)
|
||||
}
|
||||
val typeLabel = if (stage != null) effectiveStageType(stage.type) else "terminal"
|
||||
|
||||
// Reset the selected visit when the stage (but not the user's tap within it)
|
||||
@@ -255,64 +323,150 @@ fun StageDetailSheet(
|
||||
}
|
||||
val clampedVisit = clampVisitIndex(visitIndex, runSteps.size)
|
||||
val selectedStep = runSteps.getOrNull(clampedVisit)
|
||||
val run = selectedStep?.let(::runStepFields).orEmpty()
|
||||
// Derived once per selected step, not per recomposition.
|
||||
val runFields = remember(selectedStep) { selectedStep?.let(::runStepFields).orEmpty() }
|
||||
val headline = headlineFields(runFields)
|
||||
val evidence = evidenceFields(runFields)
|
||||
val expansion = rememberSectionExpansion(stageKey)
|
||||
|
||||
ModalBottomSheet(
|
||||
onDismissRequest = onDismiss,
|
||||
sheetState = sheetState,
|
||||
dragHandle = { BottomSheetDefaults.DragHandle() },
|
||||
) {
|
||||
Box(Modifier.fillMaxWidth(), contentAlignment = Alignment.TopCenter) {
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.widthIn(max = DETAIL_MAX_WIDTH_DP.dp)
|
||||
.fillMaxWidth()
|
||||
.verticalScroll(rememberScrollState())
|
||||
.padding(horizontal = 16.dp, vertical = 8.dp),
|
||||
verticalArrangement = Arrangement.spacedBy(4.dp),
|
||||
) {
|
||||
Text(
|
||||
GraphSemantics.nodeLabel(stageKey),
|
||||
style = text.screenTitle,
|
||||
modifier = Modifier.semantics { heading() },
|
||||
)
|
||||
StageTypeChip(typeLabel)
|
||||
if (showVisitTabs(runSteps.size)) {
|
||||
PrimaryScrollableTabRow(
|
||||
selectedTabIndex = clampedVisit,
|
||||
edgePadding = 0.dp,
|
||||
modifier = Modifier.fillMaxWidth().padding(top = 8.dp),
|
||||
) {
|
||||
runSteps.forEachIndexed { index, _ ->
|
||||
Tab(
|
||||
selected = index == clampedVisit,
|
||||
onClick = { visitIndex = index },
|
||||
text = { Text("visit ${index + 1}", maxLines = 1) },
|
||||
)
|
||||
}
|
||||
DetailTabBody(wide, modifier) { columnModifier ->
|
||||
Column(
|
||||
modifier = columnModifier
|
||||
.verticalScroll(rememberScrollState())
|
||||
.padding(horizontal = 16.dp, vertical = 8.dp),
|
||||
verticalArrangement = Arrangement.spacedBy(4.dp),
|
||||
) {
|
||||
Text(
|
||||
GraphSemantics.nodeLabel(stageKey),
|
||||
style = text.screenTitle,
|
||||
modifier = Modifier.semantics { heading() },
|
||||
)
|
||||
StageTypeChip(typeLabel)
|
||||
if (showVisitTabs(runSteps.size)) {
|
||||
PrimaryScrollableTabRow(
|
||||
selectedTabIndex = clampedVisit,
|
||||
edgePadding = 0.dp,
|
||||
modifier = Modifier.fillMaxWidth().padding(top = 8.dp),
|
||||
) {
|
||||
runSteps.forEachIndexed { index, _ ->
|
||||
Tab(
|
||||
selected = index == clampedVisit,
|
||||
onClick = { visitIndex = index },
|
||||
text = { Text("visit ${index + 1}", maxLines = 1) },
|
||||
)
|
||||
}
|
||||
}
|
||||
if (definition.isNotEmpty()) {
|
||||
Text("Definition", style = text.sectionHeader, modifier = Modifier.padding(top = 8.dp))
|
||||
}
|
||||
|
||||
// Identity and result: always visible, never behind a collapse, so a
|
||||
// freshly opened pane never reads as empty.
|
||||
headline.forEach { field -> StageFieldRow(field) }
|
||||
if (headline.isEmpty() && selectedStep == null && stage == null && definition.isEmpty()) {
|
||||
Text("No details recorded for this node.", style = text.meta)
|
||||
}
|
||||
|
||||
if (definition.isNotEmpty()) {
|
||||
val key = "definition"
|
||||
SectionHeader(key.capitalized(), expansion.isExpanded(key), { expansion.toggle(key) })
|
||||
if (expansion.isExpanded(key)) {
|
||||
definition.forEach { field -> StageFieldRow(field) }
|
||||
}
|
||||
if (selectedStep != null) {
|
||||
Text("This run", style = text.sectionHeader, modifier = Modifier.padding(top = 8.dp))
|
||||
run.forEach { field -> StageFieldRow(field) }
|
||||
}
|
||||
|
||||
if (selectedStep != null) {
|
||||
val inputFields = runFields.filter { it.label == "Input" }
|
||||
val outputFields = runFields.filter { it.label == "Output" }
|
||||
if (inputFields.isNotEmpty()) {
|
||||
val key = "input"
|
||||
SectionHeader(key.capitalized(), expansion.isExpanded(key), { expansion.toggle(key) })
|
||||
if (expansion.isExpanded(key)) inputFields.forEach { StageFieldRow(it) }
|
||||
}
|
||||
if (outputFields.isNotEmpty()) {
|
||||
val key = "output"
|
||||
SectionHeader(key.capitalized(), expansion.isExpanded(key), { expansion.toggle(key) })
|
||||
if (expansion.isExpanded(key)) outputFields.forEach { StageFieldRow(it) }
|
||||
}
|
||||
val artifactsKey = "artifacts"
|
||||
SectionHeader(
|
||||
artifactsKey.capitalized(),
|
||||
expansion.isExpanded(artifactsKey),
|
||||
{ expansion.toggle(artifactsKey) },
|
||||
)
|
||||
if (expansion.isExpanded(artifactsKey)) {
|
||||
ArtifactsSection(
|
||||
step = selectedStep,
|
||||
configuredServerUrl = configuredServerUrl,
|
||||
fetchArtifactBytes = fetchArtifactBytes,
|
||||
)
|
||||
}
|
||||
if (definition.isEmpty() && selectedStep == null) {
|
||||
Text("No details recorded for this node.", style = text.meta)
|
||||
if (evidence.isNotEmpty()) {
|
||||
val key = "run"
|
||||
SectionHeader(
|
||||
"This run",
|
||||
expansion.isExpanded(key),
|
||||
{ expansion.toggle(key) },
|
||||
)
|
||||
if (expansion.isExpanded(key)) {
|
||||
evidence.forEach { field -> StageFieldRow(field) }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** The stage pane hosted directly by the run destination, reading the run detail. */
|
||||
@Composable
|
||||
fun RunStagePane(
|
||||
vm: AppViewModel,
|
||||
runId: Long,
|
||||
stageKey: String,
|
||||
visitIndex: Int,
|
||||
onBack: () -> Unit,
|
||||
wide: Boolean,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
val state by vm.runDetail.collectAsStateWithLifecycle()
|
||||
val configuredServerUrl by vm.configuredServerUrl.collectAsStateWithLifecycle()
|
||||
val run = state.data?.takeIf { it.id == runId }
|
||||
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,
|
||||
)
|
||||
}
|
||||
|
||||
/** The stage pane hosted by the pipeline destination; a definition has no run. */
|
||||
@Composable
|
||||
fun PipelineStagePane(
|
||||
vm: AppViewModel,
|
||||
pipelineId: Long,
|
||||
version: Int,
|
||||
stageKey: String,
|
||||
onBack: () -> Unit,
|
||||
wide: Boolean,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
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,
|
||||
)
|
||||
}
|
||||
|
||||
/** One field as either the shared code card (blocks) or a key/value row. */
|
||||
@Composable
|
||||
internal fun StageFieldRow(field: StageField) {
|
||||
@@ -338,3 +492,7 @@ internal fun StageTypeChip(label: String) {
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/** A section key as its visible title ("definition" → "Definition"). */
|
||||
private fun String.capitalized(): String =
|
||||
replaceFirstChar { if (it.isLowerCase()) it.titlecase() else it.toString() }
|
||||
@@ -33,7 +33,6 @@ import androidx.compose.material3.TopAppBar
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableIntStateOf
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.saveable.rememberSaveable
|
||||
@@ -57,7 +56,6 @@ import net.awan.pipelines.ui.components.LoadingState
|
||||
import net.awan.pipelines.ui.components.collapsibleSection
|
||||
import net.awan.pipelines.ui.components.pipelineDetailTabs
|
||||
import net.awan.pipelines.ui.components.rememberSectionExpansion
|
||||
import net.awan.pipelines.ui.graph.StageDetailSheet
|
||||
import net.awan.pipelines.ui.graph.StageFieldRow
|
||||
import net.awan.pipelines.ui.graph.WorkflowGraph
|
||||
import net.awan.pipelines.ui.graph.effectiveStageType
|
||||
@@ -72,13 +70,14 @@ fun PipelineDetailScreen(
|
||||
version: Int,
|
||||
onBack: () -> Unit,
|
||||
onOpenRun: (Long) -> Unit,
|
||||
selectedSection: Int,
|
||||
onSelectSection: (Int) -> Unit,
|
||||
onOpenStage: (String) -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
wide: Boolean = false,
|
||||
) {
|
||||
val state by vm.pipelineDetail.collectAsStateWithLifecycle()
|
||||
var showStart by remember { mutableStateOf(false) }
|
||||
// Summary is the first/default tab; selection survives config changes.
|
||||
var selectedTab by rememberSaveable { mutableIntStateOf(0) }
|
||||
|
||||
LaunchedEffect(pipelineId, version) { vm.loadPipeline(pipelineId, version) }
|
||||
|
||||
@@ -114,15 +113,19 @@ fun PipelineDetailScreen(
|
||||
detail == null -> LoadingState("Loading pipeline…", Modifier.padding(padding))
|
||||
else -> DetailTabs(
|
||||
tabs = pipelineDetailTabs,
|
||||
selectedIndex = selectedTab,
|
||||
onSelect = { selectedTab = it },
|
||||
selectedIndex = selectedSection,
|
||||
onSelect = onSelectSection,
|
||||
wide = wide,
|
||||
modifier = Modifier.padding(padding),
|
||||
modifier = Modifier.padding(padding).fillMaxSize(),
|
||||
) { tab, contentModifier ->
|
||||
// Only the selected tab's content composes (one scroll container each).
|
||||
// The pager composes only the visible section's content.
|
||||
when (tab.key) {
|
||||
"summary" -> PipelineSummaryTab(detail, wide, contentModifier)
|
||||
"graph" -> PipelineGraphTab(detail, contentModifier)
|
||||
"graph" -> PipelineGraphTab(
|
||||
detail = detail,
|
||||
modifier = contentModifier,
|
||||
onStageTap = onOpenStage,
|
||||
)
|
||||
else -> PipelineSourceTab(detail, contentModifier)
|
||||
}
|
||||
}
|
||||
@@ -203,11 +206,12 @@ private fun PipelineSummaryTab(detail: PipelineDetail, wide: Boolean, modifier:
|
||||
|
||||
/** The graph tab on its own: the full-height panel with its Fit/expand controls. */
|
||||
@Composable
|
||||
private fun PipelineGraphTab(detail: PipelineDetail, modifier: Modifier) {
|
||||
private fun PipelineGraphTab(
|
||||
detail: PipelineDetail,
|
||||
modifier: Modifier,
|
||||
onStageTap: (String) -> Unit,
|
||||
) {
|
||||
val text = pipelinesText()
|
||||
// The stage whose detail sheet is open; survives configuration changes. The
|
||||
// sheet is an overlay on this screen (no navigation route).
|
||||
var selectedStage by rememberSaveable { mutableStateOf<String?>(null) }
|
||||
LazyColumn(
|
||||
modifier = modifier,
|
||||
contentPadding = PaddingValues(vertical = 16.dp),
|
||||
@@ -224,18 +228,11 @@ private fun PipelineGraphTab(detail: PipelineDetail, modifier: Modifier) {
|
||||
WorkflowGraph(
|
||||
graph = detail.graph,
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
onStageTap = { selectedStage = it },
|
||||
onStageTap = onStageTap,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
selectedStage?.let { key ->
|
||||
StageDetailSheet(
|
||||
stageKey = key,
|
||||
graph = detail.graph,
|
||||
onDismiss = { selectedStage = null },
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -8,7 +8,6 @@ import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.lazy.items
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.automirrored.filled.KeyboardArrowLeft
|
||||
import androidx.compose.material.icons.filled.AccountTree
|
||||
import androidx.compose.material.icons.filled.Refresh
|
||||
import androidx.compose.material.icons.filled.Search
|
||||
@@ -45,7 +44,6 @@ fun PipelineListScreen(
|
||||
onOpen: (id: Long, version: Int) -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
selectedId: Long? = null,
|
||||
onTogglePane: (() -> Unit)? = null,
|
||||
) {
|
||||
val state by vm.pipelines.collectAsStateWithLifecycle()
|
||||
var query by remember { mutableStateOf("") }
|
||||
@@ -61,14 +59,6 @@ fun PipelineListScreen(
|
||||
IconButton(onClick = vm::refreshPipelines) {
|
||||
Icon(Icons.Default.Refresh, contentDescription = "Refresh pipelines")
|
||||
}
|
||||
if (onTogglePane != null) {
|
||||
IconButton(onClick = onTogglePane) {
|
||||
Icon(
|
||||
Icons.AutoMirrored.Filled.KeyboardArrowLeft,
|
||||
contentDescription = "Collapse list pane",
|
||||
)
|
||||
}
|
||||
}
|
||||
},
|
||||
)
|
||||
},
|
||||
|
||||
@@ -6,6 +6,7 @@ import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.PaddingValues
|
||||
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.foundation.layout.size
|
||||
@@ -32,10 +33,8 @@ import androidx.compose.material3.TopAppBar
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableIntStateOf
|
||||
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
|
||||
@@ -65,8 +64,10 @@ import net.awan.pipelines.ui.components.runDetailTabs
|
||||
import net.awan.pipelines.ui.components.runStateOf
|
||||
import net.awan.pipelines.ui.displayText
|
||||
import net.awan.pipelines.ui.formatDuration
|
||||
import net.awan.pipelines.ui.graph.StageDetailSheet
|
||||
import net.awan.pipelines.ui.artifactsEmptyMessage
|
||||
import net.awan.pipelines.ui.graph.ArtifactGallery
|
||||
import net.awan.pipelines.ui.graph.WorkflowGraph
|
||||
import net.awan.pipelines.ui.runArtifactGroups
|
||||
import net.awan.pipelines.ui.theme.pipelinesText
|
||||
import net.awan.pipelines.ui.visitCount
|
||||
|
||||
@@ -76,6 +77,9 @@ fun RunDetailScreen(
|
||||
vm: AppViewModel,
|
||||
runId: Long,
|
||||
onBack: () -> Unit,
|
||||
selectedSection: Int,
|
||||
onSelectSection: (Int) -> Unit,
|
||||
onOpenStage: (String, Int) -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
wide: Boolean = false,
|
||||
) {
|
||||
@@ -85,9 +89,6 @@ fun RunDetailScreen(
|
||||
var confirmCancel by remember { mutableStateOf(false) }
|
||||
var confirmRetry by remember { mutableStateOf(false) }
|
||||
var actionError by remember { mutableStateOf<String?>(null) }
|
||||
// Selected tab survives recomposition and configuration changes; the first
|
||||
// tab (Summary) is the default.
|
||||
var selectedTab by rememberSaveable { mutableIntStateOf(0) }
|
||||
|
||||
LaunchedEffect(runId) {
|
||||
// Scope evidence to this run: drop the previous run's records, then fetch
|
||||
@@ -145,50 +146,56 @@ fun RunDetailScreen(
|
||||
modifier = Modifier.padding(padding),
|
||||
)
|
||||
run == null -> LoadingState("Loading run…", Modifier.padding(padding))
|
||||
else -> DetailTabs(
|
||||
tabs = runDetailTabs,
|
||||
selectedIndex = selectedTab,
|
||||
onSelect = { selectedTab = it },
|
||||
wide = wide,
|
||||
modifier = Modifier.padding(padding),
|
||||
) { tab, contentModifier ->
|
||||
// Only the selected tab's content composes (one scroll container each).
|
||||
when (tab.key) {
|
||||
"summary" -> RunSummaryTab(run, wide, contentModifier)
|
||||
"graph" -> RunGraphTab(
|
||||
run = run,
|
||||
configuredServerUrl = configuredServerUrl,
|
||||
fetchArtifactBytes = vm::fetchArtifactBytes,
|
||||
modifier = contentModifier,
|
||||
)
|
||||
"input" -> RunFieldSectionsTab(
|
||||
emptyMessage = "No input recorded.",
|
||||
keyPrefix = "input",
|
||||
entries = run.input.orEmpty().toList(),
|
||||
wide = wide,
|
||||
modifier = contentModifier,
|
||||
)
|
||||
"output" -> RunFieldSectionsTab(
|
||||
emptyMessage = "No output recorded.",
|
||||
keyPrefix = "output",
|
||||
entries = run.output.orEmpty().toList(),
|
||||
wide = wide,
|
||||
modifier = contentModifier,
|
||||
)
|
||||
"evidence" -> RunEvidenceTab(
|
||||
evidenceState = evidenceState,
|
||||
steps = run.steps,
|
||||
onLoadEvidence = { vm.loadEvidence(runId) },
|
||||
wide = wide,
|
||||
modifier = contentModifier,
|
||||
)
|
||||
else -> RunTimelineTab(
|
||||
run = run,
|
||||
configuredServerUrl = configuredServerUrl,
|
||||
fetchArtifactBytes = vm::fetchArtifactBytes,
|
||||
wide = wide,
|
||||
modifier = contentModifier,
|
||||
)
|
||||
else -> {
|
||||
DetailTabs(
|
||||
tabs = runDetailTabs,
|
||||
selectedIndex = selectedSection,
|
||||
onSelect = onSelectSection,
|
||||
wide = wide,
|
||||
modifier = Modifier.padding(padding).fillMaxSize(),
|
||||
) { tab, contentModifier ->
|
||||
// The pager composes only the visible section's content.
|
||||
when (tab.key) {
|
||||
"summary" -> RunSummaryTab(
|
||||
run = run,
|
||||
wide = wide,
|
||||
modifier = contentModifier,
|
||||
configuredServerUrl = configuredServerUrl,
|
||||
fetchArtifactBytes = vm::fetchArtifactBytes,
|
||||
)
|
||||
"graph" -> RunGraphTab(
|
||||
run = run,
|
||||
modifier = contentModifier,
|
||||
onStageTap = onOpenStage,
|
||||
)
|
||||
"input" -> RunFieldSectionsTab(
|
||||
emptyMessage = "No input recorded.",
|
||||
keyPrefix = "input",
|
||||
entries = run.input.orEmpty().toList(),
|
||||
wide = wide,
|
||||
modifier = contentModifier,
|
||||
)
|
||||
"output" -> RunFieldSectionsTab(
|
||||
emptyMessage = "No output recorded.",
|
||||
keyPrefix = "output",
|
||||
entries = run.output.orEmpty().toList(),
|
||||
wide = wide,
|
||||
modifier = contentModifier,
|
||||
)
|
||||
"evidence" -> RunEvidenceTab(
|
||||
evidenceState = evidenceState,
|
||||
steps = run.steps,
|
||||
onLoadEvidence = { vm.loadEvidence(runId) },
|
||||
wide = wide,
|
||||
modifier = contentModifier,
|
||||
)
|
||||
else -> RunTimelineTab(
|
||||
run = run,
|
||||
wide = wide,
|
||||
modifier = contentModifier,
|
||||
onStageTap = onOpenStage,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -260,9 +267,17 @@ private fun ConfirmDialog(
|
||||
* the failure diagnostic.
|
||||
*/
|
||||
@Composable
|
||||
private fun RunSummaryTab(run: RunDetail, wide: Boolean, modifier: Modifier) {
|
||||
private fun RunSummaryTab(
|
||||
run: RunDetail,
|
||||
wide: Boolean,
|
||||
modifier: Modifier,
|
||||
configuredServerUrl: String,
|
||||
fetchArtifactBytes: suspend (String) -> ByteArray?,
|
||||
) {
|
||||
val text = pipelinesText()
|
||||
val state = runStateOf(run.status)
|
||||
// Aggregated once per step-list change, never per recomposition.
|
||||
val artifactGroups = remember(run.steps) { runArtifactGroups(run.steps) }
|
||||
DetailTabBody(wide, modifier) { columnModifier ->
|
||||
LazyColumn(
|
||||
modifier = columnModifier,
|
||||
@@ -303,6 +318,23 @@ private fun RunSummaryTab(run: RunDetail, wide: Boolean, modifier: Modifier) {
|
||||
CodeBlock("Diagnostic", run.diagnostic, Modifier.padding(top = 8.dp))
|
||||
}
|
||||
}
|
||||
item(key = "run-artifacts") {
|
||||
Column(
|
||||
modifier = Modifier.fillMaxWidth().padding(horizontal = 16.dp, vertical = 8.dp),
|
||||
verticalArrangement = Arrangement.spacedBy(8.dp),
|
||||
) {
|
||||
Text("Artifacts", style = text.sectionHeader)
|
||||
if (artifactGroups.isEmpty()) {
|
||||
Text(artifactsEmptyMessage(run.executing), style = text.meta)
|
||||
} else {
|
||||
ArtifactGallery(
|
||||
groups = artifactGroups,
|
||||
configuredServerUrl = configuredServerUrl,
|
||||
fetchArtifactBytes = fetchArtifactBytes,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -315,17 +347,14 @@ private fun RunSummaryTab(run: RunDetail, wide: Boolean, modifier: Modifier) {
|
||||
@Composable
|
||||
private fun RunGraphTab(
|
||||
run: RunDetail,
|
||||
configuredServerUrl: String,
|
||||
fetchArtifactBytes: suspend (String) -> ByteArray?,
|
||||
modifier: Modifier,
|
||||
onStageTap: (String, Int) -> Unit,
|
||||
) {
|
||||
val text = pipelinesText()
|
||||
val runState = remember(run.id, run.steps) { RunGraphState.from(run) }
|
||||
// Grouped once per step-list change; the sheet opened from the graph starts on
|
||||
// the most recent visit of the tapped stage.
|
||||
val timeline = remember(run.steps) { runTimeline(run.steps) }
|
||||
// The stage whose detail sheet is open; the sheet overlays this screen.
|
||||
var selectedStage by rememberSaveable { mutableStateOf<String?>(null) }
|
||||
LazyColumn(
|
||||
modifier = modifier,
|
||||
contentPadding = PaddingValues(vertical = 16.dp),
|
||||
@@ -347,25 +376,15 @@ private fun RunGraphTab(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
runState = runState,
|
||||
selectedStage = runState.currentStage,
|
||||
onStageTap = { selectedStage = it },
|
||||
onStageTap = { key ->
|
||||
val visits = timeline.visitsByStage[key].orEmpty()
|
||||
onStageTap(key, (visits.size - 1).coerceAtLeast(0))
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
selectedStage?.let { key ->
|
||||
val visits = timeline.visitsByStage[key].orEmpty()
|
||||
StageDetailSheet(
|
||||
stageKey = key,
|
||||
graph = run.graph,
|
||||
// Every recorded visit for the stage, opening on the most recent one.
|
||||
runSteps = visits,
|
||||
initialVisitIndex = (visits.size - 1).coerceAtLeast(0),
|
||||
configuredServerUrl = configuredServerUrl,
|
||||
fetchArtifactBytes = fetchArtifactBytes,
|
||||
onDismiss = { selectedStage = null },
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -529,7 +548,7 @@ internal fun evidenceSectionTitle(record: SessionEvidence, step: RunStep?): Stri
|
||||
/**
|
||||
* The Timeline tab: one compact line per recorded visit (stage name, visit
|
||||
* number, outcome chip and duration plus a brief description) and nothing else.
|
||||
* The heavy per-step evidence lives only in the [StageDetailSheet] opened by
|
||||
* The heavy per-step evidence lives only in the stage pane opened by
|
||||
* tapping an entry. The steps are grouped once per step-list change, not per
|
||||
* recomposition, and rendered in this single LazyColumn.
|
||||
*/
|
||||
@@ -537,16 +556,13 @@ internal fun evidenceSectionTitle(record: SessionEvidence, step: RunStep?): Stri
|
||||
@Composable
|
||||
private fun RunTimelineTab(
|
||||
run: RunDetail,
|
||||
configuredServerUrl: String,
|
||||
fetchArtifactBytes: suspend (String) -> ByteArray?,
|
||||
wide: Boolean,
|
||||
modifier: Modifier,
|
||||
onStageTap: (String, Int) -> Unit,
|
||||
) {
|
||||
val text = pipelinesText()
|
||||
// Grouped once per step-list change, not per recomposition.
|
||||
val timeline = remember(run.steps) { runTimeline(run.steps) }
|
||||
var sheetStage by rememberSaveable { mutableStateOf<String?>(null) }
|
||||
var sheetVisit by rememberSaveable { mutableIntStateOf(0) }
|
||||
DetailTabBody(wide, modifier) { columnModifier ->
|
||||
LazyColumn(
|
||||
modifier = columnModifier,
|
||||
@@ -566,26 +582,13 @@ private fun RunTimelineTab(
|
||||
key = { "timeline-${it.stageKey}-${it.step.sequence}" },
|
||||
) { entry ->
|
||||
TimelineRow(entry) {
|
||||
sheetStage = entry.stageKey
|
||||
sheetVisit = entry.visitIndex
|
||||
onStageTap(entry.stageKey, entry.visitIndex)
|
||||
}
|
||||
HorizontalDivider(color = MaterialTheme.colorScheme.outlineVariant)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
sheetStage?.let { key ->
|
||||
StageDetailSheet(
|
||||
stageKey = key,
|
||||
graph = run.graph,
|
||||
runSteps = timeline.visitsByStage[key].orEmpty(),
|
||||
// Open on the exact visit that was tapped.
|
||||
initialVisitIndex = sheetVisit,
|
||||
configuredServerUrl = configuredServerUrl,
|
||||
fetchArtifactBytes = fetchArtifactBytes,
|
||||
onDismiss = { sheetStage = null },
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -16,7 +16,6 @@ import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.lazy.items
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.automirrored.filled.KeyboardArrowLeft
|
||||
import androidx.compose.material.icons.filled.Refresh
|
||||
import androidx.compose.material3.Card
|
||||
import androidx.compose.material3.CircularProgressIndicator
|
||||
@@ -66,7 +65,6 @@ fun RunHistoryScreen(
|
||||
modifier: Modifier = Modifier,
|
||||
filterPipelineId: Long? = null,
|
||||
selectedRunId: Long? = null,
|
||||
onTogglePane: (() -> Unit)? = null,
|
||||
) {
|
||||
val state by vm.runs.collectAsStateWithLifecycle()
|
||||
LaunchedEffect(Unit) { vm.refreshRuns() }
|
||||
@@ -80,14 +78,6 @@ fun RunHistoryScreen(
|
||||
IconButton(onClick = vm::refreshRuns) {
|
||||
Icon(Icons.Default.Refresh, contentDescription = "Refresh runs")
|
||||
}
|
||||
if (onTogglePane != null) {
|
||||
IconButton(onClick = onTogglePane) {
|
||||
Icon(
|
||||
Icons.AutoMirrored.Filled.KeyboardArrowLeft,
|
||||
contentDescription = "Collapse list pane",
|
||||
)
|
||||
}
|
||||
}
|
||||
},
|
||||
)
|
||||
},
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
package net.awan.pipelines.ui
|
||||
|
||||
import net.awan.pipelines.data.protocol.ControlEvidence
|
||||
import net.awan.pipelines.data.protocol.RunStep
|
||||
import net.awan.pipelines.data.protocol.StageArtifact
|
||||
import net.awan.pipelines.ui.screens.runTimeline
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
|
||||
class ArtifactGroupsTest {
|
||||
|
||||
private fun step(
|
||||
stage: String,
|
||||
sequence: Int,
|
||||
visit: Int = 0,
|
||||
artifacts: List<StageArtifact>? = null,
|
||||
) = RunStep(
|
||||
sequence = sequence,
|
||||
stage = stage,
|
||||
control = ControlEvidence(visit = visit),
|
||||
artifacts = artifacts,
|
||||
)
|
||||
|
||||
private fun artifact(name: String, url: String = "/artifacts/$name") =
|
||||
StageArtifact(name = name, url = url)
|
||||
|
||||
@Test
|
||||
fun groupsByStageAndVisitInStableOrder() {
|
||||
val steps = listOf(
|
||||
step("planner", sequence = 1, visit = 1, artifacts = listOf(artifact("plan.md"))),
|
||||
step("planner", sequence = 2, visit = 2, artifacts = listOf(artifact("plan-2.md"))),
|
||||
step("build", sequence = 3, visit = 1, artifacts = listOf(artifact("app.apk"))),
|
||||
)
|
||||
val groups = runArtifactGroups(steps)
|
||||
assertEquals(listOf("planner" to 1, "planner" to 2, "build" to 1), groups.map { it.stageKey to it.visit })
|
||||
assertEquals("plan.md", groups[0].artifacts.single().name)
|
||||
assertEquals("plan-2.md", groups[1].artifacts.single().name)
|
||||
assertEquals("app.apk", groups[2].artifacts.single().name)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun duplicateNamesAreKeptNotDeduped() {
|
||||
val steps = listOf(
|
||||
step(
|
||||
"planner",
|
||||
sequence = 1,
|
||||
visit = 1,
|
||||
artifacts = listOf(artifact("shot.png", "/a"), artifact("shot.png", "/b")),
|
||||
),
|
||||
)
|
||||
val group = runArtifactGroups(steps).single()
|
||||
assertEquals(2, group.artifacts.size)
|
||||
assertEquals(listOf("/a", "/b"), group.artifacts.map { it.url })
|
||||
}
|
||||
|
||||
@Test
|
||||
fun visitsWithoutArtifactsProduceNoGroup() {
|
||||
// An explicitly empty capture and a stage the run never recorded artifacts
|
||||
// for both yield nothing.
|
||||
val steps = listOf(
|
||||
step("planner", sequence = 1, visit = 1, artifacts = emptyList()),
|
||||
step("planner", sequence = 2, visit = 2, artifacts = null),
|
||||
step("build", sequence = 3, visit = 1, artifacts = listOf(artifact("app.apk"))),
|
||||
)
|
||||
val groups = runArtifactGroups(steps)
|
||||
assertEquals(listOf("build" to 1), groups.map { it.stageKey to it.visit })
|
||||
}
|
||||
|
||||
@Test
|
||||
fun emptyRunProducesNoGroups() {
|
||||
assertEquals(emptyList<ArtifactGroup>(), runArtifactGroups(emptyList()))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun visitNumbersMatchRunTimeline() {
|
||||
val steps = listOf(
|
||||
step("planner", sequence = 1, visit = 0, artifacts = listOf(artifact("a"))),
|
||||
step("planner", sequence = 2, visit = 0, artifacts = listOf(artifact("b"))),
|
||||
)
|
||||
val groups = runArtifactGroups(steps)
|
||||
val timelineVisits = runTimeline(steps).visitsByStage.getValue("planner")
|
||||
assertEquals(timelineVisits.size, groups.size)
|
||||
groups.forEachIndexed { index, group ->
|
||||
// The display visit number is the same as the timeline's position+1
|
||||
// when the step carries no recorded control visit.
|
||||
assertEquals(index + 1, group.visit)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun emptyStateDistinguishesRunningFromFinished() {
|
||||
assertEquals("No artifacts recorded for this run.", artifactsEmptyMessage(executing = false))
|
||||
val pending = artifactsEmptyMessage(executing = true)
|
||||
assertTrue(pending.startsWith("Artifacts · "))
|
||||
assertTrue(pending.contains(ARTIFACT_CAPTURE_PENDING))
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package net.awan.pipelines.ui
|
||||
|
||||
import java.io.File
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
|
||||
/**
|
||||
* Guards that the collapse-based master/detail interaction is gone for good: no
|
||||
* source file may mention the removed composables, callbacks, constants or
|
||||
* content descriptions. The scan is source text, so it is fast and needs no
|
||||
* device.
|
||||
*/
|
||||
class CollapseRemovalTest {
|
||||
|
||||
/** Identifiers/labels that existed only for the removed collapse behaviour. */
|
||||
private val banned = listOf(
|
||||
// List-pane collapse.
|
||||
"CollapsedListPane",
|
||||
"onTogglePane",
|
||||
"paneExpanded",
|
||||
"COLLAPSED_LIST_PANE_WIDTH",
|
||||
"LIST_PANE_WIDTH",
|
||||
"Collapse list pane",
|
||||
// Observed-side rail collapse.
|
||||
"RailToggle",
|
||||
"railWidthDp",
|
||||
"COLLAPSED_RAIL_WIDTH_DP",
|
||||
"Collapse tabs",
|
||||
)
|
||||
|
||||
@Test
|
||||
fun noCollapseBehaviourRemainsInSources() {
|
||||
val root = sourceRoot()
|
||||
val hits = ArrayList<String>()
|
||||
root.walkTopDown()
|
||||
.filter { it.isFile && it.extension == "kt" }
|
||||
.forEach { file ->
|
||||
file.useLines { lines ->
|
||||
lines.forEachIndexed { index, line ->
|
||||
banned.firstOrNull { line.contains(it) }?.let { token ->
|
||||
hits += "${file.relativeTo(root)}:${index + 1}: $token"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
assertTrue("removed collapse identifiers remain: $hits", hits.isEmpty())
|
||||
}
|
||||
|
||||
private fun sourceRoot(): File {
|
||||
val candidates = listOf("src/main/java", "app/src/main/java")
|
||||
.map { File(System.getProperty("user.dir"), it) }
|
||||
val root = candidates.firstOrNull { it.isDirectory }
|
||||
assertTrue("could not locate src/main/java from ${System.getProperty("user.dir")}: $candidates", root != null)
|
||||
// Fail loudly if the scan found nothing, so the guard can never pass
|
||||
// vacuously.
|
||||
assertTrue("no Kotlin sources found under $root", root!!.walkTopDown().any { it.extension == "kt" })
|
||||
return root
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
package net.awan.pipelines.ui
|
||||
|
||||
import androidx.compose.runtime.saveable.SaverScope
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
|
||||
class PaneStateTest {
|
||||
|
||||
@Test
|
||||
fun backFromListLeavesTheApp() {
|
||||
assertEquals(BackResult.Exit, backStep(PaneSelection()))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun backInsideDetailReturnsToTheListAndClearsTheItem() {
|
||||
val detail = PaneSelection(MasterPane.Detail, itemId = 7L, itemVersion = 3, sectionIndex = 2)
|
||||
val result = backStep(detail) as BackResult.Show
|
||||
// One pane level only: sections are navigated by their own tab row, never
|
||||
// by Back, so the section index is not touched by a Back step.
|
||||
assertEquals(MasterPane.List, result.selection.pane)
|
||||
assertEquals(0L, result.selection.itemId)
|
||||
assertEquals(0, result.selection.depth)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun backInsideStageReturnsToTheDetailClearingTheStage() {
|
||||
val stage = PaneSelection(
|
||||
pane = MasterPane.Stage,
|
||||
itemId = 7L,
|
||||
itemVersion = 3,
|
||||
sectionIndex = 1,
|
||||
stageKey = "planner",
|
||||
stageVisit = 2,
|
||||
)
|
||||
val result = backStep(stage) as BackResult.Show
|
||||
// Exactly one level: stage -> detail, keeping the item and section, and
|
||||
// clearing the stage selection.
|
||||
assertEquals(MasterPane.Detail, result.selection.pane)
|
||||
assertEquals(7L, result.selection.itemId)
|
||||
assertEquals(1, result.selection.sectionIndex)
|
||||
assertEquals(null, result.selection.stageKey)
|
||||
assertEquals(0, result.selection.stageVisit)
|
||||
assertEquals(1, 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)
|
||||
// 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)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun popToClosesEveryPaneToTheRight() {
|
||||
val stage = PaneSelection(
|
||||
pane = MasterPane.Stage,
|
||||
itemId = 9L,
|
||||
itemVersion = 2,
|
||||
sectionIndex = 1,
|
||||
stageKey = "s",
|
||||
stageVisit = 3,
|
||||
)
|
||||
// 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(MasterPane.Detail, detail.pane)
|
||||
assertEquals(9L, detail.itemId)
|
||||
assertEquals(2, detail.itemVersion)
|
||||
assertEquals(1, detail.sectionIndex)
|
||||
assertEquals(null, detail.stageKey)
|
||||
// A level at or beyond the current depth is a no-op.
|
||||
assertEquals(stage, popTo(stage, 2))
|
||||
assertEquals(stage, popTo(stage, 5))
|
||||
assertEquals(PaneSelection(MasterPane.Detail, 4L), popTo(PaneSelection(MasterPane.Detail, 4L), 3))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun savedStateRoundTripsThroughTheSaver() {
|
||||
val scope = SaverScope { true }
|
||||
val cases = listOf(
|
||||
PaneSelection(),
|
||||
PaneSelection(MasterPane.Detail, itemId = 42L, itemVersion = 5, sectionIndex = 3),
|
||||
PaneSelection(MasterPane.Detail, itemId = 1L, itemVersion = 0, sectionIndex = 0),
|
||||
PaneSelection(
|
||||
pane = MasterPane.Stage,
|
||||
itemId = 8L,
|
||||
itemVersion = 2,
|
||||
sectionIndex = 4,
|
||||
stageKey = "planner",
|
||||
stageVisit = 3,
|
||||
),
|
||||
)
|
||||
cases.forEach { selection ->
|
||||
val saved = with(PaneSelectionSaver) { scope.save(selection) }
|
||||
assertEquals(selection, PaneSelectionSaver.restore(saved!!))
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun encodedPayloadIsPrimitivesOnly() {
|
||||
// Process-death restoration stays small: only Strings, ints and a long,
|
||||
// with a null stage key encoded as an empty string.
|
||||
val encoded = encodePaneSelection(
|
||||
PaneSelection(
|
||||
pane = MasterPane.Stage,
|
||||
itemId = 9L,
|
||||
itemVersion = 2,
|
||||
sectionIndex = 1,
|
||||
stageKey = "planner",
|
||||
stageVisit = 4,
|
||||
),
|
||||
)
|
||||
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),
|
||||
encodePaneSelection(PaneSelection(MasterPane.Detail, 9L, 2, 1)),
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -16,12 +16,11 @@ class PipelinesNavTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun detailRoutesKeepTheirListDestinationSelected() {
|
||||
// A pipeline detail belongs to Pipelines, a run detail to Runs.
|
||||
assertTrue(destinationSelected("pipeline/1/2", "pipelines"))
|
||||
assertFalse(destinationSelected("pipeline/1/2", "runs"))
|
||||
assertTrue(destinationSelected("run/5", "runs"))
|
||||
assertFalse(destinationSelected("run/5", "pipelines"))
|
||||
fun detailRoutesAreNoLongerSeparateDestinations() {
|
||||
// Detail panes are saved state inside a destination, not routes, so a
|
||||
// stale route string selects nothing.
|
||||
assertFalse(destinationSelected("pipeline/1/2", "pipelines"))
|
||||
assertFalse(destinationSelected("run/5", "runs"))
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -37,11 +37,6 @@ class DetailTabsTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun collapsedRailIsNarrowerThanExpanded() {
|
||||
assertTrue(railWidthDp(false) < railWidthDp(true))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun clampTabIndexKeepsAValidSelection() {
|
||||
assertEquals(0, clampTabIndex(0, 6))
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
package net.awan.pipelines.ui.components
|
||||
|
||||
import androidx.compose.ui.unit.dp
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
|
||||
class SlidingPaneStackTest {
|
||||
|
||||
@Test
|
||||
fun peekIsAtLeastTheNamedMinimum() {
|
||||
// The named token (56dp) wins over a smaller platform minimum.
|
||||
assertEquals(56.dp, peekWidthDp(minimumInteractive = 48.dp))
|
||||
assertEquals(56.dp, peekWidthDp(minimumInteractive = 40.dp))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun peekWidensSoTheStripIsStillTappableAfterTheGestureInset() {
|
||||
// The left gesture inset eats 30dp; the visible peek grows so the
|
||||
// tappable strip (peek - inset) is still the minimum interactive size.
|
||||
val peek = peekWidthDp(minimumInteractive = 48.dp, startInset = 30.dp)
|
||||
assertEquals(78.dp, peek)
|
||||
assertTrue(peek - 30.dp >= 48.dp)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun peekWithoutInsetStaysTheNamedToken() {
|
||||
assertEquals(56.dp, peekWidthDp(minimumInteractive = 48.dp, startInset = 0.dp))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun paneOffsetIsOnePeekPerLevel() {
|
||||
// Each open pane sits one more peek to the right, so the pane below keeps
|
||||
// exactly its own peek visible.
|
||||
assertEquals(0.dp, paneOffsetDp(level = 0, peek = 56.dp))
|
||||
assertEquals(56.dp, paneOffsetDp(level = 1, peek = 56.dp))
|
||||
assertEquals(112.dp, paneOffsetDp(level = 2, peek = 56.dp))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun paneWidthIsTheHostLessItsPeeks() {
|
||||
assertEquals(411.dp, paneWidthDp(hostWidth = 411.dp, level = 0, peek = 56.dp))
|
||||
assertEquals(355.dp, paneWidthDp(hostWidth = 411.dp, level = 1, peek = 56.dp))
|
||||
assertEquals(299.dp, paneWidthDp(hostWidth = 411.dp, level = 2, peek = 56.dp))
|
||||
// Never negative when the host is narrower than the stacked peeks.
|
||||
assertEquals(0.dp, paneWidthDp(hostWidth = 100.dp, level = 2, peek = 56.dp))
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package net.awan.pipelines.ui.graph
|
||||
|
||||
import androidx.compose.ui.unit.dp
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
|
||||
class ArtifactGalleryTest {
|
||||
|
||||
private val spacing = 8.dp
|
||||
private val preferred = 96.dp
|
||||
|
||||
@Test
|
||||
fun narrowWidthShrinksTilesSoTheRowNeverOverflows() {
|
||||
// A depth-2 phone stage pane is ~360dp less two 56dp peeks and the 16dp
|
||||
// side paddings ≈216dp; three preferred 96dp tiles would overflow, so the
|
||||
// tile shrinks to the widest that fits.
|
||||
val tile = artifactTileDp(availableWidth = 216.dp, columns = 3, spacing = spacing, preferred = preferred)
|
||||
assertEquals((216f - 2 * 8f) / 3f, tile.value, 0.001f)
|
||||
assertTrue(tile < preferred)
|
||||
assertTrue(tile.value * 3 + 2 * 8f <= 216f)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun widthThatFitsThreePreferredTilesKeepsThePreferredTile() {
|
||||
// 328dp fits 3x96 + 2x8 with room to spare, so tiles stay compact and the
|
||||
// row does not overflow.
|
||||
val tile = artifactTileDp(availableWidth = 328.dp, columns = 3, spacing = spacing, preferred = preferred)
|
||||
assertEquals(preferred, tile)
|
||||
assertTrue(tile.value * 3 + 2 * 8f <= 328f)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun wideWidthKeepsThePreferredCompactTile() {
|
||||
val tile = artifactTileDp(availableWidth = 1200.dp, columns = 3, spacing = spacing, preferred = preferred)
|
||||
assertEquals(preferred, tile)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun exactFitKeepsThePreferredTile() {
|
||||
val available = preferred * 3 + spacing * 2
|
||||
val tile = artifactTileDp(availableWidth = available, columns = 3, spacing = spacing, preferred = preferred)
|
||||
assertEquals(preferred, tile)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun degenerateInputsReturnValidTiles() {
|
||||
// A zero/negative column count or a host narrower than the gaps never
|
||||
// yields a negative tile.
|
||||
assertEquals(preferred, artifactTileDp(availableWidth = 300.dp, columns = 0, spacing = spacing, preferred = preferred))
|
||||
assertEquals(0.dp, artifactTileDp(availableWidth = 4.dp, columns = 3, spacing = spacing, preferred = preferred))
|
||||
}
|
||||
}
|
||||
@@ -135,4 +135,32 @@ class StageDetailSheetTest {
|
||||
assertEquals(listOf("Incoming routes"), incoming.map { it.label })
|
||||
assertTrue(incoming.single().value.contains("a · success → SUCCESS"))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun headlineFieldsAreTheAlwaysVisibleIdentityAndResult() {
|
||||
val step = RunStep(
|
||||
status = "succeeded",
|
||||
outcome = "success",
|
||||
target = "cleanup",
|
||||
diagnostic = "why",
|
||||
transcript = "said something",
|
||||
input = mapOf("prompt" to JsonPrimitive("do it")),
|
||||
output = mapOf("result" to JsonPrimitive("done")),
|
||||
control = ControlEvidence(visit = 2, maxVisits = 4, modelTarget = "gpt"),
|
||||
startedAt = "2026-01-01T00:00:00Z",
|
||||
finishedAt = "2026-01-01T00:00:05Z",
|
||||
)
|
||||
val fields = runStepFields(step)
|
||||
val headline = headlineFields(fields).map { it.label }
|
||||
// Exactly the identity/result facts, visible without expanding anything.
|
||||
assertEquals(listOf("Status", "Outcome", "Duration", "Visit", "Model target", "Target"), headline)
|
||||
// None of the collapsible evidence leaks into the headline.
|
||||
assertTrue(headline.none { it == "Diagnostic" || it == "Transcript" || it == "Input" || it == "Output" })
|
||||
// And the headline facts are not repeated in the evidence section.
|
||||
val evidence = evidenceFields(fields).map { it.label }
|
||||
assertTrue(evidence.none { it in headline })
|
||||
assertTrue(evidence.containsAll(listOf("Diagnostic", "Transcript")))
|
||||
// Input/output are surfaced as their own sections, not the evidence block.
|
||||
assertTrue(evidence.none { it == "Input" || it == "Output" })
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user