Float one chat pane over the app and toggle it with Ctrl+Y / Cmd+Y
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
# Floating chat pane
|
||||
|
||||
On a wide layout one chat at a time can leave the split tiling and float in a
|
||||
window over the app, like the floating terminal. Ctrl+Y (Cmd+Y on macOS)
|
||||
shows or hides it.
|
||||
|
||||
## Behaviour
|
||||
|
||||
- **Float**: a tiled pane's More menu offers `Float (Ctrl+Y)` (`Cmd+Y` on Apple
|
||||
platforms) when another chat stays in the tiling. A single chat cannot float,
|
||||
because the tiling would be empty. Floating a second chat swaps them: the chat
|
||||
that was floating goes back into the tiling where the new one was.
|
||||
- **Window**: you drag it by its title bar and resize it from the lower right
|
||||
corner. The title bar has Dock and Hide buttons. The window keeps its frame
|
||||
inside the app when the browser window resizes (`fitChatFloat`). Grow and fade
|
||||
in, and shrink and fade out, use `Motion.standard` through `Motion.of`, so
|
||||
reduced motion and the animation speed apply.
|
||||
- **Floating chat's menu**: Dock (back into the tiling, right of the active pane,
|
||||
which it becomes), `Hide floating chat (Ctrl+Y)`, and Close pane (removes it
|
||||
from the workspace; no backend close). If the last tiled pane closes, the
|
||||
floating chat docks in its place.
|
||||
- **Shortcut**: Ctrl+Y on every platform, and Cmd+Y on macOS and iOS. It is an
|
||||
early key handler, so it works from a composer or the terminal; Y, Shift+Y and
|
||||
Alt+Y still type. When no chat floats, Ctrl+Y floats the tiled pane that has
|
||||
the keyboard. When no pane has the keyboard, or that pane cannot float, the
|
||||
chord is left alone. So in the terminal Ctrl+Y stays the shell's yank until a
|
||||
chat floats. After that, on Windows, Linux and web, Ctrl+Y toggles even from
|
||||
the terminal (yank is unavailable there, as with Ctrl+T). On macOS, Ctrl+Y in
|
||||
a `TypingSurface` (terminal) always goes to the shell, and Cmd+Y toggles.
|
||||
- **Focus**: showing the chat focuses its composer. Hiding it gives the keyboard
|
||||
back to whatever had it before (as `TerminalFocus` does), otherwise the
|
||||
keyboard is unfocused.
|
||||
- **Where it shows**: only on a wide layout and while Chat is the current
|
||||
destination. On narrow or phone layouts, and on other destinations, the menu
|
||||
item is absent and the chord passes through. A chat that is already floating
|
||||
stays floating there, unpainted, with its state, and reappears when the
|
||||
window is wide again.
|
||||
- **Persistence**: `pipelines.next.chatFloat.v1` is stored device-locally and
|
||||
scoped like the workspace layout. It records the floating pane's id and
|
||||
session, whether it is shown, and the frame. It is restored after the
|
||||
workspace layout. A saved float whose session is already tiled is dropped.
|
||||
|
||||
## Design
|
||||
|
||||
- `ChatWorkspaceController` keeps the floating pane outside the tree
|
||||
(`chat_workspace_float.dart`, a `part` with the `ChatWorkspaceFloat`
|
||||
extension). `panes` and `paneCount` stay tiled-only. The pane keeps its id
|
||||
through float, swap, hide and dock.
|
||||
- `ChatWorkspace` gives each pane's content a `GlobalKey`. The floating chat is
|
||||
that same keyed subtree, built by `ChatFloatHost` inside the workspace, so the
|
||||
`ChatThreadView` State, draft, scroll and running turn move with it and are
|
||||
not rebuilt. Its inherited context and focus tree stay in the workspace.
|
||||
- `FloatingLayer` (`lib/ui/floating/`) paints a layer in the root overlay
|
||||
through `OverlayPortal`. The chat window covers the whole app. The terminal's
|
||||
floating window now uses the same layer, so the two share one z-order: the
|
||||
last one pressed, focused or opened is on top. Without an overlay (bare
|
||||
widget tests) the layer paints in place.
|
||||
- New files: `chat_float_{host,window,binding,store,shortcut}.dart`,
|
||||
`chat_workspace_float.dart`, `chat_screen_float.dart` and
|
||||
`ui/floating/floating_layer.dart`. Existing files changed: workspace
|
||||
controller hooks (open, split, close, replace, restore), the
|
||||
`ChatWorkspace.floatFrame` parameter and keyed content, the pane controls and
|
||||
`/close` and `/new` handling in `screen.dart`, the persistence wiring in
|
||||
`chat_screen_workspace.dart`, and `terminal_stage.dart`.
|
||||
|
||||
## Not done
|
||||
|
||||
- The sidebar's "visible" highlight does not count the floating chat.
|
||||
- Cmd+Y in a browser on macOS may be taken by the browser (History) before the
|
||||
app sees it. Ctrl+Y works there.
|
||||
Reference in New Issue
Block a user