Merge main: pane moves alongside center stage

This commit is contained in:
2026-11-10 13:12:24 +00:00
18 changed files with 1152 additions and 52 deletions
@@ -0,0 +1,222 @@
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:pipelines_app/core/api_gateway.dart';
import 'package:pipelines_app/features/chat/screen.dart';
import 'package:pipelines_app/features/chat/conversation/chat_thread_view.dart';
import 'package:pipelines_app/features/chat/ui/sessions/session_actions.dart';
import 'package:pipelines_app/features/chat/workspace/chat_workspace.dart';
import 'package:pipelines_app/features/chat/workspace/chat_workspace_store.dart';
import 'conversation/chat_thread_fixtures.dart';
class _Gateway extends FakeChatGateway {
@override
Future<JsonMap> call(String type, [JsonMap fields = const {}]) {
if (type == 'chat_sessions') {
return Future.value({
'chat_sessions': [
for (final id in ['a', 'b', 'c']) {'id': id, 'title': 'Chat $id'},
],
});
}
if (type == 'chat_shells') return Future.value({'chat_shells': []});
return super.call(type, fields);
}
}
Finder _thread(String id) => find.byWidgetPredicate(
(widget) => widget is ChatThreadView && widget.sessionId == id,
);
Finder _input(String id) => find.descendant(
of: find.byKey(ValueKey('chat-composer-$id')),
matching: find.byType(EditableText),
);
Future<_Gateway> _setup(WidgetTester tester, {Size? size}) async {
SharedPreferences.setMockInitialValues({});
tester.view.physicalSize = size ?? const Size(1800, 1000);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.reset);
final gateway = _Gateway()..history = (_) async => chatPage([]);
addTearDown(gateway.close);
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
body: ChatScreen(gateway: gateway, persistWorkspace: true),
),
),
);
await tester.pumpAndSettle();
await tester.tap(find.text('Chat a').first);
await tester.pumpAndSettle();
return gateway;
}
Future<void> _split(WidgetTester tester, String id) async {
await tester.tap(
find.byWidgetPredicate(
(widget) => widget is SessionActionsButton && widget.session['id'] == id,
),
);
await tester.pumpAndSettle();
await tester.tap(find.text('Open to the right'));
await tester.pumpAndSettle();
}
Future<void> _openMenu(WidgetTester tester, String session) async {
await tester.tap(
find.descendant(
of: find.descendant(
of: _thread(session),
matching: find.byKey(const Key('chat-actions-island')),
),
matching: find.byTooltip('More actions'),
),
);
await tester.pumpAndSettle();
}
MenuItemButton _item(WidgetTester tester, String label) =>
tester.widget<MenuItemButton>(
find.ancestor(of: find.text(label), matching: find.byType(MenuItemButton)),
);
ChatWorkspaceController _controller(WidgetTester tester) =>
tester.widget<ChatWorkspace>(find.byType(ChatWorkspace)).controller;
void main() {
testWidgets(
'pane menu moves a chat beside its neighbour and keeps its state',
(tester) async {
final gateway = await _setup(tester);
await _split(tester, 'b');
final state = tester.state(_thread('a'));
await tester.enterText(_input('a'), 'Keep this draft');
gateway.emitEvent(
chatTextFrame('Streamed to a', session: 'a', messageId: 'live-a'),
);
await tester.pumpAndSettle();
expect(
tester.getCenter(_thread('a')).dx,
lessThan(tester.getCenter(_thread('b')).dx),
);
await _openMenu(tester, 'a');
expect(_item(tester, 'Move right').onPressed, isNotNull);
for (final label in ['Move up', 'Move down', 'Move left']) {
expect(_item(tester, label).onPressed, isNull, reason: label);
}
expect(
(_item(tester, 'Move right').shortcut! as SingleActivator)
.debugDescribeKeys(),
'Control + Alt + Shift + Arrow Right',
);
await tester.tap(find.text('Move right'));
await tester.pumpAndSettle();
expect(
tester.getCenter(_thread('a')).dx,
greaterThan(tester.getCenter(_thread('b')).dx),
);
expect(tester.state(_thread('a')), same(state));
expect(
tester.widget<EditableText>(_input('a')).controller.text,
'Keep this draft',
);
expect(
find.descendant(of: _thread('a'), matching: find.text('Streamed to a')),
findsOneWidget,
);
expect(_controller(tester).activePane?.sessionId, 'a');
expect(
tester.widget<EditableText>(_input('a')).focusNode.hasFocus,
isTrue,
);
// The new order is what a reload restores.
await tester.pump(const Duration(milliseconds: 300));
await tester.pumpAndSettle();
final preferences = await SharedPreferences.getInstance();
final saved = preferences
.getKeys()
.where((key) => key.startsWith(chatWorkspacePreferenceKey))
.map(preferences.getString)
.single!;
final root = jsonDecode(saved)['root'] as Map;
expect((root['first'] as Map)['session_id'], 'b');
expect((root['second'] as Map)['session_id'], 'a');
await _openMenu(tester, 'a');
expect(_item(tester, 'Move left').onPressed, isNotNull);
expect(_item(tester, 'Move right').onPressed, isNull);
await tester.sendKeyEvent(LogicalKeyboardKey.escape);
await tester.pumpAndSettle();
expect(tester.takeException(), isNull);
},
variant: TargetPlatformVariant.only(TargetPlatform.linux),
);
testWidgets(
'Ctrl+Alt+Shift+Arrow moves the focused chat with its draft and focus',
(tester) async {
await _setup(tester);
await _split(tester, 'b');
final state = tester.state(_thread('b'));
await tester.enterText(_input('b'), 'Typed in b');
await tester.pumpAndSettle();
final text = tester.widget<EditableText>(_input('b')).controller;
final selection = text.selection;
await tester.sendKeyDownEvent(LogicalKeyboardKey.controlLeft);
await tester.sendKeyDownEvent(LogicalKeyboardKey.altLeft);
await tester.sendKeyDownEvent(LogicalKeyboardKey.shiftLeft);
await tester.sendKeyEvent(LogicalKeyboardKey.arrowLeft);
await tester.sendKeyUpEvent(LogicalKeyboardKey.shiftLeft);
await tester.sendKeyUpEvent(LogicalKeyboardKey.altLeft);
await tester.sendKeyUpEvent(LogicalKeyboardKey.controlLeft);
await tester.pumpAndSettle();
expect(
tester.getCenter(_thread('b')).dx,
lessThan(tester.getCenter(_thread('a')).dx),
);
expect(tester.state(_thread('b')), same(state));
expect(text.text, 'Typed in b');
expect(text.selection, selection);
expect(
tester.widget<EditableText>(_input('b')).focusNode.hasPrimaryFocus,
isTrue,
);
expect(_controller(tester).activePane?.sessionId, 'b');
expect(tester.takeException(), isNull);
},
variant: TargetPlatformVariant.only(TargetPlatform.linux),
);
testWidgets('a phone shows no move items for its one-at-a-time panes', (
tester,
) async {
SharedPreferences.setMockInitialValues({});
tester.view.physicalSize = const Size(560, 1000);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.reset);
final gateway = _Gateway()..history = (_) async => chatPage([]);
addTearDown(gateway.close);
await tester.pumpWidget(
MaterialApp(home: Scaffold(body: ChatScreen(gateway: gateway))),
);
await tester.pumpAndSettle();
await tester.tap(find.text('Chat a').first);
await tester.pumpAndSettle();
_controller(tester).splitActive('b', ChatSplitAxis.horizontal);
await tester.pumpAndSettle();
await tester.tap(find.byTooltip('More actions').hitTestable().first);
await tester.pumpAndSettle();
expect(find.text('Close pane'), findsOneWidget);
for (final label in ['Move up', 'Move down', 'Move left', 'Move right']) {
expect(find.text(label), findsNothing, reason: label);
}
});
}
@@ -0,0 +1,308 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/features/chat/workspace/chat_center_stage_controller.dart';
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_workspace.dart';
import 'package:pipelines_app/features/chat/workspace/chat_workspace_geometry.dart';
class _MemoryStore implements ChatCenterStageStore {
_MemoryStore();
bool? saved;
@override
Future<bool?> load() async => saved;
@override
Future<bool> save(bool on) async {
saved = on;
return true;
}
}
class _Draft extends StatefulWidget {
const _Draft({super.key, required this.name});
final String name;
@override
State<_Draft> createState() => _DraftState();
}
class _DraftState extends State<_Draft> {
final text = TextEditingController();
@override
void dispose() {
text.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) =>
TextField(key: ValueKey('input-${widget.name}'), controller: text);
}
Widget host(
ChatWorkspaceController workspace,
ChatCenterStageController stage, {
double width = 1368,
bool singlePane = false,
bool reduceMotion = false,
List<KeyEvent>? fieldKeys,
}) => MaterialApp(
home: MediaQuery(
data: MediaQueryData(disableAnimations: reduceMotion),
child: Scaffold(
body: Align(
alignment: Alignment.topLeft,
child: SizedBox(
width: width,
height: 800,
child: ChatCenterStageKeys(
controller: stage,
enabled: () => !singlePane,
child: ChatWorkspace(
controller: workspace,
centerStage: stage,
singlePane: singlePane,
paneTitle: (pane) => pane.sessionId,
paneBuilder: (_, pane, active) => Focus(
onKeyEvent: (_, event) {
fieldKeys?.add(event);
return KeyEventResult.ignored;
},
child: _Draft(
key: ValueKey(pane.sessionId),
name: pane.sessionId,
),
),
),
),
),
),
),
),
);
ChatWorkspaceController threePanes() => ChatWorkspaceController()
..open('one')
..splitActive('two', ChatSplitAxis.horizontal)
..splitActive('three', ChatSplitAxis.horizontal);
void wide(WidgetTester tester) {
tester.view
..physicalSize = const Size(1600, 1000)
..devicePixelRatio = 1;
addTearDown(tester.view.reset);
}
double widthOf(WidgetTester tester, String session) =>
tester.getSize(find.byKey(ValueKey('input-$session'))).width;
void main() {
group('layout', () {
test(
'stage is the reading width plus a quarter, others share the rest',
() {
final layout = ChatCenterStageLayout.of(const Size(1368, 800), [
'a',
'b',
'c',
], 'b')!;
expect(chatCenterStageWidth, 950);
expect(layout.rects['b'], const Rect.fromLTWH(209, 0, 950, 800));
expect(layout.rects['a'], const Rect.fromLTWH(0, 0, 197, 800));
expect(layout.rects['c']!.right, 1368);
expect(layout.strips, {'a', 'c'});
expect(layout.neighbor('b', ChatPaneDirection.left), 'a');
expect(layout.neighbor('b', ChatPaneDirection.right), 'c');
expect(layout.neighbor('b', ChatPaneDirection.up), isNull);
},
);
test('a narrow workspace caps the stage to leave every strip', () {
final layout = ChatCenterStageLayout.of(const Size(700, 800), [
'a',
'b',
'c',
], 'a')!;
expect(layout.rects['a']!.width, 700 - 24 - 2 * 56);
expect(layout.rects['c']!.right, 700);
expect(
ChatCenterStageLayout.of(const Size(300, 800), ['a', 'b'], 'a'),
isNull,
);
});
test('a very wide workspace keeps the stage and shows live columns', () {
final layout = ChatCenterStageLayout.of(const Size(2560, 800), [
'a',
'b',
], 'a')!;
expect(layout.rects['a']!.width, 950);
expect(layout.strips, isEmpty);
expect(
ChatCenterStageLayout.of(const Size(2560, 800), ['a'], 'a'),
isNull,
);
});
});
testWidgets('toggling stages the active chat, keeps drafts and split sizes', (
tester,
) async {
wide(tester);
final workspace = threePanes();
final stage = ChatCenterStageController(store: _MemoryStore());
addTearDown(workspace.dispose);
addTearDown(stage.dispose);
final split = (workspace.root! as ChatWorkspaceSplit).id;
workspace.resize(split, .3);
await tester.pumpWidget(host(workspace, stage));
await tester.enterText(find.byKey(const ValueKey('input-three')), 'draft');
final before = {
for (final id in ['one', 'two', 'three']) id: widthOf(tester, id),
};
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));
await tester.pumpAndSettle();
expect(widthOf(tester, 'three'), 950);
expect(find.byType(ChatCenterStageStrip), findsNWidgets(2));
expect(find.text('draft'), findsOneWidget);
stage.value = false;
await tester.pumpAndSettle();
for (final id in before.keys) {
expect(widthOf(tester, id), before[id]);
}
expect((workspace.root! as ChatWorkspaceSplit).ratio, .3);
expect(find.byType(ChatCenterStageStrip), findsNothing);
expect(find.text('draft'), findsOneWidget);
});
testWidgets('the stage follows the active chat and strip presses', (
tester,
) async {
wide(tester);
final workspace = threePanes();
final stage = ChatCenterStageController(store: _MemoryStore())
..value = true;
addTearDown(workspace.dispose);
addTearDown(stage.dispose);
await tester.pumpWidget(host(workspace, stage));
await tester.enterText(find.byKey(const ValueKey('input-three')), 'kept');
expect(widthOf(tester, 'three'), 950);
workspace.activate(workspace.panes.first.id);
await tester.pumpAndSettle();
expect(widthOf(tester, 'one'), 950);
expect(widthOf(tester, 'three'), chatPaneMinimumWidth);
await tester.tap(find.bySemanticsLabel('Show two on center stage'));
await tester.pumpAndSettle();
expect(workspace.activePane?.sessionId, 'two');
expect(widthOf(tester, 'two'), 950);
expect(find.text('kept'), findsOneWidget);
});
testWidgets('reduced motion stages at once', (tester) async {
wide(tester);
final workspace = threePanes();
final stage = ChatCenterStageController(store: _MemoryStore());
addTearDown(workspace.dispose);
addTearDown(stage.dispose);
await tester.pumpWidget(host(workspace, stage, reduceMotion: true));
stage.value = true;
await tester.pump();
expect(widthOf(tester, 'three'), 950);
});
testWidgets('phones keep their one-chat layout', (tester) async {
final workspace = threePanes();
final stage = ChatCenterStageController(store: _MemoryStore())
..value = true;
addTearDown(workspace.dispose);
addTearDown(stage.dispose);
await tester.pumpWidget(
host(workspace, stage, width: 400, singlePane: true),
);
expect(widthOf(tester, 'three'), 400);
expect(find.byType(ChatCenterStageStrip), findsNothing);
await tester.sendKeyDownEvent(LogicalKeyboardKey.controlLeft);
await tester.sendKeyEvent(LogicalKeyboardKey.keyE);
await tester.sendKeyUpEvent(LogicalKeyboardKey.controlLeft);
expect(stage.value, isTrue);
});
for (final mac in [false, true]) {
testWidgets(
'${mac ? 'Cmd' : 'Ctrl'}+E toggles; a plain e reaches the field',
(tester) async {
wide(tester);
debugDefaultTargetPlatformOverride = mac
? TargetPlatform.macOS
: TargetPlatform.linux;
final workspace = threePanes();
final store = _MemoryStore();
final stage = ChatCenterStageController(store: store);
addTearDown(workspace.dispose);
addTearDown(stage.dispose);
final keys = <KeyEvent>[];
await tester.pumpWidget(host(workspace, stage, fieldKeys: keys));
await tester.tap(find.byKey(const ValueKey('input-three')));
await tester.pump();
await tester.sendKeyEvent(LogicalKeyboardKey.keyE);
expect(stage.value, isFalse);
expect(keys.whereType<KeyDownEvent>(), hasLength(1));
final modifier = mac
? LogicalKeyboardKey.metaLeft
: LogicalKeyboardKey.controlLeft;
final other = mac
? LogicalKeyboardKey.controlLeft
: LogicalKeyboardKey.metaLeft;
keys.clear();
await tester.sendKeyDownEvent(modifier);
await tester.sendKeyEvent(LogicalKeyboardKey.keyE);
await tester.sendKeyUpEvent(modifier);
expect(stage.value, isTrue);
expect(store.saved, isTrue);
expect(
keys.whereType<KeyDownEvent>().map((e) => e.logicalKey),
isNot(contains(LogicalKeyboardKey.keyE)),
);
await tester.pumpAndSettle();
expect(widthOf(tester, 'three'), 950);
// The other platform's chord stays with the field (Ctrl+E on a Mac is
// its end of line).
await tester.sendKeyDownEvent(other);
await tester.sendKeyEvent(LogicalKeyboardKey.keyE);
await tester.sendKeyUpEvent(other);
expect(stage.value, isTrue);
debugDefaultTargetPlatformOverride = null;
},
);
}
test('the choice is remembered', () async {
final store = _MemoryStore();
final first = ChatCenterStageController(store: store)..toggle();
await Future<void>.delayed(Duration.zero);
expect(store.saved, isTrue);
first.dispose();
final next = ChatCenterStageController(store: store);
await next.restore();
expect(next.value, isTrue);
next.dispose();
});
test('labels name the platform chord', () {
expect(chatCenterStageShortcutLabel(TargetPlatform.macOS), 'Cmd+E');
expect(chatCenterStageShortcutLabel(TargetPlatform.windows), 'Ctrl+E');
});
}
@@ -0,0 +1,238 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/features/chat/workspace/chat_pane_move_shortcuts.dart';
import 'package:pipelines_app/features/chat/workspace/chat_workspace.dart';
import 'package:pipelines_app/features/chat/workspace/chat_workspace_geometry.dart';
import 'package:pipelines_app/features/chat/workspace/chat_workspace_snapshot.dart';
/// a | (b over (c | d)): a on the left, b top right, c and d below b.
ChatWorkspaceController _nested() {
final controller = ChatWorkspaceController()..open('a');
controller.splitActive('b', ChatSplitAxis.horizontal);
controller.splitActive('c', ChatSplitAxis.vertical);
controller.splitActive('d', ChatSplitAxis.horizontal);
return controller;
}
String _id(ChatWorkspaceController controller, String session) =>
controller.panes.firstWhere((pane) => pane.sessionId == session).id;
Map<ChatPaneDirection, String?> _targets(
ChatWorkspaceController controller,
String session,
) {
final geometry = ChatWorkspaceGeometry(
controller.root!,
const Size(1200, 800),
);
final names = {for (final p in controller.panes) p.id: p.sessionId};
return {
for (final direction in ChatPaneDirection.values)
direction: names[geometry.adjacent(_id(controller, session), direction)],
};
}
class _Draft extends StatefulWidget {
const _Draft({super.key, required this.name});
final String name;
@override
State<_Draft> createState() => _DraftState();
}
class _DraftState extends State<_Draft> {
final text = TextEditingController();
@override
void dispose() {
text.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) =>
TextField(key: ValueKey('input-${widget.name}'), controller: text);
}
Widget _host(ChatWorkspaceController controller, {bool reduce = false}) =>
MaterialApp(
home: MediaQuery(
data: MediaQueryData(
size: const Size(1200, 800),
disableAnimations: reduce,
),
child: Scaffold(
body: SizedBox(
width: 1200,
height: 800,
child: ChatWorkspace(
controller: controller,
paneBuilder: (_, pane, _) =>
_Draft(key: ValueKey(pane.sessionId), name: pane.sessionId),
),
),
),
),
);
Future<void> _chord(WidgetTester tester, LogicalKeyboardKey arrow) async {
await tester.sendKeyDownEvent(LogicalKeyboardKey.controlLeft);
await tester.sendKeyDownEvent(LogicalKeyboardKey.altLeft);
await tester.sendKeyDownEvent(LogicalKeyboardKey.shiftLeft);
await tester.sendKeyEvent(arrow);
await tester.sendKeyUpEvent(LogicalKeyboardKey.shiftLeft);
await tester.sendKeyUpEvent(LogicalKeyboardKey.altLeft);
await tester.sendKeyUpEvent(LogicalKeyboardKey.controlLeft);
}
void main() {
test('adjacency follows nested splits and stops at outer edges', () {
final controller = _nested();
addTearDown(controller.dispose);
expect(_targets(controller, 'a'), {
ChatPaneDirection.up: null,
ChatPaneDirection.down: null,
ChatPaneDirection.left: null,
// b and c share a's right edge equally and a's centre line falls in
// their divider: the tie goes to the first in reading order.
ChatPaneDirection.right: 'b',
});
expect(_targets(controller, 'b'), {
ChatPaneDirection.up: null,
ChatPaneDirection.down: 'c',
ChatPaneDirection.left: 'a',
ChatPaneDirection.right: null,
});
// Once d is wider it spans b's centre line, so b's move down takes d.
final bottom =
((controller.root as ChatWorkspaceSplit).second as ChatWorkspaceSplit)
.second
as ChatWorkspaceSplit;
controller.resize(bottom.id, .3);
expect(_targets(controller, 'b')[ChatPaneDirection.down], 'd');
controller.resize(bottom.id, .5);
expect(_targets(controller, 'c'), {
ChatPaneDirection.up: 'b',
ChatPaneDirection.down: null,
ChatPaneDirection.left: 'a',
ChatPaneDirection.right: 'd',
});
expect(_targets(controller, 'd')[ChatPaneDirection.left], 'c');
expect(_targets(controller, 'd')[ChatPaneDirection.up], 'b');
});
test('swap trades places both ways, keeping ids, ratios and focus', () {
final controller = _nested();
addTearDown(controller.dispose);
final outer = controller.root as ChatWorkspaceSplit;
controller.resize(outer.id, .3);
final ids = {
for (final s in ['a', 'b', 'c', 'd']) s: _id(controller, s),
};
final serial = controller.moveSerial;
controller.swap(ids['a']!, ids['c']!);
expect(controller.panes.map((p) => p.sessionId), ['c', 'b', 'a', 'd']);
expect({for (final p in controller.panes) p.sessionId: p.id}, ids);
expect(controller.activePaneId, ids['a']);
expect(controller.moveSerial, serial + 1);
expect(controller.movedPaneIds, {ids['a'], ids['c']});
expect((controller.root as ChatWorkspaceSplit).ratio, .3);
expect((controller.root as ChatWorkspaceSplit).id, outer.id);
controller.swap(ids['a']!, ids['c']!);
expect(controller.panes.map((p) => p.sessionId), ['a', 'b', 'c', 'd']);
controller.swap(ids['a']!, 'missing');
controller.swap(ids['a']!, ids['a']!);
expect(controller.moveSerial, serial + 2);
});
test('a moved layout survives an encode/decode round trip', () {
final controller = _nested();
addTearDown(controller.dispose);
controller.swap(_id(controller, 'b'), _id(controller, 'd'));
final source = controller.snapshot(sidebarMode: 'compact')!.encode();
final restored = ChatWorkspaceController();
addTearDown(restored.dispose);
expect(restored.restoreLayout(ChatWorkspaceSnapshot.decode(source)!), true);
expect(restored.panes.map((p) => p.sessionId), ['a', 'd', 'c', 'b']);
expect(restored.activePane?.sessionId, 'b');
});
test('the move chord adds Alt to the focus chord, Command on macOS', () {
expect(
chatPaneMoveActivator(
ChatPaneDirection.up,
platform: TargetPlatform.macOS,
).debugDescribeKeys(),
'Alt + Meta + Shift + Arrow Up',
);
expect(
chatPaneMoveActivator(
ChatPaneDirection.down,
platform: TargetPlatform.windows,
).debugDescribeKeys(),
'Control + Alt + Shift + Arrow Down',
);
});
test('the chord family: Alt turns focusing into moving', () {
// Only real key events reach the handler; the parse is checked through
// the widget tests below. Here, the menu's chord and the handler agree.
final activator = chatPaneMoveActivator(
ChatPaneDirection.left,
platform: TargetPlatform.linux,
);
expect(activator.trigger, LogicalKeyboardKey.arrowLeft);
expect(
[activator.control, activator.alt, activator.shift, activator.meta],
[true, true, true, false],
);
});
testWidgets(
'the chord moves the focused pane, keeps its draft, and is inert at edges',
(tester) async {
final controller = ChatWorkspaceController()
..open('one')
..splitActive('two', ChatSplitAxis.horizontal);
addTearDown(controller.dispose);
await tester.pumpWidget(_host(controller));
final input = find.byKey(const ValueKey('input-one'));
await tester.enterText(input, 'draft one');
final state = tester.state(find.byKey(const ValueKey('one')));
final before = tester.getRect(input);
await _chord(tester, LogicalKeyboardKey.arrowRight);
await tester.pump();
await tester.pump(const Duration(milliseconds: 100));
// Mid-glide: the retained view is between its old and new tiles.
final middle = tester.getRect(input);
await tester.pumpAndSettle();
final after = tester.getRect(input);
expect(middle.left, greaterThan(before.left));
expect(after.left, greaterThan(middle.left));
expect(tester.state(find.byKey(const ValueKey('one'))), same(state));
expect(tester.widget<TextField>(input).controller!.text, 'draft one');
expect(controller.activePane?.sessionId, 'one');
expect(controller.panes.map((p) => p.sessionId), ['two', 'one']);
final serial = controller.moveSerial;
await _chord(tester, LogicalKeyboardKey.arrowRight);
await _chord(tester, LogicalKeyboardKey.arrowUp);
await tester.pumpAndSettle();
expect(controller.moveSerial, serial);
expect(tester.widget<TextField>(input).controller!.text, 'draft one');
},
variant: TargetPlatformVariant.only(TargetPlatform.linux),
);
testWidgets('reduced motion swaps the panes instantly', (tester) async {
final controller = ChatWorkspaceController()
..open('one')
..splitActive('two', ChatSplitAxis.horizontal);
addTearDown(controller.dispose);
await tester.pumpWidget(_host(controller, reduce: true));
final input = find.byKey(const ValueKey('input-one'));
final twoBefore = tester.getRect(find.byKey(const ValueKey('input-two')));
controller.swap(_id(controller, 'one'), _id(controller, 'two'));
await tester.pump();
expect(tester.getRect(input).left, twoBefore.left);
expect(tester.hasRunningAnimations, isFalse);
});
}