41d30a4280
Split the 406-line chat session browser into a controller, body, shared adaptive primitives and separate standard Material and Cupertino lists and dialogs. Preserve the existing server directory/backend catalogs, instructions field, closed/starred grouping, directory headings and empty/no-match states. - keep refresh generations so stale replies are discarded - open a created chat immediately and refresh the list in the background - disable rename Save while the trimmed name is blank - label row actions per session, with the id on duplicate titles - wrap Cupertino empty/no-match/error messages instead of clipping, and give them a Cupertino text style under a bare MaterialApp - allow the Material rename helper to wrap at large text scales - cover both native branches, lifecycle ordering, create/rename/close/star and the Cupertino theme path with widget tests
164 lines
9.3 KiB
Markdown
164 lines
9.3 KiB
Markdown
# C1b — Chat session browser completion
|
|
|
|
The 406-line sessions screen is split into a controller, adaptive primitives,
|
|
session groups/rows, action dialogs, a rename dialog and a create dialog. The
|
|
server directory and backend catalogs, the instructions field, the closed/star
|
|
grouping and the distinct empty/no-match states are retained. No repository,
|
|
domain, shell or pubspec file changed.
|
|
|
|
The UI review's must-fix is addressed: Cupertino no-match, empty and error
|
|
messages are no longer forced through `CupertinoListTile`'s one-line title. They
|
|
use a wrapping grouped card with `Clear search`/`Retry` as separate buttons. The
|
|
same turn also fixed the related behavioural findings: a failed initial load no
|
|
longer also shows the empty-server message, creating a chat opens it without
|
|
waiting for the list refresh, blank rename disables Save, and row action labels
|
|
name their session (adding the id when titles repeat).
|
|
|
|
The second UI review's must-fixes are also addressed:
|
|
|
|
- `ChatCupertinoMessage` now sets `DefaultTextStyle.merge` from
|
|
`CupertinoTheme.of(context).textTheme.textStyle`. Mounted under a bare
|
|
`MaterialApp` (the screen's iOS/macOS path, no `Material` ancestor), its text
|
|
previously inherited MaterialApp's intentional "missing Material" fallback
|
|
style (48px red monospace with a double yellow underline). The card now
|
|
renders as ordinary Cupertino body text in that configuration.
|
|
- The Material rename dialog sets `helperMaxLines: 2`, so "This name is shared
|
|
with every device." wraps instead of being ellipsised at 2.0x text scale.
|
|
|
|
## Source layout
|
|
|
|
All paths under `lib/features/chat/ui/sessions/` (1,584 lines total):
|
|
|
|
| File | Lines | Responsibility |
|
|
| --- | ---: | --- |
|
|
| `chat_sessions_screen.dart` | 176 | Screen composition, toolbar/FAB, controller wiring |
|
|
| `chat_sessions_controller.dart` | 111 | List state, generation-guarded refresh, row actions, create |
|
|
| `chat_sessions_body.dart` | 97 | Filtering, starred/open/closed sections, duplicate titles |
|
|
| `session_list_material.dart` | 140 | Material list sections and rows |
|
|
| `session_list_cupertino.dart` | 134 | Cupertino list sections and rows |
|
|
| `session_row_style.dart` | 51 | Shared subtitle, icons and action labels |
|
|
| `session_actions.dart` | 161 | Star control, actions menu/sheet, close confirmation |
|
|
| `rename_chat_dialog.dart` | 107 | Rename dialog and its blank-name guard |
|
|
| `create_chat_dialog.dart` | 222 | Create state, draft fields, submit |
|
|
| `chat_create_fields.dart` | 185 | Catalog loading/error/retry and directory/backend pickers |
|
|
| `chat_adaptive.dart` | 200 | Style detection, bar actions, search, wrapping message card, loading |
|
|
|
|
`chatControlsStyleOf` chooses Cupertino for a Cupertino app (no `MaterialApp`
|
|
ancestor) and for iOS/macOS Material themes; Material otherwise. The Cupertino
|
|
branch uses only Cupertino controls (`CupertinoPageScaffold`,
|
|
`CupertinoNavigationBar`, `CupertinoSearchTextField`, `CupertinoListSection`/
|
|
`CupertinoListTile`, `CupertinoAlertDialog`, `CupertinoActionSheet`,
|
|
`CupertinoTextField`, `CupertinoActivityIndicator`). It therefore has no
|
|
Material ancestor dependency. The `SafeArea` in that branch keeps the search
|
|
field below the translucent navigation bar (the first browser capture caught
|
|
this overlap).
|
|
|
|
Behavior:
|
|
|
|
- `chat_sessions`, `chat_directories`, `chat_backends` and `chat_create` use the
|
|
existing repository envelopes; no fallback directory or backend is invented.
|
|
- A catalog failure keeps the dialog open, shows the server reason with Retry,
|
|
and retains the typed name and instructions.
|
|
- Closed starred rows appear once, only under Closed.
|
|
- Directory headings appear only when a section has more than one directory.
|
|
- Empty and search-no-match states stay distinct; "Clear search" restores the
|
|
list. In the Cupertino branch the message and its action are a wrapping
|
|
`ChatCupertinoMessage` card, and a failed load uses the same card for the
|
|
server reason with Retry. The failed initial load no longer also renders the
|
|
empty-server message. The card supplies a Cupertino text style, so it renders
|
|
normally when the Cupertino branch is mounted under the app's bare
|
|
`MaterialApp` root instead of a `Material`/`CupertinoApp`.
|
|
- Creating a chat opens it as soon as `chat_create` replies; the list refresh
|
|
continues in the background, so a slow listing cannot look like a failed
|
|
create.
|
|
- Star, rename, close (with the web's confirmation wording), reopen and row
|
|
opening keep their existing request shapes. Save is disabled while the
|
|
rename name is blank, matching the web dialog.
|
|
- Row action labels are `Chat actions for {title}`, adding `({id})` when two
|
|
visible sessions share a title, matching the web's accessible label.
|
|
|
|
## Checks (actual)
|
|
|
|
- `flutter test test/features/chat/ui/sessions`: 24 widget tests, all passed.
|
|
They cover Material and Cupertino list branches, both create branches, the
|
|
delayed catalog failure with draft retention and Retry, rename/close/reopen/
|
|
star, blank-name Save disabling in both branches, the close confirmation,
|
|
catalog-empty state, stale refresh ordering, dispose while a reply is
|
|
pending, opening a created chat before the refresh completes, Cupertino
|
|
no-match/error wrapping (including 2x text scale), separate Clear search
|
|
semantics, duplicate-title action labels, the Cupertino message card under a
|
|
bare `MaterialApp` iOS theme (empty, no-match, long error style), and the
|
|
Material rename helper at 2x text scale. The three MaterialApp-hosted tests
|
|
fail when the `DefaultTextStyle` merge is removed (verified).
|
|
- `flutter test`: 46 tests passed.
|
|
- `flutter analyze`: no issues.
|
|
- `flutter build web`: built `lib/main.dart` successfully.
|
|
- Fixture probe built for both variants and run in real headless Chrome through
|
|
the local loopback server in `tool/chat_sessions_probe.mjs`. Each run loaded
|
|
the list, opened the create dialog, confirmed the rendered catalog controls,
|
|
opened a row action menu/sheet, and captured PNGs. The probe now clicks the
|
|
per-session action label and requires `Rename…` in the action labels instead
|
|
of accepting the dismiss barrier. Material and Cupertino PNGs were inspected.
|
|
|
|
Captures from this turn's fix (shared with later stages under
|
|
`public/c1b-fix/`):
|
|
|
|
- `/Users/alan/.local/share/pipelines/data/artifacts/42/public/c1b-fix/cupertino-fix-search-no-match.png` — light, 390x844, long query wraps in full with Clear search on its own line.
|
|
- `.../cupertino-fix-search-no-match-dark.png` — same state in dark appearance.
|
|
- `.../cupertino-fix-load-error.png` — long server reason wraps; Retry is separate and the empty-server message is absent.
|
|
- `.../cupertino-fix-list-phone.png` and `.../material-fix-actions.png` — probe list and actions after the label change.
|
|
|
|
Probe commands (run from `app/`):
|
|
|
|
```sh
|
|
flutter build web -t tool/chat_sessions_probe_entry.dart \
|
|
--dart-define=CHAT_PROBE_STYLE=material --output build/probe-material-fix
|
|
PROBE_WEB_ROOT="$PWD/build/probe-material-fix" PROBE_VARIANT=material \
|
|
OPENCODE_ARTIFACT_DIR=/private/var/folders/jp/q0qvjyg54fl_c5vhhk1ylz2m0000gn/T/opencode/chat-sessions-capture \
|
|
node tool/chat_sessions_probe.mjs
|
|
# repeat with CHAT_PROBE_STYLE=cupertino and build/probe-cupertino-fix
|
|
```
|
|
|
|
Captures for the second review's fixes (same `public/c1b-fix/` folder, real
|
|
headless Chrome at 390x844 through a temporary fixture entry that was deleted
|
|
afterwards; the shipped probe entry was not changed):
|
|
|
|
- `platform-default-empty-phone.png` — `MaterialApp` default theme (macOS →
|
|
Cupertino branch), empty server. The message is ordinary body text.
|
|
- `platform-default-search-no-match-phone.png` — long query; message wraps and
|
|
`Clear search` is a separate control.
|
|
- `platform-default-error-phone.png` — long server reason wraps; `Retry` is
|
|
separate and no empty-server message appears.
|
|
- `material-scale2-rename-phone.png` — Material rename dialog at 2.0x text
|
|
scale; the helper sentence wraps onto two lines in full.
|
|
|
|
## Not changed in this turn
|
|
|
|
These review notes remain advisory and were left alone because they predate
|
|
C1b or are native behaviour:
|
|
|
|
- The Material FAB can still cover the last row's star/actions when the list
|
|
exactly fills a phone viewport. Same as the base screen.
|
|
- Raw exception text (`Bad state: …`, `Exception: …`) is still shown to the
|
|
operator; wording belongs to a separate error-presentation change.
|
|
- Cupertino row titles/subtitles still truncate to one line (standard
|
|
`CupertinoListTile` behaviour). The no-match/error messages no longer do.
|
|
- The Cupertino-under-MaterialApp probe still takes its accent from the ambient
|
|
`ThemeData`. No theme override was added.
|
|
|
|
## Remaining gaps
|
|
|
|
- Mobile is unverified: no Android/iOS builds, devices or installs were run.
|
|
Source is portable but only web was exercised.
|
|
- Browser evidence uses the fixture gateway, not an authenticated live server.
|
|
No real chat was created, renamed, closed or starred in the browser; those
|
|
request paths are covered by widget tests.
|
|
- The Cupertino list/actions probes use the local Chrome dark appearance; the
|
|
no-match fix was captured in both light and dark. The long-error capture came
|
|
from a temporary private fixture entry that was deleted afterwards.
|
|
- The create dialog still omits the web's default instruction text and its
|
|
backend segmented control; it preserves the existing name/directory/backend/
|
|
instructions request fields.
|
|
- This stage did not commit. The changes remain an uncommitted working-tree
|
|
candidate for the next stage.
|