Files
pipelines/app/notes/phone-back-server-sync.md
T
alan 45f5323c75 Keep phone chat back on the list
Treat server-synced open workspace snapshots as pane membership only so they do not show or retain a phone chat page. Add regression coverage for repeated system, button, and predictive Back cycles with tiled and floating entries.
2026-11-12 13:18:05 +00:00

74 lines
4.4 KiB
Markdown

# Phone Back after server-synced open chats
## Cause
`_applyOpenWorkspace` (`lib/features/chat/chat_screen_workspace.dart`) showed the
workspace on the first server snapshot that held panes: it set
`_workspaceVisible = true`, marked the Chat destination used, and published
`/chat/<id>`. On a phone the first Back then only cleared the route to the
chat again, so the route stayed `/chat/<id>` and the list reported
`handlesBack=true` before any chat was tapped.
## Change
- `_applyOpenWorkspace` only changes pane membership (windows, panes, floating
state, active pane for a deep link). It no longer shows the workspace, sets
`_usedWorkspace` or publishes a route.
- A server snapshot that removes the last pane while a chat is shown no longer
calls `_back()`. Review must-fix (`chat_screen_workspace.dart`, the
`paneCount == 0 && _workspaceVisible` check) removed: that call changed the
route and view from a snapshot. The chat page stays as it was; Back from it
still returns to the list on the first press.
## Tests
- `test/application/chat_phone_back_server_sync_test.dart` (new): 412x915 phone,
server holds two tiled chats, or one tiled plus one floating. Opens a tiled
chat from its row and presses Back 20 times each via `handlePopRoute`, the
BackButton tap and a predictive back gesture. After each Back asserts route
`/chat`, no thread, list rows present (including the floating chat's row),
and `setFrameworkHandlesBack(false)`. Before the fix the run failed with the
route still `/chat/a` after the first Back (observed in several cases).
A floating chat's row raises its window rather than opening a page (existing
behaviour; `ChatWorkspaceController.open` returns early for floating chats),
so the cycle opens only tiled chats.
- Same file, new test: a server snapshot that removes the open chat while its
page is shown leaves route `/chat/a` unchanged; the first system Back then
returns to the list with its rows and `setFrameworkHandlesBack(false)`. It
fails when the removed `_back()` call is put back (checked).
- `test/features/chat/chat_open_workspace_sync_test.dart`: "rebinding to another
server disposes the old sync" depended on the first snapshot showing the
workspace on a wide layout. It now taps each server's chat row before
checking panes; its pane and write assertions are unchanged.
## Results (focused, via tool/memwatch/full.sh)
- Two changed test files (chat_phone_back_server_sync, chat_open_workspace_sync):
10 passed, 0 failed.
- Related files (chat_phone_back_server_sync, chat_registration, chat_wide_back,
chat_scroll_back, list_detail_consistency, chat_floating_pane,
chat_open_workspace_sync, chat_pane_move, chat_workspace_restore,
chat_open_workspace_controller, chat_open_workspace_gateway), after the
must-fix: 66 passed, 4 failed. The 4 failures are all in `test/application/chat_registration_test.dart`
and also fail with the fix reverted (same names):
- mobile Chats retap reopens the retained multi-pane workspace after tabs
- a folded workspace rejects paste while retained behind the list
- mobile Chats retap stays on list with no history or a removed chat
- Chats retap restores a boot deep link after folding and Back
These are pre-existing on this HEAD; they are phone chat-list tests, so they
cannot confirm this change's phone behaviour. Not investigated further.
- `tool/analyze.sh`: clean (run after the focused tests).
- `dart format --set-exit-if-changed` clean on the changed Dart files.
## Affected states (not captured here; ui-review owns capture)
- Phone, Chat list after server sync with 2 tiled or 1 tiled + 1 floating: list
stays on screen; Back from a chat returns to it on the first press.
- Wide layout, server holds open chats and no local layout: the list shows
without the tiling until a chat is opened from its row. Previously the
server's panes appeared at once. Desktop behaviour change, see limitations.
## Limitations
- Wide/desktop: a new device no longer shows the server's open chats beside
the list on first load; they stay retained and appear when a chat is opened.
- Server removes the open chat while its page is shown: the page stays with
route `/chat/<id>` and no pane until the user presses Back. The snapshot no
longer changes the view, so this empty page is left for the user to dismiss.
Whether it should show differently (e.g. an empty state) is open for review.
- Not built or captured; no device run.