Merge commit '699c3adea55fa1a33801988e0cd588ff610be06a' into pipelines/run-20261112-0201-chat-seen-only-after-real-interaction-7302
This commit is contained in:
@@ -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,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.
|
||||
@@ -0,0 +1,71 @@
|
||||
# Android notifications grouped per chat and run
|
||||
|
||||
## What changed (native service only; Flutter unchanged)
|
||||
|
||||
- `android/.../notify/NotificationThreads.kt` (new): `ThreadEntry`, `ThreadHistory`
|
||||
(bounded per-thread entries, bounded thread count, persisted through the
|
||||
ledger's `LedgerStore` under `threads.history`), and naming helpers. Threads are
|
||||
keyed by the server `group` (`chat:<id>` or `run:<id>`, per `docs/ntfy.md`).
|
||||
- `NotificationPresenter.kt`: a grouped notification posts one conversation
|
||||
notification per thread with a stable id (`thread:<group>`), the latest 5 lines
|
||||
(sender = chat title, run title for runs), the unread count (`setNumber`), and a
|
||||
shared group per namespace (`pipelines.chats`, `pipelines.runs`). The group
|
||||
summary reads "N chats" / "N runs" and is removed when fewer than two are shown.
|
||||
Empty-group notifications keep the old standalone path. Channels and importance
|
||||
are unchanged (`channelFor` takes kind and priority, same rules).
|
||||
- `cancel(ids)` removes the cleared entries from history, drops a thread whose
|
||||
entries are all gone, and reposts a partially cleared thread with its new count.
|
||||
`cancelAll()` also clears the history.
|
||||
- `NotificationDismissReceiver.kt`: `EXTRA_NOTIFICATION_ID` may carry several
|
||||
newline-separated ids, so a tap or swipe on a thread clears every entry it shows.
|
||||
- `NotificationService.kt`, the ledger and the protocol are untouched, so run 405's
|
||||
reconnect/wakelock work is not affected.
|
||||
|
||||
## Review fix (visit 2)
|
||||
|
||||
- The thread notification now uses `androidx.core.app.NotificationCompat.MessagingStyle`
|
||||
with `androidx.core.app.Person`, built by `NotificationCompat.Builder` (the presenter's
|
||||
builder is compat throughout). Platform `Notification.MessagingStyle` and its API 28
|
||||
BigTextStyle fallback are gone; the compat style renders on every supported API level.
|
||||
- `app/android/app/build.gradle.kts` adds `implementation("androidx.core:core:1.15.0")`
|
||||
(already in the offline Gradle cache).
|
||||
|
||||
## Focused results
|
||||
|
||||
- Gradle 9.1.0 (cached), `--offline`, JDK 17 (`/opt/homebrew/opt/openjdk@17`):
|
||||
`:app:testDebugUnitTest --tests 'net.awan.pipelines_app.notify.*'` → BUILD SUCCESSFUL.
|
||||
JUnit XML: ThreadHistoryTest 9 tests / 0 failures, DeliveryLedgerTest 8 / 0,
|
||||
NotificationProtocolTest 12 / 0.
|
||||
- `tool/analyze.sh` (run from `app/`, after the Kotlin tests): clean, exit 0.
|
||||
- No Flutter test was run: no Dart source changed.
|
||||
- JDK 27 fails the Android JDK image transform (`jlink`) in a plugin, so builds here
|
||||
need JDK 17 (environment issue, unrelated to this change).
|
||||
|
||||
## Affected states
|
||||
|
||||
- No Flutter UI changed. Native states not exercised on a device: a second chat
|
||||
appearing as a thread, a summary at 2 and 1 chats, tap/swipe on a multi-line
|
||||
thread, and the restart rebuild from persisted history.
|
||||
|
||||
## Merge with main (land re-entry)
|
||||
|
||||
- main moved `NotificationPresenter.kt` (sign-in notice, `openApp()` helper,
|
||||
`SIGN_IN_ID`, `ACCOUNT_CHANNEL`). Resolved by keeping both sides: the
|
||||
connection notification uses `openApp()`, and the sign-in block, constants and
|
||||
thread code all remain. The merge is staged with `--no-commit`; land concludes it.
|
||||
- Gradle, JDK 17, offline: `:app:compileDebugUnitTestKotlin` succeeds.
|
||||
- Gradle, JDK 17, offline: `:app:testDebugUnitTest --tests 'net.awan.pipelines_app.notify.*'`
|
||||
passes 37 of 37 (ConnectionLog 5, DeliveryLedger 8, NotificationProtocol 12,
|
||||
ReconnectPolicy 3, ThreadHistory 9).
|
||||
- No Dart changed in this stage, so no Flutter tests or analyze were run.
|
||||
|
||||
## Limitations
|
||||
|
||||
- Android posting (MessagingStyle, summary, PendingIntent extras) is not covered by
|
||||
JVM tests and has not been run on a device. Mobile behaviour is unverified.
|
||||
- The new androidx.core dependency is compiled offline but not run through a full
|
||||
APK build or on a device in this stage.
|
||||
- History is capped: 100 unread entries per thread (count is capped there) and 50
|
||||
threads; the oldest thread is forgotten first when the cap is hit.
|
||||
- Swipe-dismissal of a thread clears its ids on the server, but the local history
|
||||
is trimmed only when the server confirms (`notifications_cleared`).
|
||||
Reference in New Issue
Block a user