Merge commit 'c8d9f661b5285a97ff9b2fb5f670549d09ac2ebf' into pipelines/run-20261111-1811-preserve-center-stage-reading-width-with-c833

This commit is contained in:
2026-11-11 18:25:51 +00:00
4 changed files with 82 additions and 15 deletions
@@ -71,18 +71,25 @@ class ChatCenterStageController extends ValueNotifier<bool> {
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';
@@ -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<ChatCenterStageKeys> {
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();
+11 -3
View File
@@ -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
@@ -491,6 +491,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();
@@ -504,7 +542,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;
}