Merge commit '35e4aec0a753e7ff46b345e0bc83e391cf905ed4' into pipelines/run-20261112-0055-ctrl-k-and-alt-k-open-chat-24be
This commit is contained in:
@@ -11,6 +11,7 @@ import 'package:pipelines_app/features/chat/windows/chat_windows.dart';
|
||||
import 'package:pipelines_app/features/chat/workspace/chat_float_store.dart';
|
||||
import 'package:pipelines_app/features/chat/workspace/chat_workspace.dart';
|
||||
import 'package:pipelines_app/features/chat/workspace/chat_workspace_store.dart';
|
||||
import 'package:pipelines_app/features/terminal/terminal_scope.dart';
|
||||
import 'package:pipelines_app/shell/windows/window_frame.dart';
|
||||
import 'package:pipelines_app/shell/windows/window_host.dart';
|
||||
import 'package:pipelines_app/shell/windows/window_kind.dart';
|
||||
@@ -48,6 +49,16 @@ class _Store implements WindowStore {
|
||||
}
|
||||
}
|
||||
|
||||
class _ClaimingTerminal implements TerminalActions {
|
||||
const _ClaimingTerminal();
|
||||
@override
|
||||
void toggle() {}
|
||||
@override
|
||||
bool get claimsTabKeys => true;
|
||||
@override
|
||||
Future<String?> openAt(ApiGateway gateway, String cwd) async => null;
|
||||
}
|
||||
|
||||
class _TerminalKind extends WindowKind {
|
||||
@override
|
||||
String get key => 'terminal';
|
||||
@@ -105,6 +116,7 @@ class _App {
|
||||
WidgetTester tester, {
|
||||
Size size = const Size(1800, 1000),
|
||||
bool terminalSurface = false,
|
||||
bool terminalClaimsTabs = false,
|
||||
}) async {
|
||||
tester.view.physicalSize = size;
|
||||
tester.view.devicePixelRatio = 1;
|
||||
@@ -124,6 +136,13 @@ class _App {
|
||||
);
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
// A terminal that shows its tabs: it claims Ctrl+Tab.
|
||||
builder: terminalClaimsTabs
|
||||
? (context, child) => TerminalScope(
|
||||
actions: const _ClaimingTerminal(),
|
||||
child: child!,
|
||||
)
|
||||
: null,
|
||||
home: Scaffold(
|
||||
body: Stack(
|
||||
fit: StackFit.expand,
|
||||
@@ -218,6 +237,19 @@ Future<void> _chord(WidgetTester tester) async {
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
|
||||
/// Ctrl+Tab, or Ctrl+Shift+Tab with [shift].
|
||||
Future<void> _tab(WidgetTester tester, {bool shift = false}) async {
|
||||
await tester.sendKeyDownEvent(LogicalKeyboardKey.controlLeft);
|
||||
if (shift) await tester.sendKeyDownEvent(LogicalKeyboardKey.shiftLeft);
|
||||
await tester.sendKeyEvent(LogicalKeyboardKey.tab);
|
||||
if (shift) await tester.sendKeyUpEvent(LogicalKeyboardKey.shiftLeft);
|
||||
await tester.sendKeyUpEvent(LogicalKeyboardKey.controlLeft);
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
|
||||
bool _composerFocused(WidgetTester tester, String id) =>
|
||||
tester.widget<EditableText>(_input(id)).focusNode.hasPrimaryFocus;
|
||||
|
||||
Future<void> _controlChord(WidgetTester tester) async {
|
||||
await tester.sendKeyDownEvent(LogicalKeyboardKey.controlLeft);
|
||||
await tester.sendKeyEvent(LogicalKeyboardKey.keyY);
|
||||
@@ -452,6 +484,91 @@ void main() {
|
||||
await app.stop(tester);
|
||||
});
|
||||
|
||||
testWidgets('Ctrl+Tab and Ctrl+Shift+Tab cycle the floating chat windows, '
|
||||
'each composer taking the keyboard', (tester) async {
|
||||
await _saved('a', 'b', 'c');
|
||||
final app = _App(_Store());
|
||||
await app.start(tester);
|
||||
await _menu(tester, 'b', 'Float (Alt+Y)');
|
||||
await _menu(tester, 'c', 'Float (Alt+Y)');
|
||||
await _menu(tester, 'a', 'Float (Alt+Y)');
|
||||
expect(app.floating, ['b', 'c', 'a']);
|
||||
|
||||
// Command+Tab belongs to the system.
|
||||
await tester.sendKeyDownEvent(LogicalKeyboardKey.metaLeft);
|
||||
await tester.sendKeyEvent(LogicalKeyboardKey.tab);
|
||||
await tester.sendKeyUpEvent(LogicalKeyboardKey.metaLeft);
|
||||
await tester.pumpAndSettle();
|
||||
expect(app.floating, ['b', 'c', 'a']);
|
||||
|
||||
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, shift: true);
|
||||
expect(app.floating, ['a', 'c', 'b']);
|
||||
expect(_composerFocused(tester, 'b'), isTrue);
|
||||
await _tab(tester, shift: true);
|
||||
expect(app.floating, ['a', 'b', 'c']);
|
||||
expect(_composerFocused(tester, 'c'), 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 {
|
||||
await _saved('a', 'b', 'c');
|
||||
final app = _App(_Store());
|
||||
await app.start(tester);
|
||||
await _menu(tester, 'c', 'Float (Alt+Y)');
|
||||
expect(app.floating, ['c']);
|
||||
final controller = _workspace(tester);
|
||||
|
||||
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(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();
|
||||
expect(_composerFocused(tester, 'c'), isTrue);
|
||||
await _tab(tester);
|
||||
expect(controller.activePane?.sessionId, 'b');
|
||||
expect(app.floating, ['c']);
|
||||
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');
|
||||
final app = _App(_Store());
|
||||
await app.start(tester, terminalClaimsTabs: true);
|
||||
await _menu(tester, 'b', 'Float (Alt+Y)');
|
||||
await _menu(tester, 'c', 'Float (Alt+Y)');
|
||||
expect(app.floating, ['b', 'c']);
|
||||
await tester.tapAt(tester.getCenter(_input('c')));
|
||||
await tester.pump();
|
||||
expect(_composerFocused(tester, 'c'), isTrue);
|
||||
|
||||
// The terminal's tabs get the key (its own handler is not in this app);
|
||||
// neither the windows nor the panes move.
|
||||
await _tab(tester);
|
||||
expect(app.floating, ['b', 'c']);
|
||||
expect(_composerFocused(tester, 'c'), isTrue);
|
||||
expect(_workspace(tester).activePane?.sessionId, 'a');
|
||||
expect(tester.takeException(), isNull);
|
||||
await app.stop(tester);
|
||||
});
|
||||
|
||||
testWidgets('a floating chat types, runs its tickers, hides and shows over '
|
||||
'another destination', (tester) async {
|
||||
await _saved('a', 'b');
|
||||
|
||||
@@ -3,6 +3,7 @@ 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_edges.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';
|
||||
@@ -82,7 +83,10 @@ Widget host(
|
||||
List<KeyEvent>? fieldKeys,
|
||||
bool actionBars = false,
|
||||
bool filesProbe = false,
|
||||
ThemeMode themeMode = ThemeMode.light,
|
||||
}) => MaterialApp(
|
||||
themeMode: themeMode,
|
||||
darkTheme: ThemeData.dark(),
|
||||
home: MediaQuery(
|
||||
data: MediaQueryData(disableAnimations: reduceMotion),
|
||||
child: Scaffold(
|
||||
@@ -410,6 +414,71 @@ void main() {
|
||||
},
|
||||
);
|
||||
|
||||
test(
|
||||
'the stage edges sit in the gaps beside the stage, or on the workspace edge',
|
||||
() {
|
||||
final (left, right) = chatCenterStageEdgeRects(
|
||||
const Rect.fromLTWH(418, 0, 950, 800),
|
||||
const Size(1368, 800),
|
||||
);
|
||||
expect(left, const Rect.fromLTWH(411.5, 0, 1, 800));
|
||||
expect(right, const Rect.fromLTWH(1367, 0, 1, 800));
|
||||
|
||||
// A stage that reaches the workspace's right edge keeps its hairline inside.
|
||||
final (edgeLeft, edgeRight) = chatCenterStageEdgeRects(
|
||||
const Rect.fromLTWH(650, 0, 950, 800),
|
||||
const Size(1600, 800),
|
||||
);
|
||||
expect(edgeLeft, const Rect.fromLTWH(643.5, 0, 1, 800));
|
||||
expect(edgeRight, const Rect.fromLTWH(1599, 0, 1, 800));
|
||||
},
|
||||
);
|
||||
|
||||
for (final mode in [ThemeMode.light, ThemeMode.dark]) {
|
||||
testWidgets(
|
||||
'center stage draws the column edges in the ${mode.name} theme, only on stage',
|
||||
(tester) async {
|
||||
wide(tester);
|
||||
final workspace = threePanes();
|
||||
final stage = ChatCenterStageController(store: _MemoryStore());
|
||||
addTearDown(workspace.dispose);
|
||||
addTearDown(stage.dispose);
|
||||
await tester.pumpWidget(host(workspace, stage, themeMode: mode));
|
||||
await tester.pumpAndSettle();
|
||||
const leftKey = ValueKey('chat-center-stage-edge-left');
|
||||
const rightKey = ValueKey('chat-center-stage-edge-right');
|
||||
expect(find.byKey(leftKey), findsNothing);
|
||||
expect(find.byKey(rightKey), findsNothing);
|
||||
|
||||
stage.value = true;
|
||||
await tester.pumpAndSettle();
|
||||
final outline = Theme.of(
|
||||
tester.element(find.byType(ChatWorkspace)),
|
||||
).colorScheme.outlineVariant;
|
||||
for (final key in [leftKey, rightKey]) {
|
||||
expect(
|
||||
tester
|
||||
.widget<ColoredBox>(
|
||||
find.descendant(
|
||||
of: find.byKey(key),
|
||||
matching: find.byType(ColoredBox),
|
||||
),
|
||||
)
|
||||
.color,
|
||||
outline,
|
||||
);
|
||||
}
|
||||
// The hairlines frame the stage; the reading width is unchanged.
|
||||
expect(widthOf(tester, 'three'), 950);
|
||||
|
||||
stage.value = false;
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(leftKey), findsNothing);
|
||||
expect(find.byKey(rightKey), findsNothing);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
testWidgets('reduced motion stages at once', (tester) async {
|
||||
wide(tester);
|
||||
final workspace = threePanes();
|
||||
|
||||
Reference in New Issue
Block a user