Skip to content

The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.

Merge branch 'main' into fix/opt-and-cmd-delete-in-a-pane

reinSPQRdfd8e21ecd68
diff --cc desktop/lib/shortcuts/app_shortcuts.dart
index c846d875a,69c8675ec..d8a564e1c
--- a/desktop/lib/shortcuts/app_shortcuts.dart
+++ b/desktop/lib/shortcuts/app_shortcuts.dart
@@@ -544,17 -573,19 +573,25 @@@ class TerminalKey
/// The shortcuts screen prints these beside the ones the app takes, because
/// "why is there no shortcut for X" is answered by seeing that X already
/// belongs to something.
- const List<TerminalKey> kTerminalOwnedKeys = [
- TerminalKey(['⌘', 'C'], 'Copy'),
- TerminalKey(['⌘', 'V'], 'Paste'),
- TerminalKey(['⌘', 'A'], 'Select all'),
- TerminalKey(['esc'], 'Interrupt the engine'),
- TerminalKey(['⌥', '⏎'], "Newline in the engine's prompt"),
+ List<TerminalKey> get kTerminalOwnedKeys => [
+ if (defaultTargetPlatform == TargetPlatform.linux) ...const [
+ TerminalKey(['⌃', '⇧', 'C'], 'Copy'),
+ TerminalKey(['⌃', '⇧', 'V'], 'Paste'),
+ TerminalKey(['⌃', '⇧', 'A'], 'Select all'),
+ ] else ...const [
+ TerminalKey(['⌘', 'C'], 'Copy'),
+ TerminalKey(['⌘', 'V'], 'Paste'),
+ TerminalKey(['⌘', 'A'], 'Select all'),
+ ],
+ const TerminalKey(['esc'], 'Interrupt the engine'),
+ const TerminalKey(['⌥', '⏎'], "Newline in the engine's prompt"),
+ // Kept as short as the rows around them: the deck's narrowest card is 280px, where a label much
+ // past thirty characters takes a second line to itself.
- TerminalKey(['⌥', '⌫'], 'Delete the previous word'),
- TerminalKey(['⌘', '⌫'], "Delete to the line's start"),
- TerminalKey(['⌃', 'C'], 'Cancel / interrupt in the agent'),
++ const TerminalKey(['⌥', '⌫'], 'Delete the previous word'),
++ // ⌘⌫ is taken in the pane on Apple only — elsewhere ⌘ is Super and stays the app's.
++ if (defaultTargetPlatform != TargetPlatform.linux)
++ const TerminalKey(['⌘', '⌫'], "Delete to the line's start"),
+ const TerminalKey(['⌃', 'C'], 'Cancel / interrupt in the agent'),
];
/// Turns the declared shortcuts into the map [CallbackShortcuts] wants.
diff --cc desktop/lib/terminal/terminal_session.dart
index a42af01c9,06a57f7c4..0086d8cfc
--- a/desktop/lib/terminal/terminal_session.dart
+++ b/desktop/lib/terminal/terminal_session.dart
@@@ -777,10 -883,11 +883,12 @@@ class TerminalSession extends ChangeNot
Terminal _newTerminal({bool bindCallbacks = true}) {
final result = Terminal(
maxLines: 10000,
- platform: TerminalTargetPlatform.macos,
+ platform: defaultTargetPlatform == TargetPlatform.linux
+ ? TerminalTargetPlatform.linux
+ : TerminalTargetPlatform.macos,
- // ⌥⏎ has to become a Meta-prefixed Return before it reaches the pty, or the engine's prompt
- // reads it as the submit it is byte-identical to. See [MetaEnterInputHandler].
+ // ⌥⏎ and ⌥⌫ have to become Meta-prefixed before they reach the pty, or the engine's prompt
+ // reads the first as the submit it is byte-identical to and never hears the second at all.
+ // See [AltAsMetaInputHandler].
inputHandler: harnessInputHandler,
// The remote pane owns its grid and redraws after resize. Reflowing TUI
// rows locally both changes their geometry and exercises an xterm.dart
diff --cc desktop/lib/widgets/terminal_panel.dart
index af1735427,f581cc60e..df767a7e1
--- a/desktop/lib/widgets/terminal_panel.dart
+++ b/desktop/lib/widgets/terminal_panel.dart
@@@ -931,65 -1121,37 +1121,82 @@@ class _TerminalPanelState extends State
return;
}
}
- widget.session.terminal.keyInput(TerminalKey.keyV, ctrl: true);
+ target.terminal.keyInput(TerminalKey.keyV, ctrl: true);
}
- /// Take the platform's exact paste chord before xterm's text-only action,
- /// so agent image paste follows the same path. Linux reserves Ctrl-V for
- /// the terminal program and uses Ctrl-Shift-V for its clipboard.
+ /// ⌘⌫ — kill back to the start of the line, the way a macOS text field does it.
+ ///
+ /// The pty has no Command key. What a prompt understands is readline's ^U (`\x15`), and it means
+ /// the same thing: verified against a live Claude Code and Codex, it clears back to the start of
+ /// the CURRENT line and leaves the lines composed above it standing — which is exactly what ⌘⌫
+ /// does in a Mac field. Asked of the keytab as `^U` rather than written as a byte so a terminal
+ /// carrying its own handler still answers with whatever ^U means to it.
+ ///
+ /// Taken HERE, in the pane's own hook, and not in the input handler with ⌥⌫: a ⌘ chord never
+ /// reaches `keyInput` at all. xterm hands every one of them back to the app untouched (patch 3 in
+ /// `third_party/xterm/README.autonomous.md`) — and `TerminalKeyboardEvent` has no `meta` field to
+ /// answer it with even if it did. Nothing in `app_shortcuts.dart` claims ⌘⌫ either, so the chord
+ /// went up the focus chain and off the end of it, doing nothing.
+ ///
+ /// Apple only. Elsewhere ⌘ is Super, where killing a line is not what it means, and the app's own
+ /// Super chords have to keep reaching the app.
+ KeyEventResult _onDeleteToLineStart() {
+ final keyboard = HardwareKeyboard.instance;
+ final apple =
+ defaultTargetPlatform == TargetPlatform.macOS ||
+ defaultTargetPlatform == TargetPlatform.iOS;
+ if (!apple || !keyboard.isMetaPressed) return KeyEventResult.ignored;
+ // ⌃ and ⌥ each carry a kill of their own to the pty (^U and Meta+⌫); a chord mixing them with
+ // ⌘ is nobody's idea of this one, so it is left for the shell to make sense of.
+ if (keyboard.isControlPressed || keyboard.isAltPressed) {
+ return KeyEventResult.ignored;
+ }
+ if (widget.readOnly || !widget.session.acceptsInput) {
+ return KeyEventResult.ignored;
+ }
+ widget.session.terminal.keyInput(TerminalKey.keyU, ctrl: true);
+ return KeyEventResult.handled;
+ }
+
+ /// ⌘V (Ctrl+V off Apple) — taken from xterm so the fallthrough above applies. ⌘⌫ joins it here,
+ /// for the reason spelled out on [_onDeleteToLineStart].
+ ///
+ /// xterm binds paste itself, but only ever to its text-only action. `onKeyEvent`
+ /// is the one hook that runs BEFORE its shortcut map (terminal_view.dart), so
- /// this is where the binding has to be replaced rather than added.
++ /// this is where the binding has to be replaced rather than added. The chord taken is the
++ /// platform's exact one: Linux reserves Ctrl-V for the terminal program and pastes with
++ /// Ctrl-Shift-V.
KeyEventResult _onTerminalKey(FocusNode node, KeyEvent event) {
+ final keyboard = HardwareKeyboard.instance;
+ // A pane that lost control still gets the keys (xterm's read-only mode
+ // keeps the focus node, it only stops opening an input connection), and
+ // dropping them silently is how people sit typing into a frozen pane. ⏎
+ // takes control back; any other plain key nudges the banner that says so.
+ // ⌘/⌃ chords are left alone: they are the app's and the pane's shortcuts.
+ if (event is KeyDownEvent &&
+ _inputBlocked &&
+ !keyboard.isMetaPressed &&
+ !keyboard.isControlPressed) {
+ if (event.logicalKey == LogicalKeyboardKey.enter ||
+ event.logicalKey == LogicalKeyboardKey.numpadEnter) {
+ unawaited(_takeControl());
+ return KeyEventResult.handled;
+ }
+ if (_isTypingKey(event)) {
+ _nudgeControlBanner();
+ return KeyEventResult.ignored;
+ }
+ }
+ // A held ⌘⌫ repeats, the way a held Backspace does — unlike ⌘V, where a second paste is never
+ // what the finger that stayed down meant.
+ if ((event is KeyDownEvent || event is KeyRepeatEvent) &&
+ event.logicalKey == LogicalKeyboardKey.backspace) {
+ return _onDeleteToLineStart();
+ }
- if (event is! KeyDownEvent) return KeyEventResult.ignored;
- if (event.logicalKey != LogicalKeyboardKey.keyV) {
+ if (event is! KeyDownEvent || event.logicalKey != LogicalKeyboardKey.keyV) {
return KeyEventResult.ignored;
}
- final keyboard = HardwareKeyboard.instance;
- if (keyboard.isShiftPressed) {
- return KeyEventResult.ignored; // ⇧⌘V is a different verb
- }
-
+ if (keyboard.isAltPressed) return KeyEventResult.ignored;
final apple =
defaultTargetPlatform == TargetPlatform.macOS ||
defaultTargetPlatform == TargetPlatform.iOS;