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.
This commit is contained in:
2026-10-17 14:50:30 +01:00
parent bb486acc11
commit 355fe4e908
6 changed files with 387 additions and 16 deletions
+69
View File
@@ -5714,3 +5714,72 @@ 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.
## Finding a session among many: search and directory grouping (17 Oct 2026)
The chat list is the operator's own sessions in recency order, but as a day's work
accumulates it is a flat, unsearchable wall and the session that is wanted is the
one that cannot be found. The list can now be narrowed by typing over each chat's
title and directory, sessions of one repository are grouped together, and a
narrowing that matches nothing says so and offers to clear it.
`android/` only; no dependency was added beyond the already-declared
material-icons-extended, nothing in the Pipelines server, its Go source, the
installer or the Docker files was touched, and no run is started from the app.
- **The search control reuses the list-filter pattern.**
`ChatListSearchControl` is the shared `FilterMenu` (the same top-bar icon with
an active-count badge used by the pipelines and runs lists), carrying one
`OutlinedTextField` and a `Clear search` reset. It is not a new control: the
field narrows the list as the operator types and the menu stays open behind it,
exactly like the pipelines name filter.
- **The match rule is one pure derivation.** `ui/chat/ChatListFilter.kt`
adds `sessionMatchesQuery` / `filterChatSessions`: a case-insensitive substring
over the session's title (the local rename included, since it is applied to the
visible list first) and its directory. A blank or whitespace query narrows
nothing, and the survivors keep their incoming order — so the search composes
with the recency order rather than re-sorting it.
- **Same repository, together.** `groupChatSessionsByDirectory` groups the
narrowed sessions by directory, each group keeping the recency order inside it
and the groups ordered by their first (most recent) session, so the top of the
list still leads with the newest activity. The list pane renders a directory
heading per group only when there is more than one directory; a single directory
(or none) stays the flat list, which is already together. Every row still shows
its directory as before.
- **Empty result and the create path.** A narrowing that matches nothing renders
the shared `EmptyState` — `No chats match "<query>".` with a `Clear search`
action — the same empty-state pattern the other lists use. The trailing
`New chat` action is never hidden while the list is narrowed, so creating stays
one tap away.
- **State and marks untouched.** `ChatState.sessionQuery` (set through
`ChatStore.searchSessions` / `AppViewModel.setChatSessionQuery`) is a display
narrowing only: it never touches the server's list or an open conversation, and
the activity marks derive from the same session ids as before.
Tests (`ChatListFilterTest`, 9 cases): the match rule over title and directory
(case-insensitive, blank matches all, a miss is empty), that filtering 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.
Evidence (this run's implementer pass, macOS, Gradle 8.11.1 at
`~/.gradle/wrapper/dists/gradle-8.11.1-bin/bpt9gzteqjrbo1mjrsomdt32c/gradle-8.11.1/bin/gradle`
with `JAVA_HOME="/Applications/Android Studio.app/Contents/jbr/Contents/Home"`
(JDK 17) and `ANDROID_HOME=/Users/alan/Library/Android/sdk`):
`gradle --offline --no-daemon :app:testDebugUnitTest` → `BUILD SUCCESSFUL`; the
JUnit XMLs total **55 suites / 501 tests / 0 failures / 0 errors / 0 skipped** (9
new in `ChatListFilterTest`). `gradle --offline --no-daemon :app:assembleDebug` →
`BUILD SUCCESSFUL`; the APK was published to this run's artifacts directory as
`pipelines-debug-wip-bb486ac.apk` (18,486,624 bytes, sha256
`d276f7be66501c7becdd83628e3407f955ec982552a87a6a5146d4f44cb5598d`; `bb486ac` 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/271/1/pipelines-debug-wip-bb486ac.apk`
(`HTTP/1.1 200 OK`, `Content-Type: application/vnd.android.package-archive`,
`Content-Length: 18486624`).
Not verified in this pass: the search field, the directory sections and the
empty state on a device, and the narrow/wide layouts — the brief keeps
implementation verification to the build and the unit tests, and visual review
owns the operator's Pixel 9 Pro XL.