Fix Ctrl+Tab chat window navigation
Keep Ctrl+Tab scoped to shown floating chats when windows are visible, and otherwise cycle only visible tiled panes. Remove the single-pane recent-chat swap and use stable floating-window open order so raising a window does not alter navigation.
This commit is contained in:
@@ -133,9 +133,8 @@ void main() {
|
||||
await tester.pumpWidget(const SizedBox.shrink());
|
||||
});
|
||||
|
||||
testWidgets('single pane focuses input; empty workspace does not consume', (
|
||||
tester,
|
||||
) async {
|
||||
testWidgets('single pane with no shown window does nothing; empty workspace '
|
||||
'does not consume', (tester) async {
|
||||
await _setup(tester, open: false);
|
||||
await _chord(tester);
|
||||
expect(find.byType(ChatWorkspace), findsNothing);
|
||||
@@ -144,7 +143,9 @@ void main() {
|
||||
_focusSidebar(tester);
|
||||
await tester.pumpAndSettle();
|
||||
await _chord(tester);
|
||||
expect(_editable(tester, 'a').focusNode.hasPrimaryFocus, isTrue);
|
||||
expect(find.byType(ChatWorkspace), findsOneWidget);
|
||||
expect(_workspace(tester).paneCount, 1);
|
||||
expect(_editable(tester, 'a').focusNode.hasPrimaryFocus, isFalse);
|
||||
expect(_editable(tester, 'a').controller.text, isEmpty);
|
||||
await tester.pumpWidget(const SizedBox.shrink());
|
||||
});
|
||||
|
||||
@@ -526,25 +526,36 @@ void main() {
|
||||
await tester.pumpAndSettle();
|
||||
expect(app.floating, ['b', 'c', 'a']);
|
||||
|
||||
// The cycle follows the order the windows were opened in (b, c, a), not
|
||||
// the stacking order, which each raise changes. From a (opened last) the
|
||||
// next is b, the first opened.
|
||||
await _tab(tester);
|
||||
expect(app.floating, ['c', 'a', 'b']);
|
||||
expect(_composerFocused(tester, 'b'), isTrue);
|
||||
// Past the top, the bottom window comes up again.
|
||||
await _tab(tester);
|
||||
expect(app.floating, ['a', 'b', 'c']);
|
||||
expect(_composerFocused(tester, 'c'), isTrue);
|
||||
await _tab(tester);
|
||||
expect(app.floating, ['b', 'c', 'a']);
|
||||
expect(_composerFocused(tester, 'a'), isTrue);
|
||||
await _tab(tester, shift: true);
|
||||
expect(app.floating, ['b', 'a', 'c']);
|
||||
expect(_composerFocused(tester, 'c'), isTrue);
|
||||
await _tab(tester, shift: true);
|
||||
expect(app.floating, ['a', 'c', 'b']);
|
||||
expect(_composerFocused(tester, 'b'), isTrue);
|
||||
// Back past the first opened: the last opened (a) comes up.
|
||||
await _tab(tester, shift: true);
|
||||
expect(app.floating, ['a', 'b', 'c']);
|
||||
expect(_composerFocused(tester, 'c'), isTrue);
|
||||
expect(app.floating, ['c', 'b', 'a']);
|
||||
expect(_composerFocused(tester, 'a'), isTrue);
|
||||
expect(tester.takeException(), isNull);
|
||||
await app.stop(tester);
|
||||
});
|
||||
|
||||
testWidgets('with the tiling focused Ctrl+Tab cycles its panes and leaves '
|
||||
'the windows alone', (tester) async {
|
||||
testWidgets('with the tiling focused Ctrl+Tab goes to the top-most shown '
|
||||
'window, and cycles the panes only when no window is shown', (
|
||||
tester,
|
||||
) async {
|
||||
await _saved('a', 'b', 'c');
|
||||
final app = _App(_Store());
|
||||
await app.start(tester);
|
||||
@@ -552,26 +563,61 @@ void main() {
|
||||
expect(app.floating, ['c']);
|
||||
final controller = _workspace(tester);
|
||||
|
||||
// A window is shown: from the tiling, Ctrl+Tab takes the keyboard to it
|
||||
// and the panes stay where they are.
|
||||
await tester.tapAt(tester.getCenter(_input('a')));
|
||||
await tester.pump();
|
||||
expect(controller.activePane?.sessionId, 'a');
|
||||
await _tab(tester);
|
||||
expect(controller.activePane?.sessionId, 'b');
|
||||
expect(_composerFocused(tester, 'b'), isTrue);
|
||||
expect(controller.activePane?.sessionId, 'a');
|
||||
expect(_composerFocused(tester, 'c'), isTrue);
|
||||
expect(app.floating, ['c']);
|
||||
|
||||
// With a window focused, the panes stay where they are; a single window
|
||||
// has nothing to cycle to.
|
||||
await tester.tapAt(tester.getCenter(_input('c')));
|
||||
await tester.pump();
|
||||
// A single shown window has nothing to cycle to.
|
||||
await _tab(tester);
|
||||
expect(controller.activePane?.sessionId, 'a');
|
||||
expect(_composerFocused(tester, 'c'), isTrue);
|
||||
expect(app.floating, ['c']);
|
||||
|
||||
// No window shown: the panes cycle and the hidden window stays hidden.
|
||||
await _chord(tester);
|
||||
expect(_shown('Chat c'), findsNothing);
|
||||
await tester.tapAt(tester.getCenter(_input('a')));
|
||||
await tester.pump();
|
||||
await _tab(tester);
|
||||
expect(controller.activePane?.sessionId, 'b');
|
||||
expect(_composerFocused(tester, 'b'), isTrue);
|
||||
expect(_shown('Chat c'), findsNothing);
|
||||
expect(app.floating, ['c']);
|
||||
expect(tester.takeException(), isNull);
|
||||
await app.stop(tester);
|
||||
});
|
||||
|
||||
testWidgets('with one tiled pane and no shown window Ctrl+Tab does nothing; '
|
||||
'a minimised chat is not brought up', (tester) async {
|
||||
await _saved('a', 'b');
|
||||
final app = _App(_Store());
|
||||
await app.start(tester);
|
||||
await _menu(tester, 'b', 'Float (Alt+Y)');
|
||||
await tester.tap(find.byTooltip('Minimise'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(_shown('Chat b'), findsNothing);
|
||||
final controller = _workspace(tester);
|
||||
expect(controller.panes.map((p) => p.sessionId), ['a']);
|
||||
|
||||
await tester.tapAt(tester.getCenter(_input('a')));
|
||||
await tester.pump();
|
||||
await _tab(tester);
|
||||
await _tab(tester, shift: true);
|
||||
expect(controller.panes.map((p) => p.sessionId), ['a']);
|
||||
expect(controller.activePane?.sessionId, 'a');
|
||||
expect(_shown('Chat b'), findsNothing);
|
||||
expect(app.floating, ['b']);
|
||||
expect(app.opened, isEmpty);
|
||||
expect(tester.takeException(), isNull);
|
||||
await app.stop(tester);
|
||||
});
|
||||
|
||||
testWidgets('a terminal that claims tab keys keeps Ctrl+Tab over a focused '
|
||||
'floating chat', (tester) async {
|
||||
await _saved('a', 'b', 'c');
|
||||
|
||||
@@ -150,38 +150,29 @@ void main() {
|
||||
await tester.pumpWidget(const SizedBox.shrink());
|
||||
});
|
||||
|
||||
testWidgets('Control Tab over one pane returns to the previous chat', (
|
||||
tester,
|
||||
) async {
|
||||
testWidgets('Control Tab over one pane does nothing: it never brings up '
|
||||
'another chat', (tester) async {
|
||||
await _setup(tester);
|
||||
await _openRow(tester, 'a');
|
||||
final workspace = _workspace(tester);
|
||||
// Nothing shown before: the chord only focuses the composer.
|
||||
await _controlTab(tester);
|
||||
expect(workspace.activePane?.sessionId, 'a');
|
||||
expect(_editable(tester, 'a').focusNode.hasPrimaryFocus, isTrue);
|
||||
expect(_editable(tester, 'a').focusNode.hasPrimaryFocus, isFalse);
|
||||
|
||||
// Opening b replaces the lone pane; a is no longer shown anywhere.
|
||||
await _openRow(tester, 'b');
|
||||
await tester.enterText(_input('b'), 'Draft B');
|
||||
await _focusSidebar(tester);
|
||||
for (final id in ['a', 'b', 'a']) {
|
||||
await _controlTab(tester);
|
||||
for (final shift in [false, true]) {
|
||||
await _controlTab(tester, shift: shift);
|
||||
expect(workspace.paneCount, 1);
|
||||
expect(workspace.activePane?.sessionId, id);
|
||||
expect(_editable(tester, id).focusNode.hasPrimaryFocus, isTrue);
|
||||
expect(workspace.activePane?.sessionId, 'b');
|
||||
expect(_editable(tester, 'b').focusNode.hasPrimaryFocus, isFalse);
|
||||
expect(_editable(tester, 'b').controller.text, 'Draft B');
|
||||
}
|
||||
await _controlTab(tester, shift: true);
|
||||
expect(workspace.activePane?.sessionId, 'b');
|
||||
expect(_editable(tester, 'b').controller.text, 'Draft B');
|
||||
|
||||
// A third chat makes the pair c and b; a is no longer one step away.
|
||||
// Two panes cycle the panes, not the history.
|
||||
await _openRow(tester, 'c');
|
||||
await _controlTab(tester);
|
||||
expect(workspace.activePane?.sessionId, 'b');
|
||||
await _controlTab(tester);
|
||||
expect(workspace.activePane?.sessionId, 'c');
|
||||
|
||||
// Two panes cycle the panes as before, not the history.
|
||||
await tester.tap(_actions('a'));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.text('Open to the right'));
|
||||
|
||||
Reference in New Issue
Block a user