Merge main into chat tab re-tap

This commit is contained in:
2026-11-12 03:52:20 +00:00
66 changed files with 4417 additions and 530 deletions
+63
View File
@@ -0,0 +1,63 @@
# Server-authoritative open chat workspace
## Behaviour
The authenticated `/connect` protocol stores one bounded ordered open-chat set
per server scope (`default`). Entries hold only an operator session id and a
floating bit; split ratios, pane ids and window rectangles stay on the device.
* `chat_open_workspace` without `chat_open_workspace_request` reads the set.
With a request it replaces the set as a compare-and-swap on `base_revision`:
a write from a stale base is not applied and the reply carries the current
set with `rejected: true`. Each stored change increments `revision`; an
identical write stores nothing.
* `seed: true` applies only when the server never stored a set (even an
emptied set wins over an old device-local snapshot), so the migration from
the old local layout happens once.
* Stored changes are pushed to every other connection as
`chat_open_workspace_changed`. Pushes run on separate goroutines and can
arrive out of order; clients keep the highest revision.
* Only recorded, not-closed operator chats are kept (registry check; the broker
is not asked, so validation never starts a harness). `chat_close` drops the
chat and pushes the new revision to every connection. A new connection
prunes stale entries and pushes the result to all connections, else sends
the current set to the new connection only (reconnect catch-up).
App (`ChatOpenWorkspaceController`): one write in flight at a time; later
changes coalesce into the newest full set, sent from the revision of the last
reply. Pushes and replies with a lower (or, for pushes, equal) revision are
ignored. A push or a rejected reply wins over unsent local changes. After the
local layout is restored, the device seeds (or, with no chats, reads) and
applies the answer; the first answer keeps a deep-linked chat. Server drops in
a successful reply are not applied locally, so a closed chat can still be read
on the device that opened it, but no other device receives it. Remote
membership is applied with `reconcileChatWorkspaceTree`: removed chats' panes
go, survivors keep pane ids and split sizes and move to follow the order, new
chats split off the last pane. The controller is disposed on a server or
gateway rebind. A federated (all-servers) list keeps its local layout.
Ctrl+Tab: main's behaviour (floating chats when shown, else visible panes) is
kept; the single-pane recent-chat swap is removed there.
## Verification
* Go: `internal/pipeline` `TestChatOpenWorkspace*` (seed once, stale revision,
remove, bounds); `internal/server` `TestChatOpenWorkspaceSyncsEveryConnection`
(two connections get the same snapshot, stale write rejected, reorder,
close pruned and pushed to both, closed chat not restorable) and
`TestChatOpenWorkspacePrunesOnConnectForEveryone`.
* App: `test/features/chat/workspace/chat_open_workspace_controller_test.dart`
(serialized writes, late reply vs newer push, rejected write, dispose),
`chat_workspace_reconcile_test.dart`, and
`test/features/chat/chat_open_workspace_sync_test.dart` (seed migration,
remote removal drops the pane, server set wins over an old local snapshot,
rebind disposes the old sync).
* Live two-client check (2026-11-12): server built from this worktree, run on
an OS-assigned loopback port with a scratch HOME/XDG and database, three
scratch operator rows; a Node script drove two websocket clients through
read, open, reorder, stale write, float, pane close, `chat_close`, write-back
of the closed chat, and an out-of-band close pruned on a third connection.
All 16 checks passed (`RESULT: PASS`); every connection received the same
revisions. The scratch server and its own OpenCode child were stopped.
Not verified: rendered UI captures and on-device behaviour.
@@ -0,0 +1,110 @@
# Chat seen only after a real interaction
A chat's `chat_seen` watermark (which clears its phone notifications on every
device) is now sent only after the user acts in that chat while the app window
is focused. Showing, restoring or receiving a reply in an open chat is no
longer enough.
## Before
- `ChatSessionsScreen` called `markOpened` for the open chat on every list
update and widget change, so a chat left open on one device (the Mac) was
marked seen within about a second.
- Any reply in the open chat scheduled an acknowledgement after a 1.5 s quiet
period, whether or not the user was there.
## After
| State | Seen sent? | Why |
| --- | --- | --- |
| Reply while the window is unfocused / backgrounded | no | `ChatSeenFocus` is not `resumed`; the chat is marked locally unread. |
| Layout restored on start with a chat open | no | The screen only sets the open id; it no longer calls `markOpened`. |
| Open chat, no interaction since, reply arrives | no | Not engaged; reply is marked locally unread. |
| Open chat idle for minutes | no | Same as above; nothing schedules an acknowledgement. |
| Engaged chat, window then unfocused, refocused without input, reply | no | Losing focus clears the engagement. |
| Engaged chat, reply still in its quiet period, then focus lost | no | The pending acknowledgement is cancelled and the reply is marked locally unread at once. |
| Engaged chat, reply still in its quiet period, then another chat opened | no | Same cancel path; the reply stays New. |
| Reply in a chat that is not open | no (New badge) | Unchanged behaviour. |
| Click / tap in the pane | yes | `ChatSeenInteraction` pointer listener. |
| User scroll (drag, wheel) of the transcript | yes | Scroll notifications. Programmatic scroll is ignored. |
| Key press with focus in the pane (typing, Tab) | yes | `Focus.onKeyEvent` on the pane. |
| Keyboard focus moved into the pane by a key press outside it (Tab) | yes | `HardwareKeyboard` flags the key-down; the pane's `Focus.onFocusChange` reports when focus arrives during it. |
| Focus moved into the pane in code, no key press (restore, autofocus) | no | No key-down in progress, so nothing is reported. |
| Opening from the list / shortcut | yes | `markOpened` (unchanged call site, now the only open path). |
| Notification tap that opened the chat | yes | `ServerConnections.requestChatOpen` / `takeChatOpenIntent`. |
| Engaged chat, reply arrives | yes, after 1.5 s quiet | Existing quiet-period ack, now gated on engagement. |
Once the user interacts, the chat is marked seen up to now (the server lifts
it to the registry recency). Repeated interactions in an already-engaged, read
chat send nothing further.
## Where
- `lib/features/chat/ui/sessions/chat_seen_focus.dart`: window focus from the
framework lifecycle (`resumed` = focused).
- `lib/features/chat/ui/sessions/chat_sessions_controller.dart`:
`reportInteraction`, the engagement set (cleared on focus loss or when the
open chat changes), and the passive/active split in the frame path. A reply
waiting in its quiet period is tracked (`_pendingAckId`); focus loss or a
chat change cancels that wait and marks the reply New (`_cancelPendingActiveAck`)
instead of letting the timer drop it silently.
- `lib/features/chat/conversation/chat_seen_interaction.dart`: the region
wrapped around each open conversation pane.
- `lib/features/chat/chat_pane_content.dart`: wraps the pane.
- `lib/features/chat/ui/sessions/chat_sessions_screen.dart`: removed the
passive mark-read on rebuild and restore.
- `lib/features/settings/server_connections.dart` and
`lib/application/pipelines_app.dart`: the notification-open intent.
No server or web change: the server is untouched and still clears app
notifications on the watermark.
## Tests (focused)
- `test/features/chat/ui/sessions/chat_seen_interaction_test.dart` (15 tests):
passive cases (unfocused reply, restored layout, idle open chat,
background then refocus, reply in another chat, reply after leaving an
engaged chat, interaction while unfocused, a reply still in its quiet period
when focus is lost or another chat is opened, and the restored layout through
`ChatSessionsScreen`) and interaction cases (interaction in an unread open
chat, opening from the list, reply after an interaction, repeated
interactions, interaction in a non-open chat).
- `test/features/chat/conversation/chat_seen_interaction_test.dart` (9 tests):
showing the pane, programmatic scroll, and code-driven focus into the pane
report nothing; click, user drag, mouse wheel, key press, Tab from outside
into the pane, and notification open each report.
- Last run: the two focused files above, 24 passed, 0 failed (memwatch PASS,
peak 943 MB, names only the two intended paths). `tool/analyze.sh`: clean.
- Existing suites that touch the list, controller or server connections
(`chat_seen_sync_test`, `chat_active_session_test`, `chat_active_selection_test`,
`chat_sessions_screen_test`, `chat_sessions_lifecycle_test`,
`chat_sessions_activity_test`, `chat_new_session_controller_test`,
`chat_runtime_test`, `chat_floating_pane_test`, `chat_windows_test`,
`chat_color_test`, `chat_star_optimistic_test`, `chat_state_legibility_test`,
`chat_visibility_marker_test`, `chat_add_pane_picker_test`,
`chat_session_local_state_test`, `server_connections_recovery_test`) pass
unchanged, except one expectation (below).
- Land-gate fix: `test/features/chat/ui/sessions/chat_sessions_live_new_test.dart`
"a tool call and reply in the open chat stay read on leaving" failed in the
full `test/features test/shell test/ui test/core` run. The chat was open with
no user interaction, so under the new rule the reply is not seen. The test
was renamed to "...stay New on leaving without interaction" and now expects
the `chat-row-unread` dot and `isUnseen('s1')` after the chat is left. Its
open-chat assertion (no dot while open) is unchanged. This is the one
behaviour change the task asked for; no other expectation changed.
- Focused rerun after that fix: `chat_sessions_live_new_test.dart`,
`conversation/chat_seen_interaction_test.dart`,
`ui/sessions/chat_seen_interaction_test.dart`: 34 passed, 0 failed (memwatch
PASS, peak 1182 MB, names only those three paths). `tool/analyze.sh`: clean.
## Limitations
- Focus is `resumed` only. On web a backgrounded tab reports `hidden` and
should count as unfocused; an unfocused window with no lifecycle change is
not detected there. Verify on the device or in the browser.
- Only the chat-question notification path (`ChatQuestionNotices`) is wired as
a notification open. Run-level notifications do not name a chat.
- Interactions are reported at the pane level. A chat in a floating window
uses the same pane content, so it is covered, but this was not exercised on
a device.
- No browser or device capture was taken (ui-review owns that).
+75
View File
@@ -0,0 +1,75 @@
# 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.
## Land-gate fix (visit 2)
`chat_permission_card_test.dart`: "a turn waiting on a pending card hides the
running indicator but keeps Stop" asserted a `Stop` tooltip on the composer,
which this change removes by design. It now asserts no `chat-composer-stop`
and that Stop is in the More menu, before and after the permission resolves.
Expectations for behaviour this change did not touch are unchanged.
| Run | Paths | Result |
|---|---|---|
| 3 | `chat_permission_card_test`, `chat_thread_stop_menu_test` | PASS 15/15 |
| 4 | all six focused paths above (escape, spinner, running, stop menu, bar state, permission card) | PASS 44/44 |
`tool/analyze.sh`: 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.
+94
View File
@@ -0,0 +1,94 @@
# Phone bottom navigation bar
Replaces the floating round destination pill on phone-width windows (narrower
than the 600 px list-detail split) with a full-width Material 3 `NavigationBar`:
Pipelines, Runs, Chat, Search, Settings, each with icon, label and the rail's
badges. Wider windows keep the floating bar (the list beside an open item needs
it) and the rail keeps its existing layout.
## Changed paths
- `app/lib/shell/shell_navigation_bar.dart` (new): `ShellNavigationBar`, the
phone bar. Reuses `destinationDetails`, `shellTabDestinations` and the shell's
badge icon builder. Settings is its fifth destination. Wrapped in `SafeArea`
(bottom only). Returns nothing while the keyboard is open
(`viewInsets.bottom > 0`).
- `app/lib/shell/adaptive_shell.dart`: phone path uses the new bar; the floating
bar stays for wider non-rail windows; `hideNavigation` specs still hide the bar.
Pushed detail routes already cover the shell, so the bar stays hidden there.
- Tests: `test/shell/shell_navigation_bar_test.dart` (new, 7 cases),
`test/shell/shell_bar_test.dart`, `test/shell/floating_tab_bar_test.dart`,
`test/shell/attention_badge_test.dart`, `test/shell/navigation_rail_test.dart`,
`test/shell/split_destination_bar_test.dart`,
`test/application/settings_page_test.dart`, `test/widget_test.dart`,
`test/perf/background_work_bench_test.dart` (counts `ShellNavigationBar`
rebuilds now, since the pill is no longer built on phones).
## Behaviour decisions
- Re-tap: `ShellNavigationBar` calls `onSelected` on every tap, including the
shown destination, so `AdaptiveShell._select` (and its `onDestinationSelected`
callback) fires on re-tap. Run 404's hook is not in this branch; nothing to
rename.
- Settings selected: the bar marks Settings (index 4) while the Settings page is
open. The Pipelines gear stays in the Pipelines toolbar.
- Keyboard: the bar leaves whenever the keyboard is open on a phone, not only in
chat. Chat on phone already hides it through its workspace `hideNavigation`.
## Focused results
Command: `tool/memwatch/full.sh` with one quoted path list (new shell test, the
shell and application users of the bar, `widget_test`, two features/chat files,
perf bench). The verdict line named only those paths.
- Final run: 129 passed, 2 failed. Both failures are
`test/application/search_wiring_test.dart` ("field and artifact hits select
their run detail selection", "an abandoned selection does not replay on run
reopen"). They also fail on an untouched base worktree (HEAD 9bb87e51, detached
temporary worktree, removed afterwards), with the same `ok` EditableText
assertion. They are pre-existing and unrelated to the bar.
- New file alone: `shell_navigation_bar_test.dart` 7/7 passed.
- `tool/analyze.sh`: clean (0 errors, 0 warnings, 0 infos) after the final edits.
## Affected UI states (not captured here)
- Phone (390 px) bar, each of Pipelines, Runs, Chat, Search, Settings selected:
covered by widget tests for selection, not rendered.
- Badges: running count on Runs, unread on Chat (widget tests).
- Keyboard open: bar absent (widget test).
- Pushed detail route: bar absent (existing test, `shell_bar_test.dart`).
- Chat workspace: bar absent (existing `hideNavigation`).
- Light and dark captures: NOT produced. Capture belongs to ui-review.
## Limitations
- No device or browser verification of the bar. Its metrics (80 dp `NavigationBar`
height, SafeArea) and the gesture-inset clearance are verified only in widget
tests with the padding faked.
- Settings-as-destination on the phone bar is new behaviour; the Pipelines gear
is still present.
- Medium widths (600 px to the rail threshold) keep the floating pill, by design.
## Land-gate fix (visit 2)
- Failure: `test/ui/adaptive/floating_tab_motion_test.dart` ("switching the shell
tabs never replays the main bar's entrance") ran the shell at 560 px, which is a
phone now and shows the `NavigationBar`, so no `GlassPill` existed (`StateError:
No element`).
- Fix (test only): that one test now sets a 640 px window, above the 600 px split
and below the rail threshold, so it still exercises the floating bar it covers.
No expectation changed; the other six tests in the file are untouched.
- Focused result: `tool/memwatch/full.sh 'test/ui/adaptive/floating_tab_motion_test.dart'`
→ PASS 7 passed, 0 failed (verdict named only that path).
- `tool/analyze.sh`: clean.
- The full gate suite was not re-run here (the land stage runs it).
## Review fix (implement visit 3): run detail hides the phone bar
- Failure: on a phone, a run detail (loaded, and the loading/failed placeholder)
still showed the `NavigationBar`, because both `ShellBar`s in
`lib/features/runs/ui/run_detail_view.dart` lacked `hideNavigation`.
- Fix: `hideNavigation: true` on the detail `ShellBar` and on the placeholder
`ShellBar`. Nothing else changed.
- Regression test: new `test/features/runs/ui/run_detail_phone_navigation_test.dart`
mounts `RunDetailView` in `AdaptiveShell` at 390×844. It asserts no
`NavigationBar` for the loaded detail and for the placeholder, and keeps a
control that the runs list still shows the bar.
- Negative check: with the two `hideNavigation` lines removed, the two detail
tests fail and the control passes; the fix was then restored.
- Focused result: `tool/memwatch/full.sh 'test/features/runs/ui/run_detail_phone_navigation_test.dart test/features/runs/ui/run_detail_widget_test.dart'`
→ PASS 5 passed, 0 failed (verdict named only those two paths).
- `tool/analyze.sh`: clean.
- Not captured here (ui-review owns captures).