Double-click a chat divider to switch the split layout

Double-clicking the divider between two chat panes flips that split between
side by side and stacked, keeping its proportion, instead of resetting it to
50/50. Screen readers get the same action.
This commit is contained in:
2026-11-09 18:36:16 +00:00
parent 96b71d122e
commit 73e55b0b0c
4 changed files with 83 additions and 4 deletions
@@ -176,7 +176,7 @@ void main() {
);
testWidgets(
'divider keyboard resizing and double-click reset use the same limits',
'divider keyboard resizing; double-click switches the split layout',
(tester) async {
final controller = ChatWorkspaceController()
..open('one')
@@ -193,11 +193,29 @@ void main() {
await tester.sendKeyEvent(LogicalKeyboardKey.arrowRight);
await tester.pump();
expect((controller.root! as ChatWorkspaceSplit).ratio, greaterThan(.5));
final resized = (controller.root! as ChatWorkspaceSplit).ratio;
await tester.tap(divider);
await tester.pump(const Duration(milliseconds: 50));
await tester.tap(divider);
await tester.pump(const Duration(milliseconds: 500));
expect((controller.root! as ChatWorkspaceSplit).ratio, .5);
// Side by side becomes stacked, keeping the chosen proportion.
final stacked = controller.root! as ChatWorkspaceSplit;
expect(stacked.axis, ChatSplitAxis.vertical);
expect(stacked.ratio, resized);
final flipped = find.byType(ChatWorkspaceDivider);
expect(
tester.widget<ChatWorkspaceDivider>(flipped).geometry.split.axis,
ChatSplitAxis.vertical,
);
await tester.tap(flipped);
await tester.pump(const Duration(milliseconds: 50));
await tester.tap(flipped);
await tester.pump(const Duration(milliseconds: 500));
expect(
(controller.root! as ChatWorkspaceSplit).axis,
ChatSplitAxis.horizontal,
);
expect(tester.takeException(), isNull);
},
);
@@ -339,4 +357,27 @@ void main() {
},
variant: TargetPlatformVariant.only(TargetPlatform.macOS),
);
test('toggleAxis flips only the named split and keeps every ratio', () {
final controller = ChatWorkspaceController()
..open('one')
..splitActive('two', ChatSplitAxis.horizontal);
addTearDown(controller.dispose);
controller.activate(controller.panes.last.id);
controller.splitActive('three', ChatSplitAxis.vertical);
final root = controller.root! as ChatWorkspaceSplit;
final nested = root.second as ChatWorkspaceSplit;
controller.resize(nested.id, .3);
var notified = 0;
controller.addListener(() => notified++);
controller.toggleAxis(nested.id);
final after = controller.root! as ChatWorkspaceSplit;
expect(after.axis, ChatSplitAxis.horizontal);
final inner = after.second as ChatWorkspaceSplit;
expect(inner.axis, ChatSplitAxis.horizontal);
expect(inner.ratio, .3);
expect(after.ratio, root.ratio);
expect(controller.panes.map((p) => p.sessionId), ['one', 'two', 'three']);
expect(notified, 1);
});
}