From 61e5f19abd88775aee0372de660997a4c9d56e5f Mon Sep 17 00:00:00 2001 From: Alan Silva Date: Tue, 10 Nov 2026 13:26:15 +0000 Subject: [PATCH] Lay out each chat once per center stage move and record the feature --- .../workspace/chat_center_stage_motion.dart | 13 ++-- app/notes/chat-center-stage.md | 72 +++++++++++++++++++ .../workspace/chat_center_stage_test.dart | 15 +++- 3 files changed, 94 insertions(+), 6 deletions(-) create mode 100644 app/notes/chat-center-stage.md diff --git a/app/lib/features/chat/workspace/chat_center_stage_motion.dart b/app/lib/features/chat/workspace/chat_center_stage_motion.dart index 7c5e1f44..fad8bfdd 100644 --- a/app/lib/features/chat/workspace/chat_center_stage_motion.dart +++ b/app/lib/features/chat/workspace/chat_center_stage_motion.dart @@ -95,8 +95,11 @@ class ChatCenterStageMotion { _controller.forward(from: 0); } - /// Where [id] paints now, or null when this motion does not place it. + /// Where [id] paints now, or null when this motion does not place it: at + /// rest in the split layout the workspace's own geometry (and its pane-move + /// glide) applies. Rect? rectFor(String id) { + if (_stage == null && !isAnimating) return null; final to = _to[id]; if (to == null) return null; if (!isAnimating) return to; @@ -111,11 +114,13 @@ class ChatCenterStageMotion { return lerpDouble(from, to, _t)!; } - /// A strip keeps its chat laid out at a usable width beneath the title, so - /// the transcript never reflows into a sliver. + /// The size [id]'s chat is laid out at. A strip keeps its chat at a usable + /// width beneath the title, so the transcript never reflows into a sliver. + /// While moving, each chat is laid out once at its destination size and only + /// its clipped, painted rectangle travels: no transcript relayout per frame. Size? viewportFor(String id) { if (_role == null || (_stage == null && !isAnimating)) return null; - final rect = rectFor(id); + final rect = _to[id]; if (rect == null) return null; return Size(math.max(rect.width, chatPaneMinimumWidth), rect.height); } diff --git a/app/notes/chat-center-stage.md b/app/notes/chat-center-stage.md new file mode 100644 index 00000000..b5e2bf7c --- /dev/null +++ b/app/notes/chat-center-stage.md @@ -0,0 +1,72 @@ +# Chat center stage + +A toggle for the wide (browser/desktop) split chat workspace. While it is on, +the active chat takes center stage and the other chats line up beside it; the +stage follows whichever chat becomes active. Phones (the one-chat layout) are +unchanged. + +## Using it + +- Cmd+E on macOS/iOS, Ctrl+E elsewhere, or the pane's More menu: + **Center stage (Cmd+E)** / **Leave center stage (Cmd+E)** (shown with two or + more panes on a wide window). +- The choice is device-local (`pipelines.next.chatCenterStage.v1` in shared + preferences) and survives reloads. It is not part of the server-scoped + workspace snapshot. +- Any activation moves the stage: clicking or tapping a strip (which also + focuses that chat's composer), Ctrl/Cmd+Shift+Left/Right, Ctrl+Tab, opening an + already-open chat from the list, quick switch, or the Open chats picker. + Opening a new chat from the list replaces the staged chat, as in the split + layout. +- Ctrl/Cmd+Alt+Shift+Left/Right (pane moves) moves the staged chat along the + strip order. Up/down have no neighbours on stage. + +## Layout (`chat_center_stage_layout.dart`) + +- Stage width = `kChatReadingWidth` (760, the transcript's reading column) x + 1.25 = 950, capped so every other pane keeps at least a 56 px strip. Stage + and strips take the full height and are separated by the 12 px divider gap. +- Panes keep their split-tree order left to right. The others share the + remaining width. A column narrower than `chatPaneMinimumWidth` (240) is + covered by a strip (`ChatCenterStageStrip`: the chat colour, a dot and the + title running down the column, Material InkWell / CupertinoButton). Wider + columns, on very wide screens, stay as live, usable chats. +- If there is not room for a 240 px stage plus every strip, or there is only + one pane, the split layout stays. +- The split tree, ratios and dividers are never touched, so leaving center + stage restores the exact split sizes. Dividers are hidden on stage. + +## Motion (`chat_center_stage_motion.dart`) + +- 350 ms, `Curves.easeInOutCubicEmphasized`, for entering, leaving and the + stage moving between chats. Divider drags and window resizes follow at once. + Durations are scaled by the animation-speed setting through the global clock; + reduced motion (MediaQuery) settles instantly. +- Every chat view stays one retained sibling (no reparenting, no remount): the + painted, clipped rectangle travels while each chat is laid out once at its + destination size, so drafts, scroll positions and running turns are kept + and transcripts do not relayout per frame. A covered strip lays its chat out + at 240 px underneath and excludes it from focus traversal. + +## Keyboard and browser + +`ChatCenterStageKeys` is a FocusManager early key handler (like the terminal's +toggle), so the chord works while a composer, the sidebar or a toolbar has +focus and is never typed. A plain `e` and the other platform's chord pass +through: on a Mac, Ctrl+E stays the text fields' end-of-line. Elsewhere Ctrl+E +is left to the terminal while it has focus (the shell's end-of-line); on a Mac +Cmd+E works in the terminal too. Handling the key makes the Flutter web engine +call `preventDefault`, so Chrome's Ctrl+E (address bar search on +Windows/Linux) and Cmd+E (use selection for Find on macOS) do not fire while +the app has the keyboard. Neither is a browser-reserved shortcut. Only +CDP-injected keys were used in captures, so the physical browser default was +not observed directly. + +## Files + +New: `lib/features/chat/workspace/chat_center_stage_{layout,motion,controller,keys,strip,action}.dart`, +`test/features/chat/workspace/chat_center_stage_test.dart`. +Small edits: `chat_workspace.dart` (centerStage/paneColor parameters, motion, +stage-aware neighbours), `chat_workspace_surface.dart` (stage rects, viewport, +strip layer, dividers), `chat_screen_workspace.dart` (keys wrapper, colours), +`screen.dart` (menu action). diff --git a/app/test/features/chat/workspace/chat_center_stage_test.dart b/app/test/features/chat/workspace/chat_center_stage_test.dart index 8f72556c..e097f094 100644 --- a/app/test/features/chat/workspace/chat_center_stage_test.dart +++ b/app/test/features/chat/workspace/chat_center_stage_test.dart @@ -6,6 +6,7 @@ import 'package:pipelines_app/features/chat/workspace/chat_center_stage_controll import 'package:pipelines_app/features/chat/workspace/chat_center_stage_keys.dart'; import 'package:pipelines_app/features/chat/workspace/chat_center_stage_layout.dart'; import 'package:pipelines_app/features/chat/workspace/chat_center_stage_strip.dart'; +import 'package:pipelines_app/features/chat/workspace/chat_motion_viewport.dart'; import 'package:pipelines_app/features/chat/workspace/chat_workspace.dart'; import 'package:pipelines_app/features/chat/workspace/chat_workspace_geometry.dart'; @@ -166,8 +167,18 @@ void main() { stage.value = true; await tester.pump(); await tester.pump(const Duration(milliseconds: 40)); - // Mid-flight the stage is on its way, neither split nor staged. - expect(widthOf(tester, 'three'), inExclusiveRange(before['three']!, 950)); + // Mid-flight the stage's painted rectangle is on its way, while its chat + // is laid out once, at its destination width. + final painted = tester + .getSize( + find.ancestor( + of: find.byKey(const ValueKey('input-three')), + matching: find.byType(ChatMotionViewport), + ), + ) + .width; + expect(painted, inExclusiveRange(before['three']!, 950)); + expect(widthOf(tester, 'three'), 950); await tester.pumpAndSettle(); expect(widthOf(tester, 'three'), 950); expect(find.byType(ChatCenterStageStrip), findsNWidgets(2));