Pad chat bar text buttons 12 px and add Alt+Y for floating chats
Model, mode and thinking buttons carry 12 px horizontal padding, replacing
the pill inset from 440995e3. Alt+Y (Option+Y by key position) toggles the
floating chats, like Alt+T for the terminal.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/features/chat/conversation/chat_bar_control_style.dart';
|
||||
import 'package:pipelines_app/features/chat/conversation/chat_thread_view.dart';
|
||||
import 'package:pipelines_app/features/chat/conversation/chat_thread_header.dart';
|
||||
import 'package:pipelines_app/features/chat/conversation/chat_sidebar_controls.dart';
|
||||
@@ -80,20 +81,7 @@ void main() {
|
||||
tester.getTopRight(find.byKey(Key(left))).dx;
|
||||
|
||||
expect(gap('header-control-1', 'header-control-2'), 8);
|
||||
// The model/mode island keeps its text 12 px off its pill's ends.
|
||||
final island = tester.getRect(
|
||||
find.byKey(const Key('chat-model-permission-island')),
|
||||
);
|
||||
expect(
|
||||
tester.getTopLeft(find.byKey(const Key('header-control-1'))).dx -
|
||||
island.left,
|
||||
12,
|
||||
);
|
||||
expect(
|
||||
island.right -
|
||||
tester.getTopRight(find.byKey(const Key('header-control-2'))).dx,
|
||||
12,
|
||||
);
|
||||
expect(gap('header-control-2', 'header-action-1'), 8);
|
||||
expect(gap('header-action-1', 'header-action-2'), 8);
|
||||
expect(
|
||||
tester.getTopLeft(find.byKey(segmentedMoreKey).first).dx -
|
||||
@@ -396,4 +384,23 @@ void main() {
|
||||
);
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
|
||||
testWidgets('wide bar text buttons keep their text off the shape ends', (
|
||||
tester,
|
||||
) async {
|
||||
late ButtonStyle wide;
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Builder(
|
||||
builder: (context) {
|
||||
wide = chatBarTextButtonStyle(context);
|
||||
return const SizedBox();
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
expect(wide.padding?.resolve({}), chatBarButtonPadding);
|
||||
expect(chatBarButtonPadding.left, 12);
|
||||
expect(chatBarButtonPadding.right, 12);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -225,4 +225,62 @@ void main() {
|
||||
await _chord(tester, LogicalKeyboardKey.controlLeft);
|
||||
expect(h.controller.floatShown, isTrue);
|
||||
});
|
||||
|
||||
testWidgets('Alt+Y floats, hides and shows like Ctrl+Y, also from a '
|
||||
'terminal', (tester) async {
|
||||
final h = await pump(tester);
|
||||
tester.state<_PaneState>(_pane('b')).focus.requestFocus();
|
||||
await tester.pump();
|
||||
await _chord(tester, LogicalKeyboardKey.altLeft);
|
||||
expect(h.controller.floatingPanes.firstOrNull?.sessionId, 'b');
|
||||
expect(h.controller.floatShown, isTrue);
|
||||
h.typing.requestFocus();
|
||||
await tester.pump();
|
||||
h.typed.clear();
|
||||
await _chord(tester, LogicalKeyboardKey.altLeft);
|
||||
expect(h.controller.floatShown, isFalse);
|
||||
expect(h.typed, isEmpty);
|
||||
});
|
||||
|
||||
test('Option+Y matches by key position; extra modifiers do not', () {
|
||||
// On a Mac, Option+Y produces ¥: the logical key is not Y.
|
||||
const yen = KeyDownEvent(
|
||||
physicalKey: PhysicalKeyboardKey.keyY,
|
||||
logicalKey: LogicalKeyboardKey(0x00a5),
|
||||
character: '¥',
|
||||
timeStamp: Duration.zero,
|
||||
);
|
||||
final keyboard = _FakeKeyboard({LogicalKeyboardKey.altLeft});
|
||||
expect(
|
||||
chatFloatShortcut(yen, keyboard, platform: TargetPlatform.macOS),
|
||||
isTrue,
|
||||
);
|
||||
const y = KeyDownEvent(
|
||||
physicalKey: PhysicalKeyboardKey.keyY,
|
||||
logicalKey: LogicalKeyboardKey.keyY,
|
||||
timeStamp: Duration.zero,
|
||||
);
|
||||
for (final extra in [
|
||||
LogicalKeyboardKey.controlLeft,
|
||||
LogicalKeyboardKey.metaLeft,
|
||||
LogicalKeyboardKey.shiftLeft,
|
||||
]) {
|
||||
expect(
|
||||
chatFloatShortcut(
|
||||
y,
|
||||
_FakeKeyboard({LogicalKeyboardKey.altLeft, extra}),
|
||||
),
|
||||
isFalse,
|
||||
reason: '$extra',
|
||||
);
|
||||
}
|
||||
expect(chatFloatShortcut(y, _FakeKeyboard({})), isFalse);
|
||||
});
|
||||
}
|
||||
|
||||
class _FakeKeyboard extends HardwareKeyboard {
|
||||
_FakeKeyboard(this.pressed);
|
||||
final Set<LogicalKeyboardKey> pressed;
|
||||
@override
|
||||
bool isLogicalKeyPressed(LogicalKeyboardKey key) => pressed.contains(key);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user