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.
This commit is contained in:
@@ -5641,3 +5641,76 @@ the counter and the kept file). The APK was republished for this stage as
|
||||
at `http://10.0.0.75:8080/artifacts/249/3/pipelines-debug-wip-d1a859e.apk`
|
||||
(`HTTP/1.1 200 OK`, `Content-Type: application/vnd.android.package-archive`,
|
||||
`Content-Length: 18470240`).
|
||||
|
||||
## New activity in the session list (17 Oct 2026)
|
||||
|
||||
With several operator sessions open 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. A row now signals a transcript the
|
||||
operator has not read, and a turn streaming right now, distinctly from each other
|
||||
and from an idle chat; opening a chat clears its mark; and the marks survive a
|
||||
restart, not only a reconnect. The signal is derived from what the app already
|
||||
receives — the sessions' own `updated_at` recency and the message ids/timestamps
|
||||
of pushed chat events and history — so no server request is added for it.
|
||||
`android/` only; nothing in the Pipelines server, its Go source, the installer or
|
||||
the Docker files was touched, no dependency was added beyond the already-declared
|
||||
material-icons-extended, and no run is started from the app.
|
||||
|
||||
- **Read state, persisted.** `ui/chat/ChatSeen.kt` adds `ChatSeenState`: a
|
||||
per-session recency watermark (`seenAt`, the newest `updated_at` the operator
|
||||
has read) plus the ids that moved on while the app was open (`unseen`). It is
|
||||
stored as one opaque JSON preference (`SettingsRepository.chat_seen`, observed
|
||||
by `AppViewModel.observeChatSeen`), exactly like `ChatSessionOverrides`, so a
|
||||
mark is still there after a restart.
|
||||
- **Unseen, derived not requested.** `ChatState.isUnseen` marks a session that is
|
||||
not on screen and either carried a live mark (a pushed frame arrived for it
|
||||
while it was backgrounded — `ChatStore.event`/`permission` mark any activity for
|
||||
a chat that is not active) or, if it has never been opened on this device, is
|
||||
newer than its stored watermark. First sight of a session is seeded to its
|
||||
current recency (`ChatSeenState.seeded`), so a chat that predates the feature is
|
||||
not reported as new; a reply that arrived while the app was closed is newer than
|
||||
the watermark and reads as unseen after a restart. An **open** thread is judged
|
||||
by its live mark alone, so a conversation the operator has been in is never
|
||||
re-flagged by a later list refresh — only by activity after they leave it.
|
||||
- **Opened means read.** `ChatStore.open`/`activate` advance the watermark to the
|
||||
session's recency and clear its live mark; `history` for the active chat also
|
||||
advances it to the newest message the server reports; `close` clears a live mark
|
||||
because a chat the operator had open was read.
|
||||
- **Three distinguishable states.** `ChatFormat.sessionActivity(running, unseen)`
|
||||
is the one pure derivation (streaming outranks finished-unseen, which outranks
|
||||
idle) and `SessionActivityBadge` renders it as a labelled dot: `Streaming`
|
||||
(tertiary) while a turn is in flight, `New` (primary) once it settles unseen,
|
||||
and the existing `Open` (outline) otherwise. The kind chip and the directory
|
||||
line are unchanged beside it — this adds a signal, it does not replace them.
|
||||
- **Ordering untouched.** The list is still the server's most-recently-used order;
|
||||
nothing here reorders it.
|
||||
|
||||
Tests (`ChatActivityTest`, 5 cases): an unseen session is marked (a pushed frame
|
||||
for a background chat, and a session newer than the stored watermark with no frame
|
||||
at all), opening clears the mark from the persisted state too, the pure activity
|
||||
derivation distinguishes streaming/finished-unseen/idle and the store agrees
|
||||
across a background turn, and the seen state survives an encode/decode into a
|
||||
fresh store.
|
||||
|
||||
Evidence (this run's implementer pass, macOS, Gradle 9.7.1 `--offline
|
||||
--no-daemon`, `ANDROID_HOME=/Users/alan/Library/Android/sdk`): `gradle --offline
|
||||
--no-daemon :app:testDebugUnitTest` → `BUILD SUCCESSFUL`; the JUnit XMLs total **54
|
||||
suites / 492 tests / 0 failures / 0 errors / 0 skipped** (5 new in
|
||||
`ChatActivityTest`). `gradle --offline --no-daemon :app:assembleDebug` → `BUILD
|
||||
SUCCESSFUL`; the APK was published to this run's artifacts directory as
|
||||
`pipelines-debug-wip-5adc961.apk` (18,470,240 bytes, sha256
|
||||
`0866b7c2c1cfbd51f55bd8a81e3550437553ff542a04de605d7f994060ee63ea`; `5adc961` is
|
||||
`git rev-parse --short HEAD`, the tree being uncommitted WIP on top of it) and is
|
||||
served at
|
||||
`http://10.0.0.75:8080/artifacts/270/1/pipelines-debug-wip-5adc961.apk`
|
||||
(`HTTP/1.1 200 OK`, `Content-Type: application/vnd.android.package-archive`,
|
||||
`Content-Length: 18470240`).
|
||||
|
||||
Not verified in this pass: the badge on a device, the wide/narrow layouts, and a
|
||||
mark surviving a real process restart — the brief keeps implementation
|
||||
verification to the build and the unit tests, and visual review owns the operator's
|
||||
Pixel 9 Pro XL. Known limitation: a reply streamed and watched while the chat was
|
||||
active carries no wall-clock stamp on its pushed frames, so its exact recency is
|
||||
only learned from the server's history/`updated_at` on a later read; if the app is
|
||||
killed before that, a restart can conservatively re-flag that chat until it is
|
||||
opened again. Opening always clears the mark.
|
||||
|
||||
Reference in New Issue
Block a user