Files
pipelines/app/notes/chat-stack.md
T
alan fba3b924f1 Chat stack: hold and drag to reorder the open chats, or onto x to remove
A 300 ms hold lifts a chat in the open column; dragging opens a gap and
dropping commits through ChatWorkspaceController.movePane, the pane order
the server syncs. An x comes in at the bottom while dragging; dropping on
it removes the chat with Undo, which restores its place. Escape, a
cancelled pointer or a drop away from the column put it back. Move up,
Move down and Remove are semantic actions. Repaint-only motion; reduced
motion swaps at once. Also keep floating-layout tracking out of
initState, and let the capture kit hold a press before a drag.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-03 21:17:51 +00:00

92 lines
5.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Chat stack (phone chat navigation)
## Setting
Settings → Mobile chat navigation: Quick switch (default, the next chat's
peek under the current one) or Chat stack. Per device
(`pipelines.mobile-chat-navigation.v1`, `MobileChatNavigationController`,
restored in `bootstrap.dart`), applied live, and only on a phone-width layout
(`!showsListBesideDetail`). A wide window keeps its panes and shows no stack.
## Behaviour
- The stack's chats are the workspace's panes: the same open-chat set the
server syncs (`ChatOpenWorkspaceController`). Choosing one opens it as a tap
on its list row does (`_openBySelection`); Add chat is the pane menu's Add
chat pane picker (searchable, the list's own rows) titled "Add chat".
- Drag: in the open column a 300 ms hold (a quicker tap still opens) lifts
a chat with its pill: a medium haptic, 1.1x scale and a deeper shadow
(flat designs: a primary-colour frame instead). Dragged up or down, the
others slide aside (200 ms ease-out) to open its slot, with a selection
tick per slot; dropping commits through `ChatWorkspaceController.movePane`
(the pane order the server syncs as the open-chat order). A "×" fades and
slides in, centred in the band below the stack's slot (over the composer,
above the safe area); over it (a reach of 0.8x its size around its centre)
it grows 1.2x and fills with the error colour, and the chat shrinks into
it. Dropping there removes the pane with the Undo snack bar; Undo re-adds
it at its old index and keeps the chat on screen. A drop far to the side
(more than 1.5 pitches) or Escape or a cancelled pointer puts it back.
Add chat never lifts and is never a slot. Semantics: Move up, Move down,
Remove from open chats as custom actions on each chat. Reduced motion:
neighbours swap at once, the lift and settle are instant, the "×" only
fades and does not grow.
- Collapsed: up to four avatars piled with small offsets and turns, the chat
on screen on top; a count badge when more are open, and a bell when another
open chat waits on the operator. It sits bottom-end in the active chat's
transcript area, just above the composer, so it never covers Send; the
transcript pads its last line and Jump to latest above it. It hides while
the on-screen keyboard is up (the window's view insets).
- Expanded: a scrim, and a column rising from the stack's slot. The chats keep
the open-chat order bottom-up (stable positions for muscle memory); the chat
on screen wears a ring in its colour; each avatar keeps its list badges
(waiting, working, background tasks) and has a name pill tinted with its
colour. Add chat is the last item, at the top: the reachable bottom slots
go to switching, the frequent action. Tap outside, Back or Escape folds it.
- Motion: one controller, 280 ms open (staggered, a slight-overshoot ease),
220 ms fold (top first). Items move through `ChatStackPoseTransition`, a
repaint-only transform render object that reuses its matrix and layer; no
per-frame rebuilds, no blur. A drag adds `ChatStackDragShift` (same idea,
driven by a per-item notifier, no layer at rest); the column rebuilds only
when a drag starts and ends. Reduced motion: a 120 ms plain fade in place.
- Design tokens: circle discs with a short shadow under Default; the design's
square corners and no shadow under flat designs (Terminal, Paper); label
pills take the design radius and frame.
## Structure
- `lib/features/chat/stack/`: setting, pose, motion, disc/label, column and
its items, drag (session, shift render object, handles, remove target), FAB,
anchor (a `LayerLink` the active pane's transcript marks; the one stack
above the workspace follows it, so it survives switching chats).
- `lib/features/chat/chat_screen_stack.dart`: entries, open/add/remove.
- `chat_thread_view.dart`: anchor target, bottom clearance, Jump offset.
- `tool/search_selection_probe_entry.dart`: `?chatNav=stack`.
## Floating chats on a phone
A phone layout (Quick switch or Chat stack) ignores floating: windows are
hidden below `kListDetailMinWidth`, so each floating chat is held as an
ordinary pane (`_phoneDocked` in `chat_screen_workspace.dart`) and the
server's set keeps it `floating`. Widening the window (a foldable opened, a
desktop resized) floats those chats again; closing one on the phone drops
it from the open chats. Tests: `test/features/chat/chat_floating_phone_test.dart`.
## Captures
Drag captures use the kit's mouse `drag` with `press: 700`: with Flutter
web semantics on (the kit turns it on), the engine's click debouncer holds a
press on a tappable node for about 200 ms before the framework sees it, so
a 300 ms hold needs about 500 ms in the browser. Not an issue on a device
without a screen reader.
## Not verified
On-device behaviour (Android keyboard insets, haptics) was not run on a
device; web captures used Chrome's touch emulation at 390x844.
Drag limits: no auto-scroll while dragging; when the column is taller than
the screen it scrolls and clips, so a lifted chat cannot leave the clipped
column to reach the "×" there (Move and Remove remain as semantic actions).
The drag captures used the mouse (CDP), not touch; on-device haptics and the
hold feel are unverified.