Files
pipelines/app/notes/C2-wire.md
T

140 lines
8.9 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# C2-wire — Chat session list to read-only conversation
The Chat tab is now the real session browser plus a selected read-only thread.
The shell registers a normal Chat destination, `/chat/:id` is a real history
entry, and the existing `ChatThreadController`/`ChatMessageView` render the
stored transcript. No composer, markdown, forms, metrics, attachments, new
socket, server or platform change is included.
## Behavior
- The destination renders the list at `/chat`; tapping a row records
`/chat/<session-id>`, and Back (the in-page control, browser Back, or system
back through `AppRouterDelegate.popRoute`) returns to `/chat`. The list stays
mounted offstage, so its rows, grouping, search text and actions survive the
round trip.
- `/chat/:id` opens the exact session. Parsing is total and matches the web
parser: a nonempty, bounded, URL-safe id is accepted after percent-decoding;
malformed escapes, extra segments and invalid ids resolve to the default
Pipelines route rather than throwing. The route serialises through
`Uri.encodeComponent`.
- Before the shared socket has ever connected, the destination shows the normal
connection screen and sends no chat request. It never opens its own socket or
subscribes outside the shared `AppSession`.
- The selected thread subscribes that one session, reads the newest history
page (`limit: 200`, empty cursor), renders `transcriptRows` with
`ChatMessageView`, and folds pushed `chat_event` frames for that session only.
Live text/reasoning/tool parts use the landed native surfaces; reasoning and
tools stay collapsed until opened.
- `Load older` is shown only while the server says `has_more`; the server's
`next_cursor` is passed back verbatim and is never parsed. Paging prepends
messages, and a page boundary can fall inside one folded assistant turn (the
repository's paged history fixture pages consecutive assistant messages). A
turn's first message id is therefore not widget identity: `ChatRowKeys`
carries each turn's key forward while it still holds a message it had before,
and each agent part carries its server id. An open reasoning/tool disclosure
stays on the answer the operator opened, whether the older page extends a turn
at its head or the `Load older` control disappears. A part without a server id
still falls back to its position; server history parts carry ids.
- `ChatThreadController.subscriptionError` and history `error` render as two
separate notices with separate Retry actions. Readable stored history can
therefore never hide a refused live watch. Initial loading, a running turn
and an honest empty transcript each have their own state.
- On reconnect, `connectionEpoch` advances the thread's `syncToken`; the
mounted view re-subscribes and replaces the transcript in place, keeping the
selected session id and route. A session change mounts a keyed view, so a
superseded read from the previous session cannot land in the new thread. The
offstage session list also re-reads on the same token, so a session created,
renamed or closed on another device during the socket gap appears without
pressing Refresh.
- The shell owns the only navigation bar. `ChatSessionsScreen` gained a small
`embedded` flag: under the shell it renders a compact action row for New chat
and Refresh instead of a second `AppBar`/`CupertinoNavigationBar`. Standalone
use keeps its previous native scaffolding.
- Deep links only carry the session id, so a directly opened thread may show no
title until it is opened from a list row. The transcript itself is complete
and honest; this is not treated as chat parity.
## Files
| Path | Lines | Role |
| --- | ---: | --- |
| `lib/features/chat/screen.dart` | 99 | List/thread switch, selection, in-page Back, reconnect token |
| `lib/features/chat/conversation/chat_thread_view.dart` | 195 | Keyed read-only transcript, paging, live/history notices |
| `lib/features/chat/conversation/chat_row_keys.dart` | 63 | Stable row identity while a folded turn grows at either end |
| `lib/features/chat/domain/chat_transcript.dart` | 246 | History merge, turn folding, live frame fold |
| `lib/features/chat/ui/transcript/chat_message_view.dart` | 218 | Agent parts keyed by part identity (disclosure state) |
| `lib/application/chat_destination.dart` | 69 | Connection gate/banner and shared session wiring |
| `lib/features/chat/ui/sessions/chat_sessions_screen.dart` | 191 | Embedded layout flag, actions, reconnect re-read |
| `lib/application/app_route.dart` | +30/−4 | `/chat/:id` parse, serialise, equality |
| `lib/application/app_router.dart` | +13/−3 | System Back callback for a chat session |
| `lib/application/pipelines_app.dart` | +9 | Destination registration and `/chat` route mapping |
Focused tests: `test/application/chat_registration_test.dart`,
`test/application/chat_destination_test.dart`, `test/application/app_router_test.dart`,
`test/application/app_route_test.dart`,
`test/features/chat/conversation/chat_thread_view_test.dart`,
`test/features/chat/conversation/chat_row_keys_test.dart`.
The thread tests cover both paging variants (the older page keeps `has_more`, and
the older page ends history) in Material and Cupertino, for alternating pages and
for the assistant-only fixture shape. In every case the newest `Reasoning` stays
open and the older blocks stay collapsed. `chat_row_keys_test.dart` covers a
prepended assistant page, an appended live assistant message and distinct turns.
Probe: `tool/chat_wire_probe.dart` and `tool/chat_wire_probe.mjs` include both
alternating variants plus two assistant-fold sessions (`has_more` kept and ended).
## Checks (actual)
- `flutter test test/features/chat test/application` — **110 tests passed**.
- `flutter test` (full suite) — **696 tests passed**.
- `flutter analyze` — **No issues found**.
- `dart format --output=none --set-exit-if-changed` on the changed Dart files —
exit 0.
- `flutter build web` — built successfully.
- `flutter build web -t tool/chat_wire_probe.dart` for the Material and Cupertino
dark fixtures — both built successfully.
- `node tool/chat_wire_probe.mjs` against real headless Chrome for both hosts —
exit 0. Each run checked, with the semantics tree and OCR of the rendered
canvas:
- embedded list shows server rows and keeps New chat/Refresh;
- the thread shows the exact stored user body, assistant body, `Reasoning` and
`shell` disclosures while collapsed bodies stay hidden;
- `Load older` renders the opaque-cursor page;
- a pushed `chat_event` delta appends to the open thread;
- after expanding the newest `Reasoning`, paging with `has_more` still true and
paging that removes `Load older` both keep the newest body open and the older
body collapsed (`newestKept: true`, `olderLeaked: false` in both hosts);
- the assistant-fold sessions repeat that check with pages of consecutive
assistant messages, for both `has_more` outcomes.
- Captures and evidence JSON: `/Users/alan/.local/share/pipelines/data/artifacts/79/public/chat-fold-paging/`
(`{material,cupertino}-{list,thread,expanded,older,live,more-expanded,more-older,fold-expanded,fold-older,fold-end-expanded,fold-end-older}.png`
and `*-evidence.json`). These come from the standalone `ChatScreen` fixture.
- Normal-app rendered check: `/Users/alan/.local/share/pipelines/data/artifacts/79/public/chat-fold-app/`
has `{material,cupertino}-{fold,fold-end}-{collapsed,expanded,older}.png` and
`fold-app-evidence.json`, driven through the real `build/web` composition and
the real router at `/chat/<session>`. Material is a Linux UA in light mode,
Cupertino the macOS host in dark mode. Both hosts and both `has_more` outcomes
report `newestKept: true`, `olderLeaked: false`, and the expected `Load older`
presence; no page exceptions.
Not done: composer, markdown rendering, attachments, forms, permissions, model
selection, metrics, shells, and the initial newest-message placement / live
follow scroll behaviour remain the tracked next chat items. The transcript is
still an eager, keyed `ListView` so an open disclosure also survives while its
row is offscreen; moving to a lazy builder would need that expansion state to
live above the rows. Mobile builds/devices were not used or verified. Nothing
was committed, pushed, merged or deployed.
## Manager completion after the Code deadline
The final Code visit reached its 30-minute deadline while active; the session then
settled and all edits were retained. No retry was started. The manager ran the
focused application/chat suites (110 tests pass) and drove the fixture probes for
both hosts. Material and Cupertino each passed and wrote captures; the Cupertino
live capture was inspected and shows the read-only conversation with the exact
user text, the stored assistant reply, collapsed Reasoning/tool disclosures, the
live delta and the responding line, all under the shell's single bar.
Scope stays read-only: no composer, markdown rendering, forms, approvals, metrics
or attachments are claimed by this item.