diff --git a/apps/mobile_app/lib/features/terminal/terminal_page.dart b/apps/mobile_app/lib/features/terminal/terminal_page.dart index e7b65f6..8a563d8 100644 --- a/apps/mobile_app/lib/features/terminal/terminal_page.dart +++ b/apps/mobile_app/lib/features/terminal/terminal_page.dart @@ -509,6 +509,7 @@ class _TerminalPageState extends ConsumerState return showModalBottomSheet( context: context, backgroundColor: const Color(0xFF13191F), + isScrollControlled: true, builder: (context) { return SafeArea( child: AnimatedBuilder( @@ -541,6 +542,31 @@ class _TerminalPageState extends ConsumerState 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 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 ); } - 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', diff --git a/apps/mobile_app/test/features/terminal/terminal_page_input_test.dart b/apps/mobile_app/test/features/terminal/terminal_page_input_test.dart index 5d3cca6..68a300b 100644 --- a/apps/mobile_app/test/features/terminal/terminal_page_input_test.dart +++ b/apps/mobile_app/test/features/terminal/terminal_page_input_test.dart @@ -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(); diff --git a/apps/mobile_app/test/widget_test.dart b/apps/mobile_app/test/widget_test.dart index e03466b..c9f9d90 100644 --- a/apps/mobile_app/test/widget_test.dart +++ b/apps/mobile_app/test/widget_test.dart @@ -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);