App: open a chat, the terminal or a diff in a new window

"Open in new window" sits beside Float: the chat pane and chat list row
menus, a floating chat window's title bar, the terminal options menu and
the diff bar, plus Alt+Shift+Y for the chat with the keyboard (listed in
the shortcut help). Once the window opens the item leaves the main window
as Float takes a pane out of the tiling.

The window is its own app instance at /window/chat/<id>,
/window/terminal?tab=<key> or /window/diff/<token>: only that item, named
after it, with "Bring back to main window". It has its own connection and
writes no shared layout (no open-chat workspace, window store or terminal
layout) and posts no notifications, so they stay the main window's.

Web opens a popup window (a blocked popup offers a tab); Linux and macOS
start a second process with --detached (Flutter's multi-window API is still
experimental); Android and iOS hide the action. The capture kit gains a
follow step for windows a page opens.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-12-03 12:47:42 +00:00
parent c4de1de27b
commit 61c7eee2b0
46 changed files with 3223 additions and 72 deletions
+75
View File
@@ -0,0 +1,75 @@
# Detached windows (Open in new window)
Besides floating inside the app (`notes/floating-windows.md`), a chat, the
terminal or a diff can go to a window of its own, so the app becomes
multi-window.
## Behaviour
- **Entry points** (only where the platform has windows, see below):
- chat pane More menu and chat list row menu: `Open in new window
(Alt+Shift+Y)`, after Float;
- a floating chat window's title bar: the same action beside Dock;
- terminal options (⋮) menu: `Open in new window`, on the selected tab;
- diff page and floating diff window bar: `Open in new window` button.
- **Shortcut**: Alt+Shift+Y (Option+Shift+Y) sends the chat with the keyboard
(a floating chat window's, else the active tiled pane's). Alt+Y stays Float.
Listed in the shortcut help under Windows.
- Once the new window is open the item leaves the main window, as Float takes
a pane out of the tiling: a tiled chat's panes close (the server-synced
open-chat workspace is written by the main window without it), its floating
window closes, the terminal hides, a diff page pops or its floating window
closes. If the window did not open, nothing moves.
- **Detached window**: route `/window/chat/<id>`, `/window/terminal?tab=<key>`
or `/window/diff/<token>` (`lib/application/detached/detached_route.dart`).
It renders only the item: the chat pane with header, find, files and
composer; the terminal's tab strip and body (no panel/float modes); or the
diff page. Its title names the item (`Chat title · Pipelines`).
`Bring back to main window` (chat More menu, terminal strip and diff bar
button) hands it back: the chat docks into the tiling (or opens in Chat),
the terminal shows on that tab, the diff opens in a floating window; then
the detached window closes. With no main window left, a chat or the terminal
turns the detached window into the full app (web) or starts a new main
process (desktop); a diff says so and stays.
- Closing a detached window just closes it.
- A detached window has its own connection and runtime and never writes the
shared layout: no Chat destination (so no `chat_open_workspace` write), no
window manager (no `pipelines.windows.v1`), and `TerminalLayout.persist` is
off. It builds no notification, attention or update machinery, so system
notifications and badges come only from the main window (per origin on the
web, the main process on a desktop).
## Platforms
- **Web**: `window.open(url, name, 'popup,width=…,height=…')`, one window name
per item (opening it again focuses that window). A blocked popup shows a
SnackBar explaining it, with `Open in tab` (a fresh click, so allowed).
Same origin: the session cookie and local preferences are shared. Bring back
posts a marked message to `window.opener` (same origin only). A diff's files
are handed over in `localStorage` under a one-time token, then kept in the
window's `sessionStorage` for reloads. The page keeps its `/window/…` URL
(the MaterialApp's only route is named by it), so a reload reopens it.
- **Linux, macOS**: Flutter 3.44's multi-window API is still experimental, so
a second process of the same executable starts with `--detached <path>`
and `PIPELINES_DETACHED=<path>` (the macOS runner does not pass arguments to
Dart). The Linux runner reads `PIPELINES_WINDOW_TITLE` and
`PIPELINES_WINDOW_SIZE` for the GTK title and default size. The child writes
Bring back as a marked line on stdout, which the parent reads; the diff
hand-over is a temp file.
- **Android, iOS**: no action (the opener scope is absent).
## Checks
- Tests: `test/application/detached/` (route parsing, opener, detached app,
no shared writes, main-window integration), `test/features/chat/
chat_new_window_test.dart`, `test/features/terminal/
terminal_new_window_test.dart`, `test/features/changes/
diff_new_window_test.dart`, `test/shell/detached/`.
- Captures (web, 2026-12-03, 1400x900, light and dark):
`tool/capture/examples/detached-chat-window.json` (pane menu, the detached
chat, its menu, the main window after, Bring back) and
`detached-terminal-window.json`. The kit's `follow=<url part|main>` step
moves to a window the page opened.
- Not verified: the native Linux/macOS processes (no CMake on the review host,
no Mac); the runner change was only syntax-checked. Installed-PWA window
behaviour was not captured (headless Chrome).