Commit Graph

125 Commits

Author SHA1 Message Date
alan 269a8d65bb Guard socket recovery from stale callbacks
Serialize socket replacement and callbacks so a superseded socket cannot clear or regress the active connection, and make reconnect backoff safe after a successful open. Add focused recovery regression coverage.\n\nChecked packaged templates and packaged authoring skill references; neither needs updating for this Android transport-only change.
2026-10-18 12:27:24 +01:00
alan 70529926cc Merge main into session-html-only: combine the html-only session export with chat-tool-group and chat-activity 2026-10-18 10:06:54 +01:00
alan 95362134aa session export: write only session.html, retire the markdown export
A stage's session was exported twice, as session.md and session.html, and both
files were presented. It is now one html file; the markdown export is retired.

- internal/stage/session_export.go: ExportSession renders and writes exactly one
  file, session.html, via writeSessionFile; renderSessionMarkdown and its helpers
  are gone; SessionExportResult carries HTML/HTMLBytes only. The source read, the
  8 MiB source / 2 MiB rendered bounds, the truncation banner, the
  never-overwrite rule and the honest empty-session handling are unchanged.
- internal/protocol/runs.go: SessionExport drops markdown/markdown_bytes (a
  record written before the change still decodes; unknown fields are ignored),
  and adds LegacySessionMarkdownArtifact with RunStep.PresentedArtifacts(), the
  one Go rule that hides the retired session.md from every artifact listing.
- internal/server/runner.go: evidence.Markdown/MarkdownBytes are no longer copied.
- internal/tui: the artifacts panel, the recorded count and the per-visit summary
  derive from PresentedArtifacts(), so the terminal never lists session.md.
- web/src/app.js: the spike's renderArtifacts applies the same filter.
- android: the Session section is the html export alone in a WebView — SessionView,
  the Markdown/HTML toggle and the session markdown path are removed;
  presentedArtifacts(step) filters the retired session.md out of the per-visit
  gallery, the run gallery and its count, the verdict/selection lists and the
  timeline indicator; data/protocol SessionExport drops the markdown fields.
- Tests pin the single html file, prove no session.md is written and that a
  pre-existing one is neither overwritten nor presented, and prove a legacy
  export record still loads and its session.md is hidden.

The legacy session.md of an older run stays on disk (dated evidence); it is only
no longer produced and no longer presented.

Checks (macOS, Go 1.24, Android Gradle 8.11.1, 18 Oct 2026): gofmt -l . prints
nothing; go build ./... && go vet ./... clean; go test ./internal/... ./cmd/...
-> 19 packages ok, 0 failures; node --check web/src/app.js ok and node --test
web/test -> 20/20; gradle --offline --no-daemon :app:assembleDebug
:app:testDebugUnitTest -> BUILD SUCCESSFUL.

Packaged references checked: internal/author/skill/references/delivery.md and
operations.md both described the session.md+session.html pair, so both are
updated here to describe the single session.html export and the retired, hidden
session.md. README.md and internal/author/skill/SKILL.md carry no session.md
reference and install.go's managed inventory is unchanged (no reference added or
removed). docs/notes/session-html-only.md records the remaining stale shared
documentation (docs/stage-artifacts.md, docs/app-integration-verification.md) for
the docs-fold writer; shared docs are not edited by this item.
2026-10-18 10:06:49 +01:00
alan 194540b768 Merge main into chat-tool-group: combine the tool-call summary chip with the chat-activity feature
Brings the tool-call summary chip (7fbbd95) together with main's chat in-flight
state and background-process surface (7b0dc94). Both edit ChatFormat.kt and
ChatTranscript.kt; the merge combined them cleanly (no conflict markers) — the
chip's live gating (live = streaming, toolStartedAt) now sits alongside main's
turn-phase labels and background-process bar, and both sides' pure helpers
coexist.

Re-ran the repository checks on the resolved tree: gradle --offline --no-daemon
:app:testDebugUnitTest :app:assembleDebug => BUILD SUCCESSFUL; JUnit XML
aggregate classes=70 tests=680 failures=0 errors=0 skipped=0.
2026-10-18 09:59:13 +01:00
alan 7fbbd95374 chat: one tool-call summary chip per turn, opening the call list
The chat transcript no longer renders a chip per tool call: `ToolCalls`
(`android/.../ui/chat/ChatToolCalls.kt`) now draws a single summary chip
reading `N tools called` (`1 tool called` for one) as the turn's only
tool-call surface. While the turn streams the chip shows the call count
growing and the existing spinner while any call is in flight, plus the
existing `· long` mark for a running call past `TOOL_LONG_RUNNING_MILLIS`;
both are gated on the turn still streaming (`live = streaming` in
`AgentTurnItem`), so a settled chip never spins or fakes a long mark.

Tapping the chip opens the existing `ToolPanel` as a popup listing every
call of the turn, in the order the agent made them: one independently
collapsible row per call naming it, showing its one-line detail, its
`+N -M` edit stat and its duration, expanding in place to the
pretty-printed INPUT, the synthesised edit diff, then the ERROR block for
a failed call or the OUTPUT (`(no output)` when empty). The list is
bounded by the new `TOOL_PANEL_MAX_HEIGHT_DP` (`Dimens.kt`, purpose-named)
and scrolls inside the panel, so many calls never grow the popup past the
window nor re-flow the transcript. The chip announces the count ("N tool
calls, expand for details") through the app's accessibility treatment.

Pure logic lives in `ChatFormat.kt` (`toolCallsLabel`,
`toolCallsAnnouncement`, `toolCallCount`, `toolsRunning`, `toolCallRow`)
with unit cases added to the existing `ChatFormatTest`; no raw dimension
was introduced, so `DimensTest` is unchanged.

Checked for staleness: the packaged authoring skill references
(`internal/author/skill/references/`) and the packaged templates carry no
Android-chat content, so neither needs updating — this change is
`android/`-only. The shared docs this change makes stale
(`android/README.md`'s "Tool-call chips and the expandable panel" section
and `docs/chat-verification.md`'s tool-chip row) are recorded in
`docs/notes/chat-tool-group.md` for the single `docs-fold` writer rather
than edited here.
2026-10-18 09:58:28 +01:00
alan 7d9490bba1 chat: name the in-flight state, and surface background processes
Two gaps in the chat's in-flight feedback.

The turn indicator no longer reads a bare `Working…` for every state. A new
pure derivation (TurnPhase/turnPhase/turnPhaseLabel in ui/chat/ChatFormat.kt)
labels the headline from evidence already on the wire: `Thinking…` while text
or reasoning deltas are still arriving (within TURN_THINKING_WINDOW_MILLIS),
`Running a tool…` while calls are in flight, `Waiting…` otherwise. No
percentage, ETA or invented progress.

The agent's shell commands are now surfaced end to end as their own frame kind,
so a background process (a dev server, a watching build) that outlives its tool
call is visible and clears when it exits.

Server:
- protocol/chat.go adds ChatEventShell, ChatShell (id, status, command, *int
  exit — a pointer so exit 0 is not "absent") and ChatEventFrame.shell.
- opencode/chat.go maps shell.created/shell.exited through a new exported
  ChatStreamState, attributing created via info.metadata.sessionID and exit via
  the ids the stream already surfaced; another session's or an unattributed
  shell is ignored, an id-less shell fails the stream. No cwd/file/credential is
  carried.
- server/chat_hub.go retains still-running shells (chatShellLimit plus the
  shared byte cap) and drops them on exit; chat_stream.go replays them on
  chat_subscribe, the shell half of the resume (a shell is not a turn, so the
  message snapshot cannot carry it).

App:
- data/protocol/Chat.kt adds ChatShell, ChatEventFrame.shell, EVENT_SHELL,
  SHELL_RUNNING/SHELL_EXITED.
- ui/chat/ChatStore.kt stamps ChatThread.lastDeltaAt on each delta (cleared when
  the turn settles) and keeps ChatThread.shells across a chat switch; a shell
  never marks the thread running. streamResumed drops shells so the subscribe
  replay re-syncs the still-running ones.
- ui/chat/ChatTranscript.kt: RunningIndicator prints the phase label; a new
  always-visible BackgroundProcessBar names each running shell.
- ui/chat/ChatConversationPane.kt shows the bar whenever a shell is running,
  whether or not a turn is.

Tests extend the server's event mapping (opencode/chat_v2_test.go,
server/chat_test.go) and the app's pure folds (new
ui/chat/ChatInFlightStateTest.kt, 15 tests), pinning the shell mapping, the
other-session rejection and the "background process outlives the turn" state.

Checked and intentionally unchanged:
- No packaged OpenCode skill reference documents either surface.
  internal/author/skill/references/operations.md describes the brokered chat_*
  protocol in prose without naming frame kinds or the app indicator, so it stays
  correct as-is; no reference was added, so install.go's managed inventory needs
  no change.
- This repository has no packaged templates directory.
- Shared docs are not edited here per the map: docs/notes/chat-shell-background
  -process.md records what is now stale in docs/cli.md and android/README.md for
  the docs-fold writer.

Verification (this session): gofmt -l clean, go build ./... and go vet ./... OK.
Android unit suite and the on-device capture were run in the preceding review
stage; see the note for the live-verification limitation.
2026-10-18 09:45:28 +01:00
alan 798e958cb7 chat: fold an agent turn into one reply, split reasoning from answer, keep tool name/input
The phone's chat transcript rendered one agent reply as ~36 bubbles, each with
its own thinking block, and a finished tool call lost its name and its input.

- Turn fold (android): ChatFormat.kt gains the pure ChatTurn / TranscriptRow /
  transcriptRows fold - each run of consecutive assistant messages between two of
  the operator's messages is one agent turn - and ChatTranscript renders one
  bubble per turn: the turn's single collapsible thinking block (all its
  reasoning, in order, growing live while it streams), then its tool-call chips,
  then one answer block of just the turn's text parts. AssistantParts/MessagePart
  are replaced by AgentTurnItem/UserMessageItem; ChatConversationPane counts the
  folded rows.
- Delta part ids (server + client): internal/protocol/chat.go adds
  ChatDeltaPartID(messageID, kind, ordinal), mirrored as ChatProtocol.deltaPartId
  in data/protocol/Chat.kt, and NormalizeChatEvent keys a text or reasoning delta
  on it. OpenCode numbers a message's text and reasoning parts independently from
  0, so the old "%s#%d" gave the first text delta and first reasoning part the
  same id: the answer was appended into the thinking block, and the server's
  retained state (chat_hub.go) re-collided on resume. ChatStore's upsert now
  routes a delta through the kind-aware deltaPartId fold, so it stays robust even
  against a peer that still shares one id.
- Tool fields (server + client): NormalizeChatEvent takes a call's arguments from
  session.tool.input.ended's text as well as session.tool.called's input object
  (toolInput), and chat_hub.go's new mergeChatToolPart folds each tool frame onto
  the retained part so the progress/success frames that omit name and input never
  blank them. ChatFormat.kt's mergeToolPart mirrors that on the client, so the
  chip and panel header keep the real tool name and the panel shows INPUT beside
  OUTPUT.

Tests: chat_v2_test.go and chat_test.go add the text/reasoning id-collision and
the tool name+input retention cases; ChatReasoningTurnTest, ChatTranscriptTest
and ChatRunningWorkTest cover the turn fold, the collision and the tool lifecycle.

Checks: Go build, vet, gofmt and the package tests pass (go build ./... &&
go vet ./...; gofmt -l . empty; go test ./internal/server ./internal/opencode
./internal/protocol ./internal/stage ./internal/pipeline; go test ./...).
Android passes offline with --no-daemon (assembleDebug and the full
testDebugUnitTest suite, 660 tests). The on-phone observation was not performed:
the device lock was held by another run and adb was not available here.

Documentation inventory checked: no packaged OpenCode skill reference in
internal/author/skill/references/ and no packaged template documents the app's
chat transcript, this delta part-id derivation or the tool-field retention, and
no internal/author/ managed file inventory entry names any touched file, so none
of them needs updating. The shared android/README.md behaviour statements are
made stale by this change and are recorded instead in
docs/notes/chat-transcript-turn-fold.md for the docs-fold writer, per the repo
rule that an item never edits a shared document itself.
2026-10-18 01:47:52 +01:00
alan 49f40bfe45 android: move the detail and visit selectors to a bottom strip on narrow windows
The two selectors that were a horizontally scrolling Material 3 tab row at
the top of a surface become one deliberate treatment. On a narrow window the
shared detail selector (`DetailTabs`) and the visit selector are now the shared
bottom strip (`ui/components/SelectorStrip.kt`), pinned in the thumb zone above
the system gesture inset with the content filling the area above; a wide window
keeps the left rail for the detail selector and the pinned top row for visits.

- SelectorStrip: the one bottom strip plus its pure model (`SelectorEntry`,
  `SelectorPlacement`, `detailSelectorPlacement`, `visitSelectorPlacement`,
  `selectorStripShown`, `detailSelectorEntries`, `visitSelectorKey/Label`,
  `visitMarker`, `visitSelectorEntries`). Each entry keeps at least the platform
  minimum touch target, shows its whole label, and a visit shows its recorded
  status/outcome as a small `RunStatusIcon` marker rather than an invented one.
  Selection is carried by tab semantics and container colour, not colour alone.
  A single entry (or none) draws no strip.
- `DetailTabs` narrow branch replaced by `SelectorStrip` after the panel in a
  Column; the wide rail is unchanged.
- `StageDetailPane`: `StageVisitStrip` is the narrow visit selector; the bodies
  put a `weight(1f)` scroll above it and keep the top row only on a wide window.
  The stage definition section still shows no strip.
- `SessionExport`: `SessionExportSection` gains `visitTabs` so the narrow pane
  does not render the visit selector twice.
- `PipelinesApp`: the strip publishes its measured height through the new
  `LocalBottomStripInset`/`BottomStripInset`, and the floating pill's overlay
  lifts by `pillBottomOffset(stripHeight) = SPACING_L + stripHeight` (pure, zero
  when no strip is up), so the pill never overlaps the strip.
- Tests: new `SelectorStripTest` (placements, single-entry no strip, detail
  entries keep tab keys/titles/icons, visit labels and markers, stable visit
  keys) and a new `PipelinesNavTest` case pinning the pill lift.

Pill/strip clearance is the brief's "pill moves clear of the strip" option,
implemented once in `pillBottomOffset`. All geometry and motion come from the
existing named tokens and the layout; no new dependency.

Documentation checked: no packaged OpenCode skill reference (`internal/author/
skill/references/`) or packaged template (`examples/*.md`) documents the app's
detail/visit selector presentation, so neither is stale and `internal/author/
install.go`'s managed inventory needs no change. The shared `android/README.md`
is made stale by this change (the narrow tab-row wording at lines ~182-184,
~233-235 and ~487-488) and is recorded for the single `docs-fold` writer in the
new `docs/notes/bottom-selector-strip.md` rather than edited here.
2026-10-18 00:50:15 +01:00
alan dc75791992 Merge main into slash-commands: combine the composer's slash commands with the
server-side chat close

What was combined:

- main brought the server-side close (chat_close/chat_reopen over the protocol,
  PipelinesRepository.chatClose/chatReopen, ChatStore.sessionClosed/sessionReopened
  and active/closed session projections, the list's Close chat… confirmation and
  the Closed chip), plus the destinations-pill overlay and the omni-search and
  status-label work from the lanes that landed beside this one.
- this branch brought the composer's slash commands: parsing, the filtered offer
  list with Enter/tap/D-pad, the shared prompt path, /new in the current
  directory, the local /rename, /stop, /help and the unknown-command offer, with
  local command lines rendered outside the model's conversation.

Resolution (the one place the two sides disagreed):

The branch's /close reported that no real session close existed, because none did
when it was written. main now has one, so /close delegates to it instead:
AppViewModel.SessionChatCommandHost.finishSession calls closeChatSession, which
uses the server's own chat_close (a running turn is stopped, the session is marked
closed for every client, the history is kept), and then chatStore.close returns the
operator to the list. A failure is reported on the list, where the list's own close
reports it. The now-false "this build has no real session close yet" line and its
CHAT_CLOSE_UNAVAILABLE constant are removed, /close's offer summary says it
finishes the session for every client, and its test now drives the real store
close (sessionClosed + close) and asserts the row is closed, kept as history and
off the pane.

Checks run after resolving, on the merged tree (HEAD = this merge):
`--offline --no-daemon :app:assembleDebug` BUILD SUCCESSFUL, and
`:app:testDebugUnitTest` BUILD SUCCESSFUL with 646 tests, 0 failures (including
ChatCommandsTest.closeDelegatesToTheRealServerCloseAndReturnsToTheList). DimensTest
still holds: no raw dimension was added outside the token files. The packaged
templates and packaged authoring skill references are unaffected — this is an
Android-app-only change with no protocol, server, installer or Docker change — so
none of them needed updating.

Documentation now stale (not edited here; one writer folds shared docs):
android/README.md's chat section describes the composer and the session list
without the slash commands (vocabulary, offer list, unknown-command guard) and
without the composer's /close path to the server close.
2026-10-18 00:24:41 +01:00
alan fa6106ea46 android: add slash commands to the chat composer, starting with /new
The composer now reads a leading slash as a command instead of a prompt, so the
operator can start a session, rename it, stop a turn or ask for help without
leaving the input field — the same surface the pipeline terminal gives with
`:status`, `:logs`, …

- ChatCommands.kt: parsing (a bare `/`, an unknown word, an argument, text that
  merely starts with a slash), the filtered offer list, the Enter target, the
  `/help` listing, the effect routing and the host interface. Pure, so the
  routing is testable without a device or server.
- ChatComposer.kt: the offer list above the field, Up/Down to move the highlight
  and Enter/tap to run the highlighted row, shown only while the draft is a bare
  command word. Sending, attachments, stop-while-streaming, queued state and the
  field's ordinary keyboard action are unchanged.
- AppViewModel.kt: one shared prompt path (`postChatPrompt`) for the composer and
  the unknown-command offer, and a host that performs the effects. `/new` creates
  in the current session's directory and switches to it, leaving the old session
  open, listed and with its history; `/rename` uses the device's own local rename
  and says so; `/stop` interrupts a running turn; `/close` reports that this
  revision has no real session close rather than dressing up the local hide.
- ChatStore.kt / ChatTranscript.kt / ChatCommandUi.kt: local command lines
  (`ChatCommandNotice`) rendered as their own transcript item, visually distinct
  from a message to the agent, with an error container for a failed command.
- An unrecognised `/…` is never sent to the agent: it becomes an offer to send it
  as a message or cancel, and the offer is taken once so a stale tap sends
  nothing. Running a command adds nothing to the model's conversation.
- Dimens.kt: one new token, CHAT_COMMAND_LIST_MAX_HEIGHT, for the capped list.
- ChatCommandsTest.kt: parsing, filtering, `/new` in the current directory and
  switching, `/rename` and `/close` delegating, `/stop` only while running, and
  the unknown command never reaching the prompt path.

Checks made before committing: this is an Android-app-only change with no
protocol, server, installer or Docker change, so the packaged templates and the
packaged authoring skill references (internal/author/skill/references/) are
unaffected and no managed-file inventory in internal/author/install.go changes;
none of them needed updating. No dependency was added — Icons.Default.Terminal
comes from the already-declared material-icons-extended. Verified with the
Android map's own checks for an implementation change, build plus unit tests
(`--offline --no-daemon :app:assembleDebug` and `:app:testDebugUnitTest`), and
DimensTest's geometry-token rule holds: the only new dimension is the named token
above. Device behaviour was deliberately not exercised here (this stage does not
use adb); the rendered offer list, D-pad handling and notice item belong to
visual review.

Documentation that is now stale (not edited here; a single writer folds shared
docs): android/README.md's chat section describes the composer without the slash
commands — it should gain the command vocabulary, the offer list and the
unknown-command guard.
2026-10-18 00:22:33 +01:00
alan d6cb1931d0 Merge main into lane-pill: combine the pill overlay with main's chat-close, omni-search and status work
Brings the branch up to date with main's tip so it can be merged back without
conflict. Merged cleanly, with no conflicted path: git auto-merged
ui/PipelinesApp.kt, ui/chat/ChatListPane.kt and ui/screens/RunHistoryScreen.kt,
keeping main's changes (the omni-search panel, the one status colour, the chat
close/tool-work surfaces) alongside this item's pill overlay, its
LocalPillBottomInset clearance and the SettingsDestination templates stack.

android/README.md is main's version, not this item's: this item records its
documentation change in docs/notes/pill-overlay-and-position.md for the single
docs-fold writer instead of editing that shared document.

Checks re-run on the merged tree (macOS, JAVA_HOME=Android Studio jbr,
ANDROID_HOME=~/Library/Android/sdk, Gradle 8.11.1, --offline --no-daemon):
`gradle :app:assembleDebug :app:testDebugUnitTest` -> BUILD SUCCESSFUL, 67 result
XMLs aggregating to 627 tests, 0 failures, 0 errors, 0 skipped.
2026-10-18 00:21:20 +01:00
alan 5a44ff1568 android: make the destinations pill a true overlay, centred narrow and right when wide
The floating destination pill no longer takes layout space: it is drawn in the
bottom overlay layer above the content, horizontally centred on a narrow window
and anchored to the bottom-right corner on a wide one. Templates leaves the pill
for a Templates row on the Settings page.

- PipelinesApp: the content Column's pill reservation is gone; contentPillPadding
  (pillVisible) is the named zero and a unit test pins both states. The pill and
  the attention chip stay in their own bottom-anchored overlay Column, a sibling
  of the content in the Box, so nothing positions the content. The one placement
  rule is destinationPillAlignment(wide) (CenterHorizontally narrow, End wide);
  the corner margin is the named SPACING_L, so no new number. The attention chip
  keeps its own bottom-right place at every width via Modifier.align(End).
- Trailing clearance moves into each scrollable's own content: pillScrollInset
  (DESTINATION_PILL_RESERVE + ATTENTION_CHIP_RESERVE while drawn, zero while
  hidden) is published through the new LocalPillBottomInset
  (components/PillInset.kt) and applied with pillContentPadding /
  Modifier.pillBottomPadding in every list, grid and scrolling detail, stage and
  settings body. The container keeps its full height, a hidden pill leaves no
  empty band, and the last row still scrolls clear of the pill.
- Templates is no longer a pill destination: TemplatesDestination.kt is deleted
  and destinations is pipelines/runs/chat/settings. The new SettingsDestination
  sliding stack (pane 0 SettingsScreen, 1 TemplateGalleryScreen, 2
  TemplateDetailScreen) with the pure, Bundle-able SettingsSelection model gives
  the gallery the shared covered-pane strip and one-level Back; SettingsScreen
  gains the Templates row that opens it. This re-lands the intent of a2043f9,
  which never reached main.
- Dimens: the two reserve tokens' docs now describe the scroll-content clearance
  and the chip's share of it; no new token and no hardcoded geometry.

Checked where the change belongs: no packaged template (examples/*.md) and no
packaged authoring skill reference (internal/author/skill/references/*) describes
the Android pill, its destinations or the Templates gallery, so none needs
updating and internal/author/install.go's inventory is unchanged. android/README.md
does document the surfaces this item changed, so it is now stale: this item does
not edit that shared document - docs/notes/pill-overlay-and-position.md records
the two places that need it (the Templates bullet and the dated section to append)
for the single docs-fold writer.

Tests: at a297fb6 with these working changes the build and unit suite were green
(593 tests, 0 failures); no device command was run and the geometry stays
token-derived. Visual rendering of the centred/right pill needs the device and
was not verified here.
2026-10-18 00:20:37 +01:00
alan f85c172dc2 Merge main into chat-close: combine the shared chat room with the server-side close
The item adds chat_close/chat_reopen to the brokered chat protocol and the
operator-session registry's closed state. main replaced the per-session claim
model with shared chat rooms (chat_subscribe, a prompt queue, one broker stream
fanned out to every watcher). This merges the two.

Resolved conflicts:
- internal/protocol/chat.go, internal/protocol/message.go: kept both additions -
  ChatClose/ChatReopen and main's ChatSubscribe/ChatQueued.
- internal/server/chat_sessions.go: kept the closed fields on a listed session;
  dropped the `Busy` assignment, because main no longer marks a session Busy (any
  number of clients may watch and write one).
- internal/server/chat_claims.go: main deleted the claim model, so the file goes;
  close's "is a turn running" check is now `chatHub.turnInFlight` in
  internal/server/chat_room.go, reading the room's `running` flag. That is the
  same question the old claim answered, against main's model.
- internal/server/chat_close.go: calls turnInFlight instead of the removed
  `active`.
- android AppViewModel.kt, ChatFormat.kt, ChatListPane.kt, Message.kt: kept both
  sides - main's search state, queued-prompt handling, `Busy`-free status label
  and row/menu shape, plus the item's close/reopen actions, closed chip and
  section, close confirmation and "Hide on this device" rename.

Also in this merge: main's new convention (AGENTS.md) that an item does not edit
a shared document; the item's stale-document record for this change lives in
docs/notes/chat-close.md, and docs/cli.md, android/README.md and
internal/author/skill/references/operations.md are left to the docs-fold writer.

Checks after resolving: gofmt clean, go build ./... and go vet ./... clean, the
Go module passes, and the app's :app:assembleDebug and :app:testDebugUnitTest
pass (--offline --no-daemon).
2026-10-18 00:19:23 +01:00
alan 971e555ceb chat: close and reopen an operator session on the server, keeping its history
Add a server-side close for operator chats, so finishing with a chat takes it out
of the active list for every client without deleting anything. The brokered
protocol gains chat_close and chat_reopen; chat_close stops a running turn by
reusing the existing broker interrupt (its result carries an interrupted flag, so
a stream is never left running into nothing) and then sets closed_at on the
session's operator_sessions row. The session, its transcript and its history
survive, and because the closed state lives in the registry chat_sessions reports
it to every client, not just the one that asked. An id that is not a recorded
operator session, including a pipeline-owned run session, is refused before
anything is written. chat_reopen clears the state again, and simply prompting a
closed session also clears it (the store clears closed_at on touch).

The registry gains closed_at for a fresh database and an idempotent migration for
one created before it existed. The app renders closed sessions under a labelled
Closed section with a Closed chip, offers a Close action with a confirmation that
says it stops a running turn, marks the chat closed on every device and deletes
nothing, and a Reopen action on each closed row. The device-local hide is renamed
Hide on this device, with a snackbar saying the chat stays on the server, so it is
never confused with the real close. No new dependency, the installer and Docker
files are untouched, and no run is started from the app.

Checked before committing: the packaged templates carry no chat surface and need
no update, and internal/author/install.go's managed inventory needs none either
(this adds no reference file). The packaged authoring skill reference
internal/author/skill/references/operations.md and the shared docs/cli.md and
android/README.md are stale because of this change, but an item no longer edits a
shared document: what is stale and what should change there is recorded in
docs/notes/chat-close.md for the docs-fold writer, which is committed here with
the change.

Checks: gofmt clean, go build ./... and go vet ./... clean, and
go test ./internal/protocol/... ./internal/pipeline/... ./internal/server/...
./internal/author/... pass. The app side is verified with :app:assembleDebug and
:app:testDebugUnitTest (--offline --no-daemon, BUILD SUCCESSFUL); the on-device
close, second-client and reopen check is deferred to visual review.

Not deployed; deploying is the operator's step.
2026-10-18 00:16:24 +01:00
alan 2c1dfe9a35 android: restore the shared LabelChip the search-icon replay deleted
Replaying b808158 removed ui/components/LabelChip.kt: that commit predates
e2147b0, which extracted one shared LabelChip for the chat panes, so the older
diff carried the file's deletion. Restored from the commit before the replay; the
build and the full unit suite pass again. A cherry-pick's deletions need the same
scrutiny as its conflicts.
2026-10-18 00:13:17 +01:00
alan 986a62b09f android: add omni-search type icons with a kind filter and sorting
The search results panel replaces each row's text type badge (LabelChip,
removed) with a glyph derived from the result kind and, for an artifact,
from its content type. The artifact branch reuses the gallery's own
artifactKind/artifactIcon mapping in ui/graph/ArtifactType.kt instead of
a second table, and the glyph's contentDescription carries the kind in
words so a screen reader hears what the icon cannot show.

The panel's header gains the runs list's FilterMenu and SortMenu: a kind
filter (All kinds, Pipelines, Runs, Steps, Fields, Artifacts, Versions)
that sends the server's SearchRequest.kind verbatim, and Relevance /
Newest / Name sorting. The server's search takes no sort, so Newest and
Name order the results in hand and say so ("Sort results in hand", the
collapsed summary's "(in hand)"); no Prompts option is offered because
the server's search kinds cannot produce one. The chosen kind and order
persist via SettingsRepository, surviving query changes and streaming.

Tests: OmniSearchResultsTest covers the per-kind and per-content-type
glyph (checked against the gallery mapping), the kind label, filter
narrowing, Relevance/Newest/Name ordering with ties, and the empty-state
line; ArtifactTypeTest covers artifactKindLabel.

Checked before committing:
- Packaged templates: none describes the app's search panel; unchanged.
- README/topic docs: android/README.md gains the "Search type icons, a
  kind filter and sorting" section; docs/cli.md and docs/ui-ux-review.md
  describe only the TUI/server search, so they stay accurate and are
  unchanged.
- Packaged authoring skill references: internal/author/skill/references/
  contains no Android search-panel documentation (operations.md's "omni
  search" is the TUI), so none needs updating; install.go's inventory is
  untouched.

Evidence: gradle :app:testDebugUnitTest --rerun 433 tests 0 failures;
:app:assembleDebug successful, APK published to the run artifacts; the
API-27 NewApi lint errors are pre-existing and unrelated.

(cherry picked from commit b808158d499912e09872c31b5259205ee6cd8838)
2026-10-18 00:12:07 +01:00
alan 672d260b33 Merge main into multiclient: combine the multi-client chat fan-out with main's chat tool-work, notifications, status palette and docs-fold changes
No conflicts: main's chat-surface work (the in-flight tool work in ChatFormat,
ChatStore and ChatTranscript, run notifications, the status palette) sits in
different hunks from this branch's fan-out edits, and main did not touch
docs/cli.md. Checks re-run on the merged tree: gofmt -l . (clean), go build ./...,
go vet ./..., go test -count=1 ./... (all packages pass; the focused multi-client
tests fan-out, per-session serialisation, first-answer-wins, pending replay and
resync pass), and the Android unit tests
(gradle --offline --no-daemon :app:testDebugUnitTest, BUILD SUCCESSFUL, 598 tests,
0 failures).
2026-10-18 00:10:15 +01:00
alan 6cb61578de Fan a chat session out to every client and share approvals exactly-once
A session was owned by one connection: the claim map in chat_claims.go let the
first client hold it, every other client saw the session Busy and read-only, and
a second client's prompt was rejected. Replace the claim with a per-session
"room" so the operator's phone, tablet and terminal all watch and write the same
conversation, and a pending approval is a shared, exactly-once object.

Server (internal/server, internal/protocol):
- New chat_room.go: one room per session holding the session's single broker
  stream, its one bounded prompt queue (8) and the fan-out to every attached
  client. A chat_subscribe frame attaches a connection to a session's shared
  stream and replays the still-unresolved approval requests the room holds.
- chat_stream.go: handleChatPrompt accepts a prompt from any client. It attaches
  the sender, either starts a turn or queues the prompt behind the in-flight turn
  and acknowledges it with chat_queued:true ("queued" is the chosen behaviour,
  stated on the wire and in docs/cli.md), and echoes the user turn to every other
  client attributed to the sender's label. The prompt handler no longer owns the
  stream; one turn runner per room drains the queue, so two turns never
  interleave. Per-connection write serialisation is unchanged (each chatSub has
  its own writer goroutine and bounded buffer).
- chat_permissions.go / chat_commands.go: an approval is reserved by the first
  answer and confirmed once delivered; the first answer wins, is recorded with
  the answering client's label, and the resolution is pushed to every watching
  client as chat_permission with resolved/decision/resolved_by so their cards
  clear. A later answer is refused with an error naming the client that answered,
  and never reaches the agent twice; a reservation whose reply failed is
  released.
- chat_hub.go / chat_sessions.go / chat.go: the hub now owns rooms and the
  user-turn id sequence; the resulting user turns are retained (role and client
  carried) so a reconnect re-syncs who said what. chat_sessions no longer marks a
  session Busy and its clientID parameter is gone; the protocol keeps the Busy
  field for wire compatibility only. websocket.go detaches a connection's chat
  subscriptions when the read loop ends.
- chat_claims.go is removed, not left vestigial: the only exclusive thing left is
  a turn, and the room's queue is that.

App (android):
- PipelinesRepository carries a stable per-device client label (Build.MODEL, with
  a fallback) on prompts and replies, and adds chatSubscribe; AppViewModel
  subscribes on opening a chat (best-effort, an older server's error frame does
  not stop history loading) and records the queued ack.
- ChatStore folds a user frame from another client into the transcript once,
  attributed by the sender's label, and never receives its own prompt back, so
  the sender's own message is never duplicated. ChatThread.readOnly is gone:
  canSend no longer depends on another client, the composer says "Queued - it
  will send when the current turn finishes." instead of disabling input, and the
  status label is Running/Idle only. Scroll/follow behaviour is untouched.
- Tests: ChatProtocolTest round-trips the new wire fields, ChatFormatTest asserts
  the stale Busy flag cannot produce a read-only label, MultiChatStateTest asserts
  a session another client watches stays writable.

Reflected where it belongs: no packaged template changes (no bundled starter
embeds the chat protocol). Checked the packaged authoring skill references: none
of them describes the chat wire beyond operations.md, and
internal/author/skill/references/operations.md is now stale - its "Brokered
OpenCode chat" section still says chat_sessions marks "busy" when another client
holds the session and that a second client's chat_prompt is rejected, and it does
not mention chat_subscribe, the per-session prompt queue/chat_queued, the
per-client label or the shared exactly-once approval (it also still describes the
per-subscription permission poller, which the room's single poller replaced). The
supported semantics are the ones in docs/cli.md, updated in this commit; the
operations.md section needs a rewrite to match. No README or other shared
document was edited here.

Checks run on the committed tree: gofmt -l internal cmd examples (nothing), go
build ./..., go vet ./internal/... ./cmd/..., go test ./internal/server
./internal/protocol ./internal/stage ./internal/pipeline.
2026-10-18 00:09:14 +01:00
alan f339503f68 Merge branch 'main' into session-activity 2026-10-18 00:05:10 +01:00
alan 597c7b5e76 android: show a chat's in-flight tool work instead of a bare Running
A session said "Running" with an empty tool chip while it worked, so a silent
wait was indistinguishable from a stuck one. Derive the in-flight work from the
stream the app already folds and show it on both surfaces.

- ChatFormat: runningToolCalls() reads the tool parts still running, in
  transcript order, so the conversation and the session row share one set;
  toolDetail() takes the command/description the part actually carries (the
  first of description/command/filePath/file_path/path/pattern/query/url),
  collapsed to one line and elided at 72 chars, and returns null rather than a
  fabricated summary; runningToolElapsedMillis() uses the protocol's own
  time.ran/created when present and the local per-part stamp otherwise;
  runningToolStamps() keeps a stable start per part across frames;
  TOOL_LONG_RUNNING_MILLIS (60s) and toolLongRunning() mark an unusually long
  call; sessionWorkLabel() names what a working session is doing while a
  text-streaming turn stays plain "Running" and a busy session never reads
  "Idle".
- ChatStore: ChatThread gains toolStartedAt, stamped when a part turns running
  and dropped when it settles, plus runningTools/toolElapsedMillis; history()
  and the frame fold maintain it; setRunning/turn end clear it.
- ChatTranscript: RunningIndicator lists one line per running call (name,
  detail where present, live elapsed) keyed by part id so concurrent calls
  render together without flicker; no percentage, ETA or progress bar.
- ChatListPane: the session row renders sessionWorkLabel(busy, thread).
- ChatRunningWorkTest covers name/detail/elapsed, clear on completion, error
  state, concurrent calls and the no-detail stream.

Only fields the harness reports are used: tool name, state.status and input;
the live brokered frame carries no timing envelope, so elapsed falls back to the
local stamp. Existing chips, INPUT/OUTPUT, reasoning blocks, stop control,
activity marks and scroll/follow behaviour are untouched.

Checked and unchanged: no packaged template or packaged authoring-skill
reference describes this app surface (the chat references in
internal/author/skill/references/ document the server's brokered chat_* protocol,
which this change does not touch), so none is stale. android/AGENTS.md already
names ui/chat/ and its files. The shared documents this change does make stale
are recorded, not edited, in docs/notes/chat-in-flight-tool-work.md: the
Running-indicator and session-status statements in android/README.md.
2026-10-18 00:05:07 +01:00
alan 87856eaaf0 android: complete the status-palette port onto main's tree
The recovered commit gave every status one colour, but it predates main's split of the run
view and main's own cyan 'waiting' colour. Resolution: keep main's Waiting, keep the run
view's own file (main already has RunSummaryTab), and carry the parts that were genuinely
missing - RunState.Blocked and RunState.Skipped with their words, glyphs and one colour
each - so the palette and the enum agree.
2026-10-18 00:03:29 +01:00
alan 8411d47b29 android: colour every status from one palette
A successful stage read amber in the Timeline because a visit's chip was
coloured from the graph's outcome palette (`graphColors`/`outcomeColor`) while
every other surface used the run-status palette, so the same word meant two
colours. This makes `RunStatusPalette` the single source of truth:

- `RunState` gains the server's own `Waiting`/`Blocked`/`Skipped` words, each
  with a deliberate palette entry, a distinct material glyph and a label, so a
  status is never colour alone and success is green / failure red everywhere.
- `graphColors()` takes success/error from `runStateColor(Succeeded/Failed)`;
  `outcomeColor()` returns the shared status colour for any word that resolves
  to a `RunState` and leaves `GraphPalette` only the graph-only flow outcomes
  (`rejected`/`exhausted`/`retry`/`approved`/`fast`/`missing`; `blocked`/
  `skipped`/`done` removed). The Timeline's `TimelineRow` uses the same factory.
- A visit's *outcome* stays distinct from the run's *status* by the chip's own
  label and the row's state glyph, never a second colour.
- The runs-list failure diagnostic uses `runStateColor(Failed)` instead of a
  scheme role that could drift from the chip above it; the status filter gains
  `waiting`.

Tests: new `StatusColorConsistencyTest` (timeline colour comes from the runs-list
source; every state maps to exactly one colour) and extended `GraphPaletteTest`/
`RunStatusTest`. `gradle --offline --no-daemon :app:testDebugUnitTest
--rerun-tasks` -> 516 tests, 0 failures, 0 errors, 0 skipped.

Docs check: the root README and docs/ do not describe the Android status
colours; the packaged templates and internal/author/skill/references cover the
authoring surface and are unrelated, so nothing there needed updating.
android/README.md did enumerate the run states and claimed the graph outcome
palette was unchanged, so its features bullets were updated and a new "One status
colour everywhere" section added, with the old bullet marked superseded.

APK published to the run's artifacts as pipelines-debug-wip-d13f359.apk.

(cherry picked from commit a3caa734cd4769f42883b518d877dd0132ef57ae)
2026-10-18 00:00:31 +01:00
alan c7f009d850 Merge main into notif: combine the run notifications with main's chat reasoning grouping
Brings this branch up to main (73284ff) so it can be merged back without
conflict. Main's two chat commits (ChatFormat/ChatTranscript reasoning into
one collapsible block) do not touch any of the notification files, so the
merge was clean with no conflicts to resolve. The merged tree keeps both
intents unchanged.
2026-10-17 23:56:52 +01:00
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 ec6a350a17 Group a chat turn's reasoning into one collapsible block
The chat rendered every reasoning part as its own ReasoningBlock, so a turn
that reasoned several times stacked several thinking boxes between messages.
This folds a turn's reasoning parts into a single collapsible entry, anchored
where the turn's first reasoning part sits, so a streaming turn grows the
block it has instead of gaining another.

- ChatFormat.kt: add ReasoningTurn / turnReasoning (the ordered fold of a
  turn's reasoning parts), reasoningLabel (counted wording for >1 steps, plain
  one-block wording otherwise) and turnElapsedMillis (elapsed from the turn's
  own part timing envelopes, null when unknown). ReasoningExpansion is now
  keyed by the turn's message id via reasoningTurnKey rather than a per-part
  key.
- ChatTranscript.kt: AssistantParts renders exactly one ReasoningBlock per
  turn (first reasoning part wins the anchor); the collapsed line reads
  "Thinking · N steps"/"Reasoning · N steps" when the turn reasoned more than
  once, else "Thinking…"/"Reasoning", with elapsed time appended when known.
  Streaming elapsed is driven by thread.runningSince so it matches the running
  indicator. The answer, tool chips, diff cards, attachments and approval
  cards are untouched.
- Tests: ChatTranscriptTest exercises the turn-keyed expansion; new
  ChatReasoningTurnTest covers the fold (several parts -> one entry in order),
  the collapsed wording, elapsed derivation and a streaming turn appending
  into the same entry.

Checked for stale packaged artefacts: none needs updating. The packaged
authoring skill references (internal/author/skill/references/) document the
protocol (reasoning deltas, cost/token budgets), not the Android transcript
rendering, so nothing there describes per-part thinking blocks. No packaged
template mentions reasoning rendering. Shared docs / the Android area map are
left to the single documentation writer; nothing here changes documented
behaviour beyond the transcript fold.

Verified with the Android toolchain (no daemon): :app:testDebugUnitTest passes
567 tests, 0 failures, 0 errors, including ChatReasoningTurnTest (5),
ChatTranscriptTest (7) and DimensTest (2). No new raw geometry literals.
2026-10-17 23:46:00 +01:00
alan a2a64931eb Merge main into sweep-ui: combine the UI sweep fixes with main's per-area agent maps
Main adds only documentation (per-area agent maps for the Android app, the TUI
and the server); the sweep-ui side holds the UI/UX sweep fixes. No overlapping
files, so both intents are kept unchanged.
2026-10-17 23:28:02 +01:00
alan 2e9ba100bd Fix UI/UX sweep findings across the Android app
Addresses the survey/review findings on the sweep-ui branch, reusing the
app's existing patterns and named tokens (DetailTabBody, formatLocalTimestamp,
stageCountText, ATTENTION_CHIP_RESERVE) rather than hardcoding values.

Fixed findings:
- n:1  attention-chip reserve (OmniSearchResults, ATTENTION_CHIP_RESERVE in
       Dimens, PipelinesApp bottom content reserve).
- n:2  formatted local timestamps via the shared Format.formatLocalTimestamp
       (PipelinesApp lists, RunHistory, RunSummaryTab, PipelineDetail).
- n:3  decodeHtmlEntities for the session export's HTML entities (Markdown),
       with regression cases for entities and a bold-only line.
- n:4  Raw/Rendered control now labels the current view and its state
       (SourceView).
- n:5  filters as a Material modal bottom sheet capped at a window-derived
       filterMenuMaxHeight with a scrolling body (FilterMenu), plus tests.
- n:7  stage-count wording via the shared stageCountText helper.
- n:8  labelled key row on the template detail screen.
- n:9  stage pane de-duplicates identity / folds the definition.
- n:10 wide-flag plumbing into the destination lists and ChatListPane, which
       now wraps its session list in DetailTabBody(wide, ...) so wide rows keep
       DETAIL_MAX_WIDTH_DP centred.
- n:13 Settings: Disconnect is the filled primary while connected and the
       trust warning moved into a surfaceVariant card.
- n:15 CodeBlock bounded height plus a scroll affordance with an unbounded
       option.

Deferred findings (with reason):
- n:3  (Chat transcript) residual is server-side data: chat_messages returns a
       single assistant part whose text is already interleaved/doubled, so the
       renderer cannot close it. The android half (entities/Markdown) is fixed.
- n:6  Runs list titles arrive truncated to 80 chars mid-word from the server.
- n:11 Two-pane top-band layering is a product/design decision.
- n:12 48dp graph-node hit targets and label dodging are product decisions.
- n:14 The session-list chip is OpenChatStrip (open chats), not a list filter;
       relabelling it would misdescribe it.

Commands: :app:compileDebugKotlin + :app:testDebugUnitTest (562 tests, 0
failures) and :app:assembleDebug all succeed.
2026-10-17 23:27:57 +01:00
alan a4cf7366dd docs: per-area agent maps for the Android app, the TUI and the server 2026-10-17 22:56:17 +01:00
alan 5e2aece1be android+server: make every view live from the pushed run events
The pipelines list (and every other run-state view) kept the row it had when
the screen was last fetched. Two class-level root causes, fixed here:

- The app subscribed to run events scoped to the one workspace the operator
  configured, so a run executing in another workspace (a lane worktree is its
  own workspace) never delivered a frame: the rows only changed on a manual
  refresh. The app now asks for the blank "any workspace" scope the server
  already treats as any (ALL_WORKSPACES in AppViewModel.subscribeRuns, blank
  default on PipelinesRepository.subscribeRuns). Workspace isolation on the
  server is unchanged: an explicit workspace scope still matches only that
  workspace (TestRunEventWorkspaceIsolation); the new
  TestRunEventAllWorkspacesSubscription pins the blank "any" scope.
- foldRunEvent refused to insert a run the list had never held, returning
  needsResync and leaving the list untouched, so a run started after the
  screen loaded appeared only after a fetch. The pushed frame now carries the
  pipeline identity a row needs (RunEventFrame.PipelineID/Name/Title/Version),
  so the fold inserts the new run at the head from the frame's own identity
  without a fetch and without reordering existing rows; a server that predates
  those fields still falls back to the one resync. Added fields and why each
  is needed: pipeline_id (row's pipeline join), name (row title), title (the
  stored operator-facing title a row shows), version (the row's pinned
  version) - everything a RunSummary row renders, so no per-event fetch and no
  guess from stale cache. The server stamps them on every emitted frame from a
  per-run identity remembered at create/decide/cancel/resume (runner.go
  runIdentity/rememberRunIdentity/stampRunIdentity), first-write-wins through
  the coalescer (mergeRunEventFrame) and on the subscribe snapshot, so every
  transition - created/queued, running, each stage start/finish, terminal -
  carries them. Reconnect still resyncs once then follows pushes; the
  pull-to-refresh path is untouched.

Checks run: go build ./..., go vet ./..., go test ./... (all packages ok),
go test -race -run 'RunEvent|RunEvents|Subscribe' ./internal/protocol/
./internal/server/, and gradle --no-daemon testDebugUnitTest assembleDebug
(558 tests, 0 failures, 0 skipped; BUILD SUCCESSFUL).

Packaged templates and the packaged authoring skill references were checked:
nothing there describes the run_event field list or the client's subscription
scope, so neither needs updating (references/notifications.md only says the
attention surface is derived from the pushed run events, which is unchanged).
Docs are a shared file owned by a single writer and were not edited:
docs/cli.md's description of the pushed `run_event` frame still enumerates
only the older fields (status, outcome, current stage, completed-step count,
timestamps, optional step) and is now incomplete - it should mention the
pipeline identity fields; docs/ntfy.md remains accurate.
2026-10-17 20:20:05 +01:00
alan 752e761837 android: read a stage's exported session from the run view
Add a Session section to the stage detail that appears only when the visit's
session export actually wrote a file, beside the artifacts it was written with,
and opens the transcript on a click like any artifact.

- Derive the section from the recorded `session_export` matched against the
  step's artifact listing (`sessionExportFiles`), so a visit with no export - a
  non-OpenCode harness, an export failure, or a pre-export server - lists no
  empty section, mirroring internal/protocol/runs.go and the server's export.
- Default to the markdown export rendered with the app's existing markdown
  renderer (new lazy `MarkdownBlocks` reusing `MarkdownBlock`), and when both
  files exist offer the html export through an "HTML view" toggle in a WebView
  for fidelity; html is the default only when markdown is absent.
- Behave like the artifacts around it: the same Scaffold/TopAppBar/back chrome,
  the shared ArtifactBytesCache so the file is fetched once and never loaded
  twice, decode/parse off the main thread so a several-hundred-kilobyte session
  stays responsive in a lazy block list, and a failed fetch shown as its own
  in-pane error without hiding the other sections.
- `SessionExport` protocol model and `RunStep.session_export`, with the
  unit tests for section presence, fetch/render, fetch failure isolation and a
  large session.

Checked the packaged templates and the packaged authoring skill references: the
session export's server-side behaviour is already documented in
references/delivery.md and references/operations.md (landed with the server
change), and no packaged reference or template describes the Android stage
pane's sections, so none of them needs updating for this client-only change.

Verified before commit (recorded by the independent code review on this tree):
compileDebugKotlin, testDebugUnitTest (forced rerun) and assembleDebug all
BUILD SUCCESSFUL, 554 tests / 0 failures across 61 classes, SessionExportTest
9/0/0.
2026-10-17 19:55:56 +01:00
alan 9f7c4a8c77 Split the run view and the app shell into files by concern
Pure move of two oversized Android UI files into smaller files by concern,
with no behaviour change:

- RunDetailScreen.kt 847 -> 342: the run header and ConfirmDialog stay; the
  five run tabs move out to RunSummaryTab.kt, RunGraphTab.kt,
  RunFieldSectionsTab.kt, RunEvidenceTab.kt and RunTimelineTab.kt.
- PipelinesApp.kt 1003 -> 405: the shell/scaffold, NavHost and hoisted state
  stay; the destination pill and the three destinations move out to
  DestinationBar.kt, PipelineDestination.kt, RunsDestination.kt and
  TemplatesDestination.kt.

Same package, same composable names and signatures, same call graph and
rendering. The only textual edits are eleven private -> internal visibility
widenings on declarations now called across the new file boundaries. No
strings, colours, spacing tokens, tests or entry points changed.

Verified with `gradle :app:assembleDebug --no-daemon` (BUILD SUCCESSFUL) and
`gradle :app:testDebugUnitTest --no-daemon` (545 tests, 0 failures, 0 errors,
0 skipped).

Checked packaging that could go stale with this change:
- internal/author/skill/references/ (the packaged authoring skill references):
  none mention these files or any Android UI symbol, so nothing to update.
- packaged templates: not touched and none reference the split files.
- android/README.md: its historical prose still names some now-stale file
  locations; left unedited because the shared documentation is folded by a
  single writer and this commit's job is the move itself.
2026-10-17 17:10:10 +01:00
alan 70270fa90e Split the chat conversation screen into files by concern
Move ui/chat/ChatScreen.kt (1864 lines) into ten files by concern with no
behaviour change: ChatScreen.kt keeps the destination and the shared chat
geometry tokens (84 lines); ChatListPane, ChatCreatePane, ChatOpenStrip,
ChatConversationPane, ChatTranscript, ChatComposer, ChatToolCalls,
ChatDiffCard and ChatApprovalCard take the session list, new-chat picker,
open-conversation strip, conversation header, transcript, composer, tool
chips and the cards.

Pure move: same package, same composable names and signatures, same call
graph. The only substantive edits are per-file imports and private->internal
widenings needed for the cross-file calls; review confirmed identical
declaration sets and an equal line multiset. :app:assembleDebug and the full
unit suite pass (545 tests, 0 failures, 0 skipped) and the built APK is
byte-identical (same sha256) to the published artifact.

Checked before committing:
- Packaged templates: this repository carries no packaged template tree, so
  nothing to update.
- Packaged authoring skill references (internal/author/skill/references/):
  none reference the chat UI internals; nothing to update.
- android/README.md still cites ChatScreen.kt inner declarations
  (ChatScreen.MessagePart, rememberElapsedMillis, ChatConversationPane) that
  this move relocated; left unedited for the single documentation writer.
2026-10-17 16:56:19 +01:00
alan 1752351dbc Merge main into lane-app2: combine the pill standdown with main's run-title and conversation work
Brings main (c5b0de1) into the pill-standdown lane. Main added the whole-title
run view / two-line list rows (RunIdentity, RunTitlesTest) and the readable
conversation work (ChatFormat, ChatScreen, ChatStore, ChatTranscriptTest). Those
are disjoint from this lane's destination-pill change, so the Kotlin sources
auto-merged; only android/README.md conflicted, where both sides appended a new
dated section to the end of the item log.

Resolved android/README.md by keeping both intents: the lane's "Destination pill
stands down in an open conversation" section and main's "Run title readability"
section are both retained, in that order. No conflict marker remains and nothing
from either side was discarded.

Verified after resolving: gradle :app:testDebugUnitTest --offline --no-daemon ->
BUILD SUCCESSFUL, 60 suites / 545 tests / 0 failures / 0 errors / 0 skipped; and
gradle :app:assembleDebug --offline --no-daemon -> BUILD SUCCESSFUL.
2026-10-17 16:27:05 +01:00
alan 3e14baebd7 android: stand the destination pill down in an open chat conversation
The floating destinations pill was drawn over the bottom of every screen,
including an open chat, where it sat on the composer and the newest message
and competed with the send/stop controls. It now stands down while the Chat
destination shows an open conversation and stays everywhere else, unchanged.

- One rule: `destinationPillVisible(currentRoute, conversationOpen)` is false
  only for `chat` with an open conversation. `conversationOpen` is the new
  `AppViewModel.conversationOpen`, a distinctUntilChanged boolean derived from
  the same ChatStore the chat surface renders, so a background chat never hides
  the pill elsewhere and a streamed delta never recomposes the app shell.
- The space, not just the pill: `destinationPillReserve(pillVisible)` returns
  the named DESTINATION_PILL_RESERVE while drawn and 0.dp while hidden, so the
  content Column clears a drawn pill and leaves no empty band when it is gone,
  and no frame reserves a gap behind a hidden pill or draws one over content it
  does not clear. Keyboard-open and the IME padding are unchanged.
- Escapability untouched: the top-bar "Back to chats" arrow, ChatScreen's
  PredictiveBackHandler and SlidingPaneStack.onPopTo remain the way out.
- No other pill behaviour changed: destinations, selection indicator,
  morph-into-search and every other screen are as before.

Checked for staleness: none of the packaged templates or the packaged authoring
skill references (internal/author/skill/references) mention the destination pill,
so no template or reference needed updating for this Android-only change.

Tests: PipelinesNavTest gains thePillStandsDownOnlyWhileAConversationIsOpen and
theReserveTracksTheDrawnPillSoContentNeitherJumpsNorLeavesAGap.
2026-10-17 16:25:22 +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 c5b0de15ba Merge lane-chat4: keep run-title readability and the waiting human decision
Merge lane-chat4 (d13f359, "make a run's title readable: whole in the run
view, two lines in the list") into main (cd87982, "answer a run's waiting
human decision from the phone"). Both intents are kept.

Conflict resolution:
- android/README.md (the only conflicted path): kept both sections, HEAD's
  "Answer a waiting human decision from the phone" first and lane-chat4's
  "Run title readability" second, with nothing removed. Each heading appears
  exactly once.
- StageDetailPane.kt and RunDetailScreen.kt were changed on both sides and
  auto-merged: the staged tree carries the incoming title line budgets plus
  the local DecisionPrompt wiring (the stage pane surfaces a decision only
  for its own stage; the run detail surfaces it above the tabs).
- The remaining incoming files (RunIdentity.kt, RunHistoryScreen.kt,
  RunIdentityTest.kt, RunTitlesTest.kt) and the local files are one-sided and
  taken whole. The staged tree differs from HEAD by exactly the incoming
  diff and from MERGE_HEAD by exactly the local diff, so no side was dropped
  or duplicated.

Checks (JDK 17, ANDROID_HOME=/Users/alan/Library/Android/sdk, Gradle 9.7.1
--no-daemon --offline):
- gradle :app:testDebugUnitTest :app:assembleDebug -> BUILD SUCCESSFUL.
- 59 result XMLs aggregate to 530 tests, 0 failures, 0 errors, 0 skipped;
  RunTitlesTest 4/0 and RunIdentityTest 6/0.
No conflict markers remain.

Staleness check: the incoming work is android/-only. android/README.md is
the topic doc and now carries both sections; no packaged template, the repo
README, the other topic docs, or the packaged authoring skill references
describe this run-title UI, so none needed updating (the delivery reference's
Android build/publish example is unchanged and still accurate).
2026-10-17 16:00:11 +01:00
alan d13f359e7b android: show the run title whole in the run view, two lines in the list
A run's title is derived from its prompt, so it is often long. Give it the
room it needs where the operator reads the run, and a deliberate clamp where
it is one of many. Android only; no new dependency (the declared
material-icons-extended only), no Pipelines server/Go/installer/Docker file
touched, and no run started from the app.

- Run view shows the whole title. The run-summary title line states its
  intent with RUN_VIEW_TITLE_LINES (Int.MAX_VALUE) and TextOverflow.Clip, so
  it wraps over as many lines as it needs and is never ellipsised; the
  fixed-height M3 app-bar copy stays a compact one-line label.
- Runs-list rows grow, then clamp. RunRow's title went from maxLines = 1 to
  RUN_ROW_TITLE_LINES (2): a longer title takes a second line before it
  ellipsises, with the glyph, status chip and meta line still aligned and the
  selection highlight and tap target unchanged.
- Stage-pane context line. StageDetailPane's run-label line went from
  maxLines = 1 to STAGE_RUN_LABEL_LINES (2); the pane is compact context, not
  where the whole title lives.
- Named budgets. ui/RunIdentity.kt holds the three budgets so the choice is
  deliberate at each call site. RunTitlesTest (4 cases) pins them and asserts
  a clamping place is never more generous than the run view; RunIdentityTest
  gained a case that runLabel/runIdentity never shorten a long title.

Checked for stale copies: android/README.md gained a dated section for this
change (its existing "Run title beside the pipeline name" section still holds,
it just did not describe line budgets). The top-level README and docs/ do not
document the app's run-title rendering, and the packaged templates and
internal/author/skill/references/ packaged skill describe Pipelines authoring
and Android APK delivery, not this UI, so none of them needed updating.

Evidence (JDK 17, Gradle 9.7.1 --offline --no-daemon): :app:testDebugUnitTest
BUILD SUCCESSFUL, 57 classes / 513 tests / 0 failures / 0 errors / 0 skipped
(RunTitlesTest 4/0, RunIdentityTest 6/0); :app:assembleDebug BUILD SUCCESSFUL,
app-debug.apk 18,486,624 bytes sha256 2b23762b54f0..., published as this run's
pipelines-debug-wip-2bc00a2.apk and served at
http://10.0.0.75:8080/artifacts/278/4/pipelines-debug-wip-2bc00a2.apk.
2026-10-17 15:49:55 +01:00
alan cd87982a63 Merge lane-app2: keep the lane's reviewed work
Combine the reviewed Android work already on main (conversation reading:
markdown, collapsed reasoning, one identity) with the incoming lane's
"answer a waiting human decision from the phone" change (the waiting
run/step sync, HumanDecision/DecisionPrompt, the decide_run envelope and
the waiting RunState) over merge base d48175a.

The only conflicted file, android/README.md, now carries both sections
exactly once ("Conversation reading: markdown, collapsed reasoning, one
identity" and "Answer a waiting human decision from the phone") with no
bullet or paragraph dropped. The auto-merged Kotlin tree carries both
features; no conflict markers, duplicated blocks or dead code remain. The
resolution also restored the blank line between the two README sections.

Verified on the merged tree (JDK 17 from Homebrew openjdk@17,
ANDROID_HOME=/Users/alan/Library/Android/sdk, offline, no daemon):
- gradle :app:testDebugUnitTest --rerun-tasks -> BUILD SUCCESSFUL; JUnit
  XMLs total 58 suites / 525 tests / 0 failures / 0 errors / 0 skipped.
- gradle :app:assembleDebug -> BUILD SUCCESSFUL;
  app/build/outputs/apk/debug/app-debug.apk present (18,519,392 bytes).

Docs check: android/README.md records the resolved change. No packaged
template, README/topic doc or packaged authoring skill reference describes
the Android decision surface or changed as a result, so nothing there
needed updating. Nothing was deliberately left uncommitted.
2026-10-17 15:47:04 +01:00
alan f782c51c18 android: answer a run's waiting human decision from the phone
A human stage parks its run on a person, and the terminal client could answer
it while the app had no decide request at all. This adds the missing piece so a
waiting run is answerable from the phone.

Protocol/repo:
- PipelinesRepository.decideRun sends the same `decide_run` request the CLI and
  TUI build: stage (optional; the server infers it), option, optional feedback,
  with the exact wire names internal/protocol/message.go declares. Message gains
  the stage/option/feedback fields; no second mechanism is invented.
- A waiting run/step now forces the existing push-driven full get_run
  (runDetailNeedsFullSync), so the waiting step's recorded options/prompt
  surface live with no refresh and no server field added.
- RunState.Waiting (label "waiting", FrontHand glyph, violet palette entry)
  makes the waiting state honest in the list and summary.

UI:
- DecisionPrompt is the one shared surface: a "Waiting for your decision" card
  with a deliberate Decide action, plus the sheet showing the run and waiting
  stage, the author's instructions, every option as written with the label it
  routes to, an optional feedback field, and a Confirm decision button that is
  disabled until an option is chosen. It sits above the run detail's tabs and at
  the top of the waiting stage's pane, reachable from where the operator already
  is.
- Answering applies the returned run detail immediately, so the new stage shows
  without a manual refresh. A refusal keeps the sheet open with the server's own
  message verbatim and silently re-reads the run rather than faking success.
- Pure helpers pendingDecision, DecisionOption, DecisionDraft (the confirm gate)
  and decisionRefusalMessage; Tests: HumanDecisionTest and DecisionTest (13 new)
  plus waiting cases in RunEventsTest and RunStatusTest.

Scope: android/ only. No server/Go/installer/Docker change, no new dependency
(the glyph is from the already-declared material-icons-extended), no run started
from the app, no adb or device use.

Reflected where it belongs: android/README.md gained the dated feature section
for this change. Checked and needing no update: the packaged pipeline templates
(the change touches no pipeline definition), the repository's top-level README
and docs/ topic docs (none enumerates the app's operations or the decide
protocol; the TUI/CLI wording they carry is unchanged), and the packaged
authoring skill references (the decide protocol is unchanged and already
documented; no reference describes this app surface).
2026-10-17 15:38:58 +01:00
alan bd6a89d914 Merge lane-chat4: keep the lane's reviewed work
Combine the reviewed chat work already on main (session model in the
header, agent mirroring, chatHeaderMeta, tagged-label intent) with the
incoming lane's "make the conversation readable" change (markdown/part
rendering, collapsed reasoning, one conversation identity,
openChatsBeside, ChatTranscriptTest) over merge base 5ac196c.

Both intents survive in every conflicted file: android/README.md,
ChatFormat.kt, ChatScreen.kt (session header and conversation header),
ChatStore.kt and the new ChatTranscriptTest.kt. No conflict markers or
duplicated blocks remain.

Verified on the merged tree (JDK 17, ANDROID_HOME=/Users/alan/Library/Android/sdk,
offline, no daemon, --rerun-tasks):
- gradle :app:assembleDebug -> BUILD SUCCESSFUL
- gradle :app:testDebugUnitTest -> BUILD SUCCESSFUL; JUnit XMLs total
  512 tests, 0 failures, 0 errors, 0 skipped (7 in ChatTranscriptTest).

Docs check: android/README.md already records the resolved change, and no
packaged template, README/topic doc or packaged authoring skill reference
describes the Android chat surface, so nothing there needed updating.
2026-10-17 15:32:00 +01:00
alan 2bc00a2a94 android: make the conversation readable — markdown, collapsed reasoning, one identity
Fix the three reading problems in the chat conversation view. Android only;
no new dependency (the declared material-icons-extended only); no server,
Go, installer or Docker file touched and no run started from the app.

- Markdown reaches the transcript. Assistant text already went through
  MarkdownText inside a private composable; name the decision as the pure
  ChatFormat.partRendering(part) (MARKDOWN/REASONING/PLAIN/HIDDEN) and have
  MessagePart consume it. Text outside the renderer's documented subset and
  unknown part kinds still render as their own text (PLAIN); blank parts
  render nothing (HIDDEN).
- Reasoning collapsed by default. ReasoningBlock is now one compact, muted
  line per part (icon, label, chevron) that expands on tap to the muted
  text. Expansion is hoisted to the conversation pane as the pure
  ReasoningExpansion set keyed per stable part key, so a part keeps its
  state across scroll/disposal and every part starts collapsed in a newly
  opened chat. A running turn's streaming reasoning stays collapsed under a
  live "Thinking…" label, signalling progress without competing with the
  answer.
- One identity in the header. ChatFormat.conversationHeader(thread) builds
  the app-bar title plus only context (labelled kind chip from the server
  tag, activity, directory, model); the app bar and the context line read
  the same value. openChatsBeside drops the active chat from the open-chat
  strip so its title is shown once; every other open chat stays one tap
  away and the session list is unchanged.

Tests: new ChatTranscriptTest (7 cases) plus the existing ChatFormatTest —
the markdown subset reaches the renderer from a ChatPart, text outside the
subset and an unknown kind still render, reasoning starts collapsed and
toggles per part, the header names the session once, and the strip offers
only the other open chats.

Checked, and none needs an update: the packaged templates carry no Android
chat surface; the repository guidelines (README, docs/) document the server
and CLI, whose behaviour is unchanged — docs/cli.md's note that Android
rendering of the tag is out of scope for the server change still holds; and
the packaged authoring skill references (internal/author/skill/references/)
describe delivery/verification generally, none of which this UI change
alters. android/README.md records the new behaviour.

Verified: `gradle :app:testDebugUnitTest :app:assembleDebug --no-daemon
--offline --rerun-tasks` → BUILD SUCCESSFUL; JUnit XMLs total 508 tests, 0
failures, 0 errors, 0 skipped. app-debug.apk sha256
0df6899429a8f5632ec568340dddb63a5617b1a04af19f52c6ebb793470a0b23.
2026-10-17 15:14:52 +01:00
alan 9b67e55d70 chat: name the session's model in the conversation header
The conversation header showed only the thread title, so inside a chat there
was nothing saying which model was answering. It now renders a second line
from server-reported values only.

- ChatFormat.kt: add chatHeaderMeta(thread), joining the reported model, the
  session's kind tag and the directory with " · "; blank parts are omitted so
  no model is ever claimed when the server did not report one. Refactor
  sessionTagLabel to a tag-value overload so the list row and the header share
  one tag mapping.
- ChatStore.kt: ChatThread gains the tag field; sessionsLoaded and open fold
  the server's model/agent/tag into already-open threads, and ensureThread
  seeds them, so the header never shows a stale or missing model.
- ChatScreen.kt: the conversation top bar title becomes a two-line column with
  the meta line in the shared pipelinesText().meta role; the create flow states
  plainly that this server has no request for choosing a chat's model.
- No model chooser is shipped. The server forwards no model/agent on
  chat_prompt and exposes no model/agent catalogue, so shipping a picker would
  be a control that does nothing; android/README.md records the exact server
  change it would need.
- Tests: ChatFormatTest covers chatHeaderMeta (reported model/tag/directory,
  and never claiming an unreported model) and the shared tag mapping;
  ChatSessionManagementTest covers the open thread carrying the reported
  model/agent/tag and a list refresh folding a new model in.

Checked before committing:
- Packaged templates: none exist (the author package embeds only skill/SKILL.md
  and references/*.md; no *.tmpl/*.template in the tree) - nothing to update.
- Repository guidelines: android/README.md updated with the change and its
  evidence; the root README and docs/ describe the server and CLI, not the
  Android chat surface - no update needed.
- Packaged authoring skill references (internal/author/skill/references/): none
  describes the Android chat surface - no update needed.

android/ only, no new dependency beyond the declared material-icons-extended.
2026-10-17 15:03:00 +01:00
alan 355fe4e908 chat: search the session list and group it by directory
With a day's sessions the list was a flat, unsearchable wall in recency
order, so the chat the operator wanted was the one that could not be
found, and sessions of one repository were scattered through it.

Narrow the list as the operator types and keep same-repository chats
together, using the control and empty-state patterns the other lists
already use:

- ChatListFilter.kt adds the one pure derivation: sessionMatchesQuery /
  filterChatSessions match a case-insensitive substring over a session's
  title and directory, a blank query narrows nothing, and the survivors
  keep their incoming (recency) order. groupChatSessionsByDirectory groups
  the narrowed list by directory, each group keeping that order and the
  groups ordered by their first (most recent) session, so the top still
  leads with the newest activity.
- ChatState.sessionQuery (set through ChatStore.searchSessions /
  AppViewModel.setChatSessionQuery) is a display narrowing only: the
  server's list, open conversations and the activity marks are untouched.
  filteredSessions is visibleSessions narrowed by the query.
- ChatListPane renders the existing FilterMenu with one OutlinedTextField
  and a Clear search reset (the pipelines/runs filter pattern), shows a
  directory heading per group only when more than one directory is
  present, and renders the shared EmptyState ("No chats match ...") with
  a Clear search action when nothing matches. The trailing New chat
  action is never hidden while the list is narrowed, and every row still
  shows its directory.

Tests (ChatListFilterTest, 9 cases): the match rule over title and
directory, that a narrowing preserves the recency order, grouping by
directory (order by the first session, order kept inside a group, a
single directory yields one group, a blank directory groups too), and
through the store that searching narrows filteredSessions, clearing
restores the full list, the server's list is untouched and a filtered
session still reports its activity mark.

Checked before commit: android/README.md was updated in this change with
the behaviour, tests and evidence. The packaged authoring skill references
(internal/author/skill/references/) document the Pipelines server, its
chat_* protocol surface and authoring, none of which changed - this is a
client-side narrowing over the already-listed sessions - so none needed
updating, and the internal/author/install.go managed reference inventory
is unchanged. No repository template or root/topic doc describes the
Android session list, so none was stale.

android/ only; no dependency added beyond the already-declared
material-icons-extended; no run is started from the app.
2026-10-17 14:50:30 +01:00
alan bb486acc11 chat: mark new activity in the session list
With several operator sessions the list gave no sign of where a reply
arrived: an idle chat and one streaming a reply right now looked the same,
so the operator lost the conversation they were in.

Add a per-session read state that the session list derives from data it
already receives, and render it as a three-state activity badge:

- ChatSeenState (ui/chat/ChatSeen.kt) keeps a per-session recency watermark
  (the newest updated_at the operator has read) plus the ids that moved on
  while the app was open. It is persisted as one opaque JSON preference
  (SettingsRepository chat_seen, observed by AppViewModel.observeChatSeen),
  the same way ChatSessionOverrides is, so the marks survive a restart and
  not only a reconnect.
- ChatState.isUnseen marks a background session that carried a live mark
  (a pushed chat_event/permission frame) or, if never opened here, is newer
  than its stored watermark; first sight of a session is seeded to its
  current recency so a pre-existing chat is not reported as new. Opening,
  activating and closing a conversation reads it and clears the mark;
  history for the active chat advances the watermark to the newest server
  message. No server request is added.
- ChatFormat.sessionActivity(running, unseen) is the one pure derivation
  (streaming outranks finished-unseen, which outranks idle) and
  SessionActivityBadge renders it as Streaming/New/Open beside the
  unchanged kind chip and directory line. Most-recently-used order is
  untouched.

Tests (ChatActivityTest): unseen is marked, opening clears it including in
the persisted state, the derivation distinguishes streaming/finished-unseen/
idle, and the seen state survives an encode/decode into a fresh store.

Checked before commit: android/README.md was updated in this change with the
behaviour, tests and evidence. The packaged authoring skill references
(internal/author/skill/references/) describe the Pipelines server and its
chat_* protocol surface, neither of which changed - this is a client-side
derivation over existing frames - so none needed updating, and the
internal/author/install.go managed reference inventory is unchanged. No
repository template or root/topic doc describes the Android session list,
so none was stale.

android/ only; no dependency added; no run is started from the app.
2026-10-17 14:40:02 +01:00
alan 829d6d3551 chat: attach files to a message from the composer
Let the operator attach one or more files to the next chat message and send
them with it. The platform multi-document picker returns content URIs; the app
resolves only each file's name, size and MIME (confirming it can be opened) and
holds the attachments per chat, exactly like the draft. Nothing is read or
transmitted until the message is sent.

- Composer: an attach action, a strip of removable chips (image thumbnail or
  file glyph, name, size, remove), and a send that is blocked while any
  attachment is flagged.
- Wire: one shared builder, ChatProtocol.promptRequest(sessionId, text, files),
  carries the attached URIs on the chat_prompt frame, in attachment order and
  omitted for a text-only prompt so that shape is unchanged.
  PipelinesRepository.chatPrompt takes the same list.
- Transcript: a sent turn carries each attachment as a ChatProtocol.PART_FILE
  part, drawn through the existing UserParts -> FilePart display path rather
  than a second rendering.
- Honest failures: an unreadable or over-24-MiB file is attached with its reason
  and blocks the send; a server rejection takes the optimistic bubble back out
  and returns the files flagged with the server's message. Attaching never
  transmits on its own, and attachments clear once the message is sent.

Review follow-ups in the same slice: the composer now uses ui/Format.kt's
humanBytes instead of a duplicate formatter; optimistic user-turn ids come from a
monotonic counter so removing a rejected turn cannot re-mint a live key;
restoreAttachments keeps a file attached between send and rejection; the
thumbnail decode catches Exception rather than Throwable.

Checks made for this commit:
- The change is android/ only; the server, its Go source, the installer and the
  Docker files are untouched, no run is started from the app, and no dependency
  was added beyond the already-declared material-icons-extended.
- Packaged authoring skill references (internal/author/skill/references/): no
  update needed. operations.md documents the brokered chat server, which this
  change does not alter; the server still stores user turns as text and ignores
  the prompt's files, so that reference stays accurate.
- Packaged templates (internal/tui, internal/server) and the root README/topic
  docs: no update needed; none describes the Android chat composer. The
  Android-facing documentation lives in android/README.md, which this change
  updates with the attachment slice, its known server-side gap and its tests.

Tests: ChatAttachmentTest (5 cases), ChatAttachmentStateTest (5 cases) and a new
ChatProtocolTest case cover building the request with attachments (and omitting
them for a text-only prompt), removing one, the unreadable and oversized paths,
which files travel with the prompt, the optimistic turn's file parts, clearing
after send, and the rejected path restoring the files flagged. Verified by the
review stage with gradle --offline --no-daemon :app:testDebugUnitTest
:app:assembleDebug -> BUILD SUCCESSFUL, 487 tests / 0 failures / 0 errors /
0 skipped.
2026-10-17 13:35:56 +01:00
alan d1a859ec7d Merge lane-chat2: keep the lane's reviewed work 2026-10-17 12:46:18 +01:00
alan 664e563fca chat: open a conversation at its newest message and follow it
Opening a conversation used to start at the top, so the operator first had to
scroll down past everything already said to find the current turn. The
transcript now opens at its newest message, follows it while the operator reads
the newest part, and offers a jump-to-latest affordance when they have
deliberately scrolled up instead.

- Opening at the newest message. The transcript's list state is created the
  moment the conversation first has content, with its first visible item set by
  chatFirstScroll (ui/chat/ChatScroll.kt): a position the operator left is
  restored and clamped with the app's shared rule (restoredScrollAnchor), and
  every other conversation starts at its newest item. "A position of their own"
  is explicit now: ChatThread.scroll is nullable, null meaning the operator has
  never left a position here, so a chat left at the very top
  (ChatScrollPosition(0, 0)) is restored rather than mistaken for "new", and a
  list state that never held content saves nothing. Placement is unanimated, on
  the list's first measure, and goes through the one scroll path below.
- One scroll path, changed deliberately. The existing follow scroll, the app
  bar's approval jump and the new jump-to-latest all go through
  LazyListState.scrollToEnd(itemCount, animated); when the newest item sits
  entirely below the fold it is brought in first, and any part still below is
  then closed by exactly that distance (closeBottomGap). An item already partly
  visible is only gap-closed, so following a growing stream never bounces. The
  distance is measured against the transcript's content count
  (chatBottomDistancePx), not the layout's stale count, so an item appended
  ahead of the measure that shows it actually arrives in view.
- Follow while reading the newest part. Only the operator's own drag changes
  following (a DragInteraction.Start stops it, a settling Stop/Cancel resumes it
  at or within the threshold, chatFollowsAt); while it holds, an arriving
  message, a streamed delta, a tool chip, a freshly arrived approval card, a
  grown composer or the appearing keyboard re-follows smoothly. The item count
  is read at use time (rememberUpdatedState) so a captured count cannot go
  stale. Programmatic scrolls never touch the list's interactionSource.
- Threshold. CHAT_FOLLOW_THRESHOLD_DP (ui/theme/Dimens.kt) is 32dp: about one
  comfortable line of text.
- Jump to latest. A small Material 3 SmallFloatingActionButton (the
  already-declared KeyboardArrowDown icon, on the shared gutter token) is offered
  only while the view is not following and there is genuinely something below the
  fold (chatShowJumpToLatest), hidden at the bottom or for an empty transcript;
  tapping it re-engages the follow. A pending permission/approval is still
  brought into view as the existing code did - it is the transcript's last item,
  so the follow brings it in while the operator reads the newest part, and the
  app bar's approval action still jumps straight to it.

android/ only: no dependency added beyond the already-declared
material-icons-extended, no run is started from the app, and no Pipelines
server, Go source, installer or Docker file is touched.

Checks: the packaged authoring skill references need no update - they document
the Pipelines server's own contract, not the Android client, and this change is
app-side only, so nothing in them became stale. There are no packaged templates
in this repository. The repository's topic doc for the client, android/README.md,
is updated in this change with the flow, the threshold, the one scroll path and
what remains unverified on a device.

Verified by the review stage on this tree: gradle --no-daemon
:app:testDebugUnitTest :app:assembleDebug -> BUILD SUCCESSFUL, 50 suites / 458
tests / 0 failures / 0 errors / 0 skipped (including the new ChatScrollTest, 11
cases), and the published APK matches the freshly built app-debug.apk
byte-for-byte.
2026-10-17 12:45:37 +01:00
alan 8644ff98a3 Merge lane-chat2: combine operator chat session management with live run updates
Both sides are reviewed work and both are kept:

- android/app/.../ui/AppViewModel.kt: HEAD's live-run push wiring
  (RunStreamState/_runStream, combine(connectionState, settings.workspace),
  subscribeRuns/streamDown/resync, applyRunEvent, scheduleRunsResync/
  scheduleRunDetailSync, observeRunEvents) together with lane-chat2's chat
  management (ChatStore overrides, observeChatOverrides, refreshChatDirectories,
  startNewChat/selectChatDirectory/cancelNewChat/createNewChat,
  renameChat/removeChat/undoRemoveChat). The only textual conflict was the
  import list; combine (HEAD) plus map and ui.chat.ChatSessionOverrides (lane)
  are all kept and all used. No duplicated definitions.
- android/README.md: HEAD's "Live run updates from the socket" section and
  lane-chat2's "Operator chat sessions: choose the directory, list only your
  own" section are both present once, in file order.
- The rest of lane-chat2's chat files (ChatDirectories.kt, ChatOverrides.kt,
  ChatStore.kt, ChatScreen.kt, ChatFormat.kt, protocol Chat/Message, repositories,
  tests) merge cleanly on top of HEAD's work.

Documentation check: android/README.md is updated by this merge and its new
section is consistent with HEAD's. docs/cli.md and
internal/author/skill/references/operations.md already describe the server's
chat_sessions/chat_create/chat_directories surface this client builds on, and
the authoring skill (SKILL.md, references/) contains no Android-client behaviour
to stale, so nothing there needed changing and no packaged reference or
inventory entry was touched. No server, installer or template change is part of
this merge.

Checks (android/, Gradle 8.11.1, --offline):
- gradle :app:testDebugUnitTest --offline --rerun-tasks -> BUILD SUCCESSFUL;
  test-results report 463 tests, 0 failures, 0 errors across 50 suites
  (including ChatDirectoriesTest and ChatSessionManagementTest).
- gradle :app:assembleDebug --offline -> BUILD SUCCESSFUL (debug APK built).

Not verified here: on-device picker/rendering, which the visual-review stage owns.
2026-10-17 11:45:41 +01:00
alan 311a0156d6 chat: choose a new chat's directory and list only the operator's sessions
Starting a chat now asks where first, and the session list is the operator's
own chats alone, told apart by the server's own tag.

- The create flow is a normal pane of the chat stack, not a modal: it loads
  the server's chat_directories (home first, then the directories of previous
  operator sessions, most recently used first) into the shared ListRow, each
  with its full path, and starts on the operator's home
  (directoryChoices/defaultDirectoryChoice). Back, the app-bar back control,
  the footer Cancel and predictive back all leave it without creating
  anything. chat_create is always sent the chosen directory (HOME_DIRECTORY
  "~" for home, the absolute path for a recent), so a session is never
  created in the server's working directory; the server resolves or rejects
  it and its error is shown in the pane.
- The list renders ChatState.visibleSessions: exactly the server's
  chat_sessions (operator sessions only) with the operator's own local
  changes applied; the app adds no ownership guessing. Each row shows its
  directory and the kind chip derived from the server's tag
  (sessionTagLabel, "operator" -> "Operator"); another tag shows verbatim,
  an untagged session shows no chip.
- The brokered protocol exposes no chat rename or delete (no
  chat_rename/chat_delete type and no session endpoint), so both are
  device-local and persisted with the other settings
  (ChatSessionOverrides, KEY_CHAT_OVERRIDES): rename stores a local title
  that wins on later list loads, and "Remove from list" hides the row and
  closes its conversation with an Undo snackbar ("Removed from this list;
  the chat stays on the server."). Nothing is deleted on the server.
- Messages, streaming replies, tool chips, diff cards, approval cards, stop
  and the reconnect path are unchanged.

android/ only: no dependency added beyond the declared
material-icons-extended, no run is started from the app, and no Pipelines
server, Go source, installer or Docker file is touched.

Checks: the packaged authoring skill references need no update - the server
contract this builds on is already documented in
internal/author/skill/references/operations.md ("Brokered OpenCode chat",
committed with lane-chatsrv) and this change is app-side only, so nothing in
it became stale. There are no packaged templates in this repository. The
repository's topic doc for the client, android/README.md, is updated in this
change with the new flow, the honest local rename/removal and what remains
unverified.

Verified: gradle 8.11.1, JDK 17, --offline --no-daemon, from android/;
:app:testDebugUnitTest :app:assembleDebug -> BUILD SUCCESSFUL, 447 tests in
50 suites, 0 failures, 0 errors.
2026-10-17 11:39:11 +01:00
alan 6a6c1d65fa android: drive the runs list and run detail from server pushes
Replace the Android app's one-second run poll with the server's
workspace-scoped run_event pushes. The runs list, each pipeline row's
last-run line, the run header and the run detail (status, timeline,
stages, artifacts) now advance from the socket instead of polling or a
manual refresh.

- Wire: Message.kt mirrors internal/protocol/runevents.go (subscribe,
  unsubscribe, run_event; RunEventFrame/RunStepDelta). The frames are
  unsolicited and already arrive on the client's events stream;
  PipelinesRepository.subscribeRuns/unsubscribeRuns add the typed
  command, sent via a new PipelinesClient.sendOnly that does not hold the
  send lock waiting for the running server's unreliable subscribe ack.
- One pure fold: ui/RunEvents.kt folds a frame into the list (in place,
  order preserved) and the open detail with one shared status ladder and
  one shared run-field merge. It is monotonic (a stale or duplicate
  delta is dropped whole), reports needsResync for a run the list does
  not hold instead of inventing a row, and only requests a full get_run
  for a settled step or terminal run.
- Wiring: AppViewModel subscribes once per (re)connect and workspace;
  every (re)subscribe re-reads the list and open detail once, because the
  deployed server's subscribe snapshot is partial, then folds the pushes
  on top. Re-reads are push-driven, coalesced and keyed so no push is
  dropped and no timer remains. LiveBadge (RunStream.kt RunStreamState)
  shows honestly live/reconnecting/not live, confirmed by the ack, a
  push or a successful read and dropped when a read fails.
- ui/RunEventsTest.kt pins the delta sequence as pure cases: created run
  not in the list, step started, step finished, run finished, unknown
  run, duplicate/out-of-order deltas, and a reconnect resync.
- android/README.md records the change, the wire mapping and the
  observed limitation of the running server (partial snapshot, no ack
  within 30s), which the client tolerates without inventing a stream.

Checked where the change belongs: android/README.md gained this entry;
docs/cli.md described the Android app as still polling, which this makes
stale, so that sentence now says the app consumes the pushes while the
TUI still polls. The packaged TUI pipeline templates (internal/tui) do
not touch run-state refresh and need no change, and the packaged
authoring skill references (internal/author/skill/references) document
the authoring workflow, not the Android client's run updates, so none of
them needs updating.

Reviewed and approved by the run's review stage (build, unit tests,
Kotlin compile and lint in android/README.md); no merge/rebase/cherry-pick
was in progress and no conflict was present.
2026-10-17 11:15:21 +01:00