From 2d0e33dd67820d4890da965942116479bab403d8 Mon Sep 17 00:00:00 2001 From: Alan Silva Date: Wed, 11 Nov 2026 19:40:26 +0000 Subject: [PATCH 1/3] Unify chat selector menus Use the permission selector's shared popup and choice-row primitives for model and thinking controls while preserving catalog, search, and next-turn behavior. Remove the obsolete Cupertino model chooser parameter and cover current-model dismissal. --- .../conversation/chat_effort_control.dart | 101 ++++++----- .../chat/conversation/chat_mode_control.dart | 26 ++- .../chat/conversation/chat_model_chooser.dart | 171 ++++++++++-------- .../chat/conversation/chat_model_control.dart | 9 +- app/lib/ui/adaptive/app_popups.dart | 25 +++ app/notes/chat-selector-menu-unification.md | 18 ++ .../conversation/chat_model_picker_test.dart | 14 ++ 7 files changed, 227 insertions(+), 137 deletions(-) create mode 100644 app/notes/chat-selector-menu-unification.md diff --git a/app/lib/features/chat/conversation/chat_effort_control.dart b/app/lib/features/chat/conversation/chat_effort_control.dart index 226cafc3..3020c937 100644 --- a/app/lib/features/chat/conversation/chat_effort_control.dart +++ b/app/lib/features/chat/conversation/chat_effort_control.dart @@ -4,7 +4,7 @@ import 'package:flutter/material.dart'; import '../../../core/api_gateway.dart'; import '../../../core/error_reason.dart'; -import '../../../ui/adaptive/app_menu_anchor.dart'; +import '../../../ui/adaptive/app_popups.dart'; import 'chat_bar_control_style.dart'; import 'chat_efforts.dart'; import 'chat_models.dart'; @@ -92,9 +92,13 @@ class _ChatEffortControlState extends State { } Future _chooseFromMenu(ChatEffortLevel level) async { - if (level.id == _state.effort) return; + if (level.id == _state.effort || level.id == _state.current) { + Navigator.of(context).pop(); + return; + } try { await _choose(level); + if (mounted) Navigator.of(context).pop(); } catch (error) { if (!mounted) return; ScaffoldMessenger.maybeOf(context)?.showSnackBar( @@ -128,57 +132,62 @@ class _ChatEffortControlState extends State { ], ); const key = Key('chat-effort'); - return AppMenuAnchor( - menuChildren: [ - Padding( - padding: const EdgeInsets.fromLTRB(12, 8, 12, 4), - child: ConstrainedBox( - constraints: const BoxConstraints(maxWidth: 280), + return Semantics( + container: true, + button: true, + label: 'Change thinking level, currently ${_state.currentName}', + onTap: _open, + child: ExcludeSemantics( + child: Tooltip( + message: 'Change thinking level (currently ${_state.currentName})', + child: TextButton( + key: key, + style: chatBarTextButtonStyle(context, compact: iconOnly), + onPressed: _open, + child: content, + ), + ), + ), + ); + } + + Future _open() async { + await showAppChoiceMenu( + context, + width: 320, + semanticLabel: 'Change thinking level', + builder: (_) => ListView( + key: const Key('chat-effort-menu'), + shrinkWrap: true, + children: [ + Padding( + padding: const EdgeInsets.fromLTRB(16, 0, 16, 8), child: Text( chatEffortNote(running: widget.running), key: const Key('chat-effort-note'), style: Theme.of(context).textTheme.bodySmall, ), ), - ), - for (final level in _state.levels) - MenuItemButton( - key: ValueKey('chat-effort-option-${level.id}'), - trailingIcon: level.id == _state.current - ? const Icon(Icons.check) - : null, - onPressed: () => unawaited(_chooseFromMenu(level)), - child: level.description.isEmpty - ? Text(level.name) - : Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisSize: MainAxisSize.min, - children: [ - Text(level.name), - Text( - level.description, - style: Theme.of(context).textTheme.bodySmall, - ), - ], - ), - ), - ], - builder: (context, menu, _) => Semantics( - container: true, - button: true, - label: 'Change thinking level, currently ${_state.currentName}', - onTap: () => menu.isOpen ? menu.close() : menu.open(), - child: ExcludeSemantics( - child: Tooltip( - message: 'Change thinking level (currently ${_state.currentName})', - child: TextButton( - key: key, - style: chatBarTextButtonStyle(context), - onPressed: () => menu.isOpen ? menu.close() : menu.open(), - child: content, + for (final level in _state.levels) + AppChoiceMenuItem( + key: ValueKey('chat-effort-option-${level.id}'), + selected: level.id == _state.current, + onTap: () => unawaited(_chooseFromMenu(level)), + child: level.description.isEmpty + ? Text(level.name) + : Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + Text(level.name), + Text( + level.description, + style: Theme.of(context).textTheme.bodySmall, + ), + ], + ), ), - ), - ), + ], ), ); } diff --git a/app/lib/features/chat/conversation/chat_mode_control.dart b/app/lib/features/chat/conversation/chat_mode_control.dart index 904745e3..a84d219a 100644 --- a/app/lib/features/chat/conversation/chat_mode_control.dart +++ b/app/lib/features/chat/conversation/chat_mode_control.dart @@ -249,17 +249,23 @@ class _ChatModePickerState extends State<_ChatModePicker> { ) else for (final mode in modes) - ListTile( + AppChoiceMenuItem( key: ValueKey('chat-mode-option-${mode.id}'), - enabled: !_busy, - title: Text(mode.name), - subtitle: mode.description.isEmpty - ? null - : Text(mode.description), - trailing: mode.id == _current - ? Icon(Icons.check, color: theme.colorScheme.primary) - : null, - onTap: () => _choose(mode), + selected: mode.id == _current, + onTap: _busy ? null : () => _choose(mode), + child: mode.description.isEmpty + ? Text(mode.name) + : Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + Text(mode.name), + Text( + mode.description, + style: theme.textTheme.bodySmall, + ), + ], + ), ), ], ), diff --git a/app/lib/features/chat/conversation/chat_model_chooser.dart b/app/lib/features/chat/conversation/chat_model_chooser.dart index 81bd112d..eeaef303 100644 --- a/app/lib/features/chat/conversation/chat_model_chooser.dart +++ b/app/lib/features/chat/conversation/chat_model_chooser.dart @@ -4,6 +4,7 @@ import 'package:flutter/material.dart'; import '../../../core/api_gateway.dart'; import '../../../core/error_reason.dart'; +import '../../../ui/adaptive/app_popups.dart'; import '../data/chat_repository.dart'; import 'chat_models.dart'; @@ -22,7 +23,6 @@ class ChatModelChooser extends StatefulWidget { required this.backend, required this.currentProvider, required this.currentModel, - required this.cupertino, required this.onAccepted, }); @@ -31,7 +31,6 @@ class ChatModelChooser extends StatefulWidget { final String backend; final String currentProvider; final String currentModel; - final bool cupertino; final ValueChanged onAccepted; @override @@ -92,6 +91,10 @@ class _ChatModelChooserState extends State { Future _choose(JsonMap model) async { if (_busy) return; + if (_isCurrent(model)) { + Navigator.of(context).pop(); + return; + } setState(() { _busy = true; _error = null; @@ -147,95 +150,105 @@ class _ChatModelChooserState extends State { final secondary = theme.colorScheme.onSurfaceVariant; final matches = filterChatModels(_models, _search.text); final needle = _search.text.trim(); - return SimpleDialog( - key: const Key('chat-model-chooser'), - title: const Text('Change model'), - children: [ - Padding( - padding: const EdgeInsetsDirectional.fromSTEB(24, 0, 24, 8), - child: Text( - chatModelSelectionNote(widget.backend), - style: theme.textTheme.bodySmall?.copyWith(color: secondary), - ), - ), - if (_loading) - Padding( - padding: const EdgeInsetsDirectional.fromSTEB(24, 8, 24, 8), - child: Row( - children: [ - const CircularProgressIndicator(), - const SizedBox(width: 12), - const Expanded(child: Text('Loading models…')), - ], + return SafeArea( + child: SingleChildScrollView( + key: const Key('chat-model-chooser'), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + const Padding( + padding: EdgeInsets.fromLTRB(16, 0, 16, 8), + child: Text('Change model'), ), - ) - else if (_error != null) - Padding( - padding: const EdgeInsetsDirectional.fromSTEB(24, 0, 24, 8), - child: Text( - _error!, - key: const Key('chat-model-error'), - style: theme.textTheme.bodyMedium?.copyWith( - color: theme.colorScheme.error, - ), - ), - ) - else if (_models.isEmpty) - Padding( - padding: const EdgeInsetsDirectional.fromSTEB(24, 0, 24, 8), - child: Text( - 'No models are available for this chat.', - style: theme.textTheme.bodyMedium?.copyWith(color: secondary), - ), - ) - else ...[ - Padding( - padding: const EdgeInsetsDirectional.fromSTEB(24, 0, 24, 8), - child: TextField( - key: const Key('chat-model-search'), - controller: _search, - onChanged: (_) => setState(() {}), - decoration: const InputDecoration( - prefixIcon: Icon(Icons.search), - hintText: 'Search models', - ), - ), - ), - for (final model in matches) - SimpleDialogOption( - key: _optionKey(model), - onPressed: _busy ? null : () => _choose(model), - child: _optionRow(context, model), - ), - if (matches.isEmpty && needle.isNotEmpty) Padding( - padding: const EdgeInsetsDirectional.fromSTEB(24, 0, 24, 8), + padding: const EdgeInsetsDirectional.fromSTEB(16, 0, 16, 8), child: Text( - 'No models match "$needle".', - key: const Key('chat-model-no-match'), - style: theme.textTheme.bodyMedium?.copyWith(color: secondary), + chatModelSelectionNote(widget.backend), + style: theme.textTheme.bodySmall?.copyWith(color: secondary), ), ), - ], - Padding( - padding: const EdgeInsetsDirectional.fromSTEB(16, 4, 16, 8), - child: Align( - alignment: AlignmentDirectional.centerEnd, - child: TextButton( - key: const Key('chat-model-cancel'), - onPressed: () => Navigator.of(context).pop(), - child: const Text('Cancel'), + if (_loading) + Padding( + padding: const EdgeInsetsDirectional.fromSTEB(16, 8, 16, 8), + child: Row( + children: [ + const CircularProgressIndicator(), + const SizedBox(width: 12), + const Expanded(child: Text('Loading models…')), + ], + ), + ) + else if (_error != null) + Padding( + padding: const EdgeInsetsDirectional.fromSTEB(16, 0, 16, 8), + child: Text( + _error!, + key: const Key('chat-model-error'), + style: theme.textTheme.bodyMedium?.copyWith( + color: theme.colorScheme.error, + ), + ), + ) + else if (_models.isEmpty) + Padding( + padding: const EdgeInsetsDirectional.fromSTEB(16, 0, 16, 8), + child: Text( + 'No models are available for this chat.', + style: theme.textTheme.bodyMedium?.copyWith(color: secondary), + ), + ) + else ...[ + Padding( + padding: const EdgeInsetsDirectional.fromSTEB(16, 0, 16, 8), + child: TextField( + key: const Key('chat-model-search'), + controller: _search, + onChanged: (_) => setState(() {}), + decoration: const InputDecoration( + prefixIcon: Icon(Icons.search), + hintText: 'Search models', + ), + ), + ), + for (final model in matches) + AppChoiceMenuItem( + key: _optionKey(model), + selected: _isCurrent(model), + onTap: _busy ? null : () => _choose(model), + child: _optionRow(context, model), + ), + if (matches.isEmpty && needle.isNotEmpty) + Padding( + padding: const EdgeInsetsDirectional.fromSTEB(16, 0, 16, 8), + child: Text( + 'No models match "$needle".', + key: const Key('chat-model-no-match'), + style: theme.textTheme.bodyMedium?.copyWith( + color: secondary, + ), + ), + ), + ], + Padding( + padding: const EdgeInsetsDirectional.fromSTEB(16, 4, 16, 8), + child: Align( + alignment: AlignmentDirectional.centerEnd, + child: TextButton( + key: const Key('chat-model-cancel'), + onPressed: () => Navigator.of(context).pop(), + child: const Text('Cancel'), + ), + ), ), - ), + ], ), - ], + ), ); } Widget _optionRow(BuildContext context, JsonMap model) { final selected = _isCurrent(model); final secondary = Theme.of(context).colorScheme.onSurfaceVariant; - final accent = Theme.of(context).colorScheme.primary; final provider = '${model['provider'] ?? ''}'.trim(); return Semantics( selected: selected, @@ -252,7 +265,7 @@ class _ChatModelChooserState extends State { ], ), ), - if (selected) Icon(Icons.check, color: accent), + // The shared menu row supplies the check mark. ], ), ); diff --git a/app/lib/features/chat/conversation/chat_model_control.dart b/app/lib/features/chat/conversation/chat_model_control.dart index 0df4eb3f..0ce20e5e 100644 --- a/app/lib/features/chat/conversation/chat_model_control.dart +++ b/app/lib/features/chat/conversation/chat_model_control.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import '../../../core/api_gateway.dart'; +import '../../../ui/adaptive/app_popups.dart'; import 'chat_bar_control_style.dart'; import 'chat_model_chooser.dart'; import 'chat_models.dart'; @@ -79,10 +80,14 @@ class _ChatModelControlState extends State { backend: '${widget.session['backend'] ?? ''}'.trim(), currentProvider: _provider, currentModel: _model, - cupertino: false, onAccepted: _accept, ); - await showDialog(context: context, builder: (_) => chooser); + await showAppChoiceMenu( + context, + width: 420, + semanticLabel: 'Change model', + builder: (_) => chooser, + ); } void _accept(ChatModelSelection applied) { diff --git a/app/lib/ui/adaptive/app_popups.dart b/app/lib/ui/adaptive/app_popups.dart index b0834334..4d035b15 100644 --- a/app/lib/ui/adaptive/app_popups.dart +++ b/app/lib/ui/adaptive/app_popups.dart @@ -57,6 +57,31 @@ Future showAppChoiceMenu( ); } +/// A choice row shared by the app's anchored choice menus. Keeping the row +/// here makes checked state and tap affordances consistent across selectors. +class AppChoiceMenuItem extends StatelessWidget { + const AppChoiceMenuItem({ + super.key, + required this.child, + required this.selected, + required this.onTap, + }); + + final Widget child; + final bool selected; + final VoidCallback? onTap; + + @override + Widget build(BuildContext context) => ListTile( + enabled: onTap != null, + title: child, + trailing: selected + ? Icon(Icons.check, color: Theme.of(context).colorScheme.primary) + : null, + onTap: onTap, + ); +} + /// Shows richer content (a chat's details, a file's details) built by /// [builder]: a dialog on a wide app, a bottom sheet on a phone, on the root /// navigator either way. The content sizes itself (a `Column` with diff --git a/app/notes/chat-selector-menu-unification.md b/app/notes/chat-selector-menu-unification.md new file mode 100644 index 00000000..d09196ee --- /dev/null +++ b/app/notes/chat-selector-menu-unification.md @@ -0,0 +1,18 @@ +# Chat selector menu unification + +## Change + +Model and thinking-level controls now use the same `showAppChoiceMenu` root +popup/bottom-sheet primitive and shared `AppChoiceMenuItem` rows as the +permission-mode selector. Their catalog/search, loading, next-turn, server +echo, refusal, retry and dismissal behavior remain in their respective +controls. The model chooser's obsolete Cupertino parameter was removed. + +## Checks + +- `tool/memwatch/full.sh 'test/features/chat/conversation/chat_mode_control_test.dart test/features/chat/conversation/chat_model_picker_test.dart test/features/chat/conversation/chat_effort_control_test.dart test/features/chat/conversation/chat_effort_header_test.dart'` + — 29 passed, 0 failed, including the current-model dismissal regression. +- `tool/analyze.sh` — clean. + +Browser captures were not performed in this implementation stage; UI review +owns the requested full-app captures. diff --git a/app/test/features/chat/conversation/chat_model_picker_test.dart b/app/test/features/chat/conversation/chat_model_picker_test.dart index c5d1171d..0d3a3864 100644 --- a/app/test/features/chat/conversation/chat_model_picker_test.dart +++ b/app/test/features/chat/conversation/chat_model_picker_test.dart @@ -135,6 +135,20 @@ void main() { expect(find.text('model-b'), findsOneWidget); }); + testWidgets('choosing the current model only dismisses the chooser', ( + tester, + ) async { + final gateway = _ModelGateway()..modelsReply = _catalog; + await _openThread(tester, gateway); + await _openChooser(tester); + + await tester.tap(find.text('Model Alpha')); + await tester.pumpAndSettle(); + + expect(find.byKey(const Key('chat-model-chooser')), findsNothing); + expect(gateway.lastFields('chat_model'), isNull); + }); + testWidgets('a refusal keeps the previous model and shows the reason', ( tester, ) async { From 4668deeaf772f802facad764a57177de3016aabd Mon Sep 17 00:00:00 2001 From: Alan Silva Date: Wed, 11 Nov 2026 19:40:30 +0000 Subject: [PATCH 2/3] Focus floating chat from terminal shortcut Raise the most recently used chat when Ctrl+Y is invoked from another window, then rely on the existing host lifecycle to focus its composer. Preserve toggle behavior while chat is active and retain the Apple shortcut aliases. --- .../features/chat/windows/chat_windows.dart | 2 +- .../chat/workspace/chat_float_shortcut.dart | 9 +-- app/lib/shell/windows/window_manager.dart | 14 ++++ app/notes/chat-terminal-focus-shortcut.md | 23 ++++++ .../chat/chat_floating_pane_test.dart | 78 +++++++++++++++++-- .../chat/windows/chat_windows_test.dart | 10 +-- .../workspace/chat_float_shortcut_test.dart | 4 + .../shell/windows/window_manager_test.dart | 19 +++++ 8 files changed, 142 insertions(+), 17 deletions(-) create mode 100644 app/notes/chat-terminal-focus-shortcut.md diff --git a/app/lib/features/chat/windows/chat_windows.dart b/app/lib/features/chat/windows/chat_windows.dart index ef0e9781..247dd879 100644 --- a/app/lib/features/chat/windows/chat_windows.dart +++ b/app/lib/features/chat/windows/chat_windows.dart @@ -221,7 +221,7 @@ class ChatWindows { if (event is KeyDownEvent) tiling.floatActive(); return KeyEventResult.handled; } - if (event is KeyDownEvent) manager.toggleGroup(chatWindowKind); + if (event is KeyDownEvent) manager.toggleOrRaiseGroup(chatWindowKind); return KeyEventResult.handled; } } diff --git a/app/lib/features/chat/workspace/chat_float_shortcut.dart b/app/lib/features/chat/workspace/chat_float_shortcut.dart index 6d84b172..af6101a2 100644 --- a/app/lib/features/chat/workspace/chat_float_shortcut.dart +++ b/app/lib/features/chat/workspace/chat_float_shortcut.dart @@ -1,16 +1,13 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/services.dart'; -import '../../../ui/input/keyboard_owner.dart'; - /// Whether [event] shows or hides the floating chats: Alt+Y (Option+Y), /// Ctrl+Y, and Cmd+Y on Apple platforms, matching the terminal's Alt+T. It is /// a global key handler like the terminal's toggle, so it works while a /// composer or the terminal has the keyboard; a plain Y (or Shift+Y) always /// types. Alt+Y is always the chord, as Alt+T is for the terminal. On Apple -/// platforms Ctrl+Y inside a terminal is left to the shell (yank), since Cmd+Y -/// is there; elsewhere Ctrl+Y is the chord, so it takes priority over the -/// shell's yank. +/// platforms Ctrl+Y is also the chord, so it takes priority over the shell's +/// yank. /// /// A held chord's repeats match too (and are swallowed); only its first /// press toggles. @@ -31,7 +28,7 @@ bool chatFloatShortcut( if (alt) return !control && !meta; if (control == meta) return false; if (!_apple(platform ?? defaultTargetPlatform)) return control; - return meta || !primaryFocusIsTypingSurface(); + return control || meta; } bool _apple(TargetPlatform platform) => diff --git a/app/lib/shell/windows/window_manager.dart b/app/lib/shell/windows/window_manager.dart index ff90b0ce..fea83c79 100644 --- a/app/lib/shell/windows/window_manager.dart +++ b/app/lib/shell/windows/window_manager.dart @@ -289,6 +289,20 @@ class WindowManager extends ChangeNotifier { return true; } + /// Hides the group when it is active; otherwise shows and raises its most + /// recently used window. A global shortcut should bring a group forward when + /// pressed from another window, rather than hide it behind that window. + bool toggleOrRaiseGroup(String groupId) { + final group = inGroup(groupId).toList(); + if (group.isEmpty) return false; + if (group.any(isVisible) && active?.groupId == groupId) { + setGroupShown(groupId, false); + } else { + show(group.last.id); + } + return true; + } + /// Brings the next ([step] 1) or previous (-1) visible window to the top. void cycle([int step = 1]) { final visible = windows.where(isVisible).toList(); diff --git a/app/notes/chat-terminal-focus-shortcut.md b/app/notes/chat-terminal-focus-shortcut.md new file mode 100644 index 00000000..02801415 --- /dev/null +++ b/app/notes/chat-terminal-focus-shortcut.md @@ -0,0 +1,23 @@ +# Chat terminal shortcut focus + +Implemented the macOS Ctrl+Y floating-chat handoff. A chat shortcut now hides +the chat group only when chat is already the active window; from another +window it raises the most recently used chat. The existing window-host +post-frame lifecycle then focuses that chat's composer. Ctrl+Y now joins the +existing Option+Y and Cmd+Y aliases on Apple platforms; plain Y and repeat +events remain untouched. + +Evidence: + +- `tool/memwatch/full.sh 'test/features/chat/windows/chat_windows_test.dart test/features/chat/workspace/chat_float_shortcut_test.dart test/features/chat/chat_floating_pane_test.dart test/shell/windows/window_manager_test.dart'` + — PASS: 33 passed, 0 failed, 0 skipped; peak 1236 MB; 14s. +- `tool/analyze.sh` — clean; exit 0. +- The floating-pane regression uses a terminal-like `TypingSurface`, presses + macOS Ctrl+Y, verifies the chat composer has primary focus, types + `from terminal` without a click, and verifies the terminal did not receive + Y. The manager regression covers visible-behind-terminal, hidden, multiple + chats, and repeated toggles. + +No browser fixture was run in this implementation stage; browser terminal +fixture support and full-app rendered evidence remain for the appropriate +review stage. diff --git a/app/test/features/chat/chat_floating_pane_test.dart b/app/test/features/chat/chat_floating_pane_test.dart index 401ef3aa..d8d1fa15 100644 --- a/app/test/features/chat/chat_floating_pane_test.dart +++ b/app/test/features/chat/chat_floating_pane_test.dart @@ -16,7 +16,9 @@ import 'package:pipelines_app/shell/windows/window_host.dart'; import 'package:pipelines_app/shell/windows/window_kind.dart'; import 'package:pipelines_app/shell/windows/window_manager.dart'; import 'package:pipelines_app/shell/windows/window_store.dart'; +import 'package:pipelines_app/shell/windows/window_entry.dart'; import 'package:pipelines_app/ui/motion/fade_through_stack.dart'; +import 'package:pipelines_app/ui/input/keyboard_owner.dart'; import 'conversation/chat_thread_fixtures.dart'; @@ -46,6 +48,19 @@ class _Store implements WindowStore { } } +class _TerminalKind extends WindowKind { + @override + String get key => 'terminal'; + @override + bool get serverScoped => false; + @override + IconData get icon => Icons.terminal; + @override + String title(BuildContext context, WindowEntry entry) => entry.contentId; + @override + Widget build(BuildContext context, WindowEntry entry) => const SizedBox(); +} + Finder _thread(String id) => find.byWidgetPredicate( (widget) => widget is ChatThreadView && widget.sessionId == id, skipOffstage: false, @@ -83,21 +98,21 @@ class _App { late final ChatRuntime runtime; late final WindowManager manager; late final ChatWindows windows; + final terminalFocus = FocusNode(debugLabel: 'test terminal'); + final terminalTyped = []; Future start( WidgetTester tester, { Size size = const Size(1800, 1000), + bool terminalSurface = false, }) async { tester.view.physicalSize = size; tester.view.devicePixelRatio = 1; addTearDown(tester.view.reset); bindServerIdentity(gateway, 'server-a'); runtime = ChatRuntime(gateway: gateway, serverKey: 'server-a'); - manager = WindowManager( - kinds: WindowKinds(), - store: store, - server: 'server-a', - ); + final kinds = WindowKinds()..register(_TerminalKind()); + manager = WindowManager(kinds: kinds, store: store, server: 'server-a'); windows = ChatWindows( manager: manager, runtime: runtime, @@ -131,6 +146,21 @@ class _App { ], ), ), + if (terminalSurface) + Positioned.fill( + child: TypingSurface( + child: Focus( + focusNode: terminalFocus, + onKeyEvent: (node, event) { + if (event is KeyDownEvent) { + terminalTyped.add(event.logicalKey); + } + return KeyEventResult.handled; + }, + child: const SizedBox(), + ), + ), + ), Positioned.fill(child: WindowHost(manager: manager)), ], ), @@ -147,6 +177,7 @@ class _App { manager.dispose(); destination.dispose(); chatBuilt.dispose(); + terminalFocus.dispose(); gateway.close(); } @@ -187,6 +218,13 @@ Future _chord(WidgetTester tester) async { await tester.pumpAndSettle(); } +Future _controlChord(WidgetTester tester) async { + await tester.sendKeyDownEvent(LogicalKeyboardKey.controlLeft); + await tester.sendKeyEvent(LogicalKeyboardKey.keyY); + await tester.sendKeyUpEvent(LogicalKeyboardKey.controlLeft); + await tester.pumpAndSettle(); +} + void main() { testWidgets('Float and Dock move the live chat with its draft', ( tester, @@ -391,6 +429,36 @@ void main() { await app.stop(tester); }); + testWidgets( + 'Ctrl+Y from a terminal raises chat and focuses its composer', + (tester) async { + await _saved('a', 'b'); + final app = _App(_Store()); + await app.start(tester, terminalSurface: true); + await _menu(tester, 'b', 'Float (Option+Y)'); + app.manager.open('terminal', 'terminal'); + app.terminalFocus.requestFocus(); + await tester.pump(); + + await _controlChord(tester); + final input = _input('b'); + expect(_shown('Chat b'), findsOneWidget); + expect( + tester.widget(input).focusNode.hasPrimaryFocus, + isTrue, + ); + tester.testTextInput.enterText('from terminal'); + await tester.pump(); + expect( + tester.widget(input).controller.text, + 'from terminal', + ); + expect(app.terminalTyped, isEmpty); + await app.stop(tester); + }, + variant: const TargetPlatformVariant({TargetPlatform.macOS}), + ); + testWidgets('floating chats saved by an older build come back as windows', ( tester, ) async { diff --git a/app/test/features/chat/windows/chat_windows_test.dart b/app/test/features/chat/windows/chat_windows_test.dart index b0471607..ca135f3e 100644 --- a/app/test/features/chat/windows/chat_windows_test.dart +++ b/app/test/features/chat/windows/chat_windows_test.dart @@ -232,7 +232,7 @@ void main() { }); testWidgets( - 'on macOS Ctrl+Y in a terminal stays with it; Cmd+Y and Option+Y toggle', + 'on macOS Ctrl+Y from a terminal raises chat; Cmd+Y and Option+Y toggle', (tester) async { await wide(tester); final typing = FocusNode(); @@ -256,12 +256,12 @@ void main() { typing.requestFocus(); await tester.pump(); await _chord(tester, LogicalKeyboardKey.controlLeft); - expect(h.manager.groupShown(chatWindowKind), isTrue); - expect(typed, contains(LogicalKeyboardKey.keyY)); - await _chord(tester, LogicalKeyboardKey.metaLeft); expect(h.manager.groupShown(chatWindowKind), isFalse); - await _chord(tester); + expect(typed, isNot(contains(LogicalKeyboardKey.keyY))); + await _chord(tester, LogicalKeyboardKey.metaLeft); expect(h.manager.groupShown(chatWindowKind), isTrue); + await _chord(tester); + expect(h.manager.groupShown(chatWindowKind), isFalse); }, variant: const TargetPlatformVariant({TargetPlatform.macOS}), ); diff --git a/app/test/features/chat/workspace/chat_float_shortcut_test.dart b/app/test/features/chat/workspace/chat_float_shortcut_test.dart index 66ffc3e3..b04f2433 100644 --- a/app/test/features/chat/workspace/chat_float_shortcut_test.dart +++ b/app/test/features/chat/workspace/chat_float_shortcut_test.dart @@ -29,6 +29,10 @@ void main() { chord({LogicalKeyboardKey.controlLeft}, TargetPlatform.linux), isTrue, ); + expect( + chord({LogicalKeyboardKey.controlLeft}, TargetPlatform.macOS), + isTrue, + ); expect(chord({LogicalKeyboardKey.metaLeft}, TargetPlatform.linux), isFalse); expect(chord({LogicalKeyboardKey.metaLeft}, TargetPlatform.macOS), isTrue); expect( diff --git a/app/test/shell/windows/window_manager_test.dart b/app/test/shell/windows/window_manager_test.dart index 0e0351d3..bc7beb41 100644 --- a/app/test/shell/windows/window_manager_test.dart +++ b/app/test/shell/windows/window_manager_test.dart @@ -139,6 +139,25 @@ void main() { expect(manager.groupShown('chat'), isTrue); }); + test('toggleOrRaiseGroup brings a visible group over another window', () { + final a = manager.open('chat', 'a'); + manager.open('chat', 'b'); + final terminal = manager.open('terminal', 'terminal'); + + expect(manager.active?.id, terminal.id); + expect(manager.toggleOrRaiseGroup('chat'), isTrue); + expect(manager.active?.contentId, 'b'); + expect(manager.groupShown('chat'), isTrue); + + expect(manager.toggleOrRaiseGroup('chat'), isTrue); + expect(manager.groupShown('chat'), isFalse); + expect(manager.active?.contentId, 'terminal'); + + expect(manager.toggleOrRaiseGroup('chat'), isTrue); + expect(manager.active?.contentId, 'b'); + expect(manager.byId(a.id), isNotNull); + }); + test('close remembers the frame for the content and tells the kind', () { final a = manager.open('chat', 'a'); manager.setFrame(a.id, const Rect.fromLTWH(300, 200, 500, 400)); From 8e5a88beffea3e691e97f0e18b9a92f7b1020744 Mon Sep 17 00:00:00 2001 From: Alan Silva Date: Wed, 11 Nov 2026 20:03:57 +0000 Subject: [PATCH 3/3] Remove alternate feature icon metadata Preserve reviewed Material-only feature changes after the pipeline's landing stage incorrectly refused shell committing. Keep required shared compatibility inputs until the coordinated caller cleanup. --- .../actions/artifact_file_actions.dart | 7 ------- .../artifacts/ui/artifact_fullscreen.dart | 14 ++------------ .../artifacts/ui/artifact_viewer_bar.dart | 6 ------ .../artifacts/ui/artifact_viewer_body.dart | 2 -- .../ui/list/schedule_list_toolbar.dart | 14 +++++--------- .../search/ui/search_bar_controls.dart | 19 ++++++++----------- .../templates/ui/templates_frame.dart | 3 +-- app/notes/material-cleanup-feature-surface.md | 16 ++++++++++++++++ 8 files changed, 32 insertions(+), 49 deletions(-) create mode 100644 app/notes/material-cleanup-feature-surface.md diff --git a/app/lib/features/artifacts/actions/artifact_file_actions.dart b/app/lib/features/artifacts/actions/artifact_file_actions.dart index ea54b0dc..c2363367 100644 --- a/app/lib/features/artifacts/actions/artifact_file_actions.dart +++ b/app/lib/features/artifacts/actions/artifact_file_actions.dart @@ -1,4 +1,3 @@ -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import '../../../ui/adaptive/glass_bar.dart'; @@ -200,7 +199,6 @@ class _IconActions extends StatelessWidget { key: const Key('artifact-download'), label: 'Download', icon: Icons.download_outlined, - cupertinoIcon: CupertinoIcons.arrow_down_to_line, busy: busy, onPressed: busy ? null : controller.download, ), @@ -209,7 +207,6 @@ class _IconActions extends StatelessWidget { key: const Key('artifact-share'), label: 'Share', icon: Icons.share_outlined, - cupertinoIcon: CupertinoIcons.share, onPressed: busy ? null : controller.share, ), ], @@ -223,7 +220,6 @@ class ArtifactIconAction extends StatelessWidget { super.key, required this.label, required this.icon, - required this.cupertinoIcon, required this.onPressed, this.busy = false, }); @@ -231,9 +227,6 @@ class ArtifactIconAction extends StatelessWidget { final String label; final IconData icon; - /// Retained for callers that still pass the Cupertino glyph; the Material - /// action always draws [icon]. - final IconData cupertinoIcon; final VoidCallback? onPressed; final bool busy; diff --git a/app/lib/features/artifacts/ui/artifact_fullscreen.dart b/app/lib/features/artifacts/ui/artifact_fullscreen.dart index 3ac2d334..3362c4a4 100644 --- a/app/lib/features/artifacts/ui/artifact_fullscreen.dart +++ b/app/lib/features/artifacts/ui/artifact_fullscreen.dart @@ -1,4 +1,3 @@ -import 'package:flutter/cupertino.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; @@ -34,7 +33,7 @@ class ArtifactFullscreenScope extends InheritedWidget { /// [cupertino] is retained for callers that still pass it; the route is always /// the Material one. Route artifactFullscreenRoute({ - required bool cupertino, + bool? cupertino, required WidgetBuilder builder, }) => MaterialPageRoute(fullscreenDialog: true, builder: builder); @@ -74,7 +73,6 @@ List artifactHtmlZoomActions(ValueNotifier zoom) { Key key, String label, IconData icon, - IconData cupertinoIcon, VoidCallback? onPressed, ) => SegmentedOverflowAction( key: key, @@ -83,12 +81,7 @@ List artifactHtmlZoomActions(ValueNotifier zoom) { icon: icon, onPressed: onPressed, ), - child: ArtifactIconAction( - label: label, - icon: icon, - cupertinoIcon: cupertinoIcon, - onPressed: onPressed, - ), + child: ArtifactIconAction(label: label, icon: icon, onPressed: onPressed), ); final value = zoom.value; return [ @@ -96,21 +89,18 @@ List artifactHtmlZoomActions(ValueNotifier zoom) { artifactZoomOutKey, 'Zoom out', Icons.zoom_out, - CupertinoIcons.zoom_out, value > artifactHtmlZoomSteps.first + 0.001 ? () => step(-1) : null, ), action( artifactZoomResetKey, 'Actual size ($percent)', Icons.restart_alt, - CupertinoIcons.arrow_counterclockwise, (value - 1).abs() > 0.001 ? () => zoom.value = 1 : null, ), action( artifactZoomInKey, 'Zoom in', Icons.zoom_in, - CupertinoIcons.zoom_in, value < artifactHtmlZoomSteps.last - 0.001 ? () => step(1) : null, ), ]; diff --git a/app/lib/features/artifacts/ui/artifact_viewer_bar.dart b/app/lib/features/artifacts/ui/artifact_viewer_bar.dart index fa6a7c61..c212199c 100644 --- a/app/lib/features/artifacts/ui/artifact_viewer_bar.dart +++ b/app/lib/features/artifacts/ui/artifact_viewer_bar.dart @@ -1,6 +1,5 @@ import 'dart:math' as math; -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import '../../../ui/adaptive/glass_bar.dart'; @@ -131,14 +130,12 @@ class ArtifactViewerBar extends StatelessWidget { key: const Key('artifact-open'), label: 'Open in browser', icon: Icons.open_in_new, - cupertinoIcon: CupertinoIcons.arrow_up_right_square, onPressed: onOpen, ), ArtifactIconAction( key: const Key('artifact-copy-link'), label: 'Copy link', icon: Icons.link, - cupertinoIcon: CupertinoIcons.link, onPressed: onCopy, ), ], @@ -147,9 +144,6 @@ class ArtifactViewerBar extends StatelessWidget { key: artifactFullscreenKey, label: fullscreen ? 'Exit full screen' : 'Full screen', icon: fullscreen ? Icons.fullscreen_exit : Icons.fullscreen, - cupertinoIcon: fullscreen - ? CupertinoIcons.fullscreen_exit - : CupertinoIcons.fullscreen, onPressed: toggle, ), ]; diff --git a/app/lib/features/artifacts/ui/artifact_viewer_body.dart b/app/lib/features/artifacts/ui/artifact_viewer_body.dart index c890866d..903ba0d9 100644 --- a/app/lib/features/artifacts/ui/artifact_viewer_body.dart +++ b/app/lib/features/artifacts/ui/artifact_viewer_body.dart @@ -1,6 +1,5 @@ import 'dart:typed_data'; -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import '../../../ui/adaptive/floating_bar_layout.dart'; @@ -187,7 +186,6 @@ class ArtifactViewerInfoAction extends StatelessWidget { key: const Key('artifact-info'), label: 'Details', icon: Icons.info_outline, - cupertinoIcon: CupertinoIcons.info, onPressed: () => _show(context), ); } diff --git a/app/lib/features/schedules/ui/list/schedule_list_toolbar.dart b/app/lib/features/schedules/ui/list/schedule_list_toolbar.dart index d22a6eb5..d571e795 100644 --- a/app/lib/features/schedules/ui/list/schedule_list_toolbar.dart +++ b/app/lib/features/schedules/ui/list/schedule_list_toolbar.dart @@ -1,4 +1,3 @@ -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import '../../../../ui/input/app_search_field.dart'; @@ -19,20 +18,19 @@ class ScheduleRefreshAction extends StatelessWidget { const ScheduleRefreshAction({ super.key, required this.controller, - required this.cupertino, + this.cupertino, required this.onRefresh, }); final SchedulesController controller; - final bool cupertino; + final bool? cupertino; final VoidCallback onRefresh; @override Widget build(BuildContext context) => BarIconButton( key: controller.isLoading ? null : scheduleRefreshKey, - cupertino: false, icon: Icons.refresh, - cupertinoIcon: CupertinoIcons.refresh, + cupertinoIcon: Icons.refresh, label: 'Refresh schedules', busy: controller.isLoading, busyLabel: 'Refreshing schedules', @@ -51,13 +49,13 @@ class ScheduleListToolbar extends StatelessWidget { super.key, required this.controller, required this.searchController, - required this.cupertino, + this.cupertino, this.onRefresh, }); final SchedulesController controller; final TextEditingController searchController; - final bool cupertino; + final bool? cupertino; final VoidCallback? onRefresh; @override @@ -69,7 +67,6 @@ class ScheduleListToolbar extends StatelessWidget { final refresh = switch (onRefresh) { final refresh? => ScheduleRefreshAction( controller: controller, - cupertino: false, onRefresh: refresh, ), null => null, @@ -119,7 +116,6 @@ class ScheduleListToolbar extends StatelessWidget { Widget _search(BuildContext context) => AppSearchField( fieldKey: scheduleSearchFieldKey, controller: searchController, - cupertino: false, placeholder: 'Search schedules', onChanged: controller.setQuery, onCleared: controller.clearQuery, diff --git a/app/lib/features/search/ui/search_bar_controls.dart b/app/lib/features/search/ui/search_bar_controls.dart index bb5908be..7b409fdf 100644 --- a/app/lib/features/search/ui/search_bar_controls.dart +++ b/app/lib/features/search/ui/search_bar_controls.dart @@ -1,4 +1,3 @@ -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import '../../../ui/input/app_search_field.dart'; @@ -21,7 +20,7 @@ const searchTokenHint = class SearchBarControls extends StatelessWidget { const SearchBarControls({ super.key, - required this.cupertino, + this.cupertino, required this.text, required this.kind, required this.onChanged, @@ -32,7 +31,7 @@ class SearchBarControls extends StatelessWidget { this.focusNode, }); - final bool cupertino; + final bool? cupertino; final TextEditingController text; final SearchKind kind; final ValueChanged onChanged; @@ -59,7 +58,6 @@ class SearchBarControls extends StatelessWidget { autofocus: autofocus, focusNode: focusNode, inBar: true, - cupertino: false, placeholder: 'Search pipelines, runs, artifacts and chats', onChanged: onChanged, onSubmitted: (_) => onSubmitted(), @@ -67,14 +65,13 @@ class SearchBarControls extends StatelessWidget { ), ), ), - SearchKindButton(cupertino: false, kind: kind, onSelected: onKind), + SearchKindButton(kind: kind, onSelected: onKind), BarIconButton( key: searchHelpKey, - cupertino: false, icon: Icons.info_outline, - cupertinoIcon: CupertinoIcons.info_circle, + cupertinoIcon: Icons.info_outline, label: 'Search syntax', - onPressed: () => showSearchHelp(context, cupertino: false), + onPressed: () => showSearchHelp(context), ), ], ), @@ -86,12 +83,12 @@ class SearchBarControls extends StatelessWidget { class SearchKindButton extends StatelessWidget { const SearchKindButton({ super.key, - required this.cupertino, + this.cupertino, required this.kind, required this.onSelected, }); - final bool cupertino; + final bool? cupertino; final SearchKind kind; final ValueChanged onSelected; @@ -131,7 +128,7 @@ class SearchKindButton extends StatelessWidget { } /// The query syntax, on demand instead of a paragraph above the results. -Future showSearchHelp(BuildContext context, {required bool cupertino}) { +Future showSearchHelp(BuildContext context, {bool? cupertino}) { return showDialog( context: context, builder: (context) => AlertDialog( diff --git a/app/lib/features/templates/ui/templates_frame.dart b/app/lib/features/templates/ui/templates_frame.dart index a5ba53f1..a678d69b 100644 --- a/app/lib/features/templates/ui/templates_frame.dart +++ b/app/lib/features/templates/ui/templates_frame.dart @@ -1,4 +1,3 @@ -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import '../../../shell/shell_bar.dart'; @@ -88,7 +87,7 @@ class TemplatesFrame extends StatelessWidget { key: templatesRefreshKey, cupertino: false, icon: Icons.refresh, - cupertinoIcon: CupertinoIcons.refresh, + cupertinoIcon: Icons.refresh, label: 'Refresh', onPressed: refreshing ? null : onRefresh, ); diff --git a/app/notes/material-cleanup-feature-surface.md b/app/notes/material-cleanup-feature-surface.md new file mode 100644 index 00000000..649815fa --- /dev/null +++ b/app/notes/material-cleanup-feature-surface.md @@ -0,0 +1,16 @@ +# Material-only feature surface cleanup + +- Removed Cupertino imports and alternate glyph metadata from artifact viewer + actions, fullscreen zoom controls, and viewer controls. +- Made search, schedule-toolbar, and artifact fullscreen compatibility flags + optional and ignored while retaining shared adaptive API arguments required + by other lanes. Material icons are used for those required compatibility + glyph parameters. +- Focused checks: `tool/memwatch/full.sh` ran artifact actions/fullscreen and + controls, search bar layout, schedule refresh, and template layout tests: 30 + passed, 0 failed. +- `tool/analyze.sh`: clean. +- No rendered behavior was intentionally changed; controls remain the existing + Material widgets and layouts. +- Remaining shared compatibility metadata/flags are outside this focused edit + and should be removed only after all callers migrate during final integration.