From c8d9f661b5285a97ff9b2fb5f670549d09ac2ebf Mon Sep 17 00:00:00 2001 From: Alan Silva Date: Wed, 11 Nov 2026 18:20:24 +0000 Subject: [PATCH] Support Alt+E center stage shortcut Recognize Option+E by physical key position so macOS dead-key delivery works, including from focused composers, while preserving existing platform aliases and shell behavior. Update labels, notes, and focused coverage. --- .../chat_center_stage_controller.dart | 19 ++++--- .../workspace/chat_center_stage_keys.dart | 11 ++-- app/notes/chat-center-stage.md | 14 +++-- .../workspace/chat_center_stage_test.dart | 53 ++++++++++++++++++- 4 files changed, 82 insertions(+), 15 deletions(-) diff --git a/app/lib/features/chat/workspace/chat_center_stage_controller.dart b/app/lib/features/chat/workspace/chat_center_stage_controller.dart index 0b0c8602..e91f8ce5 100644 --- a/app/lib/features/chat/workspace/chat_center_stage_controller.dart +++ b/app/lib/features/chat/workspace/chat_center_stage_controller.dart @@ -71,18 +71,25 @@ class ChatCenterStageController extends ValueNotifier { void toggle() => value = !value; } -/// Whether [event] toggles center stage: Cmd+E on Apple platforms (where -/// Ctrl+E stays the text fields' and shell's end of line) and Ctrl+E -/// elsewhere, with no other modifier. Repeats of a held chord match too, so -/// they are swallowed; only the first press toggles. +/// Whether [event] toggles center stage: Alt+E (Option+E on Apple platforms), +/// Cmd+E on Apple platforms (where Ctrl+E stays the text fields' and shell's +/// end of line), and Ctrl+E elsewhere. Option+E is recognized by physical key +/// position because macOS delivers it as a dead-key logical value. Repeats of +/// a held chord match too, so they are swallowed; only the first press toggles. bool chatCenterStageShortcut( KeyEvent event, HardwareKeyboard keyboard, { TargetPlatform? platform, }) { - if (event is KeyUpEvent || keyboard.isShiftPressed || keyboard.isAltPressed) { + if (event is KeyUpEvent || keyboard.isShiftPressed) { return false; } + final alt = keyboard.isAltPressed; + if (alt) { + return event.physicalKey == PhysicalKeyboardKey.keyE && + !keyboard.isControlPressed && + !keyboard.isMetaPressed; + } if (event.logicalKey != LogicalKeyboardKey.keyE) return false; return chatCenterStageUsesCommand(platform) ? keyboard.isMetaPressed && !keyboard.isControlPressed @@ -96,4 +103,4 @@ bool chatCenterStageUsesCommand([TargetPlatform? platform]) { /// The shortcut as this platform shows it, for menus and tooltips. String chatCenterStageShortcutLabel([TargetPlatform? platform]) => - chatCenterStageUsesCommand(platform) ? 'Cmd+E' : 'Ctrl+E'; + chatCenterStageUsesCommand(platform) ? 'Option+E' : 'Alt+E'; diff --git a/app/lib/features/chat/workspace/chat_center_stage_keys.dart b/app/lib/features/chat/workspace/chat_center_stage_keys.dart index a30a17ed..96260c4c 100644 --- a/app/lib/features/chat/workspace/chat_center_stage_keys.dart +++ b/app/lib/features/chat/workspace/chat_center_stage_keys.dart @@ -11,9 +11,10 @@ import 'chat_center_stage_controller.dart'; /// never types it. Handling the key also stops a browser's own Ctrl+E/Cmd+E /// (address-bar search, find with selection) in the web build. /// -/// On Apple platforms the chord is Cmd+E and works in the terminal too. -/// Elsewhere it is Ctrl+E, which the terminal keeps while it has the -/// keyboard: there it is the shell's end of line. +/// Alt+E/Option+E works everywhere, including while a composer is focused. +/// On Apple platforms Cmd+E works in the terminal too. Elsewhere Ctrl+E is +/// left to the terminal while it has the keyboard: there it is the shell's +/// end of line. class ChatCenterStageKeys extends StatefulWidget { const ChatCenterStageKeys({ super.key, @@ -51,7 +52,9 @@ class _ChatCenterStageKeysState extends State { if (!mounted || !chatCenterStageShortcut(event, HardwareKeyboard.instance) || !widget.enabled() || - (!chatCenterStageUsesCommand() && primaryFocusIsTypingSurface())) { + (!HardwareKeyboard.instance.isAltPressed && + !chatCenterStageUsesCommand() && + primaryFocusIsTypingSurface())) { return KeyEventResult.ignored; } if (event is KeyDownEvent) widget.controller.toggle(); diff --git a/app/notes/chat-center-stage.md b/app/notes/chat-center-stage.md index 7a446e9a..ebffe933 100644 --- a/app/notes/chat-center-stage.md +++ b/app/notes/chat-center-stage.md @@ -7,9 +7,11 @@ unchanged. ## Using it -- Cmd+E on macOS/iOS, Ctrl+E elsewhere, or the pane's More menu: - **Center stage (Cmd+E)** / **Leave center stage (Cmd+E)** (shown with two or - more panes on a wide window). +- Alt+E (Option+E on macOS/iOS), Cmd+E on Apple platforms, Ctrl+E elsewhere, or + the pane's More menu: **Center stage (Option+E)** / **Leave center stage + (Option+E)** on Apple platforms (shown with two or more panes on a wide + window). Option+E is matched by physical key position because macOS treats it + as a dead key. - The choice is device-local (`pipelines.next.chatCenterStage.v1` in shared preferences) and survives reloads. It is not part of the server-scoped workspace snapshot. @@ -31,6 +33,12 @@ unchanged. - `tool/memwatch/full.sh 'test/features/chat/workspace'`: 87 passed, 0 failed. `tool/analyze.sh`: clean. +- Shortcut fix: `tool/memwatch/full.sh + 'test/features/chat/workspace/chat_center_stage_test.dart'`: 16 passed, 0 + failed; `tool/analyze.sh`: clean. Covered Option/Alt+E dead-key position + matching, focused-composer handling, key-up rejection, existing aliases and + platform labels. Browser interaction/capture remains with the UI review + stage. - Captures (`chats=3&rich=1&colors=1`, 1440x900, three panes, headless Chrome, macOS platform, so Cmd+E): normal split, center stage on, stage moved to api refactor, and back to the same split sizes, plus filmed toggle-on, switch diff --git a/app/test/features/chat/workspace/chat_center_stage_test.dart b/app/test/features/chat/workspace/chat_center_stage_test.dart index 9f915f09..f364ea5d 100644 --- a/app/test/features/chat/workspace/chat_center_stage_test.dart +++ b/app/test/features/chat/workspace/chat_center_stage_test.dart @@ -385,6 +385,44 @@ void main() { ); } + test('Alt+E toggles by physical key position, including Option dead keys', () { + const event = KeyDownEvent( + physicalKey: PhysicalKeyboardKey.keyE, + logicalKey: LogicalKeyboardKey(0x00B4), + character: 'ยด', + timeStamp: Duration.zero, + ); + expect(chatCenterStageShortcut(event, _AltHeld()), isTrue); + expect( + chatCenterStageShortcut( + const KeyUpEvent( + physicalKey: PhysicalKeyboardKey.keyE, + logicalKey: LogicalKeyboardKey(0x00B4), + timeStamp: Duration.zero, + ), + _AltHeld(), + ), + isFalse, + ); + }); + + testWidgets('Alt+E toggles from a focused composer without typing', ( + tester, + ) async { + wide(tester); + final workspace = threePanes(); + final stage = ChatCenterStageController(store: _MemoryStore()); + addTearDown(workspace.dispose); + addTearDown(stage.dispose); + await tester.pumpWidget(host(workspace, stage)); + await tester.tap(find.byKey(const ValueKey('input-three'))); + await tester.sendKeyDownEvent(LogicalKeyboardKey.altLeft); + await tester.sendKeyEvent(LogicalKeyboardKey.keyE); + await tester.sendKeyUpEvent(LogicalKeyboardKey.altLeft); + expect(stage.value, isTrue); + expect(find.text('e'), findsNothing); + }); + test('the choice is remembered', () async { final store = _MemoryStore(); final first = ChatCenterStageController(store: store)..toggle(); @@ -398,7 +436,18 @@ void main() { }); test('labels name the platform chord', () { - expect(chatCenterStageShortcutLabel(TargetPlatform.macOS), 'Cmd+E'); - expect(chatCenterStageShortcutLabel(TargetPlatform.windows), 'Ctrl+E'); + expect(chatCenterStageShortcutLabel(TargetPlatform.macOS), 'Option+E'); + expect(chatCenterStageShortcutLabel(TargetPlatform.windows), 'Alt+E'); }); } + +class _AltHeld extends HardwareKeyboard { + @override + bool get isAltPressed => true; + @override + bool get isControlPressed => false; + @override + bool get isMetaPressed => false; + @override + bool get isShiftPressed => false; +}