From 18db2f913aac6925267788cf86a0d41c8beadc59 Mon Sep 17 00:00:00 2001 From: Alan Silva Date: Sat, 17 Oct 2026 01:30:27 +0100 Subject: [PATCH] Add a Templates gallery and detail view to the app The server's template catalog (the list_templates command) had no surface in the app. This adds a Templates destination to the shared SlidingPaneStack: a measured card gallery (name, short description, stage count and its own glyph; one column narrow, a fitting grid wide) and a detail pane that reuses the pipeline detail's Summary/Graph/Source tabs, plus a create-from-template action that submits a create-only draft. Stage counts come from a source the server parsed (validate); a source that does not parse is still viewable as raw markdown. Added: Templates.kt (TemplateEntry/TemplateCard, the grid-column and stage-count mapping), components/GalleryGrid.kt (the shared measured-gallery fitting, extracted from the artifact gallery), graph/SourceView.kt (PipelineSourceView, the one rendered-definition view, extracted from PipelineDetailScreen), screens/TemplateGalleryScreen.kt, screens/TemplateDetailScreen.kt, TemplatesTest.kt. Changed: PipelinesApp.kt (the Templates destination), AppViewModel.kt (refreshTemplates/createFromTemplate), data/PipelinesRepository.kt (listTemplates/validateSource/createPipeline), graph/Artifacts.kt (use the shared galleryGrid), PipelineDetailScreen.kt (use the shared PipelineSourceView), ArtifactGalleryTest.kt (exercise galleryGrid). Doc/state check before committing: - android/README.md (the app's topic doc): updated. Added a Features bullet for the Templates destination and a dated "Templates: a gallery and a detail view" section, matching the per-feature convention every prior android change uses. - Packaged templates: not touched. The server's templates are Go-side and the brief forbids touching the Pipelines server; this change only renders the catalog the server already exposes. - Packaged authoring skill references (internal/author/skill/references/): not updated. They document the Pipelines harness, not the Android app, and this change adds no harness runtime behaviour. - Root README and docs/: not updated. They document the CLI/TUI/server, which are unchanged; the Android app is documented in android/README.md. No conflict was present: no unmerged paths and no unfinished merge, rebase or cherry-pick, so nothing needed resolving. Deliberately left uncommitted (other work this run did not touch, not staged): the worktree's other WIP - components/ListScroll.kt and screens/PaneStats.kt with their tests, and the uncommitted edits to components/SlidingPaneStack.kt, components/States.kt, theme/Dimens.kt and components/LoadPhaseTest.kt - plus the untracked .ui-review-*/ capture artifacts. --- android/README.md | 88 +++++ .../pipelines/data/PipelinesRepository.kt | 42 +++ .../net/awan/pipelines/ui/AppViewModel.kt | 62 +++ .../net/awan/pipelines/ui/PipelinesApp.kt | 62 +++ .../java/net/awan/pipelines/ui/Templates.kt | 78 ++++ .../pipelines/ui/components/GalleryGrid.kt | 26 ++ .../net/awan/pipelines/ui/graph/Artifacts.kt | 25 +- .../net/awan/pipelines/ui/graph/SourceView.kt | 130 +++++++ .../ui/screens/PipelineDetailScreen.kt | 107 +----- .../ui/screens/TemplateDetailScreen.kt | 352 ++++++++++++++++++ .../ui/screens/TemplateGalleryScreen.kt | 232 ++++++++++++ .../net/awan/pipelines/ui/TemplatesTest.kt | 83 +++++ .../pipelines/ui/graph/ArtifactGalleryTest.kt | 20 +- 13 files changed, 1175 insertions(+), 132 deletions(-) create mode 100644 android/app/src/main/java/net/awan/pipelines/ui/Templates.kt create mode 100644 android/app/src/main/java/net/awan/pipelines/ui/components/GalleryGrid.kt create mode 100644 android/app/src/main/java/net/awan/pipelines/ui/graph/SourceView.kt create mode 100644 android/app/src/main/java/net/awan/pipelines/ui/screens/TemplateDetailScreen.kt create mode 100644 android/app/src/main/java/net/awan/pipelines/ui/screens/TemplateGalleryScreen.kt create mode 100644 android/app/src/test/java/net/awan/pipelines/ui/TemplatesTest.kt diff --git a/android/README.md b/android/README.md index 2e0bee55..cf92f26d 100644 --- a/android/README.md +++ b/android/README.md @@ -104,6 +104,22 @@ stops it. - Pipeline list (search/refresh, empty/error/loading states), pipeline details (version list, content hash, source) and the workflow graph. +- A **Templates** destination (its own top-level pill between Pipelines and Runs, + with its own gallery glyph rather than the Pipelines workflow tree): a measured + gallery of cards, one per server template, each showing the template's name, its + short description and its stage count — `stage count unavailable` when the source + does not parse, never a claimed zero — with a single column on a narrow window + and as many equal-width cards as fit on a wide one, from the shared + `galleryGrid` fitting (the same rule the artifacts gallery uses) at the + `WIDE_RAIL_WIDTH_DP`/`SPACING_S` tokens, so the gallery widens by adding columns + instead of stretching cards. Tapping a card opens a detail pane that reuses the + pipeline detail's Summary / Graph / Source tabs (the stage list, the + `WorkflowGraph` and the shared `PipelineSourceView`), so the shape is readable + before choosing it; a source the server could not parse is still fully viewable + as raw markdown. A "create from this template" action submits the source as a + create-only draft pipeline (the app's equivalent of `pipelines new --template + KEY`) and never starts a run. Empty, loading and error states reuse the shared + state components. - Workflow graph composable: content-sized stage nodes laid out in one row in declaration order, with `#failure`/`#success` terminals sharing a lower row and arrows entering their top borders (an `error -> #failure` route leaves its @@ -3922,3 +3938,75 @@ Not verified in this pass: the on-device narrow/wide renders (a section opening over the stage and returning, and the wide panel beside the stage pane) and any screenshot of the former inline case — the brief keeps implementation verification to the build and the unit tests, and visual review owns the device. + +## Templates: a gallery and a detail view (17 Oct 2026) + +The server's template catalog (`list_templates`, which `pipelines templates` and +`pipelines template --source` already print) is now a first-class surface in +the app; before this change the app showed nothing for it. `android/` only: +nothing in the Pipelines server, its Go source, the Docker/compose files or the +installer was touched, no dependency was added (the destination glyph is the +already-declared material-icons-extended `Widgets`) and no run is started from the +app. + +- **The destination.** `PipelinesApp`'s destination list gains a `Templates` + entry between `Pipelines` and `Runs` (`TemplatesIcon`, `Icons.Filled.Widgets`, + deliberately not the Pipelines workflow tree), and `TemplatesDestination` uses + the same shared `SlidingPaneStack` the other destinations use: pane 0 the + gallery, pane 1 the selected template's detail, with the selected key in + `rememberSaveable` so the open template survives rotation and process death. +- **The gallery.** `TemplateGalleryScreen` shows one card per template from + `vm.templates` (loaded by a new `AppViewModel.refreshTemplates`, backed by + `PipelinesRepository.listTemplates`): the name, the short description and the + stage count, with the card's own leading glyph. `templateGridColumns` decides + the layout — a single column on a narrow window, and on a wide one as many + `WIDE_RAIL_WIDTH_DP`-shaped cards as fit `SPACING_S` apart via the shared + `galleryGrid` fitting — so no new geometry constant is introduced. +- **Stage counts come from a parsed source, not a guess.** `list_templates` + carries only the source, so `refreshTemplates` parses each template's source on + the server (`validateSource`, the `validate` command) once and caches the graph + per key+source. A template whose source does not parse keeps a null graph: its + card reads `stage count unavailable` (never `0 stages`), its Graph tab says the + source could not be parsed, and its Source tab shows the raw markdown — the + template stays fully viewable. +- **The detail view reuses the pipeline-detail idiom.** `TemplateDetailScreen` + uses the same `DetailTabs` (`pipelineDetailTabs`: Summary / Graph / Source) and + the same tab body/width handling as `PipelineDetailScreen`: Summary lists the + stages, Graph renders the `WorkflowGraph` (with an explicit note when the source + did not parse), and Source renders the definition through the shared + `PipelineSourceView`. +- **One rendered-definition view, not two.** `PipelineSourceTab` moved out of + `PipelineDetailScreen` into `ui/graph/SourceView.kt` as `PipelineSourceView`, so + the pipeline detail and the template detail render a definition through exactly + one composable (per-stage collapsible sections, the Raw toggle, the copy action). +- **One gallery fitting, not two.** The artifact gallery's private + `ArtifactGrid`/`artifactGrid` fitting moved to the shared + `ui/components/GalleryGrid.kt` (`GalleryGrid`/`galleryGrid`), so the templates + gallery and the artifacts gallery share one measured-column rule and the + artefact gallery tests now exercise the shared function. +- **Create from a template.** A top-bar action on the detail opens a dialog that + submits the template's source as a create-only draft pipeline + (`AppViewModel.createFromTemplate` → `PipelinesRepository.createPipeline`, the + `submit` command with `create_only`): the app's equivalent of the CLI's + `pipelines new --template KEY` (that path writes a local draft file; the app has + no filesystem, so it stores the draft on the server, where it appears in the + Pipelines list). An existing name is never overwritten and no run is started. +- **States.** Empty, loading and error states reuse the shared `StateCrossfade` + state components; a covered pane shows only its compact identity. + +Verification (this run's review stage, macOS, cached Gradle, `--no-daemon`): the +offline build and unit tests pass at **35 suites / 309 tests / 0 failures / 0 +errors**, including the new `TemplatesTest` (the card/stage-count mapping, the +`stage count unavailable` label for an unparsed source, and the narrow-column / +wide-grid decision) and the relocated artifact-gallery cases now running against +the shared `galleryGrid`. The app's create path was checked against the repo's own +Go test for the server submit-with-`create_only` behaviour. + +Visual review (this run, operator's Pixel 9 Pro XL, adb `47241FDAS00DLK`, built +from this tree and installed over the existing package) confirmed the gallery +renders 5 cards — a single column at the phone's ~448dp width and a 4-column +measured grid at `wm size 2000x2244` — and that each card opens a Summary / Graph +/ Source detail with the create dialog, consistent with the app's Material 3 +language. The empty, loading, error and unparseable-source states were built from +the app's shared state components but could not be produced live without mutating +the operator's server. diff --git a/android/app/src/main/java/net/awan/pipelines/data/PipelinesRepository.kt b/android/app/src/main/java/net/awan/pipelines/data/PipelinesRepository.kt index 7ddf2975..08b708f7 100644 --- a/android/app/src/main/java/net/awan/pipelines/data/PipelinesRepository.kt +++ b/android/app/src/main/java/net/awan/pipelines/data/PipelinesRepository.kt @@ -5,12 +5,14 @@ import java.util.concurrent.ConcurrentHashMap import kotlinx.serialization.json.JsonPrimitive import kotlinx.serialization.json.JsonElement import net.awan.pipelines.data.protocol.Message +import net.awan.pipelines.data.protocol.Graph import net.awan.pipelines.data.protocol.PipelineDetail import net.awan.pipelines.data.protocol.PipelineSummary import net.awan.pipelines.data.protocol.Protocol import net.awan.pipelines.data.protocol.RunDetail import net.awan.pipelines.data.protocol.RunSummary import net.awan.pipelines.data.protocol.SessionEvidence +import net.awan.pipelines.data.protocol.Template import net.awan.pipelines.data.protocol.UsageStats import net.awan.pipelines.data.transport.NotConnectedException import net.awan.pipelines.data.transport.PipelinesClient @@ -65,6 +67,46 @@ class PipelinesRepository( return RunHistory(response.runs ?: emptyList(), response.usage) } + /** + * The server's template catalog: each template's name/description and its + * full, defaulted source, exactly as `pipelines templates` prints it. + */ + suspend fun listTemplates(): List