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
@@ -5,6 +5,7 @@ import 'package:pipelines_app/features/terminal/terminal_hub.dart';
import 'package:pipelines_app/features/terminal/terminal_layout.dart';
import 'package:pipelines_app/features/terminal/terminal_shortcuts.dart';
import 'package:pipelines_app/features/terminal/terminal_tab.dart';
import 'package:pipelines_app/ui/input/keyboard_owner.dart';
import 'package:xterm/xterm.dart';
import 'terminal_app.dart';
@@ -239,6 +240,30 @@ void main() {
expect(windowsWeb.toggle, ['Alt+T', 'Ctrl+`']);
expect(windowsWeb.button, 'Terminal (Alt+T)');
});
testWidgets('typing / in the terminal stays in the terminal', (tester) async {
layout.setMode(TerminalMode.panel);
await pumpTerminalApp(tester, hub: hub, layout: layout);
await tester.tap(find.byKey(appField));
await tester.pump();
await chord(tester, LogicalKeyboardKey.keyT, [LogicalKeyboardKey.altLeft]);
expect(terminalFocused(key('term_a')), isTrue);
// App-wide shortcuts see a typing surface and leave the key alone.
expect(primaryFocusIsTypingSurface(), isTrue);
expect(primaryFocusTakesTyping(), isTrue);
await tester.sendKeyEvent(LogicalKeyboardKey.slash, character: '/');
await tester.pump();
expect(terminalFocused(key('term_a')), isTrue);
expect(
mac.bodies('terminal_input').map((b) => b['data']).join(),
contains('/'),
);
expect(
find.text('/'),
findsNothing,
reason: 'nothing typed into the field',
);
});
}
/// A keyboard on which only Alt (Option) is held.