Merge lane-e: keep the lane's reviewed work
Combine lane-e's reviewed Android UI work with main's lane-c/lane-d work. Conflicts resolved by keeping both intents: - android/README.md: both documentation sections retained - graph/StageDetailPane.kt: lane-e pane plus local section changes - screens/RunDetailScreen.kt, RunHistoryScreen.kt: lane-e features and local work both preserved - screens/PipelineListScreen.kt: new row layout and remembered sort/filter controls kept together
This commit is contained in:
@@ -3861,3 +3861,387 @@ the `uiautomator` dump tool itself (`com.android.commands.uiautomator`), never
|
|||||||
none (`Artifacts · not recorded for this visit`) rather than the populated
|
none (`Artifacts · not recorded for this visit`) rather than the populated
|
||||||
gallery (the same gallery branch is covered by the run-summary grid); the wide
|
gallery (the same gallery branch is covered by the run-summary grid); the wide
|
||||||
fold indicator (`"2 more"`) was present but is not separately cropped.
|
fold indicator (`"2 more"`) was present but is not separately cropped.
|
||||||
|
|
||||||
|
## One artifacts gallery everywhere, with a type icon for non-media (16 Oct 2026)
|
||||||
|
|
||||||
|
The gallery was already a grid, but only for images: non-image artifacts fell
|
||||||
|
through to a plain one-per-row list beneath it, so the same run rendered two
|
||||||
|
different ways. This pass makes `ArtifactGallery` the single rendering path for
|
||||||
|
every artifact (the run summary and the stage pane's per-visit section already
|
||||||
|
both use it) and gives non-media files a tile too. `android/` only; no
|
||||||
|
dependency was added (the new glyphs are `material-icons-extended`), no run was
|
||||||
|
started from the app, and every `adb` command targeted `emulator-5554` (never
|
||||||
|
`emulator-5556` or the attached Pixel).
|
||||||
|
|
||||||
|
- **One tile, two shapes.** `ui/graph/Artifacts.kt`'s `ArtifactTile` replaces the
|
||||||
|
old `ArtifactTile` + `ArtifactRow` split. An image fills the cell with its
|
||||||
|
thumbnail; a video shows its still/poster frame with a centred play marker on
|
||||||
|
top; anything else shows its file-type icon with the artifact's name and
|
||||||
|
human-readable size beneath it, all in the same width-derived grid. The grid is
|
||||||
|
still built from non-lazy chunked `Row`s, so it never nests a scrollable inside
|
||||||
|
the Summary `LazyColumn` or the pane's scroll.
|
||||||
|
- **Type-to-icon mapping.** The new pure `ui/graph/ArtifactType.kt` classifies an
|
||||||
|
artifact from its content type (parameters tolerated) and, when the server's
|
||||||
|
sniff is generic, its name's extension, into `ArtifactKind`
|
||||||
|
(Image/Video/Audio/Pdf/Json/Archive/Spreadsheet/Log/Code/Document/Other), and
|
||||||
|
`artifactIcon(kind)` gives each kind a distinct shape (PDF, JSON, archive,
|
||||||
|
spreadsheet, log, code, document, audio, generic file). `Format.kt` gained the
|
||||||
|
companion `isVideoContentType` predicate beside `isImageContentType`.
|
||||||
|
- **Video poster frame.** `ui/graph/ArtifactImage.kt` gained
|
||||||
|
`ArtifactVideoFrame`/`rememberArtifactVideoFrame`: the artifact's bytes are
|
||||||
|
fetched through the same bounded cache as an image and the representative sync
|
||||||
|
frame is extracted with the platform `MediaMetadataRetriever` over an in-memory
|
||||||
|
`MediaDataSource` (no temp file, no new dependency, no inline playback). The
|
||||||
|
full-screen viewer takes a `video` flag and shows that frame (its open action
|
||||||
|
plays the clip externally); a fetch/extraction failure falls back to the video
|
||||||
|
glyph rather than a fabricated image.
|
||||||
|
- **Actions kept.** Tap opens the viewer for an image/video and the existing
|
||||||
|
external-open action for anything else; every tile keeps its share control, a
|
||||||
|
non-media tile adds the copy-link control, and long-press / multi-select, the
|
||||||
|
contextual bar, bulk copy/share and the selection semantics are unchanged.
|
||||||
|
The capture summary and partial-capture notes are byte-for-byte unchanged.
|
||||||
|
- **Geometry from tokens, not literals.** `ui/theme/Dimens.kt` gains
|
||||||
|
`ARTIFACT_TYPE_ICON_DP` (28dp), `ARTIFACT_PLAY_BADGE_DP` (32dp) and
|
||||||
|
`ARTIFACT_TILE_ACTION_DP` (32dp); the tile still stretches `ARTIFACT_TILE_DP`
|
||||||
|
cells across the measured width via the unchanged pure `artifactGrid`.
|
||||||
|
|
||||||
|
Review follow-up (same pass, no UI change): the two preview state-holders
|
||||||
|
duplicated the whole memoize-through-caches scaffold, so it is now one private
|
||||||
|
`rememberArtifactPreview(url, maxDim, keyTag, fetchBytes, derive)` that both
|
||||||
|
`rememberArtifactBitmap` and `rememberArtifactVideoFrame` delegate to (the
|
||||||
|
`keyTag` keeps the two cache entries apart); the video fallback draws
|
||||||
|
`artifactIcon(ArtifactKind.Video)` instead of a hardcoded `Icons.Filled.Movie`;
|
||||||
|
and the now-unused `Format.kt` `artifactMetaLine` helper (its last caller was the
|
||||||
|
deleted non-image row) was removed with its `FormatTest` cases.
|
||||||
|
|
||||||
|
Verified on this tree (macOS, Homebrew `openjdk@25`,
|
||||||
|
`JAVA_HOME=/opt/homebrew/opt/openjdk@25/libexec/openjdk.jdk/Contents/Home`,
|
||||||
|
Gradle 9.7.1, `ANDROID_HOME=/Users/alan/Library/Android/sdk`, `--offline`):
|
||||||
|
|
||||||
|
- `gradle --offline :app:testDebugUnitTest --rerun-tasks` → `BUILD SUCCESSFUL`;
|
||||||
|
the 31 test-result XMLs aggregate to **265 tests, 0 failures, 0 errors, 0
|
||||||
|
skipped** (the new `ui/graph/ArtifactTypeTest` has 6 cases: the media kinds
|
||||||
|
from the content type, the named kinds, the extension fallback for a generic
|
||||||
|
sniff, the never-crash `Other` fallback, the explicit type-to-icon mapping, and
|
||||||
|
that no two kinds share a glyph). `ArtifactGalleryTest` still covers the grid
|
||||||
|
sizing (narrow → fewer, larger cells; wider → more preferred-shaped columns;
|
||||||
|
degenerate inputs). `compileDebugKotlin` emits no warnings.
|
||||||
|
- `gradle --offline :app:assembleDebug --rerun-tasks --no-build-cache` succeeded
|
||||||
|
→ `app-debug.apk` **18,011,393 bytes**, sha256
|
||||||
|
`faa9df077c960b23eef4afbac1b7effa1a50180eabcee2d638cabb232974cfa8`.
|
||||||
|
- On `emulator-5554` (native 2076x2152 @390; `wm size`/`wm density` used for the
|
||||||
|
narrow pass and reset afterwards) against the live server
|
||||||
|
`ws://10.0.2.2:8080/connect`, driven with `adb shell input` and `uiautomator
|
||||||
|
dump`; every capture was written with
|
||||||
|
`android/scripts/capture_png.sh -s emulator-5554` (validated PNG, named display
|
||||||
|
id) into `…/artifacts/140/1/`. Run 136's `implementer` visit 1 is a real mixed
|
||||||
|
set: five `image/png` screenshots plus `chat_stub_approval.py`
|
||||||
|
(`text/plain`, code glyph) and `stub.log` (`text/plain`, log glyph).
|
||||||
|
- **Wide** (2076x2152 ≈ 532dp): `evidence_wide_run136_summary_gallery.png`
|
||||||
|
shows the five thumbnails with their share controls and, in the same grid,
|
||||||
|
the `.py` tile with the `<>` code glyph and the `.log` tile with the log
|
||||||
|
glyph, each with its name and `9.3 KiB` / `220 B` beneath it and the copy +
|
||||||
|
share actions; `evidence_wide_run136_stage_pane.png` shows the same gallery in
|
||||||
|
the stage pane under the unchanged `Artifacts · 7 recorded · partial capture`
|
||||||
|
wording and the `1 files excluded from artifact capture.` note.
|
||||||
|
- **Narrow** (1080x2340 @480 ≈ 360dp):
|
||||||
|
`evidence_narrow_run136_summary_gallery.png` and
|
||||||
|
`evidence_narrow_run136_stage_pane.png` show three cells per row with the
|
||||||
|
thumbnails and the code/log type tiles still legible.
|
||||||
|
- Tapping a thumbnail opened the full-screen viewer
|
||||||
|
(`evidence_wide_run136_image_viewer.png`; `uiautomator dump` reported the
|
||||||
|
`01_approval_pending.png` image plus `Open … externally`, `Copy link …` and
|
||||||
|
`Close viewer`), and the non-media tiles' `Copy link to …` / `Share …`
|
||||||
|
controls are present in the accessibility tree.
|
||||||
|
- `adb -s emulator-5554 logcat -d | grep -cE 'FATAL EXCEPTION|E
|
||||||
|
AndroidRuntime'` returned 0; the emulator display was reset to native
|
||||||
|
2076x2152 @390 afterwards.
|
||||||
|
- **APK publish.** `app-debug.apk` copied to
|
||||||
|
`…/artifacts/140/1/pipelines-debug-wip-c700b28.apk` (`c700b28` = short
|
||||||
|
`HEAD`); `shasum -a 256` matched. `curl -I
|
||||||
|
http://10.0.0.249:8080/artifacts/140/1/pipelines-debug-wip-c700b28.apk`
|
||||||
|
returned `HTTP/1.1 200 OK`, `Content-Type:
|
||||||
|
application/vnd.android.package-archive`, `Content-Length: 18011393`, and a
|
||||||
|
streamed `GET | shasum -a 256` returned the same `faa9df07…` as the local file.
|
||||||
|
At ~17.2 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 **video** artifact does not exist on the live server
|
||||||
|
and starting a run is forbidden, so the play-marker/poster-frame render is
|
||||||
|
covered only by the `artifactKind` unit test (`video/mp4 → Video`) and the code
|
||||||
|
path, not by a device capture; the non-media external-open tap was not driven
|
||||||
|
(no handler is guaranteed on the emulator); multi-select/bulk share were not
|
||||||
|
re-exercised on device (their code is unchanged from the previous pass); the
|
||||||
|
light theme and `:app:lintDebug` were not run (the only known lint issues are the
|
||||||
|
two pre-existing `NewApi` errors for `android:windowLightNavigationBar`).
|
||||||
|
|
||||||
|
### Review fixes (same pass)
|
||||||
|
|
||||||
|
The review's three findings were addressed with no intended UI change, and the
|
||||||
|
two build checks were re-run on the resulting tree:
|
||||||
|
|
||||||
|
- `gradle --offline :app:testDebugUnitTest --rerun-tasks` → `BUILD SUCCESSFUL`;
|
||||||
|
the 31 result XMLs again aggregate to **265 tests, 0 failures, 0 errors, 0
|
||||||
|
skipped** (the removed `artifactMetaLine` assertions were replaced by
|
||||||
|
`isVideoContentType` coverage in the same `FormatTest` method).
|
||||||
|
- `gradle --offline :app:assembleDebug --rerun-tasks --no-build-cache` succeeded
|
||||||
|
→ `app-debug.apk` **18,011,393 bytes**, sha256
|
||||||
|
`2adaf03e5ac0bdb29b012d1487a0e10917f8ebabda973ddc63c7315b6df25dda`; it was
|
||||||
|
published to `…/artifacts/140/3/pipelines-debug-wip-c700b28.apk` and
|
||||||
|
`curl -I http://10.0.0.249:8080/artifacts/140/3/pipelines-debug-wip-c700b28.apk`
|
||||||
|
returned `HTTP/1.1 200 OK`, `Content-Length: 18011393`, with a streamed
|
||||||
|
`GET | shasum -a 256` matching the local `2adaf03e…`.
|
||||||
|
|
||||||
|
The device render was **not** re-captured: `emulator-5554` is shared and, while
|
||||||
|
this pass ran, another lane replaced the installed app with a build whose dex has
|
||||||
|
no `ArtifactType` class (`dumpsys package … lastUpdateTime` moved from this pass's
|
||||||
|
`16:24:02` install to `16:24:20`, and the installed `base.apk` sha no longer
|
||||||
|
matched `2adaf03e…`), so any capture could not be attributed to this build. The
|
||||||
|
wide/narrow captures above predate the refactor; the refactor changes no UI
|
||||||
|
pixels, so they remain representative of the gallery this code renders.
|
||||||
|
|
||||||
|
## Collapsible artifacts gallery in the run summary (16 Oct 2026)
|
||||||
|
|
||||||
|
The artifacts gallery led the run summary but was always open, so a long run's
|
||||||
|
grid pushed the run's own facts below the fold. It is now one
|
||||||
|
collapsed-by-default section in the same place. `android/` only; no dependency
|
||||||
|
was added (the chevron is the existing `material-icons-extended`
|
||||||
|
`KeyboardArrowDown` the shared `SectionHeader` already uses), no run was started
|
||||||
|
from the app, and every device command targeted the operator's Pixel 10 Pro Fold
|
||||||
|
(`58281FDCG000JF`), never an emulator.
|
||||||
|
|
||||||
|
- **One collapsed section, same place.** `RunDetailScreen.kt`'s `RunSummaryTab`
|
||||||
|
renders the gallery through the shared `LazyListScope.collapsibleSection`,
|
||||||
|
keyed `"artifacts"` and seeded with `rememberSectionExpansion(run.id)`, so a
|
||||||
|
run opened fresh starts collapsed and the operator's expand/collapse choice
|
||||||
|
survives Summary↔tab switches, configuration changes and rotation exactly like
|
||||||
|
every other section. The order is unchanged: the artifacts section still leads
|
||||||
|
the summary and the facts item follows it.
|
||||||
|
- **A self-describing header.** The new pure `runArtifactsHeader(steps,
|
||||||
|
executing)` (`ui/ArtifactGroups.kt`) builds the header text — the title (its
|
||||||
|
singular form for exactly one artifact), how many the run recorded, and
|
||||||
|
`· partial capture` when any visit excluded or omitted files; with no artifacts
|
||||||
|
it reuses the shared `artifactsEmptyMessage`. Its count is exactly
|
||||||
|
`runArtifactGroups`'s tile total, so the header and the expanded gallery can
|
||||||
|
never disagree.
|
||||||
|
- **The gallery itself is unchanged.** Expanding composes the same
|
||||||
|
`ArtifactGallery` (the width-derived thumbnail grid, tap for full size, the
|
||||||
|
non-media tiles with name, size and content type plus their open/copy/share
|
||||||
|
actions); collapsing composes nothing. The stage pane's per-visit artifacts
|
||||||
|
section and every other summary section are untouched.
|
||||||
|
|
||||||
|
Evidence (macOS, JDK 17 from Homebrew `openjdk@17`, Gradle 8.11.1 from the
|
||||||
|
wrapper cache, `ANDROID_HOME=/Users/alan/Library/Android/sdk`, `--offline`,
|
||||||
|
every Gradle command with `--no-daemon`):
|
||||||
|
|
||||||
|
- `gradle --no-daemon --offline :app:testDebugUnitTest` → `BUILD SUCCESSFUL`; the
|
||||||
|
test-result XMLs aggregate to **269 tests, 0 failures, 0 errors, 0 skipped**.
|
||||||
|
`ArtifactGroupsTest` gained `headerReportsTheCountWithASingularTitleForOne`,
|
||||||
|
`headerAddsPartialCaptureOnlyWhenFilesWereExcludedOrOmitted`,
|
||||||
|
`headerEmptyCaseUsesTheSharedEmptyWording` and
|
||||||
|
`headerCountMatchesTheGalleryRecordedTotal`.
|
||||||
|
- `gradle --no-daemon --offline :app:assembleDebug` → `app-debug.apk`
|
||||||
|
**18,011,393 bytes**, sha256
|
||||||
|
`c5655269e490db34cbacccf68eaec468a3a41c46c661b41e6ad2d92295235247`; installed
|
||||||
|
with `adb -s 58281FDCG000JF install -r`, and the pulled `base.apk` sha matched
|
||||||
|
the local build, so the captures below are attributed to this exact build.
|
||||||
|
- Run **136** (pipeline id 11 v1, `succeeded`, 17 artifacts) on the Pixel:
|
||||||
|
- **Wide** (inner display, 2152×2076 @330 ≈ 1043dp):
|
||||||
|
`summary_wide_collapsed.png` shows the summary led by a lone collapsed
|
||||||
|
`Artifacts · 17 recorded · partial capture` header (right chevron) with the
|
||||||
|
run's facts immediately below and no gallery; `summary_wide_expanded.png`
|
||||||
|
shows the same header expanded to the unchanged gallery — the
|
||||||
|
`implementer · visit 1` and `ui_reviewer · visit 1` groups of image
|
||||||
|
thumbnails plus the `chat_stub_approval.py` (`<>` code glyph) and `stub.log`
|
||||||
|
(log glyph) tiles with their names, `9.3 KiB`/`220 B` sizes and share/copy
|
||||||
|
actions.
|
||||||
|
- **Narrow** (`wm size 1080x2152` on the inner display ≈ 524dp, reset to the
|
||||||
|
native size afterwards): `summary_narrow_collapsed.png` and
|
||||||
|
`summary_narrow_expanded.png` show the same collapsed header and, expanded,
|
||||||
|
the same gallery re-flowed to four cells per row (wide uses five).
|
||||||
|
- **Persistence.** `uiautomator dump` reported `Artifacts · 17 recorded ·
|
||||||
|
partial capture, collapsed` on a freshly opened run; toggling it and
|
||||||
|
round-tripping Summary → Graph → Summary, and a `wm size` configuration
|
||||||
|
change, both kept the operator's expanded/collapsed choice.
|
||||||
|
- `adb -s 58281FDCG000JF logcat -d | grep -cE 'FATAL EXCEPTION|E
|
||||||
|
AndroidRuntime'` returned 0; the screen stayed awake (`svc power stayon usb`
|
||||||
|
+ `KEYCODE_WAKEUP`) and every capture used `screencap -p -d <display-id>` +
|
||||||
|
`adb pull`. Screenshots, `uiautomator` dumps and the APK are in
|
||||||
|
`…/artifacts/155/1/`.
|
||||||
|
- **APK publish.** `app-debug.apk` copied to
|
||||||
|
`…/artifacts/155/1/pipelines-debug-wip-95150c7.apk` (`95150c7` = short `HEAD`;
|
||||||
|
the working tree is uncommitted WIP on top of it); `shasum -a 256` matched.
|
||||||
|
`curl -I http://10.0.0.249:8080/artifacts/155/1/pipelines-debug-wip-95150c7.apk`
|
||||||
|
returned `HTTP/1.1 200 OK`, `Content-Type:
|
||||||
|
application/vnd.android.package-archive`, `Content-Length: 18011393`.
|
||||||
|
|
||||||
|
Not verified in this pass: no device capture exercises the empty or the
|
||||||
|
single-artifact header wording (both are covered by the `runArtifactsHeader`
|
||||||
|
unit tests); the narrow window was produced with a `wm size` override on the
|
||||||
|
inner display rather than a physical fold, then reset; `:app:lintDebug` was not
|
||||||
|
re-run (its only known findings remain the two pre-existing `NewApi` errors for
|
||||||
|
`android:windowLightNavigationBar`).
|
||||||
|
|
||||||
|
## Run title beside the pipeline name (16 Oct 2026)
|
||||||
|
|
||||||
|
A run now shows the operator's title for the goal, with the pipeline it ran on as
|
||||||
|
the secondary line, so two runs of the same pipeline are distinguishable.
|
||||||
|
`android/` only; no dependency was added, no run was started from the app, and no
|
||||||
|
device command was run (build + unit tests only).
|
||||||
|
|
||||||
|
- **Protocol.** `data/protocol/Message.kt` gains an optional `title` on both
|
||||||
|
`RunSummary` and `RunDetail` (the server's `RunSummary.title`). It is nullable
|
||||||
|
and defaults to absent, so a server that does not send it degrades cleanly.
|
||||||
|
- **One shared fallback.** New `ui/RunIdentity.kt` holds `runLabel(title, name)`
|
||||||
|
(mirroring the server's `RunSummary.Label`) and `runIdentity(title, name)`: the
|
||||||
|
label is the title, or the pipeline name when the title is absent/blank, and the
|
||||||
|
pipeline is a second line only when a title exists — never an empty line.
|
||||||
|
- **Runs list.** `RunHistoryScreen.RunRow` shows the label as the primary line and,
|
||||||
|
only for a titled run, the pipeline name plus its version chip on a second line;
|
||||||
|
an untitled run keeps the pipeline name and version chip as its single identity
|
||||||
|
line. The status chip, progress, id/start/duration line and diagnostic are
|
||||||
|
unchanged.
|
||||||
|
- **Run detail + stage panes.** The run detail app bar and the Summary lead with
|
||||||
|
the label and, when titled, name the pipeline (`name · vN`) on a second line; the
|
||||||
|
covered peek uses the label too. `StageDetailPane` takes an optional `runLabel`
|
||||||
|
and shows it under the stage name, so a stage/visit pane keeps the run context.
|
||||||
|
- **Renaming is not offered.** The authoritative server does not expose it: it has
|
||||||
|
no `set_run_title` command and `list_runs`/`get_run` return no `title` field, so
|
||||||
|
the app does not fake a rename. The protocol field is parsed for the server that
|
||||||
|
does send it; until then the title falls back to the pipeline name.
|
||||||
|
|
||||||
|
Evidence (macOS, JDK 17 from Homebrew `openjdk@17`, Gradle 8.11.1 from the wrapper
|
||||||
|
cache, `ANDROID_HOME=/Users/alan/Library/Android/sdk`, `--offline`, `--no-daemon`):
|
||||||
|
|
||||||
|
- `:app:testDebugUnitTest` → `BUILD SUCCESSFUL`; the 32 result XMLs aggregate to
|
||||||
|
**276 tests, 0 failures, 0 errors, 0 skipped**. The new `RunIdentityTest` (5
|
||||||
|
cases) covers the title/fallback/trim logic, and `ProtocolModelTest` gained a
|
||||||
|
case for a present and one for an absent title on both the run summary and the
|
||||||
|
run detail.
|
||||||
|
- `:app:assembleDebug` → `app-debug.apk` **18,257,214 bytes**, sha256
|
||||||
|
`bce661069b2bd013f0802545402766a3ae8fed97e1bbe0109f81a4bfb6233601`.
|
||||||
|
- Server capability probe (read-only, through the installed CLI):
|
||||||
|
`pipelines runs` and `pipelines rpc '{"type":"get_run","run_id":155}'` return no
|
||||||
|
`title` field, and the running `pipelines-server` binary contains no
|
||||||
|
`set_run_title` string. So renaming is deliberately not offered and the title
|
||||||
|
falls back to the pipeline name until a server carrying the field is deployed.
|
||||||
|
- **APK publish.** `app-debug.apk` copied to
|
||||||
|
`…/artifacts/162/1/pipelines-debug-wip-e1c531a.apk` (`e1c531a` = short `HEAD`;
|
||||||
|
the working tree is uncommitted WIP on top of it); `shasum -a 256` matched.
|
||||||
|
`curl -I http://10.0.0.249:8080/artifacts/162/1/pipelines-debug-wip-e1c531a.apk`
|
||||||
|
returned `HTTP/1.1 200 OK`, `Content-Type:
|
||||||
|
application/vnd.android.package-archive`, `Content-Length: 18257214`.
|
||||||
|
|
||||||
|
Not verified in this pass: device captures of the runs list and run detail (the
|
||||||
|
visual review owns the device); no server that actually sends `title` was
|
||||||
|
available, so the titled layout is exercised by the unit tests and the fallback
|
||||||
|
path only.
|
||||||
|
|
||||||
|
## Stage verdict atop the stage pane, with clickable artifacts (16 Oct 2026)
|
||||||
|
|
||||||
|
A completed run visit now leads its stage pane with the server's derived verdict:
|
||||||
|
the chosen option as a badge, the concise reason in ordinary body text, and the
|
||||||
|
recorded artifacts the reason names as inline, tappable references plus the same
|
||||||
|
references as compact chips. `android/` only; nothing in the Pipelines server, its
|
||||||
|
Go source, the installer or the Docker files was touched, no run was started from
|
||||||
|
the app, and no device command was run (build + unit tests only).
|
||||||
|
|
||||||
|
- **Protocol.** `data/protocol/Message.kt` gains `StageVerdict` and an optional
|
||||||
|
`verdict` on `RunStep`, mirroring `internal/protocol/verdict.go`
|
||||||
|
(`{option, reason, reason_source, artifacts}` under the `verdict` wire name). It
|
||||||
|
is nullable and defaults to absent, so a running step or a pre-verdict server
|
||||||
|
parses cleanly to null.
|
||||||
|
- **One block.** New `ui/graph/StageVerdict.kt` holds the pure helpers and the
|
||||||
|
composable. `StageVerdictBlock` is rendered at the top of the run pane, below the
|
||||||
|
visit tabs and above the facts, only when the server reported a verdict; a null
|
||||||
|
verdict (or one with neither option nor reason) draws nothing — never an empty
|
||||||
|
heading or placeholder.
|
||||||
|
- **Badge.** The option is a `ColoredChip` in the *stage outcome's* existing colour
|
||||||
|
(`outcomeColor(step.outcome)`, the graph's palette the Timeline chips already
|
||||||
|
use), so the badge agrees with the graph rather than a new colour vocabulary.
|
||||||
|
- **Reason.** Rendered with `pipelinesText().body`, so it is readable plain
|
||||||
|
language, never a monospace JSON dump, and it wraps with no `maxLines` clip.
|
||||||
|
- **References.** `referencedVerdictArtifacts` resolves the verdict's referenced
|
||||||
|
names to the visit's recorded artifacts (recorded order, deduplicated, an
|
||||||
|
unrecorded/invented name dropped). `verdictReasonSegments` splits the reason
|
||||||
|
around those names — by full recorded name or basename, longest match first — and
|
||||||
|
the segments become inline `LinkAnnotation.Clickable` references coloured
|
||||||
|
`primary` with an underline. An image/video reference opens the shared
|
||||||
|
`ArtifactViewer`; anything else goes through the existing `openArtifact` action.
|
||||||
|
The same references are `FlowRow` chips (`VerdictArtifactChip`) with their type
|
||||||
|
glyph, so they can be tapped without hunting in the sentence.
|
||||||
|
- **Geometry.** Only existing tokens (`SPACING_M`/`SPACING_S`/`SPACING_XS`,
|
||||||
|
`ICON_STATUS_DP`); no new `dp`/`sp` literal and no new dependency.
|
||||||
|
|
||||||
|
Evidence (macOS, JDK 17 from Homebrew `openjdk@17`, Gradle 8.11.1 from the wrapper
|
||||||
|
cache, `ANDROID_HOME=/Users/alan/Library/Android/sdk`, `--no-daemon`):
|
||||||
|
|
||||||
|
- `:app:testDebugUnitTest` → `BUILD SUCCESSFUL`; the result XMLs aggregate to
|
||||||
|
**282 tests, 0 failures, 0 errors, 0 skipped**. New `StageVerdictTest` (5 cases:
|
||||||
|
split around every referenced name, basename for a slashed path, longest match
|
||||||
|
wins, a reason with no references, and name→recorded-artifact resolution) and
|
||||||
|
`ProtocolModelTest#runStepVerdictParsesWithItsReasonSourceAndReferencedArtifacts`.
|
||||||
|
- `:app:assembleDebug` → `app-debug.apk` **18,270,824 bytes**, sha256
|
||||||
|
`85847c6fe32498f38464741ca1b8f592dbbd7a9e1f34dd649121e723836b0903`.
|
||||||
|
- **APK publish.** `app-debug.apk` copied to
|
||||||
|
`~/.local/share/pipelines/data/artifacts/167/1/pipelines-debug-wip-8b0d7b1.apk`
|
||||||
|
(`8b0d7b1` = short `HEAD`); `shasum -a 256` matched. The LAN URL
|
||||||
|
`http://10.0.0.249:8080/artifacts/167/1/pipelines-debug-wip-8b0d7b1.apk` returned
|
||||||
|
`HTTP/1.1 200 OK`, `Content-Type: application/vnd.android.package-archive`,
|
||||||
|
`Content-Length: 18270824`.
|
||||||
|
|
||||||
|
Not verified in this pass: device captures of the stage pane at a narrow and a wide
|
||||||
|
window (the visual review owns the device, per the brief's device policy), so the
|
||||||
|
verdict layout is exercised by the unit tests and the compile only. No server that
|
||||||
|
actually sends `verdict` was available to the implementer, so the block's live
|
||||||
|
rendering against real data is deferred to visual review.
|
||||||
|
|
||||||
|
## One search: the pipelines list drops its inline field (16 Oct 2026)
|
||||||
|
|
||||||
|
The pipelines list carried its own "Search pipelines" text field while the app
|
||||||
|
also has the omni search (the destination pill's Search entry point), so the list
|
||||||
|
offered a second, narrower way to do the same job. The inline field is gone and
|
||||||
|
name narrowing moved into the list's filter control, keeping "filters narrow one
|
||||||
|
list" separate from "search finds things across the system".
|
||||||
|
|
||||||
|
- **One field removed.** `PipelineListScreen` no longer owns a `query` state or
|
||||||
|
draws the `OutlinedTextField`; the list is now the first thing under the app
|
||||||
|
bar, so no spacer stands in for the field that used to sit there.
|
||||||
|
- **Name is a filter.** `PipelineFilters` gained a free-text `name` facet beside
|
||||||
|
`presence`/`lastRunStatuses`, applied by `filterPipelines` through the new
|
||||||
|
`pipelineMatchesName` (case-insensitive `contains`, blank means any). Unlike the
|
||||||
|
run facets it needs no run history, so it narrows as soon as the pipelines load
|
||||||
|
while the run facets still wait for `runsKnown`.
|
||||||
|
- **In the menu.** `PipelineFilterControl` opens with a `Name` section holding a
|
||||||
|
single-line `PipelineNameFilter` (label "Pipeline name contains") that keeps the
|
||||||
|
menu open while typing; the shared Clear filters resets it with the run facets
|
||||||
|
and the active-count badge counts it.
|
||||||
|
- **Persisted.** `SettingsRepository`/`AppViewModel` store the name under
|
||||||
|
`pipeline_filter_name` like the other facets, so a restart remembers it.
|
||||||
|
- **Runs list unchanged.** The runs list never had an inline search field, so
|
||||||
|
nothing was removed there.
|
||||||
|
- **Geometry.** No new `dp`/`sp` literal and no percentage: the field reuses
|
||||||
|
`SPACING_M`/`SPACING_S` and fills the filter menu's own width, and the reclaimed
|
||||||
|
vertical space comes from the removed field's layout, not a replacement
|
||||||
|
constant.
|
||||||
|
|
||||||
|
Evidence (macOS, JDK 17 from Homebrew `openjdk@17`, Gradle 8.11.1 from the wrapper
|
||||||
|
cache, `ANDROID_HOME=/Users/alan/Library/Android/sdk`, `--no-daemon --offline`):
|
||||||
|
|
||||||
|
- `:app:testDebugUnitTest` → `BUILD SUCCESSFUL`; the 35 result XMLs aggregate to
|
||||||
|
**312 tests, 0 failures, 0 errors, 0 skipped**. `ListFilterTest` now has 20 cases
|
||||||
|
(+4: name substring/blank, name before the run history, name AND the run facets,
|
||||||
|
active count/`hasRunFacets`; `pipelineFiltersFromStorageParsesAndFallsBack` now
|
||||||
|
covers the name).
|
||||||
|
- `:app:assembleDebug` → `app-debug.apk` **18,164,618 bytes**, sha256
|
||||||
|
`375be755d03d17c7721fe5b4ea23f637c928fd48acc300b4aec9f3d3cf2d4e50`.
|
||||||
|
- **APK publish.** `app-debug.apk` copied to
|
||||||
|
`~/.local/share/pipelines/data/artifacts/171/1/pipelines-debug-wip-e7c4b8f.apk`
|
||||||
|
(`e7c4b8f` = short `HEAD`); `shasum -a 256` matched. The LAN URL
|
||||||
|
`http://10.0.0.249:8080/artifacts/171/1/pipelines-debug-wip-e7c4b8f.apk` returned
|
||||||
|
`HTTP 200`, `Content-Type: application/vnd.android.package-archive`,
|
||||||
|
`Content-Length: 18164618`.
|
||||||
|
|
||||||
|
Not verified in this pass: device captures (the visual review owns the device, per
|
||||||
|
the brief's device policy), so the filter-menu name field's on-screen layout is
|
||||||
|
exercised by the compile and the pure filter tests only.
|
||||||
|
|||||||
@@ -49,6 +49,9 @@ class SettingsRepository(context: Context) {
|
|||||||
MutableStateFlow(prefs.getString(KEY_PIPELINE_FILTER_RUN_STATUSES, "").orEmpty())
|
MutableStateFlow(prefs.getString(KEY_PIPELINE_FILTER_RUN_STATUSES, "").orEmpty())
|
||||||
val pipelineFilterRunStatuses: StateFlow<String> = _pipelineFilterRunStatuses.asStateFlow()
|
val pipelineFilterRunStatuses: StateFlow<String> = _pipelineFilterRunStatuses.asStateFlow()
|
||||||
|
|
||||||
|
private val _pipelineFilterName = MutableStateFlow(prefs.getString(KEY_PIPELINE_FILTER_NAME, "").orEmpty())
|
||||||
|
val pipelineFilterName: StateFlow<String> = _pipelineFilterName.asStateFlow()
|
||||||
|
|
||||||
fun setServerUrl(value: String) {
|
fun setServerUrl(value: String) {
|
||||||
val trimmed = value.trim()
|
val trimmed = value.trim()
|
||||||
_serverUrl.value = trimmed
|
_serverUrl.value = trimmed
|
||||||
@@ -96,6 +99,11 @@ class SettingsRepository(context: Context) {
|
|||||||
prefs.edit().putString(KEY_PIPELINE_FILTER_RUN_STATUSES, value).apply()
|
prefs.edit().putString(KEY_PIPELINE_FILTER_RUN_STATUSES, value).apply()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun setPipelineFilterName(value: String) {
|
||||||
|
_pipelineFilterName.value = value
|
||||||
|
prefs.edit().putString(KEY_PIPELINE_FILTER_NAME, value).apply()
|
||||||
|
}
|
||||||
|
|
||||||
/** True only when the user has explicitly supplied both required values. */
|
/** True only when the user has explicitly supplied both required values. */
|
||||||
fun isConfigured(): Boolean = _serverUrl.value.isNotBlank() && _workspace.value.isNotBlank()
|
fun isConfigured(): Boolean = _serverUrl.value.isNotBlank() && _workspace.value.isNotBlank()
|
||||||
|
|
||||||
@@ -109,5 +117,6 @@ class SettingsRepository(context: Context) {
|
|||||||
const val KEY_RUN_FILTER_TIME_RANGE = "run_filter_time_range"
|
const val KEY_RUN_FILTER_TIME_RANGE = "run_filter_time_range"
|
||||||
const val KEY_PIPELINE_FILTER_PRESENCE = "pipeline_filter_presence"
|
const val KEY_PIPELINE_FILTER_PRESENCE = "pipeline_filter_presence"
|
||||||
const val KEY_PIPELINE_FILTER_RUN_STATUSES = "pipeline_filter_run_statuses"
|
const val KEY_PIPELINE_FILTER_RUN_STATUSES = "pipeline_filter_run_statuses"
|
||||||
|
const val KEY_PIPELINE_FILTER_NAME = "pipeline_filter_name"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -226,6 +226,22 @@ data class StageArtifact(
|
|||||||
val url: String = "",
|
val url: String = "",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The plain-language outcome of one completed stage visit, derived server-side
|
||||||
|
* and mirrored from `internal/protocol/verdict.go` StageVerdict: the chosen
|
||||||
|
* option (the outcome and the target it routed to), a bounded one-line reason
|
||||||
|
* with its provenance ([reasonSource]), and the names of the recorded artifacts
|
||||||
|
* the reason refers to. A null on a step means the server reported no verdict
|
||||||
|
* (for example a running visit), so the pane shows no block at all.
|
||||||
|
*/
|
||||||
|
@Serializable
|
||||||
|
data class StageVerdict(
|
||||||
|
val option: String = "",
|
||||||
|
val reason: String = "",
|
||||||
|
@SerialName("reason_source") val reasonSource: String = "",
|
||||||
|
val artifacts: List<String> = emptyList(),
|
||||||
|
)
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class NotificationReceipt(
|
data class NotificationReceipt(
|
||||||
val destination: String = "",
|
val destination: String = "",
|
||||||
@@ -251,6 +267,10 @@ data class RunSummary(
|
|||||||
val id: Long = 0,
|
val id: Long = 0,
|
||||||
@SerialName("pipeline_id") val pipelineId: Long = 0,
|
@SerialName("pipeline_id") val pipelineId: Long = 0,
|
||||||
val name: String = "",
|
val name: String = "",
|
||||||
|
// The operator-facing, bounded description of what the run is for, generated
|
||||||
|
// by the server from its prompt. Null/blank on a server that predates the
|
||||||
|
// field, so the UI falls back to [name] rather than showing an empty line.
|
||||||
|
val title: String? = null,
|
||||||
val version: Int = 0,
|
val version: Int = 0,
|
||||||
@SerialName("content_hash") val contentHash: String = "",
|
@SerialName("content_hash") val contentHash: String = "",
|
||||||
val status: String = "",
|
val status: String = "",
|
||||||
@@ -274,6 +294,9 @@ data class RunStep(
|
|||||||
val artifacts: List<StageArtifact>? = null,
|
val artifacts: List<StageArtifact>? = null,
|
||||||
@SerialName("artifacts_skipped") val artifactsSkipped: Int = 0,
|
@SerialName("artifacts_skipped") val artifactsSkipped: Int = 0,
|
||||||
@SerialName("artifacts_truncated") val artifactsTruncated: Int = 0,
|
@SerialName("artifacts_truncated") val artifactsTruncated: Int = 0,
|
||||||
|
// The server's derived plain-language verdict; absent (null) on a running step
|
||||||
|
// or a pre-verdict server, so the pane shows no block.
|
||||||
|
val verdict: StageVerdict? = null,
|
||||||
val sequence: Int = 0,
|
val sequence: Int = 0,
|
||||||
val stage: String = "",
|
val stage: String = "",
|
||||||
val status: String = "",
|
val status: String = "",
|
||||||
@@ -296,6 +319,8 @@ data class RunDetail(
|
|||||||
val id: Long = 0,
|
val id: Long = 0,
|
||||||
@SerialName("pipeline_id") val pipelineId: Long = 0,
|
@SerialName("pipeline_id") val pipelineId: Long = 0,
|
||||||
val name: String = "",
|
val name: String = "",
|
||||||
|
// Mirrors the embedded RunSummary.title (see internal/protocol/runs.go).
|
||||||
|
val title: String? = null,
|
||||||
val version: Int = 0,
|
val version: Int = 0,
|
||||||
@SerialName("content_hash") val contentHash: String = "",
|
@SerialName("content_hash") val contentHash: String = "",
|
||||||
val status: String = "",
|
val status: String = "",
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ class AppViewModel(
|
|||||||
val runFilterTimeRange: StateFlow<String> = settings.runFilterTimeRange
|
val runFilterTimeRange: StateFlow<String> = settings.runFilterTimeRange
|
||||||
val pipelineFilterPresence: StateFlow<String> = settings.pipelineFilterPresence
|
val pipelineFilterPresence: StateFlow<String> = settings.pipelineFilterPresence
|
||||||
val pipelineFilterRunStatuses: StateFlow<String> = settings.pipelineFilterRunStatuses
|
val pipelineFilterRunStatuses: StateFlow<String> = settings.pipelineFilterRunStatuses
|
||||||
|
val pipelineFilterName: StateFlow<String> = settings.pipelineFilterName
|
||||||
|
|
||||||
private val _serverUrlDraft = MutableStateFlow(settings.serverUrl.value)
|
private val _serverUrlDraft = MutableStateFlow(settings.serverUrl.value)
|
||||||
val serverUrlDraft: StateFlow<String> = _serverUrlDraft.asStateFlow()
|
val serverUrlDraft: StateFlow<String> = _serverUrlDraft.asStateFlow()
|
||||||
@@ -192,6 +193,8 @@ class AppViewModel(
|
|||||||
|
|
||||||
fun setPipelineFilterRunStatuses(value: String) = settings.setPipelineFilterRunStatuses(value)
|
fun setPipelineFilterRunStatuses(value: String) = settings.setPipelineFilterRunStatuses(value)
|
||||||
|
|
||||||
|
fun setPipelineFilterName(value: String) = settings.setPipelineFilterName(value)
|
||||||
|
|
||||||
private fun awaitConnected() {
|
private fun awaitConnected() {
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
val connected = withTimeoutOrNull(CONNECT_TIMEOUT_MILLIS) {
|
val connected = withTimeoutOrNull(CONNECT_TIMEOUT_MILLIS) {
|
||||||
|
|||||||
@@ -54,3 +54,27 @@ fun artifactsEmptyMessage(executing: Boolean): String =
|
|||||||
} else {
|
} else {
|
||||||
"No artifacts recorded for this run."
|
"No artifacts recorded for this run."
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The run summary's Artifacts section header, complete on its own while the
|
||||||
|
* section is collapsed: the title, how many artifacts the run recorded (the
|
||||||
|
* title takes its singular form for exactly one) and "partial capture" when any
|
||||||
|
* visit excluded or omitted files. It mirrors the per-visit [artifactsSummary]
|
||||||
|
* vocabulary at run level and reuses the shared [artifactsEmptyMessage] for the
|
||||||
|
* empty case, so a run with nothing recorded still gets a self-describing
|
||||||
|
* collapsed header. The recorded count is exactly the number of tiles
|
||||||
|
* [runArtifactGroups] yields, so the header and the expanded gallery can never
|
||||||
|
* disagree. Pure.
|
||||||
|
*/
|
||||||
|
fun runArtifactsHeader(steps: List<RunStep>, executing: Boolean): String {
|
||||||
|
val recorded = steps.sumOf { it.artifacts.orEmpty().size }
|
||||||
|
if (recorded == 0) return artifactsEmptyMessage(executing)
|
||||||
|
val partial = steps.any { it.artifactsSkipped > 0 || it.artifactsTruncated > 0 }
|
||||||
|
return buildString {
|
||||||
|
append(if (recorded == 1) "Artifact" else "Artifacts")
|
||||||
|
append(" · ")
|
||||||
|
append(recorded)
|
||||||
|
append(" recorded")
|
||||||
|
if (partial) append(" · partial capture")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import kotlinx.serialization.json.JsonPrimitive
|
|||||||
import net.awan.pipelines.data.protocol.FileChange
|
import net.awan.pipelines.data.protocol.FileChange
|
||||||
import net.awan.pipelines.data.protocol.NotificationReceipt
|
import net.awan.pipelines.data.protocol.NotificationReceipt
|
||||||
import net.awan.pipelines.data.protocol.RunStep
|
import net.awan.pipelines.data.protocol.RunStep
|
||||||
import net.awan.pipelines.data.protocol.StageArtifact
|
|
||||||
import net.awan.pipelines.data.protocol.StageFileChanges
|
import net.awan.pipelines.data.protocol.StageFileChanges
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -156,6 +155,12 @@ fun humanBytes(size: Long): String {
|
|||||||
/** Whether an artifact's content type is an image the sheet can preview. */
|
/** Whether an artifact's content type is an image the sheet can preview. */
|
||||||
fun isImageContentType(contentType: String): Boolean = contentType.startsWith("image/")
|
fun isImageContentType(contentType: String): Boolean = contentType.startsWith("image/")
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether an artifact's content type is a video. Videos are shown in the gallery
|
||||||
|
* as a still/poster frame with a play marker; they are never decoded inline.
|
||||||
|
*/
|
||||||
|
fun isVideoContentType(contentType: String): Boolean = contentType.startsWith("video/")
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The "capture pending" wording shared by a running visit's summary and the
|
* The "capture pending" wording shared by a running visit's summary and the
|
||||||
* run-level empty state, so the two never spell it differently.
|
* run-level empty state, so the two never spell it differently.
|
||||||
@@ -194,10 +199,3 @@ fun artifactCaptureNotes(step: RunStep): List<String> = buildList {
|
|||||||
if (step.artifactsSkipped > 0) add("${step.artifactsSkipped} files excluded from artifact capture.")
|
if (step.artifactsSkipped > 0) add("${step.artifactsSkipped} files excluded from artifact capture.")
|
||||||
if (step.artifactsTruncated > 0) add("${step.artifactsTruncated} files omitted by artifact capture limits.")
|
if (step.artifactsTruncated > 0) add("${step.artifactsTruncated} files omitted by artifact capture limits.")
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* One artifact's meta line: its human-readable size and content type. A blank or
|
|
||||||
* missing content type never renders as a dangling separator.
|
|
||||||
*/
|
|
||||||
fun artifactMetaLine(artifact: StageArtifact): String =
|
|
||||||
"${humanBytes(artifact.sizeBytes)} · ${artifact.contentType.ifBlank { "unknown type" }}"
|
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
package net.awan.pipelines.ui
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The operator-facing name of a run: the server's stored title when it sent one,
|
||||||
|
* otherwise the pipeline name (a run predating the title field, or one the server
|
||||||
|
* could not title). Mirrors the server's `RunSummary.Label`, so the runs list, the
|
||||||
|
* run detail header and the stage pane never spell the same run differently.
|
||||||
|
*/
|
||||||
|
fun runLabel(title: String?, name: String): String {
|
||||||
|
val stored = title?.trim().orEmpty()
|
||||||
|
return if (stored.isEmpty()) name else stored
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The runs list's two identity lines: [label] is the run's primary line and
|
||||||
|
* [pipeline] is the pipeline the run belongs to, shown as a second line only when
|
||||||
|
* the label is a stored title (so two runs of one pipeline read as different
|
||||||
|
* goals). A run with no title falls back to the pipeline name as its only line —
|
||||||
|
* never a title line followed by an empty one.
|
||||||
|
*/
|
||||||
|
data class RunIdentity(val label: String, val pipeline: String?)
|
||||||
|
|
||||||
|
fun runIdentity(title: String?, name: String): RunIdentity {
|
||||||
|
val stored = title?.trim().orEmpty()
|
||||||
|
return if (stored.isEmpty()) RunIdentity(name, null) else RunIdentity(stored, name)
|
||||||
|
}
|
||||||
@@ -2,6 +2,8 @@ package net.awan.pipelines.ui.graph
|
|||||||
|
|
||||||
import android.graphics.Bitmap
|
import android.graphics.Bitmap
|
||||||
import android.graphics.BitmapFactory
|
import android.graphics.BitmapFactory
|
||||||
|
import android.media.MediaDataSource
|
||||||
|
import android.media.MediaMetadataRetriever
|
||||||
import android.util.LruCache
|
import android.util.LruCache
|
||||||
import androidx.compose.foundation.Image
|
import androidx.compose.foundation.Image
|
||||||
import androidx.compose.foundation.layout.Box
|
import androidx.compose.foundation.layout.Box
|
||||||
@@ -28,6 +30,7 @@ import kotlinx.coroutines.withContext
|
|||||||
import net.awan.pipelines.ui.theme.ARTIFACT_PROGRESS_DP
|
import net.awan.pipelines.ui.theme.ARTIFACT_PROGRESS_DP
|
||||||
import net.awan.pipelines.ui.theme.ARTIFACT_PROGRESS_STROKE_DP
|
import net.awan.pipelines.ui.theme.ARTIFACT_PROGRESS_STROKE_DP
|
||||||
import net.awan.pipelines.ui.theme.ARTIFACT_THUMB_DP
|
import net.awan.pipelines.ui.theme.ARTIFACT_THUMB_DP
|
||||||
|
import net.awan.pipelines.ui.theme.ARTIFACT_TYPE_ICON_DP
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Encoded artifact bytes, fetched at most once per url and kept in memory so a
|
* Encoded artifact bytes, fetched at most once per url and kept in memory so a
|
||||||
@@ -126,9 +129,25 @@ internal fun rememberArtifactBitmap(
|
|||||||
url: String?,
|
url: String?,
|
||||||
maxDim: Int,
|
maxDim: Int,
|
||||||
fetchBytes: suspend (String) -> ByteArray?,
|
fetchBytes: suspend (String) -> ByteArray?,
|
||||||
|
): ArtifactImageState = rememberArtifactPreview(url, maxDim, "", fetchBytes, ::decodeSampled)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The shared memoized-preview scaffold behind [rememberArtifactBitmap] and
|
||||||
|
* [rememberArtifactVideoFrame]: a null [url] is [ArtifactImageState.Unavailable]
|
||||||
|
* with no request attempted, otherwise the bytes are fetched once through
|
||||||
|
* [ArtifactBytesCache] and [derive] runs off the main thread, its bitmap cached
|
||||||
|
* under a [keyTag]-tagged key (so an image and a video of one url never collide).
|
||||||
|
*/
|
||||||
|
@Composable
|
||||||
|
private fun rememberArtifactPreview(
|
||||||
|
url: String?,
|
||||||
|
maxDim: Int,
|
||||||
|
keyTag: String,
|
||||||
|
fetchBytes: suspend (String) -> ByteArray?,
|
||||||
|
derive: (ByteArray, Int) -> Bitmap?,
|
||||||
): ArtifactImageState {
|
): ArtifactImageState {
|
||||||
if (url == null) return ArtifactImageState.Unavailable
|
if (url == null) return ArtifactImageState.Unavailable
|
||||||
val key = "$url@$maxDim"
|
val key = "$url@$keyTag$maxDim"
|
||||||
var state by remember(key) { mutableStateOf<ArtifactImageState>(ArtifactImageState.Loading) }
|
var state by remember(key) { mutableStateOf<ArtifactImageState>(ArtifactImageState.Loading) }
|
||||||
LaunchedEffect(key) {
|
LaunchedEffect(key) {
|
||||||
artifactBitmapCache.get(key)?.let {
|
artifactBitmapCache.get(key)?.let {
|
||||||
@@ -142,7 +161,7 @@ internal fun rememberArtifactBitmap(
|
|||||||
return@LaunchedEffect
|
return@LaunchedEffect
|
||||||
}
|
}
|
||||||
ArtifactBytesCache.put(url, bytes)
|
ArtifactBytesCache.put(url, bytes)
|
||||||
val bitmap = withContext(Dispatchers.IO) { decodeSampled(bytes, maxDim) }
|
val bitmap = withContext(Dispatchers.IO) { derive(bytes, maxDim) }
|
||||||
if (bitmap == null) {
|
if (bitmap == null) {
|
||||||
state = ArtifactImageState.Error
|
state = ArtifactImageState.Error
|
||||||
} else {
|
} else {
|
||||||
@@ -153,6 +172,106 @@ internal fun rememberArtifactBitmap(
|
|||||||
return state
|
return state
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A video tile's still/poster frame: the artifact's bytes are fetched through the
|
||||||
|
* same bounded, off-main-thread path as an image ([rememberArtifactBitmap]'s
|
||||||
|
* cache), then the first sync frame is extracted with the platform
|
||||||
|
* [MediaMetadataRetriever] and cached. [url] null (no configured server) shows
|
||||||
|
* [ArtifactImageState.Unavailable] and issues no request; a fetch or extraction
|
||||||
|
* failure shows [ArtifactImageState.Error]. Unlike an image there is no honest
|
||||||
|
* "still" without a decodable frame, so both non-`Ready` states fall back to the
|
||||||
|
* video glyph the gallery would otherwise use.
|
||||||
|
*/
|
||||||
|
@Composable
|
||||||
|
internal fun ArtifactVideoFrame(
|
||||||
|
url: String?,
|
||||||
|
contentDescription: String?,
|
||||||
|
fetchBytes: suspend (String) -> ByteArray?,
|
||||||
|
modifier: Modifier = Modifier,
|
||||||
|
size: Dp = ARTIFACT_THUMB_DP,
|
||||||
|
) {
|
||||||
|
val state = rememberArtifactVideoFrame(url, VIDEO_FRAME_MAX_DIM, fetchBytes)
|
||||||
|
Box(modifier.size(size), contentAlignment = Alignment.Center) {
|
||||||
|
when (val current = state) {
|
||||||
|
is ArtifactImageState.Ready -> Image(
|
||||||
|
bitmap = current.bitmap.asImageBitmap(),
|
||||||
|
contentDescription = contentDescription,
|
||||||
|
contentScale = ContentScale.Crop,
|
||||||
|
modifier = Modifier.size(size),
|
||||||
|
)
|
||||||
|
ArtifactImageState.Loading -> CircularProgressIndicator(
|
||||||
|
modifier = Modifier.size(ARTIFACT_PROGRESS_DP),
|
||||||
|
strokeWidth = ARTIFACT_PROGRESS_STROKE_DP,
|
||||||
|
)
|
||||||
|
ArtifactImageState.Unavailable, ArtifactImageState.Error -> Icon(
|
||||||
|
imageVector = artifactIcon(ArtifactKind.Video),
|
||||||
|
contentDescription = contentDescription,
|
||||||
|
tint = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||||
|
modifier = Modifier.size(ARTIFACT_TYPE_ICON_DP),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The state of a video's poster frame at up to [maxDim] on its longest edge (0
|
||||||
|
* for the platform's native resolution). Same caching and off-main-thread
|
||||||
|
* behaviour as [rememberArtifactBitmap]; the full-size viewer shares it so a
|
||||||
|
* video's still is extracted once.
|
||||||
|
*/
|
||||||
|
@Composable
|
||||||
|
internal fun rememberArtifactVideoFrame(
|
||||||
|
url: String?,
|
||||||
|
maxDim: Int,
|
||||||
|
fetchBytes: suspend (String) -> ByteArray?,
|
||||||
|
): ArtifactImageState = rememberArtifactPreview(url, maxDim, "video", fetchBytes, ::extractVideoFrame)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The representative sync frame of [bytes] as a [maxDim]-bounded bitmap (native
|
||||||
|
* when [maxDim] <= 0), or null when the bytes are not a decodable video (or the
|
||||||
|
* platform retriever fails). Runs off the main thread; the bytes are handed over
|
||||||
|
* through an in-memory [MediaDataSource], so no temporary file is written.
|
||||||
|
*/
|
||||||
|
private fun extractVideoFrame(bytes: ByteArray, maxDim: Int): Bitmap? = runCatching {
|
||||||
|
val retriever = MediaMetadataRetriever()
|
||||||
|
try {
|
||||||
|
retriever.setDataSource(ByteArrayMediaDataSource(bytes))
|
||||||
|
retriever.getFrameAtTime(-1L, MediaMetadataRetriever.OPTION_CLOSEST_SYNC)
|
||||||
|
} finally {
|
||||||
|
runCatching { retriever.release() }
|
||||||
|
}
|
||||||
|
}.getOrNull()?.let { scaleToMaxDim(it, maxDim) }
|
||||||
|
|
||||||
|
/** The in-memory [MediaDataSource] over fetched video [data] (no temp file). */
|
||||||
|
private class ByteArrayMediaDataSource(private val data: ByteArray) : MediaDataSource() {
|
||||||
|
override fun readAt(position: Long, buffer: ByteArray, offset: Int, size: Int): Int {
|
||||||
|
if (position < 0 || position >= data.size) return -1
|
||||||
|
val count = minOf(size.toLong(), data.size - position).toInt()
|
||||||
|
System.arraycopy(data, position.toInt(), buffer, offset, count)
|
||||||
|
return count
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getSize(): Long = data.size.toLong()
|
||||||
|
|
||||||
|
override fun close() = Unit
|
||||||
|
}
|
||||||
|
|
||||||
|
/** [bitmap] scaled so its longest edge is at most [maxDim] (native when <= 0). */
|
||||||
|
private fun scaleToMaxDim(bitmap: Bitmap, maxDim: Int): Bitmap {
|
||||||
|
val longest = maxOf(bitmap.width, bitmap.height)
|
||||||
|
if (maxDim <= 0 || longest <= maxDim || longest == 0) return bitmap
|
||||||
|
val scale = maxDim.toFloat() / longest
|
||||||
|
return Bitmap.createScaledBitmap(
|
||||||
|
bitmap,
|
||||||
|
(bitmap.width * scale).toInt().coerceAtLeast(1),
|
||||||
|
(bitmap.height * scale).toInt().coerceAtLeast(1),
|
||||||
|
true,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Longest edge of a video poster-frame decode (the same shape as an image thumbnail). */
|
||||||
|
private const val VIDEO_FRAME_MAX_DIM = 320
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Decodes [bytes], downsampling to roughly [maxDim] on the longest edge when
|
* Decodes [bytes], downsampling to roughly [maxDim] on the longest edge when
|
||||||
* [maxDim] > 0 (so the list never holds full-resolution bitmaps), or at full
|
* [maxDim] > 0 (so the list never holds full-resolution bitmaps), or at full
|
||||||
|
|||||||
@@ -0,0 +1,133 @@
|
|||||||
|
package net.awan.pipelines.ui.graph
|
||||||
|
|
||||||
|
import androidx.compose.material.icons.Icons
|
||||||
|
import androidx.compose.material.icons.automirrored.filled.InsertDriveFile
|
||||||
|
import androidx.compose.material.icons.filled.AudioFile
|
||||||
|
import androidx.compose.material.icons.filled.Code
|
||||||
|
import androidx.compose.material.icons.filled.DataObject
|
||||||
|
import androidx.compose.material.icons.filled.Description
|
||||||
|
import androidx.compose.material.icons.filled.FolderZip
|
||||||
|
import androidx.compose.material.icons.filled.Image
|
||||||
|
import androidx.compose.material.icons.filled.Movie
|
||||||
|
import androidx.compose.material.icons.filled.PictureAsPdf
|
||||||
|
import androidx.compose.material.icons.automirrored.filled.ReceiptLong
|
||||||
|
import androidx.compose.material.icons.filled.TableChart
|
||||||
|
import androidx.compose.ui.graphics.vector.ImageVector
|
||||||
|
import net.awan.pipelines.ui.isImageContentType
|
||||||
|
import net.awan.pipelines.ui.isVideoContentType
|
||||||
|
|
||||||
|
/**
|
||||||
|
* What an artifact's file type is, from the app's point of view: the two media
|
||||||
|
* kinds the gallery previews (image, video) and the file kinds it labels with a
|
||||||
|
* type icon (everything else). It is the one classification the gallery branches
|
||||||
|
* on, so the grid, the tile and the icon can never disagree about a file.
|
||||||
|
*/
|
||||||
|
internal enum class ArtifactKind {
|
||||||
|
Image,
|
||||||
|
Video,
|
||||||
|
Audio,
|
||||||
|
Pdf,
|
||||||
|
Json,
|
||||||
|
Archive,
|
||||||
|
Spreadsheet,
|
||||||
|
Log,
|
||||||
|
Code,
|
||||||
|
Document,
|
||||||
|
Other,
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The gallery kind of an artifact from its [contentType] (server-sniffed, may
|
||||||
|
* carry parameters) and its [name] (the extension is the fallback when the sniff
|
||||||
|
* is generic `text/plain`/`application/octet-stream`). Image and video are
|
||||||
|
* recognised straight from the content type; the rest are matched by the
|
||||||
|
* normalised mime first, then by the name's extension. Pure and total, so the
|
||||||
|
* type-to-icon mapping is unit-tested without a device.
|
||||||
|
*/
|
||||||
|
internal fun artifactKind(contentType: String, name: String): ArtifactKind {
|
||||||
|
if (isImageContentType(contentType)) return ArtifactKind.Image
|
||||||
|
if (isVideoContentType(contentType)) return ArtifactKind.Video
|
||||||
|
val mime = contentType.substringBefore(';').trim().lowercase()
|
||||||
|
val ext = name.substringAfterLast('.', "").lowercase()
|
||||||
|
return when {
|
||||||
|
mime.startsWith("audio/") -> ArtifactKind.Audio
|
||||||
|
mime == "application/pdf" || ext == "pdf" -> ArtifactKind.Pdf
|
||||||
|
mime.contains("json") || ext == "json" -> ArtifactKind.Json
|
||||||
|
mime in ARCHIVE_MIMES || ext in ARCHIVE_EXTENSIONS -> ArtifactKind.Archive
|
||||||
|
mime in SPREADSHEET_MIMES || ext in SPREADSHEET_EXTENSIONS -> ArtifactKind.Spreadsheet
|
||||||
|
ext == "log" -> ArtifactKind.Log
|
||||||
|
mime == "text/html" -> ArtifactKind.Document
|
||||||
|
mime in CODE_MIMES || ext in CODE_EXTENSIONS -> ArtifactKind.Code
|
||||||
|
mime.startsWith("text/") || mime in DOCUMENT_MIMES || ext in DOCUMENT_EXTENSIONS -> ArtifactKind.Document
|
||||||
|
else -> ArtifactKind.Other
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The glyph that names [kind] in the gallery: a distinct [ImageVector] per kind
|
||||||
|
* (its own shape, not colour alone), so a document, archive, log, code file, JSON
|
||||||
|
* payload and PDF are told apart at a glance. Pure, so the mapping is unit-tested.
|
||||||
|
*/
|
||||||
|
internal fun artifactIcon(kind: ArtifactKind): ImageVector = when (kind) {
|
||||||
|
ArtifactKind.Image -> Icons.Filled.Image
|
||||||
|
ArtifactKind.Video -> Icons.Filled.Movie
|
||||||
|
ArtifactKind.Audio -> Icons.Filled.AudioFile
|
||||||
|
ArtifactKind.Pdf -> Icons.Filled.PictureAsPdf
|
||||||
|
ArtifactKind.Json -> Icons.Filled.DataObject
|
||||||
|
ArtifactKind.Archive -> Icons.Filled.FolderZip
|
||||||
|
ArtifactKind.Spreadsheet -> Icons.Filled.TableChart
|
||||||
|
ArtifactKind.Log -> Icons.AutoMirrored.Filled.ReceiptLong
|
||||||
|
ArtifactKind.Code -> Icons.Filled.Code
|
||||||
|
ArtifactKind.Document -> Icons.Filled.Description
|
||||||
|
ArtifactKind.Other -> Icons.AutoMirrored.Filled.InsertDriveFile
|
||||||
|
}
|
||||||
|
|
||||||
|
private val ARCHIVE_EXTENSIONS =
|
||||||
|
setOf("zip", "tar", "gz", "tgz", "bz2", "xz", "rar", "7z", "jar", "war")
|
||||||
|
|
||||||
|
private val ARCHIVE_MIMES = setOf(
|
||||||
|
"application/zip",
|
||||||
|
"application/gzip",
|
||||||
|
"application/x-tar",
|
||||||
|
"application/x-7z-compressed",
|
||||||
|
"application/x-rar-compressed",
|
||||||
|
"application/java-archive",
|
||||||
|
)
|
||||||
|
|
||||||
|
private val SPREADSHEET_EXTENSIONS = setOf("csv", "tsv", "xls", "xlsx", "ods")
|
||||||
|
|
||||||
|
private val SPREADSHEET_MIMES = setOf(
|
||||||
|
"text/csv",
|
||||||
|
"text/tab-separated-values",
|
||||||
|
"application/vnd.ms-excel",
|
||||||
|
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
||||||
|
)
|
||||||
|
|
||||||
|
private val CODE_EXTENSIONS = setOf(
|
||||||
|
"kt", "kts", "java", "go", "py", "rb", "php", "rs", "c", "h", "cc", "cpp",
|
||||||
|
"hpp", "cs", "js", "jsx", "ts", "tsx", "mjs", "cjs", "swift", "scala", "sh",
|
||||||
|
"bash", "zsh", "fish", "ps1", "sql", "yaml", "yml", "toml", "ini", "xml",
|
||||||
|
"gradle", "properties", "proto",
|
||||||
|
)
|
||||||
|
|
||||||
|
private val CODE_MIMES = setOf(
|
||||||
|
"application/xml",
|
||||||
|
"application/x-yaml",
|
||||||
|
"application/javascript",
|
||||||
|
"text/javascript",
|
||||||
|
"text/x-python",
|
||||||
|
"text/x-java-source",
|
||||||
|
"text/x-kotlin",
|
||||||
|
"application/x-sh",
|
||||||
|
"application/x-httpd-php",
|
||||||
|
"application/sql",
|
||||||
|
)
|
||||||
|
|
||||||
|
private val DOCUMENT_EXTENSIONS =
|
||||||
|
setOf("txt", "md", "markdown", "rst", "doc", "docx", "odt", "rtf", "html", "htm")
|
||||||
|
|
||||||
|
private val DOCUMENT_MIMES = setOf(
|
||||||
|
"application/msword",
|
||||||
|
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
||||||
|
"application/rtf",
|
||||||
|
)
|
||||||
@@ -61,10 +61,12 @@ import net.awan.pipelines.ui.theme.pipelinesText
|
|||||||
import kotlin.math.abs
|
import kotlin.math.abs
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The full-screen image viewer opened by tapping a gallery thumbnail (the run
|
* The full-screen media viewer opened by tapping a gallery tile (the run summary
|
||||||
* summary grid, the per-visit artifacts list and the stage pane all render
|
* grid, the per-visit artifacts section and the stage pane all render through
|
||||||
* through [ArtifactGallery], so they all open this). It replaces the former
|
* [ArtifactGallery], so they all open this): an image at full size, or a video's
|
||||||
* small centred dialog rather than stacking on top of it.
|
* poster frame (the platform retriever extracts it, [video] = true) with the
|
||||||
|
* external-open action to actually play it. It replaces the former small centred
|
||||||
|
* dialog rather than stacking on top of it.
|
||||||
*
|
*
|
||||||
* It is a [Dialog] whose window is laid out edge to edge (`decorFitsSystemWindows
|
* It is a [Dialog] whose window is laid out edge to edge (`decorFitsSystemWindows
|
||||||
* = false`): the dark [MaterialTheme.colorScheme.scrim] backdrop fills the whole
|
* = false`): the dark [MaterialTheme.colorScheme.scrim] backdrop fills the whole
|
||||||
@@ -87,6 +89,7 @@ internal fun ArtifactViewer(
|
|||||||
name: String,
|
name: String,
|
||||||
fetchBytes: suspend (String) -> ByteArray?,
|
fetchBytes: suspend (String) -> ByteArray?,
|
||||||
onDismiss: () -> Unit,
|
onDismiss: () -> Unit,
|
||||||
|
video: Boolean = false,
|
||||||
) {
|
) {
|
||||||
Dialog(
|
Dialog(
|
||||||
onDismissRequest = onDismiss,
|
onDismissRequest = onDismiss,
|
||||||
@@ -131,11 +134,23 @@ internal fun ArtifactViewer(
|
|||||||
.background(MaterialTheme.colorScheme.scrim)
|
.background(MaterialTheme.colorScheme.scrim)
|
||||||
.windowInsetsPadding(paneSafeArea()),
|
.windowInsetsPadding(paneSafeArea()),
|
||||||
) {
|
) {
|
||||||
when (val state = rememberArtifactBitmap(url, FULL_RESOLUTION, fetchBytes)) {
|
val state = if (video) {
|
||||||
|
rememberArtifactVideoFrame(url, FULL_RESOLUTION, fetchBytes)
|
||||||
|
} else {
|
||||||
|
rememberArtifactBitmap(url, FULL_RESOLUTION, fetchBytes)
|
||||||
|
}
|
||||||
|
when (state) {
|
||||||
is ArtifactImageState.Ready -> ZoomableArtifact(state.bitmap, name, url, onDismiss)
|
is ArtifactImageState.Ready -> ZoomableArtifact(state.bitmap, name, url, onDismiss)
|
||||||
ArtifactImageState.Loading -> ViewerMessage("Loading image…", spinner = true)
|
ArtifactImageState.Loading -> ViewerMessage(
|
||||||
ArtifactImageState.Error -> ViewerMessage("Couldn't load image.")
|
if (video) "Loading video frame…" else "Loading image…",
|
||||||
ArtifactImageState.Unavailable -> ViewerMessage("Image unavailable.")
|
spinner = true,
|
||||||
|
)
|
||||||
|
ArtifactImageState.Error -> ViewerMessage(
|
||||||
|
if (video) "Couldn't load the video frame." else "Couldn't load image.",
|
||||||
|
)
|
||||||
|
ArtifactImageState.Unavailable -> ViewerMessage(
|
||||||
|
if (video) "Video unavailable." else "Image unavailable.",
|
||||||
|
)
|
||||||
}
|
}
|
||||||
ArtifactViewerActions(
|
ArtifactViewerActions(
|
||||||
name = name,
|
name = name,
|
||||||
|
|||||||
@@ -9,24 +9,24 @@ import androidx.compose.foundation.border
|
|||||||
import androidx.compose.foundation.combinedClickable
|
import androidx.compose.foundation.combinedClickable
|
||||||
import androidx.compose.foundation.layout.Arrangement
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
import androidx.compose.foundation.layout.Box
|
import androidx.compose.foundation.layout.Box
|
||||||
|
import androidx.compose.foundation.layout.BoxScope
|
||||||
import androidx.compose.foundation.layout.BoxWithConstraints
|
import androidx.compose.foundation.layout.BoxWithConstraints
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.foundation.layout.Row
|
import androidx.compose.foundation.layout.Row
|
||||||
|
import androidx.compose.foundation.layout.Spacer
|
||||||
|
import androidx.compose.foundation.layout.fillMaxSize
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.foundation.layout.size
|
import androidx.compose.foundation.layout.size
|
||||||
import androidx.compose.foundation.shape.CircleShape
|
import androidx.compose.foundation.shape.CircleShape
|
||||||
import androidx.compose.material.icons.Icons
|
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.Check
|
import androidx.compose.material.icons.filled.Check
|
||||||
import androidx.compose.material.icons.filled.ContentCopy
|
import androidx.compose.material.icons.filled.ContentCopy
|
||||||
|
import androidx.compose.material.icons.filled.PlayArrow
|
||||||
import androidx.compose.material.icons.filled.Share
|
import androidx.compose.material.icons.filled.Share
|
||||||
import androidx.compose.material3.Icon
|
import androidx.compose.material3.Icon
|
||||||
import androidx.compose.material3.IconButton
|
import androidx.compose.material3.IconButton
|
||||||
import androidx.compose.material3.LocalContentColor
|
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.material3.Surface
|
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
@@ -41,6 +41,7 @@ import androidx.compose.ui.platform.LocalClipboardManager
|
|||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
import androidx.compose.ui.semantics.selected
|
import androidx.compose.ui.semantics.selected
|
||||||
import androidx.compose.ui.semantics.semantics
|
import androidx.compose.ui.semantics.semantics
|
||||||
|
import androidx.compose.ui.text.style.TextAlign
|
||||||
import androidx.compose.ui.text.style.TextOverflow
|
import androidx.compose.ui.text.style.TextOverflow
|
||||||
import androidx.compose.ui.unit.Dp
|
import androidx.compose.ui.unit.Dp
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
@@ -50,13 +51,14 @@ import net.awan.pipelines.data.protocol.StageArtifact
|
|||||||
import net.awan.pipelines.data.transport.ServerUrl
|
import net.awan.pipelines.data.transport.ServerUrl
|
||||||
import net.awan.pipelines.ui.ArtifactGroup
|
import net.awan.pipelines.ui.ArtifactGroup
|
||||||
import net.awan.pipelines.ui.artifactCaptureNotes
|
import net.awan.pipelines.ui.artifactCaptureNotes
|
||||||
import net.awan.pipelines.ui.artifactMetaLine
|
|
||||||
import net.awan.pipelines.ui.artifactsSummary
|
import net.awan.pipelines.ui.artifactsSummary
|
||||||
import net.awan.pipelines.ui.components.copyText
|
import net.awan.pipelines.ui.components.copyText
|
||||||
import net.awan.pipelines.ui.isImageContentType
|
import net.awan.pipelines.ui.humanBytes
|
||||||
import net.awan.pipelines.ui.theme.ARTIFACT_BADGE_DP
|
import net.awan.pipelines.ui.theme.ARTIFACT_BADGE_DP
|
||||||
import net.awan.pipelines.ui.theme.ARTIFACT_THUMB_DP
|
import net.awan.pipelines.ui.theme.ARTIFACT_PLAY_BADGE_DP
|
||||||
|
import net.awan.pipelines.ui.theme.ARTIFACT_TILE_ACTION_DP
|
||||||
import net.awan.pipelines.ui.theme.ARTIFACT_TILE_DP
|
import net.awan.pipelines.ui.theme.ARTIFACT_TILE_DP
|
||||||
|
import net.awan.pipelines.ui.theme.ARTIFACT_TYPE_ICON_DP
|
||||||
import net.awan.pipelines.ui.theme.SPACING_M
|
import net.awan.pipelines.ui.theme.SPACING_M
|
||||||
import net.awan.pipelines.ui.theme.SPACING_S
|
import net.awan.pipelines.ui.theme.SPACING_S
|
||||||
import net.awan.pipelines.ui.theme.SPACING_XS
|
import net.awan.pipelines.ui.theme.SPACING_XS
|
||||||
@@ -70,7 +72,7 @@ import net.awan.pipelines.ui.theme.pipelinesText
|
|||||||
* rendering path; it resolves each url against the configured server URL and
|
* rendering path; it resolves each url against the configured server URL and
|
||||||
* never hardcodes a host.
|
* never hardcodes a host.
|
||||||
*
|
*
|
||||||
* When no server URL is configured the rows still show (name/size/type) but the
|
* When no server URL is configured the tiles still show (name/size/type) but the
|
||||||
* open/copy actions are disabled and a hint is shown.
|
* open/copy actions are disabled and a hint is shown.
|
||||||
*/
|
*/
|
||||||
@Composable
|
@Composable
|
||||||
@@ -112,17 +114,18 @@ internal fun ArtifactsSection(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The artifacts gallery: one group per (stage, visit) with a header, the group's
|
* The artifacts gallery: one group per (stage, visit) with a header and every
|
||||||
* image artifacts as a grid of thumbnails (a tap opens the full-size view) and
|
* artifact as a tile in a grid. An image shows its thumbnail, a video its
|
||||||
* its non-image artifacts as rows with name, size, content type and open/copy.
|
* still/poster frame with a play marker on top, and anything else its file-type
|
||||||
* Every url is resolved with [ServerUrl.resolveArtifactUrl], so nothing here
|
* icon with the name and size beneath it. Every url is resolved with
|
||||||
* hardcodes a host. The grid is built from non-lazy chunked [Row]s, so it never
|
* [ServerUrl.resolveArtifactUrl], so nothing here hardcodes a host. The grid is
|
||||||
* nests a scrollable inside the Summary [LazyColumn] or the pane's scroll.
|
* built from non-lazy chunked [Row]s, so it never nests a scrollable inside the
|
||||||
|
* Summary [LazyColumn] or the pane's scroll.
|
||||||
*
|
*
|
||||||
* The grid geometry is derived from the measured width (one [BoxWithConstraints],
|
* The grid geometry is derived from the measured width (one [BoxWithConstraints],
|
||||||
* see [artifactGrid]): as many cells as fit at the preferred [ARTIFACT_TILE_DP]
|
* see [artifactGrid]): as many cells as fit at the preferred [ARTIFACT_TILE_DP]
|
||||||
* shape, stretched to fill the row, so a wide window shows several thumbnails per
|
* shape, stretched to fill the row, so a wide window shows several tiles per row
|
||||||
* row and a narrow one shows fewer, larger ones — never a fixed column count.
|
* and a narrow one shows fewer, larger ones — never a fixed column count.
|
||||||
*/
|
*/
|
||||||
@Composable
|
@Composable
|
||||||
internal fun ArtifactGallery(
|
internal fun ArtifactGallery(
|
||||||
@@ -149,9 +152,7 @@ internal fun ArtifactGallery(
|
|||||||
style = text.sectionHeader,
|
style = text.sectionHeader,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
val images = group.artifacts.filter { isImageContentType(it.contentType) }
|
group.artifacts.chunked(grid.columns).forEach { rowArtifacts ->
|
||||||
val others = group.artifacts.filterNot { isImageContentType(it.contentType) }
|
|
||||||
images.chunked(grid.columns).forEach { rowArtifacts ->
|
|
||||||
Row(
|
Row(
|
||||||
modifier = Modifier.fillMaxWidth(),
|
modifier = Modifier.fillMaxWidth(),
|
||||||
horizontalArrangement = Arrangement.spacedBy(ARTIFACT_TILE_SPACING_DP),
|
horizontalArrangement = Arrangement.spacedBy(ARTIFACT_TILE_SPACING_DP),
|
||||||
@@ -172,15 +173,6 @@ internal fun ArtifactGallery(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
others.forEach { artifact ->
|
|
||||||
ArtifactRow(
|
|
||||||
artifact = artifact,
|
|
||||||
configuredServerUrl = configuredServerUrl,
|
|
||||||
fetchArtifactBytes = fetchArtifactBytes,
|
|
||||||
selection = selection,
|
|
||||||
onSelectionChange = onSelectionChange,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -209,22 +201,24 @@ internal fun artifactGrid(availableWidth: Dp, preferred: Dp, spacing: Dp): Artif
|
|||||||
/**
|
/**
|
||||||
* The absolute url a gallery artifact is previewed/opened at, or null when it
|
* The absolute url a gallery artifact is previewed/opened at, or null when it
|
||||||
* cannot be resolved against the configured server (blank or invalid). The one
|
* cannot be resolved against the configured server (blank or invalid). The one
|
||||||
* place a gallery artifact url is resolved, shared by the image tile and the
|
* place a gallery artifact url is resolved, shared by every tile so they can
|
||||||
* non-image row so the two can never disagree. A null must never reach a fetch:
|
* never disagree. A null must never reach a fetch: a server-relative url has no
|
||||||
* a server-relative url has no scheme and can never load, so the tile renders the
|
* scheme and can never load, so the tile renders the distinct "unavailable"
|
||||||
* distinct "unavailable" state instead of the failure mark.
|
* state instead of the failure mark.
|
||||||
*/
|
*/
|
||||||
internal fun resolvedArtifactUrl(artifact: StageArtifact, configuredServerUrl: String): String? =
|
internal fun resolvedArtifactUrl(artifact: StageArtifact, configuredServerUrl: String): String? =
|
||||||
ServerUrl.resolveArtifactUrl(configuredServerUrl, artifact.url)
|
ServerUrl.resolveArtifactUrl(configuredServerUrl, artifact.url)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* One image artifact as a square thumbnail that opens the full-size view. A
|
* One gallery tile. An image or video fills the cell with its thumbnail (a video
|
||||||
* long-press enters artifact selection on this item; while selection mode is
|
* with a play marker on top) and opens the full-screen viewer on tap; any other
|
||||||
* active a tap toggles it instead of opening, and the selected cell gets the
|
* type shows its file-type icon with the name and size beneath it and opens
|
||||||
* app's selected treatment (a tonal ring + check badge in the shared
|
* externally on tap. A long-press enters artifact selection on this item; while
|
||||||
* secondaryContainer/onSecondaryContainer roles, and the `selected` semantics
|
* selection mode is active a tap toggles it instead of opening, and the selected
|
||||||
* state). The per-item share control is hidden while selecting so the whole cell
|
* cell gets the app's selected treatment (a tonal ring + check badge in the
|
||||||
* is the toggle target.
|
* shared secondaryContainer/onSecondaryContainer roles, and the `selected`
|
||||||
|
* semantics state). The per-item actions are hidden while selecting so the whole
|
||||||
|
* cell is the toggle target.
|
||||||
*/
|
*/
|
||||||
@OptIn(ExperimentalFoundationApi::class)
|
@OptIn(ExperimentalFoundationApi::class)
|
||||||
@Composable
|
@Composable
|
||||||
@@ -236,10 +230,15 @@ private fun ArtifactTile(
|
|||||||
selection: ArtifactSelection,
|
selection: ArtifactSelection,
|
||||||
onSelectionChange: (ArtifactSelection) -> Unit,
|
onSelectionChange: (ArtifactSelection) -> Unit,
|
||||||
) {
|
) {
|
||||||
// Resolve once per (url, configuration), not on every recomposition.
|
val context = LocalContext.current
|
||||||
|
// Resolve and classify once per data change, not on every recomposition.
|
||||||
val resolved = remember(artifact.url, configuredServerUrl) {
|
val resolved = remember(artifact.url, configuredServerUrl) {
|
||||||
resolvedArtifactUrl(artifact, configuredServerUrl)
|
resolvedArtifactUrl(artifact, configuredServerUrl)
|
||||||
}
|
}
|
||||||
|
val kind = remember(artifact.contentType, artifact.name) {
|
||||||
|
artifactKind(artifact.contentType, artifact.name)
|
||||||
|
}
|
||||||
|
val media = kind == ArtifactKind.Image || kind == ArtifactKind.Video
|
||||||
var showFull by remember(artifact.url) { mutableStateOf(false) }
|
var showFull by remember(artifact.url) { mutableStateOf(false) }
|
||||||
val selected = selection.contains(artifact.url)
|
val selected = selection.contains(artifact.url)
|
||||||
|
|
||||||
@@ -247,6 +246,13 @@ private fun ArtifactTile(
|
|||||||
Modifier
|
Modifier
|
||||||
.size(tile)
|
.size(tile)
|
||||||
.clip(MaterialTheme.shapes.medium)
|
.clip(MaterialTheme.shapes.medium)
|
||||||
|
.background(
|
||||||
|
if (selected) {
|
||||||
|
MaterialTheme.colorScheme.secondaryContainer
|
||||||
|
} else {
|
||||||
|
MaterialTheme.colorScheme.surfaceContainerHigh
|
||||||
|
},
|
||||||
|
)
|
||||||
.then(
|
.then(
|
||||||
if (selected) {
|
if (selected) {
|
||||||
Modifier.border(3.dp, MaterialTheme.colorScheme.secondary, MaterialTheme.shapes.medium)
|
Modifier.border(3.dp, MaterialTheme.colorScheme.secondary, MaterialTheme.shapes.medium)
|
||||||
@@ -256,10 +262,12 @@ private fun ArtifactTile(
|
|||||||
)
|
)
|
||||||
.combinedClickable(
|
.combinedClickable(
|
||||||
onClick = {
|
onClick = {
|
||||||
if (selection.active) {
|
when {
|
||||||
onSelectionChange(selection.toggle(artifact.url))
|
selection.active -> onSelectionChange(selection.toggle(artifact.url))
|
||||||
} else if (resolved != null) {
|
// An image or video opens the full-screen viewer; any
|
||||||
showFull = true
|
// other type uses the existing open action.
|
||||||
|
media -> if (resolved != null) showFull = true
|
||||||
|
else -> openArtifact(context, resolved)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onLongClick = { onSelectionChange(selection.enter(artifact.url)) },
|
onLongClick = { onSelectionChange(selection.enter(artifact.url)) },
|
||||||
@@ -267,20 +275,20 @@ private fun ArtifactTile(
|
|||||||
)
|
)
|
||||||
.semantics { this.selected = selected },
|
.semantics { this.selected = selected },
|
||||||
) {
|
) {
|
||||||
// Pass the resolved url (null when there is no configured server): a
|
if (media) {
|
||||||
// null never triggers a relative-url fetch, it shows the distinct
|
ArtifactMediaPreview(
|
||||||
// "unavailable" state instead of the failure mark.
|
kind = kind,
|
||||||
ArtifactImage(
|
name = artifact.name,
|
||||||
url = resolved,
|
resolved = resolved,
|
||||||
contentDescription = "Preview of ${artifact.name}",
|
fetchArtifactBytes = fetchArtifactBytes,
|
||||||
maxDim = THUMBNAIL_MAX_DIM,
|
tile = tile,
|
||||||
fetchBytes = fetchArtifactBytes,
|
)
|
||||||
size = tile,
|
} else {
|
||||||
)
|
ArtifactTypeLabel(kind = kind, artifact = artifact)
|
||||||
|
}
|
||||||
if (selection.active) {
|
if (selection.active) {
|
||||||
// While the gallery is selecting, no item exposes its own share
|
// While the gallery is selecting, no item exposes its own actions:
|
||||||
// control: every tap toggles, so only the selected cells carry the
|
// every tap toggles, so only the selected cells carry the check badge.
|
||||||
// check badge and the whole tile stays a toggle target.
|
|
||||||
if (selected) {
|
if (selected) {
|
||||||
Box(
|
Box(
|
||||||
Modifier
|
Modifier
|
||||||
@@ -298,21 +306,20 @@ private fun ArtifactTile(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// The share control is its own hit area over the thumbnail: it
|
// The per-item share (and, for a non-media tile, copy) controls are
|
||||||
// consumes the tap, so sharing never falls through to open the
|
// their own hit areas over the tile: they consume the tap, so an
|
||||||
// full-size view.
|
// action never falls through to open the artifact.
|
||||||
ArtifactShareButton(
|
ArtifactTileActions(
|
||||||
artifact = artifact,
|
artifact = artifact,
|
||||||
resolved = resolved,
|
resolved = resolved,
|
||||||
fetchArtifactBytes = fetchArtifactBytes,
|
fetchArtifactBytes = fetchArtifactBytes,
|
||||||
modifier = Modifier.align(Alignment.TopEnd),
|
media = media,
|
||||||
scrim = true,
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// The tap opens the full-screen viewer (one shared instance across the run
|
// The tap opens the full-screen viewer (one shared instance across the run
|
||||||
// summary grid, the per-visit list and the stage pane, so they never
|
// summary grid, the per-visit section and the stage pane, so they never
|
||||||
// disagree); there is no separate smaller preview to stack on top of it.
|
// disagree); there is no separate smaller preview to stack on top of it.
|
||||||
if (showFull && resolved != null) {
|
if (showFull && resolved != null) {
|
||||||
ArtifactViewer(
|
ArtifactViewer(
|
||||||
@@ -320,135 +327,155 @@ private fun ArtifactTile(
|
|||||||
name = artifact.name,
|
name = artifact.name,
|
||||||
fetchBytes = fetchArtifactBytes,
|
fetchBytes = fetchArtifactBytes,
|
||||||
onDismiss = { showFull = false },
|
onDismiss = { showFull = false },
|
||||||
|
video = kind == ArtifactKind.Video,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* One non-image artifact: a file glyph, name, size/type and open/share/copy
|
* A media tile's content: the image thumbnail, or a video's still/poster frame
|
||||||
* actions. A long-press enters artifact selection on this item; while selection
|
* with a centred play marker on top of it. Both load through the same bounded,
|
||||||
* mode is active a tap toggles it and the row wears the app's selected treatment
|
* off-main-thread cache, so a media tile never re-hits the network on a
|
||||||
* (the secondaryContainer/onSecondaryContainer roles the list rows use, plus the
|
* recomposition.
|
||||||
* `selected` semantics state), with the per-item actions swapped for a check.
|
|
||||||
* When not selecting, a tap opens the artifact.
|
|
||||||
*/
|
*/
|
||||||
@OptIn(ExperimentalFoundationApi::class)
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun ArtifactRow(
|
private fun BoxScope.ArtifactMediaPreview(
|
||||||
artifact: StageArtifact,
|
kind: ArtifactKind,
|
||||||
configuredServerUrl: String,
|
name: String,
|
||||||
|
resolved: String?,
|
||||||
fetchArtifactBytes: suspend (String) -> ByteArray?,
|
fetchArtifactBytes: suspend (String) -> ByteArray?,
|
||||||
selection: ArtifactSelection,
|
tile: Dp,
|
||||||
onSelectionChange: (ArtifactSelection) -> Unit,
|
|
||||||
) {
|
) {
|
||||||
val text = pipelinesText()
|
if (kind == ArtifactKind.Video) {
|
||||||
val context = LocalContext.current
|
ArtifactVideoFrame(
|
||||||
val clipboard = LocalClipboardManager.current
|
url = resolved,
|
||||||
// Resolve/format once per (url, configuration), not on every recomposition.
|
contentDescription = "Poster frame of $name",
|
||||||
val resolved = remember(artifact.url, configuredServerUrl) {
|
fetchBytes = fetchArtifactBytes,
|
||||||
resolvedArtifactUrl(artifact, configuredServerUrl)
|
size = tile,
|
||||||
}
|
)
|
||||||
val metaLine = remember(artifact) { artifactMetaLine(artifact) }
|
Box(
|
||||||
val selected = selection.contains(artifact.url)
|
Modifier
|
||||||
|
.align(Alignment.Center)
|
||||||
Surface(
|
.size(ARTIFACT_PLAY_BADGE_DP)
|
||||||
shape = MaterialTheme.shapes.medium,
|
.background(
|
||||||
color = if (selected) {
|
MaterialTheme.colorScheme.scrim.copy(alpha = ARTIFACT_ACTION_SCRIM_ALPHA),
|
||||||
MaterialTheme.colorScheme.secondaryContainer
|
CircleShape,
|
||||||
} else {
|
),
|
||||||
MaterialTheme.colorScheme.surfaceContainerHigh
|
contentAlignment = Alignment.Center,
|
||||||
},
|
|
||||||
contentColor = if (selected) {
|
|
||||||
MaterialTheme.colorScheme.onSecondaryContainer
|
|
||||||
} else {
|
|
||||||
LocalContentColor.current
|
|
||||||
},
|
|
||||||
modifier = Modifier
|
|
||||||
.fillMaxWidth()
|
|
||||||
.combinedClickable(
|
|
||||||
onClick = {
|
|
||||||
if (selection.active) {
|
|
||||||
onSelectionChange(selection.toggle(artifact.url))
|
|
||||||
} else {
|
|
||||||
openArtifact(context, resolved)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onLongClick = { onSelectionChange(selection.enter(artifact.url)) },
|
|
||||||
onLongClickLabel = "Select ${artifact.name}",
|
|
||||||
)
|
|
||||||
.semantics { this.selected = selected },
|
|
||||||
) {
|
|
||||||
Row(
|
|
||||||
modifier = Modifier.padding(horizontal = SPACING_S, vertical = SPACING_S),
|
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
|
||||||
horizontalArrangement = Arrangement.spacedBy(SPACING_M),
|
|
||||||
) {
|
) {
|
||||||
Box(
|
Icon(
|
||||||
Modifier.size(ARTIFACT_THUMB_DP).clip(MaterialTheme.shapes.small),
|
imageVector = Icons.Default.PlayArrow,
|
||||||
contentAlignment = Alignment.Center,
|
contentDescription = "Play $name",
|
||||||
) {
|
tint = MaterialTheme.colorScheme.inverseSurface,
|
||||||
Icon(
|
)
|
||||||
imageVector = Icons.AutoMirrored.Filled.InsertDriveFile,
|
|
||||||
contentDescription = null,
|
|
||||||
tint = LocalContentColor.current,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
Column(Modifier.weight(1f), verticalArrangement = Arrangement.spacedBy(SPACING_XXS)) {
|
|
||||||
Text(
|
|
||||||
artifact.name.ifBlank { "(unnamed artifact)" },
|
|
||||||
style = text.cardTitle,
|
|
||||||
maxLines = 2,
|
|
||||||
overflow = TextOverflow.Ellipsis,
|
|
||||||
)
|
|
||||||
Text(
|
|
||||||
metaLine,
|
|
||||||
style = text.meta,
|
|
||||||
maxLines = 2,
|
|
||||||
overflow = TextOverflow.Ellipsis,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
if (selection.active) {
|
|
||||||
// While selecting, the row's own open/copy/share controls are
|
|
||||||
// hidden so a tap anywhere on it toggles the selection instead
|
|
||||||
// of acting on the single item; only the selected row shows the
|
|
||||||
// check.
|
|
||||||
if (selected) {
|
|
||||||
Icon(
|
|
||||||
imageVector = Icons.Default.Check,
|
|
||||||
contentDescription = null,
|
|
||||||
modifier = Modifier.padding(horizontal = SPACING_M),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
IconButton(
|
|
||||||
onClick = { openArtifact(context, resolved) },
|
|
||||||
enabled = resolved != null,
|
|
||||||
) {
|
|
||||||
Icon(Icons.AutoMirrored.Filled.OpenInNew, contentDescription = "Open ${artifact.name}")
|
|
||||||
}
|
|
||||||
IconButton(
|
|
||||||
onClick = { resolved?.let { clipboard.copyText(it) } },
|
|
||||||
enabled = resolved != null,
|
|
||||||
) {
|
|
||||||
Icon(Icons.Default.ContentCopy, contentDescription = "Copy link to ${artifact.name}")
|
|
||||||
}
|
|
||||||
ArtifactShareButton(
|
|
||||||
artifact = artifact,
|
|
||||||
resolved = resolved,
|
|
||||||
fetchArtifactBytes = fetchArtifactBytes,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// Pass the resolved url (null when there is no configured server): a
|
||||||
|
// null never triggers a relative-url fetch, it shows the distinct
|
||||||
|
// "unavailable" state instead of the failure mark.
|
||||||
|
ArtifactImage(
|
||||||
|
url = resolved,
|
||||||
|
contentDescription = "Preview of $name",
|
||||||
|
maxDim = THUMBNAIL_MAX_DIM,
|
||||||
|
fetchBytes = fetchArtifactBytes,
|
||||||
|
size = tile,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The share action every artifact item carries (the gallery's image cells and
|
* A non-media tile's content: its file-type glyph ([artifactIcon]) with the
|
||||||
* its file rows): a 48dp [IconButton] target, an accurate content description,
|
* artifact's name and human-readable size beneath it, centred in the cell. The
|
||||||
* and a click that launches the platform share chooser. It is the item's own
|
* action strip is pinned to the cell's top corners, away from this centred
|
||||||
* child action, so a tap on it never opens the image or the item. [scrim] adds
|
* column, so a compact tile never draws its glyph or text under the actions.
|
||||||
* the translucent backing the viewer uses so the icon stays legible over a
|
*/
|
||||||
* bright image.
|
@Composable
|
||||||
|
private fun ArtifactTypeLabel(kind: ArtifactKind, artifact: StageArtifact) {
|
||||||
|
val text = pipelinesText()
|
||||||
|
val size = remember(artifact.sizeBytes) { humanBytes(artifact.sizeBytes) }
|
||||||
|
Column(
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxSize()
|
||||||
|
.padding(horizontal = SPACING_XS, vertical = SPACING_XS),
|
||||||
|
horizontalAlignment = Alignment.CenterHorizontally,
|
||||||
|
verticalArrangement = Arrangement.Center,
|
||||||
|
) {
|
||||||
|
Icon(
|
||||||
|
imageVector = artifactIcon(kind),
|
||||||
|
contentDescription = null,
|
||||||
|
tint = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||||
|
modifier = Modifier.size(ARTIFACT_TYPE_ICON_DP),
|
||||||
|
)
|
||||||
|
Text(
|
||||||
|
artifact.name.ifBlank { "(unnamed artifact)" },
|
||||||
|
style = text.label,
|
||||||
|
maxLines = 1,
|
||||||
|
overflow = TextOverflow.Ellipsis,
|
||||||
|
textAlign = TextAlign.Center,
|
||||||
|
modifier = Modifier.padding(top = SPACING_XXS),
|
||||||
|
)
|
||||||
|
Text(
|
||||||
|
size,
|
||||||
|
style = text.meta,
|
||||||
|
maxLines = 1,
|
||||||
|
overflow = TextOverflow.Ellipsis,
|
||||||
|
textAlign = TextAlign.Center,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The compact per-item actions strip a tile shows while not selecting: the share
|
||||||
|
* control at the end, and — for a non-media tile — the copy-link control at the
|
||||||
|
* start, so both the existing open (the tile's own tap) and copy actions stay
|
||||||
|
* reachable from the gallery. A media tile taps through to the viewer, which
|
||||||
|
* carries its own copy action, so it shows only share.
|
||||||
|
*/
|
||||||
|
@Composable
|
||||||
|
private fun BoxScope.ArtifactTileActions(
|
||||||
|
artifact: StageArtifact,
|
||||||
|
resolved: String?,
|
||||||
|
fetchArtifactBytes: suspend (String) -> ByteArray?,
|
||||||
|
media: Boolean,
|
||||||
|
) {
|
||||||
|
Row(
|
||||||
|
modifier = Modifier.align(Alignment.TopStart).fillMaxWidth(),
|
||||||
|
horizontalArrangement = Arrangement.SpaceBetween,
|
||||||
|
) {
|
||||||
|
if (media) {
|
||||||
|
Spacer(Modifier.size(ARTIFACT_TILE_ACTION_DP))
|
||||||
|
} else {
|
||||||
|
ArtifactCopyButton(artifact = artifact, resolved = resolved)
|
||||||
|
}
|
||||||
|
ArtifactShareButton(
|
||||||
|
artifact = artifact,
|
||||||
|
resolved = resolved,
|
||||||
|
fetchArtifactBytes = fetchArtifactBytes,
|
||||||
|
modifier = Modifier.size(ARTIFACT_TILE_ACTION_DP),
|
||||||
|
scrim = media,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The compact copy-link control a non-media tile carries. */
|
||||||
|
@Composable
|
||||||
|
private fun ArtifactCopyButton(artifact: StageArtifact, resolved: String?) {
|
||||||
|
val clipboard = LocalClipboardManager.current
|
||||||
|
IconButton(
|
||||||
|
onClick = { resolved?.let { clipboard.copyText(it) } },
|
||||||
|
enabled = resolved != null,
|
||||||
|
modifier = Modifier.size(ARTIFACT_TILE_ACTION_DP),
|
||||||
|
) {
|
||||||
|
Icon(Icons.Default.ContentCopy, contentDescription = "Copy link to ${artifact.name}")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The share action every artifact tile carries: a compact [IconButton] target, an
|
||||||
|
* accurate content description, and a click that launches the platform share
|
||||||
|
* chooser. It is the item's own child action, so a tap on it never opens the
|
||||||
|
* image or the item. [scrim] adds the translucent backing the viewer uses so the
|
||||||
|
* icon stays legible over a bright image.
|
||||||
*/
|
*/
|
||||||
@Composable
|
@Composable
|
||||||
private fun ArtifactShareButton(
|
private fun ArtifactShareButton(
|
||||||
@@ -491,5 +518,5 @@ internal fun openArtifact(context: Context, url: String?) {
|
|||||||
/** Longest edge of a list thumbnail decode. */
|
/** Longest edge of a list thumbnail decode. */
|
||||||
private const val THUMBNAIL_MAX_DIM = 160
|
private const val THUMBNAIL_MAX_DIM = 160
|
||||||
|
|
||||||
/** Gap between gallery thumbnails; shared by the row arrangement and the fitting. */
|
/** Gap between gallery tiles; shared by the row arrangement and the fitting. */
|
||||||
private val ARTIFACT_TILE_SPACING_DP = SPACING_S
|
private val ARTIFACT_TILE_SPACING_DP = SPACING_S
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ import androidx.compose.runtime.remember
|
|||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.semantics.heading
|
import androidx.compose.ui.semantics.heading
|
||||||
import androidx.compose.ui.semantics.semantics
|
import androidx.compose.ui.semantics.semantics
|
||||||
|
import androidx.compose.ui.text.style.TextOverflow
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||||
import net.awan.pipelines.data.protocol.ControlEvidence
|
import net.awan.pipelines.data.protocol.ControlEvidence
|
||||||
@@ -50,6 +51,7 @@ import net.awan.pipelines.ui.fileChangeLine
|
|||||||
import net.awan.pipelines.ui.fileChangesSummary
|
import net.awan.pipelines.ui.fileChangesSummary
|
||||||
import net.awan.pipelines.ui.formatDuration
|
import net.awan.pipelines.ui.formatDuration
|
||||||
import net.awan.pipelines.ui.notificationLine
|
import net.awan.pipelines.ui.notificationLine
|
||||||
|
import net.awan.pipelines.ui.runLabel
|
||||||
import net.awan.pipelines.ui.screens.runTimeline
|
import net.awan.pipelines.ui.screens.runTimeline
|
||||||
import net.awan.pipelines.ui.theme.SPACING_L
|
import net.awan.pipelines.ui.theme.SPACING_L
|
||||||
import net.awan.pipelines.ui.theme.SPACING_S
|
import net.awan.pipelines.ui.theme.SPACING_S
|
||||||
@@ -378,11 +380,14 @@ fun StageDetailPane(
|
|||||||
visitIndex: Int = 0,
|
visitIndex: Int = 0,
|
||||||
onVisitIndexChange: (Int) -> Unit = {},
|
onVisitIndexChange: (Int) -> Unit = {},
|
||||||
onOpenSection: (String) -> Unit = {},
|
onOpenSection: (String) -> Unit = {},
|
||||||
|
configuredServerUrl: String = "",
|
||||||
|
fetchArtifactBytes: suspend (String) -> ByteArray? = { null },
|
||||||
onBack: () -> Unit,
|
onBack: () -> Unit,
|
||||||
wide: Boolean = false,
|
wide: Boolean = false,
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
covered: Boolean = false,
|
covered: Boolean = false,
|
||||||
runContext: Boolean = false,
|
runContext: Boolean = false,
|
||||||
|
runLabel: String? = null,
|
||||||
) {
|
) {
|
||||||
// A covered pane shows its compact identity only; the visit tab row and the
|
// A covered pane shows its compact identity only; the visit tab row and the
|
||||||
// stage body must never be drawn squeezed into the peek strip.
|
// stage body must never be drawn squeezed into the peek strip.
|
||||||
@@ -402,7 +407,26 @@ fun StageDetailPane(
|
|||||||
contentWindowInsets = paneSafeArea(),
|
contentWindowInsets = paneSafeArea(),
|
||||||
topBar = {
|
topBar = {
|
||||||
TopAppBar(
|
TopAppBar(
|
||||||
title = { Text(GraphSemantics.nodeLabel(stageKey)) },
|
title = {
|
||||||
|
// The stage's own name leads, with the run it belongs to on a
|
||||||
|
// second line when the caller has one, so opening a stage never
|
||||||
|
// loses which run it is a visit of.
|
||||||
|
Column {
|
||||||
|
Text(
|
||||||
|
GraphSemantics.nodeLabel(stageKey),
|
||||||
|
maxLines = 1,
|
||||||
|
overflow = TextOverflow.Ellipsis,
|
||||||
|
)
|
||||||
|
runLabel?.takeIf { it.isNotBlank() }?.let { label ->
|
||||||
|
Text(
|
||||||
|
label,
|
||||||
|
style = pipelinesText().meta,
|
||||||
|
maxLines = 1,
|
||||||
|
overflow = TextOverflow.Ellipsis,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
navigationIcon = {
|
navigationIcon = {
|
||||||
IconButton(onClick = onBack) {
|
IconButton(onClick = onBack) {
|
||||||
Icon(Icons.AutoMirrored.Filled.ArrowBack, contentDescription = "Back")
|
Icon(Icons.AutoMirrored.Filled.ArrowBack, contentDescription = "Back")
|
||||||
@@ -420,6 +444,8 @@ fun StageDetailPane(
|
|||||||
visitIndex = visitIndex,
|
visitIndex = visitIndex,
|
||||||
onVisitIndexChange = onVisitIndexChange,
|
onVisitIndexChange = onVisitIndexChange,
|
||||||
onOpenSection = onOpenSection,
|
onOpenSection = onOpenSection,
|
||||||
|
configuredServerUrl = configuredServerUrl,
|
||||||
|
fetchArtifactBytes = fetchArtifactBytes,
|
||||||
wide = wide,
|
wide = wide,
|
||||||
runContext = runContext,
|
runContext = runContext,
|
||||||
modifier = Modifier.padding(padding),
|
modifier = Modifier.padding(padding),
|
||||||
@@ -436,6 +462,8 @@ private fun StageDetailBody(
|
|||||||
visitIndex: Int,
|
visitIndex: Int,
|
||||||
onVisitIndexChange: (Int) -> Unit,
|
onVisitIndexChange: (Int) -> Unit,
|
||||||
onOpenSection: (String) -> Unit,
|
onOpenSection: (String) -> Unit,
|
||||||
|
configuredServerUrl: String,
|
||||||
|
fetchArtifactBytes: suspend (String) -> ByteArray?,
|
||||||
wide: Boolean,
|
wide: Boolean,
|
||||||
runContext: Boolean,
|
runContext: Boolean,
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
@@ -468,6 +496,20 @@ private fun StageDetailBody(
|
|||||||
)
|
)
|
||||||
StageTypeChip(typeLabel)
|
StageTypeChip(typeLabel)
|
||||||
StageVisitTabs(runSteps.size, clampedVisit, onVisitIndexChange)
|
StageVisitTabs(runSteps.size, clampedVisit, onVisitIndexChange)
|
||||||
|
|
||||||
|
// The verdict leads the run pane, above the facts: the chosen option,
|
||||||
|
// the concise reason and the artifacts it names. Absent when the server
|
||||||
|
// reported none, so no empty heading is ever drawn.
|
||||||
|
if (runContext && selectedStep != null) {
|
||||||
|
StageVerdictBlock(
|
||||||
|
verdict = selectedStep.verdict,
|
||||||
|
outcome = selectedStep.outcome,
|
||||||
|
status = selectedStep.status,
|
||||||
|
artifacts = selectedStep.artifacts.orEmpty(),
|
||||||
|
configuredServerUrl = configuredServerUrl,
|
||||||
|
fetchArtifactBytes = fetchArtifactBytes,
|
||||||
|
)
|
||||||
|
}
|
||||||
headline.forEach { field -> StageFieldRow(field) }
|
headline.forEach { field -> StageFieldRow(field) }
|
||||||
if (headline.isEmpty() && selectedStep == null && stage == null && sections.isEmpty()) {
|
if (headline.isEmpty() && selectedStep == null && stage == null && sections.isEmpty()) {
|
||||||
Text("No details recorded for this node.", style = text.meta)
|
Text("No details recorded for this node.", style = text.meta)
|
||||||
@@ -717,11 +759,14 @@ fun RunStagePane(
|
|||||||
visitIndex = visitIndex,
|
visitIndex = visitIndex,
|
||||||
onVisitIndexChange = onVisitChange,
|
onVisitIndexChange = onVisitChange,
|
||||||
onOpenSection = onOpenSection,
|
onOpenSection = onOpenSection,
|
||||||
|
configuredServerUrl = configuredServerUrl,
|
||||||
|
fetchArtifactBytes = vm::fetchArtifactBytes,
|
||||||
onBack = onBack,
|
onBack = onBack,
|
||||||
wide = wide,
|
wide = wide,
|
||||||
modifier = modifier,
|
modifier = modifier,
|
||||||
covered = covered,
|
covered = covered,
|
||||||
runContext = true,
|
runContext = true,
|
||||||
|
runLabel = run?.let { runLabel(it.title, it.name) },
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
StageSectionPane(
|
StageSectionPane(
|
||||||
|
|||||||
@@ -0,0 +1,279 @@
|
|||||||
|
package net.awan.pipelines.ui.graph
|
||||||
|
|
||||||
|
import androidx.compose.foundation.clickable
|
||||||
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
|
import androidx.compose.foundation.layout.Column
|
||||||
|
import androidx.compose.foundation.layout.ExperimentalLayoutApi
|
||||||
|
import androidx.compose.foundation.layout.FlowRow
|
||||||
|
import androidx.compose.foundation.layout.Row
|
||||||
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
|
import androidx.compose.foundation.layout.padding
|
||||||
|
import androidx.compose.foundation.layout.size
|
||||||
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||||
|
import androidx.compose.material3.Icon
|
||||||
|
import androidx.compose.material3.MaterialTheme
|
||||||
|
import androidx.compose.material3.Surface
|
||||||
|
import androidx.compose.material3.Text
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.runtime.getValue
|
||||||
|
import androidx.compose.runtime.mutableStateOf
|
||||||
|
import androidx.compose.runtime.remember
|
||||||
|
import androidx.compose.runtime.setValue
|
||||||
|
import androidx.compose.ui.Alignment
|
||||||
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.platform.LocalContext
|
||||||
|
import androidx.compose.ui.text.LinkAnnotation
|
||||||
|
import androidx.compose.ui.text.SpanStyle
|
||||||
|
import androidx.compose.ui.text.TextLinkStyles
|
||||||
|
import androidx.compose.ui.text.buildAnnotatedString
|
||||||
|
import androidx.compose.ui.text.style.TextDecoration
|
||||||
|
import androidx.compose.ui.text.style.TextOverflow
|
||||||
|
import androidx.compose.ui.text.withLink
|
||||||
|
import net.awan.pipelines.data.protocol.StageArtifact
|
||||||
|
import net.awan.pipelines.data.protocol.StageVerdict
|
||||||
|
import net.awan.pipelines.ui.components.ColoredChip
|
||||||
|
import net.awan.pipelines.ui.components.runStateIcon
|
||||||
|
import net.awan.pipelines.ui.components.runStateOf
|
||||||
|
import net.awan.pipelines.ui.theme.ICON_STATUS_DP
|
||||||
|
import net.awan.pipelines.ui.theme.SPACING_M
|
||||||
|
import net.awan.pipelines.ui.theme.SPACING_S
|
||||||
|
import net.awan.pipelines.ui.theme.SPACING_XS
|
||||||
|
import net.awan.pipelines.ui.theme.pipelinesText
|
||||||
|
|
||||||
|
/**
|
||||||
|
* One piece of a verdict's reason: literal [text], or a reference to a recorded
|
||||||
|
* [artifact] the reason names. A null [artifact] is plain text.
|
||||||
|
*/
|
||||||
|
internal data class VerdictReasonSegment(val text: String, val artifact: StageArtifact? = null)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The recorded artifacts a [verdict] refers to: its own referenced names resolved
|
||||||
|
* to the visit's recorded [artifacts], in recorded order and deduplicated. A name
|
||||||
|
* the server never recorded is dropped, so only real files are ever offered, and
|
||||||
|
* no verdict or no referenced names yields nothing.
|
||||||
|
*/
|
||||||
|
internal fun referencedVerdictArtifacts(
|
||||||
|
verdict: StageVerdict?,
|
||||||
|
artifacts: List<StageArtifact>,
|
||||||
|
): List<StageArtifact> {
|
||||||
|
val names = verdict?.artifacts.orEmpty()
|
||||||
|
if (names.isEmpty()) return emptyList()
|
||||||
|
val wanted = names.toHashSet()
|
||||||
|
val seen = HashSet<String>()
|
||||||
|
val referenced = ArrayList<StageArtifact>()
|
||||||
|
for (artifact in artifacts) {
|
||||||
|
if (artifact.name.isEmpty() || !seen.add(artifact.name)) continue
|
||||||
|
if (artifact.name in wanted) referenced += artifact
|
||||||
|
}
|
||||||
|
return referenced
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Splits [reason] into literal runs and references to the recorded [references]
|
||||||
|
* it names, by an artifact's full recorded name or its basename (mirroring the
|
||||||
|
* server's own reference matching). At the same index a longer token wins over a
|
||||||
|
* shorter one, so a full slashed path is never split inside a longer match. With
|
||||||
|
* nothing to reference the whole reason is one literal segment; an empty reason
|
||||||
|
* yields no segments.
|
||||||
|
*/
|
||||||
|
internal fun verdictReasonSegments(
|
||||||
|
reason: String,
|
||||||
|
references: List<StageArtifact>,
|
||||||
|
): List<VerdictReasonSegment> {
|
||||||
|
if (reason.isEmpty()) return emptyList()
|
||||||
|
if (references.isEmpty()) return listOf(VerdictReasonSegment(reason))
|
||||||
|
val tokens = ArrayList<Pair<String, StageArtifact>>()
|
||||||
|
references.forEach { artifact ->
|
||||||
|
tokens += artifact.name to artifact
|
||||||
|
val base = artifactBaseName(artifact.name)
|
||||||
|
if (base.isNotEmpty() && base != artifact.name) tokens += base to artifact
|
||||||
|
}
|
||||||
|
// Longest token first (stable), so a full name wins over its basename at the
|
||||||
|
// same index; a bare basename still resolves to the artifact named exactly so.
|
||||||
|
tokens.sortByDescending { it.first.length }
|
||||||
|
val segments = ArrayList<VerdictReasonSegment>()
|
||||||
|
val literal = StringBuilder()
|
||||||
|
var index = 0
|
||||||
|
while (index < reason.length) {
|
||||||
|
val match = tokens.firstOrNull { reason.startsWith(it.first, index) }
|
||||||
|
if (match == null) {
|
||||||
|
literal.append(reason[index])
|
||||||
|
index++
|
||||||
|
} else {
|
||||||
|
if (literal.isNotEmpty()) {
|
||||||
|
segments += VerdictReasonSegment(literal.toString())
|
||||||
|
literal.clear()
|
||||||
|
}
|
||||||
|
segments += VerdictReasonSegment(match.first, match.second)
|
||||||
|
index += match.first.length
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (literal.isNotEmpty()) segments += VerdictReasonSegment(literal.toString())
|
||||||
|
return segments
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The last path segment of a recorded artifact name (`shots/x.png` -> `x.png`). */
|
||||||
|
private fun artifactBaseName(name: String): String =
|
||||||
|
name.substringAfterLast('/').substringAfterLast('\\')
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The stage pane's Verdict block: the completed visit's chosen option as a badge
|
||||||
|
* in the outcome's existing colour, the concise reason as ordinary body text (never
|
||||||
|
* a monospace JSON dump, and it wraps rather than clipping), and the recorded
|
||||||
|
* artifacts the reason names as inline, tappable links plus the same references as
|
||||||
|
* compact chips. An image or video reference opens the shared full-screen viewer;
|
||||||
|
* anything else goes through the existing external-open action, so the block reuses
|
||||||
|
* the gallery's behaviour instead of re-deriving it.
|
||||||
|
*
|
||||||
|
* It renders nothing at all when the server reported no verdict ([verdict] null) or
|
||||||
|
* the verdict carries neither an option nor a reason, so there is never an empty
|
||||||
|
* heading or placeholder.
|
||||||
|
*/
|
||||||
|
@OptIn(ExperimentalLayoutApi::class)
|
||||||
|
@Composable
|
||||||
|
internal fun StageVerdictBlock(
|
||||||
|
verdict: StageVerdict?,
|
||||||
|
outcome: String,
|
||||||
|
status: String,
|
||||||
|
artifacts: List<StageArtifact>,
|
||||||
|
configuredServerUrl: String,
|
||||||
|
fetchArtifactBytes: suspend (String) -> ByteArray?,
|
||||||
|
modifier: Modifier = Modifier,
|
||||||
|
) {
|
||||||
|
if (verdict == null) return
|
||||||
|
val option = verdict.option
|
||||||
|
val reason = verdict.reason
|
||||||
|
if (option.isBlank() && reason.isBlank()) return
|
||||||
|
|
||||||
|
val text = pipelinesText()
|
||||||
|
val context = LocalContext.current
|
||||||
|
val scheme = MaterialTheme.colorScheme
|
||||||
|
val linkColor = scheme.primary
|
||||||
|
val colors = remember(scheme) { graphColors(scheme) }
|
||||||
|
val tint = outcomeColor(outcome.ifBlank { status }, colors)
|
||||||
|
val references = remember(verdict, artifacts) { referencedVerdictArtifacts(verdict, artifacts) }
|
||||||
|
val segments = remember(reason, references) { verdictReasonSegments(reason, references) }
|
||||||
|
var viewerArtifact by remember { mutableStateOf<StageArtifact?>(null) }
|
||||||
|
|
||||||
|
// The one tap behaviour the inline links and the chips share: media opens the
|
||||||
|
// viewer, everything else the existing external-open action.
|
||||||
|
val open: (StageArtifact) -> Unit = { artifact ->
|
||||||
|
val resolved = resolvedArtifactUrl(artifact, configuredServerUrl)
|
||||||
|
val media = artifactKind(artifact.contentType, artifact.name).let {
|
||||||
|
it == ArtifactKind.Image || it == ArtifactKind.Video
|
||||||
|
}
|
||||||
|
if (resolved != null && media) viewerArtifact = artifact else openArtifact(context, resolved)
|
||||||
|
}
|
||||||
|
|
||||||
|
Surface(
|
||||||
|
modifier = modifier.fillMaxWidth(),
|
||||||
|
color = MaterialTheme.colorScheme.surfaceContainerHigh,
|
||||||
|
shape = MaterialTheme.shapes.medium,
|
||||||
|
) {
|
||||||
|
Column(
|
||||||
|
modifier = Modifier.padding(SPACING_M),
|
||||||
|
verticalArrangement = Arrangement.spacedBy(SPACING_S),
|
||||||
|
) {
|
||||||
|
FlowRow(
|
||||||
|
horizontalArrangement = Arrangement.spacedBy(SPACING_S),
|
||||||
|
verticalArrangement = Arrangement.spacedBy(SPACING_XS),
|
||||||
|
) {
|
||||||
|
Text("Verdict", style = text.sectionHeader)
|
||||||
|
if (option.isNotBlank()) {
|
||||||
|
ColoredChip(
|
||||||
|
label = option,
|
||||||
|
color = tint,
|
||||||
|
icon = runStateIcon(runStateOf(outcome.ifBlank { status })),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (reason.isNotBlank()) {
|
||||||
|
// Rebuilt only when the segments, link colour or configured server
|
||||||
|
// change, so the tap targets never capture a stale server.
|
||||||
|
val annotated = remember(segments, linkColor, configuredServerUrl) {
|
||||||
|
buildAnnotatedString {
|
||||||
|
segments.forEach { segment ->
|
||||||
|
val artifact = segment.artifact
|
||||||
|
if (artifact == null) {
|
||||||
|
append(segment.text)
|
||||||
|
} else {
|
||||||
|
withLink(
|
||||||
|
LinkAnnotation.Clickable(
|
||||||
|
tag = "artifact:${artifact.url}",
|
||||||
|
styles = TextLinkStyles(
|
||||||
|
style = SpanStyle(
|
||||||
|
color = linkColor,
|
||||||
|
textDecoration = TextDecoration.Underline,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
linkInteractionListener = { open(artifact) },
|
||||||
|
),
|
||||||
|
) { append(segment.text) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Text(
|
||||||
|
text = annotated,
|
||||||
|
style = text.body,
|
||||||
|
modifier = Modifier.fillMaxWidth(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
if (references.isNotEmpty()) {
|
||||||
|
FlowRow(
|
||||||
|
horizontalArrangement = Arrangement.spacedBy(SPACING_S),
|
||||||
|
verticalArrangement = Arrangement.spacedBy(SPACING_XS),
|
||||||
|
) {
|
||||||
|
references.forEach { artifact ->
|
||||||
|
VerdictArtifactChip(artifact = artifact, onClick = { open(artifact) })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val viewer = viewerArtifact
|
||||||
|
val viewerUrl = viewer?.let { resolvedArtifactUrl(it, configuredServerUrl) }
|
||||||
|
if (viewer != null && viewerUrl != null) {
|
||||||
|
ArtifactViewer(
|
||||||
|
url = viewerUrl,
|
||||||
|
name = viewer.name,
|
||||||
|
fetchBytes = fetchArtifactBytes,
|
||||||
|
onDismiss = { viewerArtifact = null },
|
||||||
|
video = artifactKind(viewer.contentType, viewer.name) == ArtifactKind.Video,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** A compact, tappable chip naming one referenced artifact, with its type glyph. */
|
||||||
|
@Composable
|
||||||
|
private fun VerdictArtifactChip(artifact: StageArtifact, onClick: () -> Unit) {
|
||||||
|
val text = pipelinesText()
|
||||||
|
val kind = remember(artifact.contentType, artifact.name) {
|
||||||
|
artifactKind(artifact.contentType, artifact.name)
|
||||||
|
}
|
||||||
|
Surface(
|
||||||
|
shape = RoundedCornerShape(50),
|
||||||
|
color = MaterialTheme.colorScheme.surfaceContainerHighest,
|
||||||
|
modifier = Modifier.clickable(onClick = onClick),
|
||||||
|
) {
|
||||||
|
Row(
|
||||||
|
modifier = Modifier.padding(horizontal = SPACING_S, vertical = SPACING_XS),
|
||||||
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
|
horizontalArrangement = Arrangement.spacedBy(SPACING_XS),
|
||||||
|
) {
|
||||||
|
Icon(
|
||||||
|
imageVector = artifactIcon(kind),
|
||||||
|
contentDescription = null,
|
||||||
|
tint = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||||
|
modifier = Modifier.size(ICON_STATUS_DP),
|
||||||
|
)
|
||||||
|
Text(
|
||||||
|
text = artifact.name,
|
||||||
|
style = text.label,
|
||||||
|
maxLines = 1,
|
||||||
|
overflow = TextOverflow.Ellipsis,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -108,27 +108,37 @@ data class RunFilters(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The pipelines-list run filters: whether a pipeline has any recorded run and
|
* The pipelines-list filters: a case-insensitive name narrowing plus whether a
|
||||||
* the status of its most recent one. The name search stays a separate control
|
* pipeline has any recorded run and the status of its most recent one. Name is
|
||||||
* (it narrows by text, not by run facts); these two are persisted per list.
|
* free text (any stored value is a legitimate filter), so it is the one facet not
|
||||||
|
* resolved against a closed vocabulary; like the run facets it is persisted per
|
||||||
|
* list. Unlike them, the name narrowing needs no run history, so it applies as
|
||||||
|
* soon as the pipelines load (see [filterPipelines]).
|
||||||
*/
|
*/
|
||||||
data class PipelineFilters(
|
data class PipelineFilters(
|
||||||
val presence: RunPresence = RunPresence.Default,
|
val presence: RunPresence = RunPresence.Default,
|
||||||
val lastRunStatuses: Set<RunState> = emptySet(),
|
val lastRunStatuses: Set<RunState> = emptySet(),
|
||||||
|
val name: String = "",
|
||||||
) {
|
) {
|
||||||
val activeCount: Int
|
val activeCount: Int
|
||||||
get() = (if (presence != RunPresence.Default) 1 else 0) +
|
get() = (if (presence != RunPresence.Default) 1 else 0) +
|
||||||
(if (lastRunStatuses.isNotEmpty()) 1 else 0)
|
(if (lastRunStatuses.isNotEmpty()) 1 else 0) +
|
||||||
|
(if (name.isNotBlank()) 1 else 0)
|
||||||
|
|
||||||
val isActive: Boolean get() = activeCount > 0
|
val isActive: Boolean get() = activeCount > 0
|
||||||
|
|
||||||
|
/** Whether a run-history facet is set; only those depend on the run history. */
|
||||||
|
val hasRunFacets: Boolean
|
||||||
|
get() = presence != RunPresence.Default || lastRunStatuses.isNotEmpty()
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
val Default = PipelineFilters()
|
val Default = PipelineFilters()
|
||||||
|
|
||||||
fun fromStorage(presence: String?, lastRunStatuses: String?): PipelineFilters =
|
fun fromStorage(presence: String?, lastRunStatuses: String?, name: String?): PipelineFilters =
|
||||||
PipelineFilters(
|
PipelineFilters(
|
||||||
presence = RunPresence.fromStorage(presence),
|
presence = RunPresence.fromStorage(presence),
|
||||||
lastRunStatuses = decodeRunStates(lastRunStatuses),
|
lastRunStatuses = decodeRunStates(lastRunStatuses),
|
||||||
|
name = name.orEmpty(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -208,10 +218,16 @@ internal fun pipelineMatchesFilters(filters: PipelineFilters, latestRun: RunSumm
|
|||||||
pipelineMatchesPresence(filters.presence, latestRun != null) &&
|
pipelineMatchesPresence(filters.presence, latestRun != null) &&
|
||||||
pipelineMatchesLastRunStatus(latestRun, filters.lastRunStatuses)
|
pipelineMatchesLastRunStatus(latestRun, filters.lastRunStatuses)
|
||||||
|
|
||||||
|
/** True when [name] is blank, or when [pipelineName] contains it, ignoring case. */
|
||||||
|
internal fun pipelineMatchesName(name: String, pipelineName: String): Boolean =
|
||||||
|
name.isBlank() || pipelineName.contains(name, ignoreCase = true)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Narrows [pipelines] by [filters]. Both facets depend on the run history, so
|
* Narrows [pipelines] by [filters]: the name narrowing and both run facets combined
|
||||||
* while that history is still unknown (`runsKnown == false`) the list is left
|
* with AND. The name facet never depends on the run history, so it applies
|
||||||
* unfiltered rather than briefly hiding every pipeline.
|
* immediately; the run facets do, so while that history is still unknown
|
||||||
|
* (`runsKnown == false`) they are skipped rather than briefly hiding every
|
||||||
|
* pipeline.
|
||||||
*/
|
*/
|
||||||
internal fun filterPipelines(
|
internal fun filterPipelines(
|
||||||
pipelines: List<PipelineSummary>,
|
pipelines: List<PipelineSummary>,
|
||||||
@@ -219,8 +235,11 @@ internal fun filterPipelines(
|
|||||||
latestRuns: Map<Long, RunSummary>,
|
latestRuns: Map<Long, RunSummary>,
|
||||||
runsKnown: Boolean = true,
|
runsKnown: Boolean = true,
|
||||||
): List<PipelineSummary> {
|
): List<PipelineSummary> {
|
||||||
if (!filters.isActive || !runsKnown) return pipelines
|
if (!filters.isActive) return pipelines
|
||||||
return pipelines.filter { pipelineMatchesFilters(filters, latestRuns[it.id]) }
|
return pipelines.filter { pipeline ->
|
||||||
|
pipelineMatchesName(filters.name, pipeline.name) &&
|
||||||
|
(!filters.hasRunFacets || !runsKnown || pipelineMatchesFilters(filters, latestRuns[pipeline.id]))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** One selectable pipeline in the run filter, named from its runs. */
|
/** One selectable pipeline in the run filter, named from its runs. */
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ import androidx.compose.foundation.lazy.items
|
|||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.filled.AccountTree
|
import androidx.compose.material.icons.filled.AccountTree
|
||||||
import androidx.compose.material.icons.filled.Refresh
|
import androidx.compose.material.icons.filled.Refresh
|
||||||
import androidx.compose.material.icons.filled.Search
|
|
||||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||||
import androidx.compose.material3.HorizontalDivider
|
import androidx.compose.material3.HorizontalDivider
|
||||||
import androidx.compose.material3.Icon
|
import androidx.compose.material3.Icon
|
||||||
@@ -28,9 +27,7 @@ import androidx.compose.material3.TopAppBar
|
|||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.LaunchedEffect
|
import androidx.compose.runtime.LaunchedEffect
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.runtime.mutableStateOf
|
|
||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
import androidx.compose.runtime.setValue
|
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.text.style.TextOverflow
|
import androidx.compose.ui.text.style.TextOverflow
|
||||||
@@ -59,6 +56,7 @@ import net.awan.pipelines.ui.components.listLoadPhase
|
|||||||
import net.awan.pipelines.ui.components.paneSafeArea
|
import net.awan.pipelines.ui.components.paneSafeArea
|
||||||
import net.awan.pipelines.ui.components.rememberLiveNowMillis
|
import net.awan.pipelines.ui.components.rememberLiveNowMillis
|
||||||
import net.awan.pipelines.ui.theme.SPACING_L
|
import net.awan.pipelines.ui.theme.SPACING_L
|
||||||
|
import net.awan.pipelines.ui.theme.SPACING_M
|
||||||
import net.awan.pipelines.ui.theme.SPACING_S
|
import net.awan.pipelines.ui.theme.SPACING_S
|
||||||
import net.awan.pipelines.ui.theme.pipelinesText
|
import net.awan.pipelines.ui.theme.pipelinesText
|
||||||
|
|
||||||
@@ -78,8 +76,8 @@ fun PipelineListScreen(
|
|||||||
val sort = PipelineSort.fromStorage(sortKey)
|
val sort = PipelineSort.fromStorage(sortKey)
|
||||||
val presenceKey by vm.pipelineFilterPresence.collectAsStateWithLifecycle()
|
val presenceKey by vm.pipelineFilterPresence.collectAsStateWithLifecycle()
|
||||||
val runStatusKey by vm.pipelineFilterRunStatuses.collectAsStateWithLifecycle()
|
val runStatusKey by vm.pipelineFilterRunStatuses.collectAsStateWithLifecycle()
|
||||||
val filters = PipelineFilters.fromStorage(presenceKey, runStatusKey)
|
val nameKey by vm.pipelineFilterName.collectAsStateWithLifecycle()
|
||||||
var query by remember { mutableStateOf("") }
|
val filters = PipelineFilters.fromStorage(presenceKey, runStatusKey, nameKey)
|
||||||
|
|
||||||
// The last-run line joins list_runs onto the pipelines client-side; runs are
|
// The last-run line joins list_runs onto the pipelines client-side; runs are
|
||||||
// fetched here too so a pipeline list opened first still shows its history.
|
// fetched here too so a pipeline list opened first still shows its history.
|
||||||
@@ -104,11 +102,11 @@ fun PipelineListScreen(
|
|||||||
// held here would be discarded and reset the scroll when a detail closes.
|
// held here would be discarded and reset the scroll when a detail closes.
|
||||||
// [RestoreListScroll] clamps it when the list changed underneath.
|
// [RestoreListScroll] clamps it when the list changed underneath.
|
||||||
|
|
||||||
// A covered pane shows its compact identity only; the search field and list
|
// A covered pane shows its compact identity only; the list must never be
|
||||||
// must never be drawn squeezed into the peek strip. Its statistics are the
|
// drawn squeezed into the peek strip. Its statistics are the run history's
|
||||||
// run history's summary, folded once; before the history has loaded the
|
// summary, folded once; before the history has loaded the identity stays
|
||||||
// identity stays title-only rather than claiming zero runs. Measured before
|
// title-only rather than claiming zero runs. Measured before the row badges
|
||||||
// the row badges below so the peek never pays for the unshown fold.
|
// below so the peek never pays for the unshown fold.
|
||||||
if (covered) {
|
if (covered) {
|
||||||
val stats = remember(runsState.data, now) {
|
val stats = remember(runsState.data, now) {
|
||||||
listStatLines(runsState.data?.runs, now)
|
listStatLines(runsState.data?.runs, now)
|
||||||
@@ -137,7 +135,7 @@ fun PipelineListScreen(
|
|||||||
val onClearFilters: () -> Unit = {
|
val onClearFilters: () -> Unit = {
|
||||||
vm.setPipelineFilterPresence("")
|
vm.setPipelineFilterPresence("")
|
||||||
vm.setPipelineFilterRunStatuses("")
|
vm.setPipelineFilterRunStatuses("")
|
||||||
query = ""
|
vm.setPipelineFilterName("")
|
||||||
}
|
}
|
||||||
|
|
||||||
Scaffold(
|
Scaffold(
|
||||||
@@ -150,6 +148,7 @@ fun PipelineListScreen(
|
|||||||
actions = {
|
actions = {
|
||||||
PipelineFilterControl(
|
PipelineFilterControl(
|
||||||
filters = filters,
|
filters = filters,
|
||||||
|
onName = { vm.setPipelineFilterName(it) },
|
||||||
onPresence = { vm.setPipelineFilterPresence(it.storageKey) },
|
onPresence = { vm.setPipelineFilterPresence(it.storageKey) },
|
||||||
onRunStatuses = { vm.setPipelineFilterRunStatuses(encodeRunStates(it)) },
|
onRunStatuses = { vm.setPipelineFilterRunStatuses(encodeRunStates(it)) },
|
||||||
onClear = onClearFilters,
|
onClear = onClearFilters,
|
||||||
@@ -175,25 +174,10 @@ fun PipelineListScreen(
|
|||||||
},
|
},
|
||||||
) { padding ->
|
) { padding ->
|
||||||
Column(Modifier.fillMaxSize().padding(padding)) {
|
Column(Modifier.fillMaxSize().padding(padding)) {
|
||||||
OutlinedTextField(
|
|
||||||
value = query,
|
|
||||||
onValueChange = { query = it },
|
|
||||||
label = { Text("Search pipelines") },
|
|
||||||
leadingIcon = { Icon(Icons.Default.Search, contentDescription = null) },
|
|
||||||
singleLine = true,
|
|
||||||
modifier = Modifier.fillMaxWidth().padding(horizontal = SPACING_L, vertical = SPACING_S),
|
|
||||||
)
|
|
||||||
val all = state.data ?: emptyList()
|
val all = state.data ?: emptyList()
|
||||||
val items = remember(all, query, sort, latestRuns, filters, runsKnown) {
|
val items = remember(all, sort, latestRuns, filters, runsKnown) {
|
||||||
filterPipelines(
|
filterPipelines(sortPipelines(all, sort, latestRuns), filters, latestRuns, runsKnown)
|
||||||
sortPipelines(all, sort, latestRuns),
|
|
||||||
filters,
|
|
||||||
latestRuns,
|
|
||||||
runsKnown,
|
|
||||||
).filter { it.name.contains(query, ignoreCase = true) }
|
|
||||||
}
|
}
|
||||||
val queryActive = query.isNotBlank()
|
|
||||||
val filtersActive = filters.isActive && runsKnown
|
|
||||||
StateCrossfade(
|
StateCrossfade(
|
||||||
phase = listLoadPhase(
|
phase = listLoadPhase(
|
||||||
loading = state.loading,
|
loading = state.loading,
|
||||||
@@ -201,13 +185,11 @@ fun PipelineListScreen(
|
|||||||
hasData = state.data != null,
|
hasData = state.data != null,
|
||||||
emptyMessage = if (items.isEmpty()) {
|
emptyMessage = if (items.isEmpty()) {
|
||||||
if (all.isEmpty()) {
|
if (all.isEmpty()) {
|
||||||
// Nothing exists: neither the search nor the filters can
|
// Nothing exists: no filter can reveal a pipeline, so
|
||||||
// reveal a pipeline, so there is no clear action.
|
// there is no clear action.
|
||||||
"No pipelines are defined on this server."
|
"No pipelines are defined on this server."
|
||||||
} else if (queryActive && filtersActive) {
|
} else if (filters.name.isNotBlank() && !filters.hasRunFacets) {
|
||||||
"No pipelines match the current search and filters."
|
"No pipelines match \"${filters.name}\"."
|
||||||
} else if (queryActive) {
|
|
||||||
"No pipelines match \"$query\"."
|
|
||||||
} else {
|
} else {
|
||||||
"No pipelines match the current filters."
|
"No pipelines match the current filters."
|
||||||
}
|
}
|
||||||
@@ -265,13 +247,16 @@ fun PipelineListScreen(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The pipelines-list run filter control: presence (has/no runs) and the
|
* The pipelines-list filter control: a case-insensitive name narrowing plus the
|
||||||
* most-recent run's status (multi-select), with the shared active-count badge
|
* run facets (has/no runs) and the most-recent run's status (multi-select), with
|
||||||
* and one Clear filters action. The name search stays a separate field.
|
* the shared active-count badge and one Clear filters action. The name is a
|
||||||
|
* filter, not a search: it narrows only this list, while the omni search is the
|
||||||
|
* one affordance that finds pipelines, runs and artifacts across the system.
|
||||||
*/
|
*/
|
||||||
@Composable
|
@Composable
|
||||||
private fun PipelineFilterControl(
|
private fun PipelineFilterControl(
|
||||||
filters: PipelineFilters,
|
filters: PipelineFilters,
|
||||||
|
onName: (String) -> Unit,
|
||||||
onPresence: (RunPresence) -> Unit,
|
onPresence: (RunPresence) -> Unit,
|
||||||
onRunStatuses: (Set<RunState>) -> Unit,
|
onRunStatuses: (Set<RunState>) -> Unit,
|
||||||
onClear: () -> Unit,
|
onClear: () -> Unit,
|
||||||
@@ -282,6 +267,9 @@ private fun PipelineFilterControl(
|
|||||||
resetLabel = "Clear filters",
|
resetLabel = "Clear filters",
|
||||||
onReset = onClear,
|
onReset = onClear,
|
||||||
) { dismiss ->
|
) { dismiss ->
|
||||||
|
FilterSectionHeader("Name")
|
||||||
|
PipelineNameFilter(filters.name, onName)
|
||||||
|
HorizontalDivider()
|
||||||
FilterSectionHeader("Runs")
|
FilterSectionHeader("Runs")
|
||||||
RunPresence.entries.forEach { presence ->
|
RunPresence.entries.forEach { presence ->
|
||||||
FilterCheckItem(presence.label, filters.presence == presence) {
|
FilterCheckItem(presence.label, filters.presence == presence) {
|
||||||
@@ -299,6 +287,24 @@ private fun PipelineFilterControl(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The name narrowing inside the pipelines filter menu: free text that keeps the
|
||||||
|
* menu open while typing so the list can be watched narrowing behind it. It fills
|
||||||
|
* the menu's own width, so it needs no width of its own.
|
||||||
|
*/
|
||||||
|
@Composable
|
||||||
|
private fun PipelineNameFilter(name: String, onName: (String) -> Unit) {
|
||||||
|
OutlinedTextField(
|
||||||
|
value = name,
|
||||||
|
onValueChange = onName,
|
||||||
|
label = { Text("Pipeline name contains") },
|
||||||
|
singleLine = true,
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.padding(horizontal = SPACING_M, vertical = SPACING_S),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* One pipeline as a row of the shared real list: a leading workflow glyph, the
|
* One pipeline as a row of the shared real list: a leading workflow glyph, the
|
||||||
* name as the title, the id/version/stage-count as the secondary line and the
|
* name as the title, the id/version/stage-count as the secondary line and the
|
||||||
|
|||||||
@@ -54,7 +54,6 @@ import net.awan.pipelines.data.protocol.SessionEvidence
|
|||||||
import net.awan.pipelines.ui.AppViewModel
|
import net.awan.pipelines.ui.AppViewModel
|
||||||
import net.awan.pipelines.ui.ArtifactGroup
|
import net.awan.pipelines.ui.ArtifactGroup
|
||||||
import net.awan.pipelines.ui.LoadState
|
import net.awan.pipelines.ui.LoadState
|
||||||
import net.awan.pipelines.ui.artifactsEmptyMessage
|
|
||||||
import net.awan.pipelines.ui.components.CodeBlock
|
import net.awan.pipelines.ui.components.CodeBlock
|
||||||
import net.awan.pipelines.ui.components.ColoredChip
|
import net.awan.pipelines.ui.components.ColoredChip
|
||||||
import net.awan.pipelines.ui.components.DetailTabBody
|
import net.awan.pipelines.ui.components.DetailTabBody
|
||||||
@@ -87,6 +86,9 @@ import net.awan.pipelines.ui.graph.graphColors
|
|||||||
import net.awan.pipelines.ui.graph.outcomeColor
|
import net.awan.pipelines.ui.graph.outcomeColor
|
||||||
import net.awan.pipelines.ui.graph.rememberArtifactSelection
|
import net.awan.pipelines.ui.graph.rememberArtifactSelection
|
||||||
import net.awan.pipelines.ui.runArtifactGroups
|
import net.awan.pipelines.ui.runArtifactGroups
|
||||||
|
import net.awan.pipelines.ui.runArtifactsHeader
|
||||||
|
import net.awan.pipelines.ui.runIdentity
|
||||||
|
import net.awan.pipelines.ui.runLabel
|
||||||
import net.awan.pipelines.ui.theme.ICON_INLINE_DP
|
import net.awan.pipelines.ui.theme.ICON_INLINE_DP
|
||||||
import net.awan.pipelines.ui.theme.ICON_STATUS_DP
|
import net.awan.pipelines.ui.theme.ICON_STATUS_DP
|
||||||
import net.awan.pipelines.ui.theme.SPACING_L
|
import net.awan.pipelines.ui.theme.SPACING_L
|
||||||
@@ -172,7 +174,7 @@ fun RunDetailScreen(
|
|||||||
pipelineStatLines(runsState.data?.runs, pipelineId, now)
|
pipelineStatLines(runsState.data?.runs, pipelineId, now)
|
||||||
}
|
}
|
||||||
PaneIdentity(
|
PaneIdentity(
|
||||||
title = run?.name ?: "Run",
|
title = run?.let { runLabel(it.title, it.name) } ?: "Run",
|
||||||
stats = stats,
|
stats = stats,
|
||||||
icon = Icons.AutoMirrored.Filled.DirectionsRun,
|
icon = Icons.AutoMirrored.Filled.DirectionsRun,
|
||||||
modifier = modifier.fillMaxSize(),
|
modifier = modifier.fillMaxSize(),
|
||||||
@@ -192,7 +194,28 @@ fun RunDetailScreen(
|
|||||||
enabled = summaryTab == "summary",
|
enabled = summaryTab == "summary",
|
||||||
topBar = {
|
topBar = {
|
||||||
TopAppBar(
|
TopAppBar(
|
||||||
title = { Text(run?.let { "Run ${it.id}" } ?: "Run") },
|
title = {
|
||||||
|
// The header names the run by its title and keeps the pipeline
|
||||||
|
// it belongs to on a second line, so a stage pane opened from
|
||||||
|
// here carries the same context. Without a title the pipeline
|
||||||
|
// name is the single identity, never a blank first line.
|
||||||
|
val identity = run?.let { runIdentity(it.title, it.name) }
|
||||||
|
Column {
|
||||||
|
Text(
|
||||||
|
identity?.label ?: "Run",
|
||||||
|
maxLines = 1,
|
||||||
|
overflow = TextOverflow.Ellipsis,
|
||||||
|
)
|
||||||
|
identity?.pipeline?.let { pipeline ->
|
||||||
|
Text(
|
||||||
|
"$pipeline · v${run?.version}",
|
||||||
|
style = pipelinesText().meta,
|
||||||
|
maxLines = 1,
|
||||||
|
overflow = TextOverflow.Ellipsis,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
navigationIcon = {
|
navigationIcon = {
|
||||||
IconButton(onClick = onBack) {
|
IconButton(onClick = onBack) {
|
||||||
Icon(Icons.AutoMirrored.Filled.ArrowBack, contentDescription = "Back")
|
Icon(Icons.AutoMirrored.Filled.ArrowBack, contentDescription = "Back")
|
||||||
@@ -352,6 +375,7 @@ private fun ConfirmDialog(
|
|||||||
* id/version, current stage, workspace, content hash, start/finish/duration and
|
* id/version, current stage, workspace, content hash, start/finish/duration and
|
||||||
* the failure diagnostic.
|
* the failure diagnostic.
|
||||||
*/
|
*/
|
||||||
|
@OptIn(ExperimentalFoundationApi::class)
|
||||||
@Composable
|
@Composable
|
||||||
private fun RunSummaryTab(
|
private fun RunSummaryTab(
|
||||||
run: RunDetail,
|
run: RunDetail,
|
||||||
@@ -365,23 +389,35 @@ private fun RunSummaryTab(
|
|||||||
) {
|
) {
|
||||||
val text = pipelinesText()
|
val text = pipelinesText()
|
||||||
val state = runStateOf(run.status)
|
val state = runStateOf(run.status)
|
||||||
|
// The artifacts section starts collapsed and its expand/collapse choice is
|
||||||
|
// remembered/saved per run id, so a different run reseeds it and a run opened
|
||||||
|
// fresh starts collapsed. Both the header and the gallery read the same
|
||||||
|
// snapshot, so they can never disagree.
|
||||||
|
val artifactsExpansion = rememberSectionExpansion(run.id)
|
||||||
|
val artifactsHeader = remember(run.steps, run.executing) {
|
||||||
|
runArtifactsHeader(run.steps, run.executing)
|
||||||
|
}
|
||||||
DetailTabBody(wide, modifier) { columnModifier ->
|
DetailTabBody(wide, modifier) { columnModifier ->
|
||||||
LazyColumn(
|
LazyColumn(
|
||||||
modifier = columnModifier,
|
modifier = columnModifier,
|
||||||
contentPadding = PaddingValues(vertical = SPACING_L),
|
contentPadding = PaddingValues(vertical = SPACING_L),
|
||||||
) {
|
) {
|
||||||
// The artifacts gallery leads the summary: the captured screenshots
|
// The artifacts gallery still leads the summary, but inside one
|
||||||
// are the first thing the operator sees, with the run's own facts
|
// collapsed section: its header alone carries the run's capture
|
||||||
// below it.
|
// wording until the operator expands it, and expanding reveals the
|
||||||
item(key = "run-artifacts") {
|
// unchanged gallery (nothing when no artifacts were recorded).
|
||||||
Column(
|
collapsibleSection(
|
||||||
modifier = Modifier.fillMaxWidth().padding(horizontal = SPACING_L, vertical = SPACING_S),
|
title = artifactsHeader,
|
||||||
verticalArrangement = Arrangement.spacedBy(SPACING_S),
|
key = SUMMARY_ARTIFACTS_KEY,
|
||||||
) {
|
expanded = artifactsExpansion.isExpanded(SUMMARY_ARTIFACTS_KEY),
|
||||||
Text("Artifacts", style = text.sectionHeader)
|
onToggle = { artifactsExpansion.toggle(SUMMARY_ARTIFACTS_KEY) },
|
||||||
if (artifactGroups.isEmpty()) {
|
) {
|
||||||
Text(artifactsEmptyMessage(run.executing), style = text.meta)
|
if (artifactGroups.isNotEmpty()) {
|
||||||
} else {
|
Column(
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.padding(horizontal = SPACING_L, vertical = SPACING_S),
|
||||||
|
) {
|
||||||
ArtifactGallery(
|
ArtifactGallery(
|
||||||
groups = artifactGroups,
|
groups = artifactGroups,
|
||||||
configuredServerUrl = configuredServerUrl,
|
configuredServerUrl = configuredServerUrl,
|
||||||
@@ -397,7 +433,7 @@ private fun RunSummaryTab(
|
|||||||
modifier = Modifier.fillMaxWidth().padding(horizontal = SPACING_L),
|
modifier = Modifier.fillMaxWidth().padding(horizontal = SPACING_L),
|
||||||
verticalArrangement = Arrangement.spacedBy(SPACING_XS),
|
verticalArrangement = Arrangement.spacedBy(SPACING_XS),
|
||||||
) {
|
) {
|
||||||
Text(run.name, style = text.screenTitle)
|
Text(runLabel(run.title, run.name), style = text.screenTitle)
|
||||||
Row(
|
Row(
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
horizontalArrangement = Arrangement.spacedBy(SPACING_S),
|
horizontalArrangement = Arrangement.spacedBy(SPACING_S),
|
||||||
@@ -776,4 +812,9 @@ private fun EvidenceDetails(evidence: SessionEvidence, modifier: Modifier = Modi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The run summary's artifacts section key: stable so its expand/collapse choice
|
||||||
|
// is remembered consistently (it is namespaced under the summary tab's saved
|
||||||
|
// state and reseeded by run id).
|
||||||
|
private const val SUMMARY_ARTIFACTS_KEY = "artifacts"
|
||||||
|
|
||||||
private const val POLL_INTERVAL_MILLIS = 1_000L
|
private const val POLL_INTERVAL_MILLIS = 1_000L
|
||||||
|
|||||||
@@ -71,6 +71,7 @@ import net.awan.pipelines.ui.components.runStateColor
|
|||||||
import net.awan.pipelines.ui.components.runStateOf
|
import net.awan.pipelines.ui.components.runStateOf
|
||||||
import net.awan.pipelines.ui.formatDuration
|
import net.awan.pipelines.ui.formatDuration
|
||||||
import net.awan.pipelines.ui.runDurationText
|
import net.awan.pipelines.ui.runDurationText
|
||||||
|
import net.awan.pipelines.ui.runIdentity
|
||||||
import net.awan.pipelines.ui.theme.ICON_LIST_DP
|
import net.awan.pipelines.ui.theme.ICON_LIST_DP
|
||||||
import net.awan.pipelines.ui.theme.ICON_STATUS_DP
|
import net.awan.pipelines.ui.theme.ICON_STATUS_DP
|
||||||
import net.awan.pipelines.ui.theme.PipelinesTextStyles
|
import net.awan.pipelines.ui.theme.PipelinesTextStyles
|
||||||
@@ -486,11 +487,14 @@ private fun Metric(label: String, value: String, color: Color, text: PipelinesTe
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* One run as a row of the shared real list: a leading status glyph, the run name
|
* One run as a row of the shared real list: a leading status glyph, then the
|
||||||
* as the title with its version chip, and a secondary line carrying the status
|
* identity lines — the run's title as the primary line (falling back to the
|
||||||
* chip, progress and id/time. The row is selected when its run is the one open in
|
* pipeline name when the server stored no title) with its version chip, and the
|
||||||
* the detail pane. [nowMillis] is the shared live clock, read only by a running
|
* pipeline name on a second line only when a title exists — followed by a
|
||||||
* row so its elapsed value advances.
|
* secondary line carrying the status chip, progress and id/start/duration. The
|
||||||
|
* row is selected when its run is the one open in the detail pane. [nowMillis] is
|
||||||
|
* the shared live clock, read only by a running row so its elapsed value
|
||||||
|
* advances.
|
||||||
*/
|
*/
|
||||||
@Composable
|
@Composable
|
||||||
private fun RunRow(
|
private fun RunRow(
|
||||||
@@ -502,6 +506,7 @@ private fun RunRow(
|
|||||||
) {
|
) {
|
||||||
val text = pipelinesText()
|
val text = pipelinesText()
|
||||||
val state = runStateOf(run.status)
|
val state = runStateOf(run.status)
|
||||||
|
val identity = runIdentity(run.title, run.name)
|
||||||
ListRow(
|
ListRow(
|
||||||
selected = selected,
|
selected = selected,
|
||||||
onClick = onClick,
|
onClick = onClick,
|
||||||
@@ -519,13 +524,32 @@ private fun RunRow(
|
|||||||
horizontalArrangement = Arrangement.spacedBy(SPACING_S),
|
horizontalArrangement = Arrangement.spacedBy(SPACING_S),
|
||||||
) {
|
) {
|
||||||
Text(
|
Text(
|
||||||
run.name,
|
identity.label,
|
||||||
style = text.cardTitle,
|
style = text.cardTitle,
|
||||||
maxLines = 1,
|
maxLines = 1,
|
||||||
overflow = TextOverflow.Ellipsis,
|
overflow = TextOverflow.Ellipsis,
|
||||||
modifier = Modifier.weight(1f),
|
modifier = Modifier.weight(1f),
|
||||||
)
|
)
|
||||||
VersionChip("v${run.version}")
|
// Without a title the pipeline name is the only identity line, so the
|
||||||
|
// version stays beside it; with one the pipeline drops to the second
|
||||||
|
// line and takes the version with it.
|
||||||
|
if (identity.pipeline == null) VersionChip("v${run.version}")
|
||||||
|
}
|
||||||
|
|
||||||
|
if (identity.pipeline != null) {
|
||||||
|
Row(
|
||||||
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
|
horizontalArrangement = Arrangement.spacedBy(SPACING_S),
|
||||||
|
) {
|
||||||
|
Text(
|
||||||
|
identity.pipeline,
|
||||||
|
style = text.meta,
|
||||||
|
maxLines = 1,
|
||||||
|
overflow = TextOverflow.Ellipsis,
|
||||||
|
modifier = Modifier.weight(1f),
|
||||||
|
)
|
||||||
|
VersionChip("v${run.version}")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Row(
|
Row(
|
||||||
|
|||||||
@@ -178,9 +178,22 @@ internal val GRAPH_PANEL_MIN_HEIGHT = 320.dp
|
|||||||
/** Preferred side of one square gallery thumbnail tile. */
|
/** Preferred side of one square gallery thumbnail tile. */
|
||||||
internal val ARTIFACT_TILE_DP = 96.dp
|
internal val ARTIFACT_TILE_DP = 96.dp
|
||||||
|
|
||||||
/** Side of an inline artifact thumbnail and a non-image row's leading glyph box. */
|
/** Side of an inline artifact thumbnail (a media preview or the viewer's). */
|
||||||
internal val ARTIFACT_THUMB_DP = 56.dp
|
internal val ARTIFACT_THUMB_DP = 56.dp
|
||||||
|
|
||||||
|
/** File-type glyph inside a non-media gallery tile. */
|
||||||
|
internal val ARTIFACT_TYPE_ICON_DP = 28.dp
|
||||||
|
|
||||||
|
/** Play marker drawn over a video tile's poster frame. */
|
||||||
|
internal val ARTIFACT_PLAY_BADGE_DP = 32.dp
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compact per-item action target overlaid on a gallery tile (share, or copy on a
|
||||||
|
* non-media tile); smaller than the 48dp standalone target because the whole tile
|
||||||
|
* is also a tap target.
|
||||||
|
*/
|
||||||
|
internal val ARTIFACT_TILE_ACTION_DP = 32.dp
|
||||||
|
|
||||||
/** Check-badge glyph on a selected gallery tile. */
|
/** Check-badge glyph on a selected gallery tile. */
|
||||||
internal val ARTIFACT_BADGE_DP = 16.dp
|
internal val ARTIFACT_BADGE_DP = 16.dp
|
||||||
|
|
||||||
|
|||||||
@@ -210,6 +210,48 @@ class ProtocolModelTest {
|
|||||||
assertEquals(0, without.artifactsTruncated)
|
assertEquals(0, without.artifactsTruncated)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun runStepVerdictParsesWithItsReasonSourceAndReferencedArtifacts() {
|
||||||
|
val json = """
|
||||||
|
{
|
||||||
|
"type": "run",
|
||||||
|
"run_detail": {
|
||||||
|
"id": 167,
|
||||||
|
"steps": [
|
||||||
|
{
|
||||||
|
"sequence": 1,
|
||||||
|
"stage": "ui_reviewer",
|
||||||
|
"status": "succeeded",
|
||||||
|
"outcome": "approved",
|
||||||
|
"target": "#success",
|
||||||
|
"verdict": {
|
||||||
|
"option": "approved → success",
|
||||||
|
"reason": "Layout matches; see review.png",
|
||||||
|
"reason_source": "model",
|
||||||
|
"artifacts": ["review.png"]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{"sequence": 2, "stage": "implementer", "status": "running", "outcome": "", "target": ""}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
""".trimIndent()
|
||||||
|
val run = PipelinesJson.decodeFromString(Message.serializer(), json).runDetail!!
|
||||||
|
val verdict = run.steps.first().verdict!!
|
||||||
|
assertEquals("approved → success", verdict.option)
|
||||||
|
assertEquals("Layout matches; see review.png", verdict.reason)
|
||||||
|
assertEquals("model", verdict.reasonSource)
|
||||||
|
assertEquals(listOf("review.png"), verdict.artifacts)
|
||||||
|
// A running step with no outcome/target carries no verdict, so the pane
|
||||||
|
// shows no block; a verdict with no artifacts defaults to an empty list.
|
||||||
|
assertNull(run.steps[1].verdict)
|
||||||
|
val noArtifacts = PipelinesJson.decodeFromString(
|
||||||
|
Message.serializer(),
|
||||||
|
"""{"type":"run","run_detail":{"id":1,"steps":[{"sequence":1,"stage":"a","verdict":{"option":"done → success"}}]}}""",
|
||||||
|
).runDetail!!.steps.single().verdict!!
|
||||||
|
assertEquals(emptyList<String>(), noArtifacts.artifacts)
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun pipelineDetailPopulatesInheritedAndWireNameFields() {
|
fun pipelineDetailPopulatesInheritedAndWireNameFields() {
|
||||||
val json = """
|
val json = """
|
||||||
@@ -330,4 +372,37 @@ class ProtocolModelTest {
|
|||||||
assertEquals(2, pipeline.succeeded)
|
assertEquals(2, pipeline.succeeded)
|
||||||
assertEquals(3.5, pipeline.averageSeconds, 0.0)
|
assertEquals(3.5, pipeline.averageSeconds, 0.0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun runSummariesAndDetailsCarryTheOperatorTitleWhenTheServerSendsIt() {
|
||||||
|
val json = """
|
||||||
|
{
|
||||||
|
"type": "runs",
|
||||||
|
"runs": [
|
||||||
|
{"id": 1, "pipeline_id": 7, "name": "demo", "title": "Add a dark mode toggle", "version": 2, "status": "succeeded"}
|
||||||
|
],
|
||||||
|
"run_detail": {
|
||||||
|
"id": 1,
|
||||||
|
"pipeline_id": 7,
|
||||||
|
"name": "demo",
|
||||||
|
"title": "Add a dark mode toggle",
|
||||||
|
"version": 2,
|
||||||
|
"steps": []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
""".trimIndent()
|
||||||
|
val message = PipelinesJson.decodeFromString(Message.serializer(), json)
|
||||||
|
assertEquals("Add a dark mode toggle", message.runs!!.single().title)
|
||||||
|
assertEquals("Add a dark mode toggle", message.runDetail!!.title)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun anAbsentRunTitleStaysNullSoTheUiFallsBackToThePipelineName() {
|
||||||
|
val json = """
|
||||||
|
{"type": "runs", "runs": [{"id": 1, "name": "demo"}], "run_detail": {"id": 1, "name": "demo"}}
|
||||||
|
""".trimIndent()
|
||||||
|
val message = PipelinesJson.decodeFromString(Message.serializer(), json)
|
||||||
|
assertNull(message.runs!!.single().title)
|
||||||
|
assertNull(message.runDetail!!.title)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,11 +15,15 @@ class ArtifactGroupsTest {
|
|||||||
sequence: Int,
|
sequence: Int,
|
||||||
visit: Int = 0,
|
visit: Int = 0,
|
||||||
artifacts: List<StageArtifact>? = null,
|
artifacts: List<StageArtifact>? = null,
|
||||||
|
skipped: Int = 0,
|
||||||
|
truncated: Int = 0,
|
||||||
) = RunStep(
|
) = RunStep(
|
||||||
sequence = sequence,
|
sequence = sequence,
|
||||||
stage = stage,
|
stage = stage,
|
||||||
control = ControlEvidence(visit = visit),
|
control = ControlEvidence(visit = visit),
|
||||||
artifacts = artifacts,
|
artifacts = artifacts,
|
||||||
|
artifactsSkipped = skipped,
|
||||||
|
artifactsTruncated = truncated,
|
||||||
)
|
)
|
||||||
|
|
||||||
private fun artifact(name: String, url: String = "/artifacts/$name") =
|
private fun artifact(name: String, url: String = "/artifacts/$name") =
|
||||||
@@ -95,4 +99,99 @@ class ArtifactGroupsTest {
|
|||||||
assertTrue(pending.startsWith("Artifacts · "))
|
assertTrue(pending.startsWith("Artifacts · "))
|
||||||
assertTrue(pending.contains(ARTIFACT_CAPTURE_PENDING))
|
assertTrue(pending.contains(ARTIFACT_CAPTURE_PENDING))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun headerReportsTheCountWithASingularTitleForOne() {
|
||||||
|
assertEquals(
|
||||||
|
"Artifact · 1 recorded",
|
||||||
|
runArtifactsHeader(
|
||||||
|
listOf(step("planner", sequence = 1, visit = 1, artifacts = listOf(artifact("a")))),
|
||||||
|
executing = false,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
assertEquals(
|
||||||
|
"Artifacts · 3 recorded",
|
||||||
|
runArtifactsHeader(
|
||||||
|
listOf(
|
||||||
|
step("planner", sequence = 1, visit = 1, artifacts = listOf(artifact("a"), artifact("b"))),
|
||||||
|
step("build", sequence = 2, visit = 1, artifacts = listOf(artifact("c"))),
|
||||||
|
),
|
||||||
|
executing = false,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun headerAddsPartialCaptureOnlyWhenFilesWereExcludedOrOmitted() {
|
||||||
|
assertEquals(
|
||||||
|
"Artifact · 1 recorded",
|
||||||
|
runArtifactsHeader(
|
||||||
|
listOf(step("planner", 1, 1, listOf(artifact("a")))),
|
||||||
|
executing = false,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
assertEquals(
|
||||||
|
"Artifacts · 2 recorded · partial capture",
|
||||||
|
runArtifactsHeader(
|
||||||
|
listOf(step("planner", 1, 1, listOf(artifact("a"), artifact("b")), skipped = 1)),
|
||||||
|
executing = false,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
assertEquals(
|
||||||
|
"Artifacts · 2 recorded · partial capture",
|
||||||
|
runArtifactsHeader(
|
||||||
|
listOf(step("planner", 1, 1, listOf(artifact("a"), artifact("b")), truncated = 3)),
|
||||||
|
executing = false,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
// A visit that recorded nothing but excluded files still marks the run's
|
||||||
|
// capture as partial.
|
||||||
|
assertEquals(
|
||||||
|
"Artifact · 1 recorded · partial capture",
|
||||||
|
runArtifactsHeader(
|
||||||
|
listOf(
|
||||||
|
step("planner", 1, 1, listOf(artifact("a"))),
|
||||||
|
step("build", 2, 1, artifacts = emptyList(), skipped = 2),
|
||||||
|
),
|
||||||
|
executing = false,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun headerEmptyCaseUsesTheSharedEmptyWording() {
|
||||||
|
assertEquals(
|
||||||
|
artifactsEmptyMessage(executing = true),
|
||||||
|
runArtifactsHeader(emptyList(), executing = true),
|
||||||
|
)
|
||||||
|
assertEquals(
|
||||||
|
artifactsEmptyMessage(executing = false),
|
||||||
|
runArtifactsHeader(emptyList(), executing = false),
|
||||||
|
)
|
||||||
|
// Excluded/omitted counts with no recorded artifacts still read as empty:
|
||||||
|
// the partial-capture note never accompanies the empty summary.
|
||||||
|
assertEquals(
|
||||||
|
artifactsEmptyMessage(executing = false),
|
||||||
|
runArtifactsHeader(
|
||||||
|
listOf(step("planner", 1, 1, artifacts = emptyList(), skipped = 2, truncated = 1)),
|
||||||
|
executing = false,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun headerCountMatchesTheGalleryRecordedTotal() {
|
||||||
|
val steps = listOf(
|
||||||
|
step("planner", 1, 1, listOf(artifact("a"), artifact("b"))),
|
||||||
|
step("planner", 2, 2, artifacts = emptyList()),
|
||||||
|
step("build", 3, 1, listOf(artifact("c"))),
|
||||||
|
)
|
||||||
|
// Every recorded artifact is exactly one gallery tile; the header can
|
||||||
|
// never announce a count the expanded gallery does not render.
|
||||||
|
assertEquals(3, runArtifactGroups(steps).sumOf { it.artifacts.size })
|
||||||
|
assertEquals(
|
||||||
|
"Artifacts · 3 recorded",
|
||||||
|
runArtifactsHeader(steps, executing = false),
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -117,20 +117,15 @@ class FormatTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun artifactContentTypeAndMetaLine() {
|
fun artifactContentTypePredicates() {
|
||||||
assertTrue(isImageContentType("image/png"))
|
assertTrue(isImageContentType("image/png"))
|
||||||
assertTrue(isImageContentType("image/jpeg"))
|
assertTrue(isImageContentType("image/jpeg"))
|
||||||
assertFalse(isImageContentType("application/pdf"))
|
assertFalse(isImageContentType("application/pdf"))
|
||||||
assertFalse(isImageContentType(""))
|
assertFalse(isImageContentType(""))
|
||||||
assertEquals(
|
// Gallery-kind classification (ArtifactTypeTest) builds on this predicate.
|
||||||
"50.9 KiB · image/png",
|
assertTrue(isVideoContentType("video/mp4"))
|
||||||
artifactMetaLine(StageArtifact(name = "a.png", sizeBytes = 52168, contentType = "image/png")),
|
assertFalse(isVideoContentType("image/png"))
|
||||||
)
|
assertFalse(isVideoContentType(""))
|
||||||
// A blank content type never renders a dangling separator.
|
|
||||||
assertEquals(
|
|
||||||
"4.9 KiB · unknown type",
|
|
||||||
artifactMetaLine(StageArtifact(name = "b", sizeBytes = 5008, contentType = "")),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -0,0 +1,50 @@
|
|||||||
|
package net.awan.pipelines.ui
|
||||||
|
|
||||||
|
import org.junit.Assert.assertEquals
|
||||||
|
import org.junit.Assert.assertNotEquals
|
||||||
|
import org.junit.Assert.assertNull
|
||||||
|
import org.junit.Test
|
||||||
|
|
||||||
|
class RunIdentityTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun aStoredTitleIsThePrimaryLineWithThePipelineOnASecondLine() {
|
||||||
|
val identity = runIdentity("Add a dark mode toggle", "android-app")
|
||||||
|
assertEquals("Add a dark mode toggle", identity.label)
|
||||||
|
assertEquals("android-app", identity.pipeline)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun twoRunsOfOnePipelineReadAsDifferentGoals() {
|
||||||
|
val first = runIdentity("Add a dark mode toggle", "android-app")
|
||||||
|
val second = runIdentity("Fix the crash on rotate", "android-app")
|
||||||
|
// Same pipeline on the second line, different title on the first.
|
||||||
|
assertEquals("android-app", first.pipeline)
|
||||||
|
assertEquals(first.pipeline, second.pipeline)
|
||||||
|
assertNotEquals(first.label, second.label)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun aMissingOrBlankTitleFallsBackToThePipelineNameWithNoSecondLine() {
|
||||||
|
for (title in listOf(null, "", " ", "\t")) {
|
||||||
|
val identity = runIdentity(title, "android-app")
|
||||||
|
assertEquals("android-app", identity.label)
|
||||||
|
assertNull(identity.pipeline)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun theStoredTitleIsTrimmed() {
|
||||||
|
val identity = runIdentity(" Add a dark mode toggle ", "android-app")
|
||||||
|
assertEquals("Add a dark mode toggle", identity.label)
|
||||||
|
assertEquals("android-app", identity.pipeline)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun runLabelMirrorsTheRowsPrimaryLine() {
|
||||||
|
assertEquals("Add a dark mode toggle", runLabel("Add a dark mode toggle", "android-app"))
|
||||||
|
assertEquals("Add a dark mode toggle", runLabel(" Add a dark mode toggle ", "android-app"))
|
||||||
|
assertEquals("android-app", runLabel(null, "android-app"))
|
||||||
|
assertEquals("android-app", runLabel(" ", "android-app"))
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,77 @@
|
|||||||
|
package net.awan.pipelines.ui.graph
|
||||||
|
|
||||||
|
import androidx.compose.material.icons.Icons
|
||||||
|
import androidx.compose.material.icons.automirrored.filled.InsertDriveFile
|
||||||
|
import androidx.compose.material.icons.filled.Code
|
||||||
|
import androidx.compose.material.icons.filled.DataObject
|
||||||
|
import androidx.compose.material.icons.filled.Description
|
||||||
|
import androidx.compose.material.icons.filled.FolderZip
|
||||||
|
import androidx.compose.material.icons.filled.Image
|
||||||
|
import androidx.compose.material.icons.filled.Movie
|
||||||
|
import androidx.compose.material.icons.filled.PictureAsPdf
|
||||||
|
import androidx.compose.material.icons.automirrored.filled.ReceiptLong
|
||||||
|
import androidx.compose.material.icons.filled.TableChart
|
||||||
|
import org.junit.Assert.assertEquals
|
||||||
|
import org.junit.Test
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pure-logic tests for the artifact type classification and its type-to-icon
|
||||||
|
* mapping: which glyph a document, archive, log, code file, JSON payload, PDF and
|
||||||
|
* so on gets, independent of a device.
|
||||||
|
*/
|
||||||
|
class ArtifactTypeTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun mediaKindsComeStraightFromTheContentType() {
|
||||||
|
assertEquals(ArtifactKind.Image, artifactKind("image/png", "shot.png"))
|
||||||
|
assertEquals(ArtifactKind.Image, artifactKind("image/jpeg; charset=binary", "shot"))
|
||||||
|
assertEquals(ArtifactKind.Video, artifactKind("video/mp4", "clip.mp4"))
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun namedFileKindsMapFromTheContentType() {
|
||||||
|
assertEquals(ArtifactKind.Pdf, artifactKind("application/pdf", "report.pdf"))
|
||||||
|
assertEquals(ArtifactKind.Json, artifactKind("application/json", "run.json"))
|
||||||
|
assertEquals(ArtifactKind.Archive, artifactKind("application/zip", "bundle.zip"))
|
||||||
|
assertEquals(ArtifactKind.Spreadsheet, artifactKind("text/csv", "rows.csv"))
|
||||||
|
assertEquals(ArtifactKind.Audio, artifactKind("audio/mpeg", "tone.mp3"))
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun theNameExtensionResolvesAGenericSniff() {
|
||||||
|
// The server's sniff of an unrecognised extension is often text/plain;
|
||||||
|
// the name's extension still names the type.
|
||||||
|
assertEquals(ArtifactKind.Log, artifactKind("text/plain", "emulator.log"))
|
||||||
|
assertEquals(ArtifactKind.Code, artifactKind("text/plain", "Main.kt"))
|
||||||
|
assertEquals(ArtifactKind.Code, artifactKind("application/octet-stream", "config.yaml"))
|
||||||
|
assertEquals(ArtifactKind.Document, artifactKind("text/plain; charset=utf-8", "notes.txt"))
|
||||||
|
assertEquals(ArtifactKind.Document, artifactKind("", "index.html"))
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun anUnknownTypeIsOtherNeverACrash() {
|
||||||
|
assertEquals(ArtifactKind.Other, artifactKind("", ""))
|
||||||
|
assertEquals(ArtifactKind.Other, artifactKind("application/octet-stream", "blob"))
|
||||||
|
assertEquals(ArtifactKind.Other, artifactKind("application/x-unknown", "data"))
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun theTypeToIconMappingIsExplicitAndDistinct() {
|
||||||
|
assertEquals(Icons.Filled.Image, artifactIcon(ArtifactKind.Image))
|
||||||
|
assertEquals(Icons.Filled.Movie, artifactIcon(ArtifactKind.Video))
|
||||||
|
assertEquals(Icons.Filled.PictureAsPdf, artifactIcon(ArtifactKind.Pdf))
|
||||||
|
assertEquals(Icons.Filled.DataObject, artifactIcon(ArtifactKind.Json))
|
||||||
|
assertEquals(Icons.Filled.FolderZip, artifactIcon(ArtifactKind.Archive))
|
||||||
|
assertEquals(Icons.Filled.TableChart, artifactIcon(ArtifactKind.Spreadsheet))
|
||||||
|
assertEquals(Icons.AutoMirrored.Filled.ReceiptLong, artifactIcon(ArtifactKind.Log))
|
||||||
|
assertEquals(Icons.Filled.Code, artifactIcon(ArtifactKind.Code))
|
||||||
|
assertEquals(Icons.Filled.Description, artifactIcon(ArtifactKind.Document))
|
||||||
|
assertEquals(Icons.AutoMirrored.Filled.InsertDriveFile, artifactIcon(ArtifactKind.Other))
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun noTwoKindsShareAGlyph() {
|
||||||
|
val glyphs = ArtifactKind.entries.map { artifactIcon(it) }
|
||||||
|
assertEquals(ArtifactKind.entries.size, glyphs.toSet().size)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,99 @@
|
|||||||
|
package net.awan.pipelines.ui.graph
|
||||||
|
|
||||||
|
import net.awan.pipelines.data.protocol.StageArtifact
|
||||||
|
import net.awan.pipelines.data.protocol.StageVerdict
|
||||||
|
import org.junit.Assert.assertEquals
|
||||||
|
import org.junit.Test
|
||||||
|
|
||||||
|
class StageVerdictTest {
|
||||||
|
|
||||||
|
private fun artifact(name: String, contentType: String = "image/png") = StageArtifact(
|
||||||
|
name = name,
|
||||||
|
sizeBytes = 1,
|
||||||
|
contentType = contentType,
|
||||||
|
url = "/artifacts/167/1/$name",
|
||||||
|
)
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun segmentsSplitTheReasonAroundEveryReferencedName() {
|
||||||
|
val png = artifact("review.png")
|
||||||
|
val txt = artifact("report.txt", contentType = "text/plain")
|
||||||
|
assertEquals(
|
||||||
|
listOf(
|
||||||
|
VerdictReasonSegment("Approved: "),
|
||||||
|
VerdictReasonSegment("review.png", png),
|
||||||
|
VerdictReasonSegment(" shows the fix; "),
|
||||||
|
VerdictReasonSegment("report.txt", txt),
|
||||||
|
VerdictReasonSegment(" lists the checks."),
|
||||||
|
),
|
||||||
|
verdictReasonSegments(
|
||||||
|
"Approved: review.png shows the fix; report.txt lists the checks.",
|
||||||
|
listOf(png, txt),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun segmentsMatchABasenameForASlashedPath() {
|
||||||
|
val nested = artifact("shots/wide.png")
|
||||||
|
assertEquals(
|
||||||
|
listOf(
|
||||||
|
VerdictReasonSegment("See "),
|
||||||
|
VerdictReasonSegment("wide.png", nested),
|
||||||
|
VerdictReasonSegment(" for the wide layout."),
|
||||||
|
),
|
||||||
|
verdictReasonSegments("See wide.png for the wide layout.", listOf(nested)),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun aLongerNameWinsOverItsBasenameAtTheSameIndex() {
|
||||||
|
val bare = artifact("wide.png")
|
||||||
|
val nested = artifact("shots/wide.png")
|
||||||
|
// The full slashed path matches whole, not just its basename, so the
|
||||||
|
// reference resolves to the artifact actually named.
|
||||||
|
assertEquals(
|
||||||
|
listOf(
|
||||||
|
VerdictReasonSegment("shots/wide.png", nested),
|
||||||
|
VerdictReasonSegment(" is the shot"),
|
||||||
|
),
|
||||||
|
verdictReasonSegments("shots/wide.png is the shot", listOf(bare, nested)),
|
||||||
|
)
|
||||||
|
// A bare basename still resolves to the artifact named exactly so.
|
||||||
|
assertEquals(
|
||||||
|
listOf(
|
||||||
|
VerdictReasonSegment("wide.png", bare),
|
||||||
|
VerdictReasonSegment(" was captured"),
|
||||||
|
),
|
||||||
|
verdictReasonSegments("wide.png was captured", listOf(bare, nested)),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun aReasonWithoutReferencesIsOneLiteralSegment() {
|
||||||
|
assertEquals(
|
||||||
|
listOf(VerdictReasonSegment("nothing referenced here")),
|
||||||
|
verdictReasonSegments("nothing referenced here", listOf(artifact("x.png"))),
|
||||||
|
)
|
||||||
|
assertEquals(
|
||||||
|
listOf(VerdictReasonSegment("no recorded artifact is named")),
|
||||||
|
verdictReasonSegments("no recorded artifact is named", emptyList()),
|
||||||
|
)
|
||||||
|
assertEquals(emptyList<VerdictReasonSegment>(), verdictReasonSegments("", listOf(artifact("x.png"))))
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun referencedArtifactsResolveNamesToRecordedFilesInRecordedOrder() {
|
||||||
|
val a = artifact("a.png")
|
||||||
|
val b = artifact("b.png", contentType = "text/plain")
|
||||||
|
val verdict = StageVerdict(
|
||||||
|
option = "approved → success",
|
||||||
|
reason = "b.png then a.png",
|
||||||
|
artifacts = listOf("b.png", "a.png", "invented.png"),
|
||||||
|
)
|
||||||
|
// Recorded order, the invented name dropped, only real recorded files.
|
||||||
|
assertEquals(listOf(a, b), referencedVerdictArtifacts(verdict, listOf(a, b)))
|
||||||
|
assertEquals(emptyList<StageArtifact>(), referencedVerdictArtifacts(null, listOf(a)))
|
||||||
|
assertEquals(emptyList<StageArtifact>(), referencedVerdictArtifacts(StageVerdict(), listOf(a)))
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -56,11 +56,18 @@ class ListFilterTest {
|
|||||||
@Test
|
@Test
|
||||||
fun pipelineFiltersFromStorageParsesAndFallsBack() {
|
fun pipelineFiltersFromStorageParsesAndFallsBack() {
|
||||||
assertEquals(
|
assertEquals(
|
||||||
PipelineFilters(RunPresence.NoRuns, setOf(RunState.Failed)),
|
PipelineFilters(RunPresence.NoRuns, setOf(RunState.Failed), "deploy"),
|
||||||
PipelineFilters.fromStorage("no_runs", "failed"),
|
PipelineFilters.fromStorage("no_runs", "failed", "deploy"),
|
||||||
|
)
|
||||||
|
// A blank or absent name is no narrowing.
|
||||||
|
assertEquals(PipelineFilters.Default, PipelineFilters.fromStorage(null, null, null))
|
||||||
|
assertEquals(PipelineFilters.Default, PipelineFilters.fromStorage("", "", ""))
|
||||||
|
// The name is free text, so any stored value is a legitimate filter and is
|
||||||
|
// kept as-is; only the closed-vocabulary run facets fall back to a default.
|
||||||
|
assertEquals(
|
||||||
|
PipelineFilters(name = "garbage"),
|
||||||
|
PipelineFilters.fromStorage("garbage", "garbage", "garbage"),
|
||||||
)
|
)
|
||||||
assertEquals(PipelineFilters.Default, PipelineFilters.fromStorage(null, null))
|
|
||||||
assertEquals(PipelineFilters.Default, PipelineFilters.fromStorage("garbage", "garbage"))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -203,6 +210,69 @@ class ListFilterTest {
|
|||||||
assertEquals(listOf(2L), filterPipelines(pipelines, filters, latest).map { it.id })
|
assertEquals(listOf(2L), filterPipelines(pipelines, filters, latest).map { it.id })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun nameNarrowsByCaseInsensitiveSubstringAndBlankNarrowsNothing() {
|
||||||
|
val pipelines = listOf(
|
||||||
|
pipeline(1, "Deploy API"),
|
||||||
|
pipeline(2, "redeploy web"),
|
||||||
|
pipeline(3, "release"),
|
||||||
|
)
|
||||||
|
assertEquals(
|
||||||
|
listOf(1L, 2L),
|
||||||
|
filterPipelines(pipelines, PipelineFilters(name = "deploy"), emptyMap()).map { it.id },
|
||||||
|
)
|
||||||
|
assertEquals(
|
||||||
|
listOf(1L),
|
||||||
|
filterPipelines(pipelines, PipelineFilters(name = "Deploy API"), emptyMap()).map { it.id },
|
||||||
|
)
|
||||||
|
// A blank name is no narrowing.
|
||||||
|
assertEquals(pipelines, filterPipelines(pipelines, PipelineFilters(name = " "), emptyMap()))
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun nameAppliesBeforeTheRunHistoryIsKnownWhileRunFacetsStillWait() {
|
||||||
|
val pipelines = listOf(pipeline(1, "alpha"), pipeline(2, "beta"))
|
||||||
|
// The name facet needs no run history, so it narrows at once.
|
||||||
|
assertEquals(
|
||||||
|
listOf(2L),
|
||||||
|
filterPipelines(pipelines, PipelineFilters(name = "bet"), emptyMap(), runsKnown = false).map { it.id },
|
||||||
|
)
|
||||||
|
// A run facet still waits for the history, combined with the name.
|
||||||
|
assertEquals(
|
||||||
|
listOf(1L),
|
||||||
|
filterPipelines(
|
||||||
|
pipelines,
|
||||||
|
PipelineFilters(presence = RunPresence.NoRuns, name = "al"),
|
||||||
|
emptyMap(),
|
||||||
|
runsKnown = false,
|
||||||
|
).map { it.id },
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun nameAndRunFacetsCombineWithAnd() {
|
||||||
|
val filters = PipelineFilters(RunPresence.HasRuns, setOf(RunState.Failed), "web")
|
||||||
|
val latest = mapOf(
|
||||||
|
1L to run(1, pipelineId = 1, status = "failed"),
|
||||||
|
2L to run(2, pipelineId = 2, status = "failed"),
|
||||||
|
3L to run(3, pipelineId = 3, status = "succeeded"),
|
||||||
|
)
|
||||||
|
val pipelines = listOf(pipeline(1, "web"), pipeline(2, "api"), pipeline(3, "web"))
|
||||||
|
// 2 fails the name; 3 fails the last-run status.
|
||||||
|
assertEquals(listOf(1L), filterPipelines(pipelines, filters, latest).map { it.id })
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun activeCountCountsTheNameAndRunFacetsButNotABlankName() {
|
||||||
|
assertEquals(0, PipelineFilters().activeCount)
|
||||||
|
assertEquals(1, PipelineFilters(name = "x").activeCount)
|
||||||
|
assertEquals(2, PipelineFilters(RunPresence.NoRuns, name = "x").activeCount)
|
||||||
|
assertEquals(0, PipelineFilters(name = " ").activeCount)
|
||||||
|
// Only the run-history facets need the history loaded.
|
||||||
|
assertFalse(PipelineFilters(name = "x").hasRunFacets)
|
||||||
|
assertTrue(PipelineFilters(RunPresence.NoRuns).hasRunFacets)
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun pipelineFiltersLeaveTheListUnfilteredUntilRunsAreKnown() {
|
fun pipelineFiltersLeaveTheListUnfilteredUntilRunsAreKnown() {
|
||||||
val filters = PipelineFilters(presence = RunPresence.NoRuns)
|
val filters = PipelineFilters(presence = RunPresence.NoRuns)
|
||||||
|
|||||||
Reference in New Issue
Block a user