Move terminal tools out of the command bar

This commit is contained in:
sladro 2026-04-04 22:26:35 +08:00
parent 682b553ace
commit 5822075a34
3 changed files with 65 additions and 33 deletions

View File

@ -509,6 +509,7 @@ class _TerminalPageState extends ConsumerState<TerminalPage>
return showModalBottomSheet<void>(
context: context,
backgroundColor: const Color(0xFF13191F),
isScrollControlled: true,
builder: (context) {
return SafeArea(
child: AnimatedBuilder(
@ -541,6 +542,31 @@ class _TerminalPageState extends ConsumerState<TerminalPage>
spacing: 8,
runSpacing: 8,
children: [
_buildModeButton(closeSheetOnPressed: true),
_buildIconActionButton(
key: const Key('terminal_keys_toggle_button'),
onPressed: () {
Navigator.of(context).pop();
_toggleKeyTray();
},
tooltip: _isKeyTrayVisible
? 'Hide quick keys'
: 'Show quick keys',
icon: Icon(
_isKeyTrayVisible
? Icons.keyboard_arrow_down
: Icons.keyboard_command_key,
),
),
_buildIconActionButton(
key: const Key('terminal_presets_button'),
onPressed: () {
Navigator.of(context).pop();
unawaited(_showPresetsSheet());
},
tooltip: 'Show presets',
icon: const Icon(Icons.flash_on_outlined),
),
OutlinedButton.icon(
onPressed: () {
Navigator.of(context).pop();
@ -1012,28 +1038,6 @@ class _TerminalPageState extends ConsumerState<TerminalPage>
children: [
Expanded(child: _buildInputField(context)),
const SizedBox(width: 8),
_buildModeButton(),
const SizedBox(width: 6),
_buildIconActionButton(
key: const Key('terminal_keys_toggle_button'),
onPressed: _toggleKeyTray,
tooltip: _isKeyTrayVisible
? 'Hide quick keys'
: 'Show quick keys',
icon: Icon(
_isKeyTrayVisible
? Icons.keyboard_arrow_down
: Icons.keyboard_command_key,
),
),
const SizedBox(width: 6),
_buildIconActionButton(
key: const Key('terminal_presets_button'),
onPressed: _showPresetsSheet,
tooltip: 'Show presets',
icon: const Icon(Icons.flash_on_outlined),
),
const SizedBox(width: 6),
_buildCommandDeckAction(
IconButton.filledTonal(
key: const Key('terminal_toggle_actions_button'),
@ -1131,12 +1135,19 @@ class _TerminalPageState extends ConsumerState<TerminalPage>
);
}
Widget _buildModeButton() {
Widget _buildModeButton({bool closeSheetOnPressed = false}) {
return KeyedSubtree(
key: const Key('terminal_direct_input_toggle'),
child: _buildIconActionButton(
key: const Key('terminal_mode_button'),
onPressed: _canSendInput ? _toggleDirectInput : null,
onPressed: _canSendInput
? () {
if (closeSheetOnPressed) {
Navigator.of(context).pop();
}
_toggleDirectInput();
}
: null,
tooltip: _inputController.isDirectInputEnabled
? 'Switch to buffered mode'
: 'Switch to direct mode',

View File

@ -22,11 +22,10 @@ void main() {
await _pumpTerminalPage(tester);
expect(find.byKey(const Key('terminal_key_tray')), findsNothing);
expect(
find.byKey(const Key('terminal_keys_toggle_button')),
findsOneWidget,
);
expect(find.byKey(const Key('terminal_keys_toggle_button')), findsNothing);
await tester.tap(find.byKey(const Key('terminal_toggle_actions_button')));
await tester.pumpAndSettle();
await tester.tap(find.byKey(const Key('terminal_keys_toggle_button')));
await tester.pumpAndSettle();
@ -46,6 +45,8 @@ void main() {
await _pumpTerminalPage(tester, socketFactory: transportFactory.factory);
await tester.tap(find.byKey(const Key('terminal_toggle_actions_button')));
await tester.pumpAndSettle();
await tester.tap(find.byKey(const Key('terminal_keys_toggle_button')));
await tester.pumpAndSettle();
@ -69,6 +70,8 @@ void main() {
await _pumpTerminalPage(tester, socketFactory: transportFactory.factory);
await tester.tap(find.byKey(const Key('terminal_toggle_actions_button')));
await tester.pumpAndSettle();
await tester.tap(find.byKey(const Key('terminal_mode_button')));
await tester.pumpAndSettle();
await tester.tap(find.byType(TextField));
@ -96,6 +99,8 @@ void main() {
]),
);
await tester.tap(find.byKey(const Key('terminal_toggle_actions_button')));
await tester.pumpAndSettle();
await tester.tap(find.byKey(const Key('terminal_presets_button')));
await tester.pumpAndSettle();

View File

@ -278,11 +278,9 @@ void main() {
expect(find.byKey(const Key('terminal_send_button')), findsOneWidget);
expect(find.byKey(const Key('terminal_command_deck')), findsOneWidget);
expect(find.byKey(const Key('terminal_key_tray')), findsNothing);
expect(find.byKey(const Key('terminal_mode_button')), findsOneWidget);
expect(
find.byKey(const Key('terminal_keys_toggle_button')),
findsOneWidget,
);
expect(find.byKey(const Key('terminal_mode_button')), findsNothing);
expect(find.byKey(const Key('terminal_keys_toggle_button')), findsNothing);
expect(find.byKey(const Key('terminal_presets_button')), findsNothing);
await tester.tap(find.byKey(const Key('terminal_toggle_actions_button')));
await tester.pumpAndSettle();
@ -290,6 +288,12 @@ void main() {
expect(find.byKey(const Key('terminal_tools_sheet')), findsOneWidget);
expect(find.text('Reconnect'), findsOneWidget);
expect(find.text('Latest'), findsOneWidget);
expect(find.byKey(const Key('terminal_mode_button')), findsOneWidget);
expect(
find.byKey(const Key('terminal_keys_toggle_button')),
findsOneWidget,
);
expect(find.byKey(const Key('terminal_presets_button')), findsOneWidget);
},
);
@ -308,9 +312,13 @@ void main() {
await _openProjectTerminal(tester);
expect(find.byKey(const Key('terminal_key_tray')), findsNothing);
expect(find.byKey(const Key('terminal_keys_toggle_button')), findsNothing);
await tester.tap(find.byKey(const Key('terminal_toggle_actions_button')));
await tester.pumpAndSettle();
await tester.tap(find.byKey(const Key('terminal_keys_toggle_button')));
await tester.pumpAndSettle();
expect(find.byKey(const Key('terminal_tools_sheet')), findsNothing);
expect(find.byKey(const Key('terminal_quick_key_esc')), findsOneWidget);
expect(find.byKey(const Key('terminal_quick_key_tab')), findsOneWidget);
expect(find.byKey(const Key('terminal_quick_key_ctrl_c')), findsOneWidget);
@ -347,6 +355,8 @@ void main() {
'Buffered mode: type a command and send',
);
await tester.tap(find.byKey(const Key('terminal_toggle_actions_button')));
await tester.pumpAndSettle();
await tester.tap(find.byKey(const Key('terminal_mode_button')));
await tester.pumpAndSettle();
@ -356,6 +366,8 @@ void main() {
'Direct mode: keys send immediately',
);
await tester.tap(find.byKey(const Key('terminal_toggle_actions_button')));
await tester.pumpAndSettle();
await tester.tap(find.byKey(const Key('terminal_mode_button')));
await tester.pumpAndSettle();
@ -405,6 +417,8 @@ void main() {
await tester.enterText(find.byType(TextField).last, 'dir');
await tester.tap(find.byKey(const Key('terminal_send_button')));
await tester.pumpAndSettle();
await tester.tap(find.byKey(const Key('terminal_toggle_actions_button')));
await tester.pumpAndSettle();
await tester.tap(find.byKey(const Key('terminal_keys_toggle_button')));
await tester.pumpAndSettle();
await tester.tap(find.byKey(const Key('terminal_quick_key_ctrl_l')));
@ -543,6 +557,8 @@ void main() {
final commandField = find.byType(TextField).last;
final editableField = find.byType(EditableText).last;
await tester.tap(find.byKey(const Key('terminal_toggle_actions_button')));
await tester.pumpAndSettle();
await tester.tap(find.byKey(const Key('terminal_mode_button')));
await tester.pumpAndSettle();
await tester.tap(commandField);