Keep keys typed in a terminal out of app shortcuts

Terminals are marked as typing surfaces. While one has focus, the chat's
"/ jumps to the composer", the Search tab's Escape, Ctrl+/, Ctrl+1…9 and
Ctrl+Shift+arrow pane moves leave the key to the terminal, like they do for
text fields.
This commit is contained in:
2026-11-10 00:14:18 +00:00
parent 339cce0424
commit 750071abe1
9 changed files with 94 additions and 31 deletions
@@ -9,6 +9,7 @@ import 'chat_shell_metrics.dart';
import 'chat_shell_terminal_links.dart';
import 'chat_shell_terminal_session.dart';
import 'chat_shell_terminal_theme.dart';
import '../../../ui/input/keyboard_owner.dart';
/// Whether the soft keyboard is the main way to type here, so the key
/// toolbar offers a text field: the terminal itself takes hardware keys only.
@@ -104,23 +105,26 @@ class _ChatShellTerminalViewState extends State<ChatShellTerminalView> {
Widget view = Semantics(
identifier: 'chat-shell-terminal',
label: live ? 'Terminal, type to send input' : 'Terminal output',
child: TerminalView(
session.terminal,
controller: _controller,
focusNode: _focus,
autofocus: widget.autofocus && live,
autoResize: widget.autoResize,
theme: chatShellTerminalTheme(context, widget.cupertino),
textStyle: style,
padding: padding,
readOnly: !live,
// Keys go straight to the process as key events (a focused text
// input would stay closed on the web); touch typing goes through the
// key toolbar's field instead.
hardwareKeyboardOnly: true,
shortcuts: chatShellTerminalShortcuts(),
cursorType: TerminalCursorType.block,
onTapUp: _tapped,
// App-wide shortcuts leave typing in the terminal alone.
child: TypingSurface(
child: TerminalView(
session.terminal,
controller: _controller,
focusNode: _focus,
autofocus: widget.autofocus && live,
autoResize: widget.autoResize,
theme: chatShellTerminalTheme(context, widget.cupertino),
textStyle: style,
padding: padding,
readOnly: !live,
// Keys go straight to the process as key events (a focused text
// input would stay closed on the web); touch typing goes through the
// key toolbar's field instead.
hardwareKeyboardOnly: true,
shortcuts: chatShellTerminalShortcuts(),
cursorType: TerminalCursorType.block,
onTapUp: _tapped,
),
),
);
// The emulator would otherwise inset itself by the window's safe area.