Animate chat composer while turns run

Replace the running Stop button with an animated composer border and task spinner. Add Escape, slash-command, and touch-menu stopping paths with focused widget coverage, including reduced-motion behavior.
This commit is contained in:
2026-11-12 02:24:46 +00:00
parent e4f3ebdcab
commit f3a469c356
14 changed files with 997 additions and 300 deletions
+60
View File
@@ -0,0 +1,60 @@
# Composer running state: border, Escape stop, tasks spinner
## Changes
- **Stop button removed.** The composer no longer shows a Stop control while a
turn runs; Send stays as before (queued/steered prompts unchanged).
`chat_stop_icon.dart` and its test are deleted (their only user was the button).
- **Running border.** `composer_running_border.dart` draws a sweep highlight
(theme primary = chat focus accent, tertiary) once around the pill's rounded
edge, 4 s per lap, with a faint blur glow. Mounted only while `running`, so
disposal stops the ticker when the turn ends. Reduced motion
(`MediaQuery.disableAnimations`) draws a static highlighted border and never ticks.
- **Escape stop.** `chat_escape_stop.dart` wraps the conversation column in
`chat_thread_view.dart`. Two plain Escape presses within 1 s stop a running turn
(`composer.stop()`); the first shows the snackbar "Press Esc again to stop".
Escape is consumed only while running; a descendant that handles Escape first
(command palette, notice) never counts. Held Escape counts as one press.
- **`/stop`.** Already existed (`chat_commands.dart`); unchanged. Typing `/stop`
and sending runs it on the first send. A partial word (`/sto`) still
completes the palette row first (`_paletteCompletes`).
- **More menu Stop.** `chat_thread_view.dart` adds a `Stop` item to the header's
More menu while a turn runs (`key chat-thread-stop-menu`). It is shown on every
platform, so touch devices without a keyboard can stop.
- **Tasks spinner.** `chat_task_spinner.dart` turns the layers icon once per
2.5 s while at least one background task runs; static otherwise and under
reduced motion. Automation-only state keeps its static schedule icon.
## Focused tests (memwatch, from app/)
| Run | Paths | Result |
|---|---|---|
| 1 | `chat_escape_stop_test`, `chat_task_spinner_test`, `chat_composer_running_test`, `chat_thread_stop_menu_test`, `chat_composer_bar_state_test`, `chat_command_palette_test` | PASS 46/46 |
| 2 | Affected users: `chat_background_tasks_*` (4), `chat_thread_view_test`, `chat_thread_header_test`, `chat_composer_*` (bar, focus ring, enter, paste, attachment send, bottom margin), `chat_busy_resume`, `chat_response_pending`, `chat_live_reasoning`, `chat_floating_chrome`, `chat_server_queue`, `chat_delivery`, `composer_focus_restore`, `chat_unfocused_paste_routing`, `chat_floating_pane`, `chat_next_chat`, `chat_shell_composer`, `glass_bar` | PASS 169/169 |
`tool/analyze.sh` (whole app): clean, exit 0.
## Affected states (widget tests)
- Running: no `chat-composer-stop`; Send present; border present; no interrupt sent.
- Turn ended: border gone; no animation ticker left.
- Reduced motion while running: border present, zero tickers.
- `/stop` (one send) interrupts; the notice shows.
- Esc once: hint shown, no interrupt. Esc twice (within 1 s): one interrupt.
Esc idle: nothing. Esc with palette open: palette closes and does not count.
- Transcript-level focus: Esc twice stops (`ChatEscapeStop` unit test). A
descendant-handled Esc never counts.
- More menu: Stop present while running and triggers the interrupt; absent when idle.
- Tasks icon: spins while a task runs; static at rest; reduced motion never turns.
## Limitations
- Not captured or reviewed visually (ui-review owns that). The border's colours
and glow strength in light and dark are unverified by eye.
- Escape stop is verified with synthetic key events in widget tests, not on a
physical keyboard or a device. Touch devices are covered by the More menu item
only; no device was tested.
- The More menu Stop item is shown on every platform while running, not only on
touch devices.
- A partial command word (`/sto`) still needs two sends (palette completes, then
runs); a fully typed `/stop` runs on one send.