Commit Graph

9 Commits

Author SHA1 Message Date
alan 54fecbb454 android: post real system-tray notifications when a run needs the operator
The app already had an in-app attention surface but nothing in the system
tray. This adds the app's own Android notifications for the two events that
need a person: a run waiting for a decision (highest importance) and a run
that failed. A successful, running or cancelled run raises nothing.

- RunAlerts.kt: the pure model. Maps the attention list's kinds to run
  alerts, coalesces several into one grouped summary, dedupes one
  notification per run+kind via AlertLedger (never repeated while the run
  stays failed or waiting), clears on resolution/dismissal/arrival, and
  decides the one-time permission prompt and tap destination. Unit-tested.
- RunNotifier.kt: the Android edge. Creates the single "Runs that need you"
  channel, posts/clears through NotificationManagerCompat, and reports
  notificationsAllowed() from POST_NOTIFICATIONS (API 33+) / the system
  notification switch. Posted from the app's own process.
- Manifest: POST_NOTIFICATIONS runtime permission; PipelinesApplication
  creates the channel before anything can post.
- SettingsRepository/AppViewModel: remembers that the permission was asked
  once (never nags), keeps notificationsAllowed fresh on resume, feeds the
  tray from the same attention flow, and clears a run's notification when
  the operator arrives at it.
- PipelinesApp/DecisionPrompt/RunDetailScreen: the one-time rationale before
  the system dialog, asked at a sensible moment (first run that needs the
  operator, or first open of the attention surface), degrading to the
  existing in-app surface on refusal; a waiting run's tap opens its decision
  sheet (pipelines://run/<id>?action=decide), a failed run's tap opens the
  run; reaching a run clears its notification.
- Attention.kt: drops the Finished kind so a successful run is never
  announced on any surface (the operator's rule), keeps the deep-link parser
  (now carrying an optional action) and still decodes an older state's
  looked-at-finished set.
- AttentionTest.kt / RunAlertsTest.kt: the mapping (waiting and failed
  only), the permission paths (granted, refused, not-yet-asked), coalescing
  and clearing, dedupe, and the tap destination.

Checks: `:app:assembleDebug` and `:app:testDebugUnitTest --rerun-tasks`
pass (578 tests, 0 failures). Reflected-where-it-belongs check: this is an
android/-only change and the packaged authoring skill references and the
packaged templates describe the server's ntfy notification authoring, not
the Android app's tray, so none of them needs updating. No README or other
shared documentation file was touched.
2026-10-17 23:56:47 +01:00
alan 890d267c71 run attention: publish to ntfy and surface what needs the operator
Nothing told the operator that a run was waiting for a person or had failed; they
found out by going looking. A run that needs attention now reaches the ntfy they
already run, and the app answers "what needs me now" in one live, ordered surface.

Server (smallest change, reusing the existing publisher):
- internal/server/notify.go adds notifyRun, called from finishRunState (failed)
  and when a run parks on a human (runner.go runLoop). It publishes to the same
  already-configured `system` destination through the unchanged stage.PublishNtfy,
  so there is no second publisher, topic or service and the token handling is the
  stage's own. runAttentionEvent maps only waiting and failed; queued, running,
  succeeded, canceled and interrupted publish nothing.
- No storms: runner.attentionSent records sequence:event per run before publishing,
  so a run that stays waiting is never republished on a re-request or restart, and
  a stage notify policy that already covers the same event marks it first so the
  run-level default is suppressed. The set is dropped when the run is terminal. A
  delivery failure is logged, never fails the run, and is not retried.
- The payload names the run and pipeline and carries a click action
  pipelines://run/<id> (validated: absolute URL, no userinfo, no fragment, no
  credentials). PublishNtfy gained the optional click parameter; existing callers
  pass "".

App:
- AndroidManifest/MainActivity declare the pipelines://run/<id> deep link
  (singleTop); runIdFromDeepLink parses it and PipelinesApp opens that run once,
  clearing the link. It opens a run; it starts nothing.
- ui/Attention.kt is the pure model (status -> Decision/Failed/Finished or
  nothing, ordered by kind then newest-first) and ui/components/AttentionSurface.kt
  is the floating indicator plus bottom sheet. It is derived from the same run
  events the server already pushes, so an entry appears with no refresh and clears
  when resolved; a finished run clears once looked at, and any entry can be
  dismissed, persisted in SettingsRepository. The existing destinations, pill and
  bottom strip are untouched and no competing navigation surface is added.

Checked before committing:
- Packaged authoring skill references: internal/author/skill/references/
  notifications.md documents the automatic run-attention notifications and the
  app surface. The only packaged "template" carrying notify is that reference; no
  pipeline definition template exists to update and install.go's managed file list
  is unchanged (notifications.md already existed).
- Repository guidelines: docs/ntfy.md gains an "Automatic run-attention
  notifications" section and no longer claims "No block means no notifications";
  the top-level README phone-notifications note now says a waiting/failed run
  notifies automatically; android/README.md gains the dated feature section and
  supersedes the previous section's note that the attention surface was absent.
- docker.md, install docs and the CLI/TUI docs describe mechanisms this change
  does not alter; left as they are.

Tests: go test ./internal/server/... ./internal/stage/... ./internal/author/...
all ok; notify_test.go covers the event mapping and the real HTTP delivery
(destination, topic, click, no duplicate). Android :app:testDebugUnitTest ->
BUILD SUCCESSFUL, 58 suites / 531 tests / 0 failures (new AttentionTest, 13 cases,
covering ordering, appearing from a push, clearing on resolution, dismissal, the
empty case, persistence and the deep link). Device screenshots and the phone's own
notification are visual review's per the brief's device policy.

Scope: android/ plus the smallest server change; no new dependency, no run started
from the app, no installer or Docker change.
2026-10-17 16:11:57 +01:00
alan 0937327e8c android: correct omni-search IME docs to the declared adjustResize mode
The soft-input comments in the manifest, PipelinesApp.kt and android/README.md
still described `adjustNothing`, a mode the activity no longer declares. MainActivity
uses `android:windowSoftInputMode="adjustResize"` and the app draws edge-to-edge, so
the Compose window inset (WindowInsets.safeDrawing) is the single source of the IME
geometry and is applied once by the surface that owns it.

- AndroidManifest.xml: rewrite the soft-input comment to describe adjustResize, why
  the app is edge-to-edge and reads the IME from Compose window insets, and warn
  against changing it without re-checking the chat composer.
- PipelinesApp.kt: correct the bottom search column comment that claimed the activity
  declares adjustNothing and the window is never resized for the IME.
- android/README.md: correct the omni-search results-panel section that claimed the
  IME inset was counted once because of adjustNothing; now records the declared
  adjustResize mode, the edge-to-edge single source of IME geometry, and the chat
  composer's imePadding.

Documentation only; no rendered surface or behaviour changes. The omni-search entry
point and pill morph already exist at this HEAD; this reconciles the stale wording
with the committed mode.
2026-10-16 22:48:28 +01:00
alan 910a7aa798 Merge lane-app2: the chat experience and its multi-conversation state
Integrates eight commits of reviewed chat work: the Chat destination with
several conversations, markdown transcripts, tool-call chips with an expandable
INPUT/OUTPUT panel, edit diff cards, the composer's stop control, and approval
cards. The automated resolver failed on this merge repeatedly (its own stages kept
dying on the malformed-result defect), so it was integrated by hand.

Integration decisions:
- Pill geometry: main's tokens win. lane-app2 carried private duplicates of
  DESTINATION_ITEM_SIZE/GAP and a private DESTINATION_PILL_RESERVE, added before the
  geometry-token migration; those duplicates are dropped in favour of the theme
  tokens main already exports.
- IME mode: kept lane-app2's adjustResize for the window, because the chat composer
  and the search field both raise the keyboard and the chat UI was reviewed with it.
- Protocol and view-model constants: both sides' independent additions are kept.
- ChatScreen now passes the compactLabel main's SlidingPaneStack gained, and the
  literals lane-app2 introduced before the token discipline are converted to five
  new named tokens (HAIRLINE_DP, ICON_BUTTON_SMALL_DP, TOOL_PANEL_MAX_WIDTH_DP,
  CHAT_TITLE_MAX_WIDTH_DP, CHAT_BUBBLE_MAX_WIDTH_DP) rather than allow-listed.

Verified: assembleDebug plus the full Android unit suite (409 tests) pass,
including the geometry enforcement test.
2026-10-16 22:27:30 +01:00
alan 80f7b0adbc android: add omni-search entry point and pill morph
Add the fourth Search destination to the floating bottom container and
morph that container into the omni-search field.

- PipelinesApp: the destination pill gains a Search icon; tapping it
  animates the icons out and turns the same Surface into a focused text
  field whose size and position derive from the pill's own layout and the
  window insets rather than fixed pill sizes. Back, the back gesture and a
  scrim tap play the reverse and restore the pill with its previous
  destination still selected. The open field covers the content behind a
  scrim and shows a results panel above it.
- OmniSearch: pure state model (open/focused/query) with the open, dismiss,
  focus and query transitions and a Bundle-able Saver, so an open field
  survives a saved-state round trip.
- OmniSearchResults / SearchResultsPanel: map the typed search reply to
  rows and render the ranked results, keeping the last accepted results
  while a newer query loads and reporting a failure without blanking.
- AppViewModel / PipelinesRepository: drive queries over the existing
  transport with debounce and reply ordering; the server search command
  arrives in a later item, so a reply is classified by envelope type and a
  non-search_results reply is reported with a clear message instead of
  being mis-parsed, never a crash.
- Message: SEARCH / SEARCH_RESULTS constants and the SearchRequest,
  SearchResponse and per-kind result payloads.
- AndroidManifest: adjustNothing so the app reads the IME from Compose
  window insets and the field is not cleared twice by a window resize.
- Dimens: spacing for the search surface.
- Unit tests for the state model (pill, opening, focused, dismissed and
  restored after the Saver round trip) and for the result-row mapping.
2026-10-16 19:29:40 +01:00
alan 0718f5ba6f Add the Chat destination and hold several conversations at once
Entry point: the floating destination pill gains a Chat icon between Runs and
Settings; it stays a single non-wrapping Row of 48dp targets using the named
DESTINATION_ITEM_SIZE/DESTINATION_ITEM_GAP tokens, clear of the existing 88dp
reserve, so it stays narrow however many destinations it holds.

Protocol/transport: new data/protocol/Chat.kt mirrors the brokered chat wire
shapes; Message gains the optional chat_* payloads, PipelinesClient forwards
unsolicited frames (chat_event/chat_permission) to a new events flow instead of
dropping them, and PipelinesRepository exposes the typed chat calls (sessions,
create, messages, prompt, interrupt, reply).

State: ui/chat/ChatStore.kt is an Android-free multi-chat holder; every open
chat keeps its own conversation, running flag, composer draft and scroll
position, open/activate report when history must be re-synced so a running
session refreshes on return instead of showing a stale copy, and busy/read-only
sessions refuse writes.

Surface: ui/chat/ChatScreen.kt lists the server's sessions with running/busy/
read-only status and an open-chat strip to switch between conversations (chip X
closes only that chat); the conversation is a bottom-anchored transcript of user
bubbles, reasoning, assistant text and tool-call chips that expand to INPUT
(pretty JSON)/OUTPUT (monospace), edit-family calls render a diff card derived
from oldString/newString, and pending chat_permission frames surface an approval
bar answered via chat_reply. New chat creates and opens a session. The manifest
sets windowSoftInputMode=adjustResize for the composer.

Tests: ChatProtocolTest, ChatFormatTest and MultiChatStateTest cover the wire
shapes, formatting and the multi-chat model (switching preserves each
conversation, a running session re-syncs on return, per-chat drafts/scroll,
busy read-only, background events land on their chat). README documents the
slice and its evidence.
2026-10-16 12:43:37 +01:00
alan 1195535852 Add a real share action to every artifact item
Give each gallery image cell and each per-visit file row its own share
control: a 48dp IconButton with an accurate "Share <name>" content
description drawn as a sibling of the item's tap handler, so sharing
never opens the image or the item.

Sharing fetches the artifact through the existing client into a scoped
cache file (cache/shared-artifacts/), exposed via a non-exported
FileProvider declared with the new res/xml/file_paths.xml, and sends it
through ACTION_SEND. When the fetch returns nothing the action falls
back to sharing the resolved link as text. Cache files are named
deterministically per artifact so re-sharing overwrites instead of
growing without bound, and a failed or unreachable fetch cannot crash.

The artifact-to-file naming, mime/extension table and the file-vs-link
fallback decision are factored into ArtifactSharing.kt and covered by
the new ArtifactSharingTest.kt. The existing open and copy-link actions
are unchanged; the viewer's action scrim alpha is shared as
ARTIFACT_ACTION_SCRIM_ALPHA. android/README.md documents the provider
and the share flow. No new dependency is added.
2026-10-16 07:03:18 +01:00
alan 5314542c13 Make the Android stage detail a pane and add an artifacts gallery
Turn the stage detail into the rightmost pane of a bounded three-level
stack and show every run artifact in a summary gallery.

- The stage detail opens as a real level-2 pane from both entry points (a
  Timeline row and a graph node). StageDetailPane is wrapped in the same
  Scaffold/TopAppBar with a back arrow as the other panes, and its
  identity/result facts (status, outcome, target, duration, visit, model
  target) render outside any collapsible so a fresh pane is never empty.
  StageDetailSheet, ModalBottomSheet and RightSlidingPanel are removed.
- SlidingPaneStack replaces SlidingMasterDetail: pane 0 fills the host,
  panes 1 and 2 overlay at peek*level, each covered pane keeps one
  tappable peek strip, and MasterPane/backStep/popTo/MAX_PANE_DEPTH are
  the pure model. The peek tap, the pane back arrow, the system Back
  button and the predictive-back gesture all pop exactly one level.
- New pure runArtifactGroups(steps) groups a run's artifacts by stage and
  visit (stable order, duplicates kept, empty run -> empty) and
  artifactsEmptyMessage distinguishes the running "capture pending" case.
  ArtifactGallery renders image thumbnails (tap opens full size) and
  non-image rows with name, size, content type and open/copy; urls resolve
  through ServerUrl, never a hardcoded host.
- Run Summary shows the run gallery and the stage pane shows that visit's
  group, keeping the existing per-visit artifacts summary and notes.
- Tests updated/added (PaneStateTest, SlidingPaneStackTest,
  ArtifactGroupsTest, ArtifactGalleryTest, StageDetailSheetTest, refreshed
  DetailTabsTest/PipelinesNavTest, CollapseRemovalTest kept green) and
  android/README.md records the pass, evidence and not-verified list.
2026-10-15 23:34:36 +01:00
alan 9a94eabaa3 Add the native Android client for the Pipelines server
Kotlin and Jetpack Compose Material 3 client that speaks the existing WebSocket
protocol: settings requiring an explicit server URL and workspace, pipeline list and
detail with the workflow graph, run history, run detail and evidence, start and
cancel run, reconnect, and the loading/empty/error/disconnected states. It stores no
credentials and keeps execution, definitions and run history on the server.

Verified on the host: :app:compileDebugKotlin and :app:assembleDebug succeed and
:app:testDebugUnitTest passes 19 tests. Ignore Gradle outputs and re-include the
net.awan.pipelines.data package, which the repository runtime data/ rule would
otherwise exclude.
2026-10-13 17:20:18 +01:00