diff --git a/app/lib/features/chat/conversation/chat_mode_control.dart b/app/lib/features/chat/conversation/chat_mode_control.dart index 75bfa927..4fd35c06 100644 --- a/app/lib/features/chat/conversation/chat_mode_control.dart +++ b/app/lib/features/chat/conversation/chat_mode_control.dart @@ -133,13 +133,21 @@ class _ChatModeControlState extends State { ), ); } - return Tooltip( - message: 'Change mode (currently $label)', - child: TextButton( - key: key, - style: chatBarTextButtonStyle(context), - onPressed: _open, - child: content, + return Semantics( + container: true, + button: true, + label: 'Change mode, currently $label', + onTap: _open, + child: ExcludeSemantics( + child: Tooltip( + message: 'Change mode (currently $label)', + child: TextButton( + key: key, + style: chatBarTextButtonStyle(context), + onPressed: _open, + child: content, + ), + ), ), ); } diff --git a/app/lib/features/chat/conversation/chat_model_control.dart b/app/lib/features/chat/conversation/chat_model_control.dart index 48fe876b..ddd09936 100644 --- a/app/lib/features/chat/conversation/chat_model_control.dart +++ b/app/lib/features/chat/conversation/chat_model_control.dart @@ -146,13 +146,21 @@ class _ChatModelControlState extends State { ), ); } - return Tooltip( - message: 'Change model (currently $label)', - child: TextButton( - key: key, - style: chatBarTextButtonStyle(context), - onPressed: _open, - child: content, + return Semantics( + container: true, + button: true, + label: 'Change model, currently $label', + onTap: _open, + child: ExcludeSemantics( + child: Tooltip( + message: 'Change model (currently $label)', + child: TextButton( + key: key, + style: chatBarTextButtonStyle(context), + onPressed: _open, + child: content, + ), + ), ), ); } diff --git a/app/lib/features/chat/conversation/chat_thread_header.dart b/app/lib/features/chat/conversation/chat_thread_header.dart index f4e871af..b9270b74 100644 --- a/app/lib/features/chat/conversation/chat_thread_header.dart +++ b/app/lib/features/chat/conversation/chat_thread_header.dart @@ -12,8 +12,8 @@ import '../ui/sessions/chat_adaptive.dart'; /// pill with the conversation's title and folder that opens the chat's /// information, a selector island holding [controls] (model and mode), /// then the Files action and a native More menu in a separate island. -/// Narrow panes give readable model/mode values a separate row; exceptionally -/// short viewports can scroll the header to keep controls reachable. +/// Narrow panes keep the model/mode selectors as compact icons in the same row; +/// their semantic labels and native pickers continue to expose the values. class ChatThreadHeader extends StatelessWidget { const ChatThreadHeader({ super.key, @@ -53,8 +53,7 @@ class ChatThreadHeader extends StatelessWidget { return LayoutBuilder( builder: (context, constraints) { final textScale = MediaQuery.textScalerOf(context).scale(14) / 14; - final readableWidth = constraints.maxWidth / textScale; - final narrow = readableWidth < 800; + final compact = constraints.maxWidth / textScale < 800; final bar = SegmentedBar( cupertino: cupertino, automaticallyImplyLeading: false, @@ -77,7 +76,7 @@ class ChatThreadHeader extends StatelessWidget { titleKey: const Key('chat-info'), separateActionIslands: true, actions: [ - if (!narrow && controls.isNotEmpty) + if (controls.isNotEmpty) _ControlIsland( key: const Key('chat-model-permission-island'), children: controls, @@ -104,35 +103,14 @@ class ChatThreadHeader extends StatelessWidget { ], ), ], - bottomPadding: narrow ? 8 : 16, + bottomPadding: compact ? 8 : 16, backdrop: backdrop, ); return ColoredBox( color: cupertino ? CupertinoTheme.of(context).scaffoldBackgroundColor : Theme.of(context).colorScheme.surface, - child: SingleChildScrollView( - primary: false, - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - bar, - if (narrow && controls.isNotEmpty) - Padding( - padding: const EdgeInsets.fromLTRB(12, 0, 12, 8), - child: SegmentedPill( - cupertino: cupertino, - child: _ControlIsland( - key: const Key('chat-model-permission-island'), - fill: true, - vertical: readableWidth < 340, - children: controls, - ), - ), - ), - ], - ), - ), + child: bar, ); }, ); @@ -142,27 +120,12 @@ class ChatThreadHeader extends StatelessWidget { /// Related selectors share the available width. Each remains a real control; /// they never migrate into the unrelated actions menu. class _ControlIsland extends StatelessWidget { - const _ControlIsland({ - super.key, - required this.children, - this.fill = false, - this.vertical = false, - }); + const _ControlIsland({super.key, required this.children}); final List children; - final bool fill; - final bool vertical; + @override - Widget build(BuildContext context) => vertical - ? Column( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.stretch, - children: children, - ) - : Row( - mainAxisSize: fill ? MainAxisSize.max : MainAxisSize.min, - children: [ - for (final child in children) - if (fill) Expanded(child: child) else Flexible(child: child), - ], - ); + Widget build(BuildContext context) => Row( + mainAxisSize: MainAxisSize.min, + children: [for (final child in children) Flexible(child: child)], + ); } diff --git a/app/lib/features/chat/conversation/chat_thread_view.dart b/app/lib/features/chat/conversation/chat_thread_view.dart index f3fa7e54..5c7b6afd 100644 --- a/app/lib/features/chat/conversation/chat_thread_view.dart +++ b/app/lib/features/chat/conversation/chat_thread_view.dart @@ -1342,7 +1342,6 @@ class _ChatThreadViewState extends State { controls: [ if (hasModel) ChatModelControl( - showLabel: true, key: ValueKey('chat-model-${widget.sessionId}'), gateway: widget.gateway, sessionId: widget.sessionId, @@ -1358,7 +1357,6 @@ class _ChatThreadViewState extends State { /// The session's permission mode, keyed per session so another chat /// re-reads its own modes. Widget _modeControl() => ChatModeControl( - showLabel: true, key: ValueKey('chat-mode-${widget.sessionId}'), gateway: widget.gateway, sessionId: widget.sessionId, diff --git a/app/notes/mobile-chat-icon-controls.md b/app/notes/mobile-chat-icon-controls.md new file mode 100644 index 00000000..acf49696 --- /dev/null +++ b/app/notes/mobile-chat-icon-controls.md @@ -0,0 +1,13 @@ +# Mobile chat selector controls + +- Mobile chat headers keep model and permission-mode selectors in the single top row, together in their selector island before Files and More. +- Mobile uses the existing memory and shield icons; semantic labels/tooltips retain the current-value explanation and native pickers. +- Desktop keeps the existing readable selector labels and picker behavior. +- Focused checks: `tool/memwatch/full.sh 'test/features/chat/conversation/chat_thread_header_test.dart test/features/chat/conversation/chat_model_picker_test.dart'` — 28 passed. +- `tool/analyze.sh` — clean. +- Fixture-browser captures were inspected for Material/Cupertino mobile (560x1000) and desktop (1280x1000), light theme: + - `public/chat-material-mobile/01-mobile-material.png` + - `public/chat-cupertino-mobile/01-mobile-cupertino.png` + - `public/chat-material-desktop/01-desktop-material.png` + - `public/chat-cupertino-desktop/01-desktop-cupertino.png` +- No device installation or deployment was performed. diff --git a/app/test/features/chat/conversation/chat_thread_header_test.dart b/app/test/features/chat/conversation/chat_thread_header_test.dart index 8192bf50..65a45103 100644 --- a/app/test/features/chat/conversation/chat_thread_header_test.dart +++ b/app/test/features/chat/conversation/chat_thread_header_test.dart @@ -38,7 +38,7 @@ void _useNarrowText(WidgetTester tester) { } void main() { - testWidgets('short large-text header scrolls controls without overflow', ( + testWidgets('short large-text header keeps controls in its single row', ( tester, ) async { _useNarrowText(tester); @@ -55,15 +55,9 @@ void main() { onInfo: () {}, showBack: true, onBack: () {}, - controls: [ - TextButton( - onPressed: () {}, - child: const Text('Current model'), - ), - TextButton( - onPressed: () {}, - child: const Text('Ask for permission'), - ), + controls: const [ + IconButton(onPressed: null, icon: Icon(Icons.memory_outlined)), + IconButton(onPressed: null, icon: Icon(Icons.shield_outlined)), ], ), ), @@ -73,9 +67,10 @@ void main() { ); await tester.pumpAndSettle(); expect(tester.takeException(), isNull); - await tester.ensureVisible(find.text('Ask for permission')); - await tester.pumpAndSettle(); - expect(find.text('Ask for permission').hitTestable(), findsOneWidget); + expect( + find.byKey(const Key('chat-model-permission-island')), + findsOneWidget, + ); expect(tester.takeException(), isNull); }); @@ -83,7 +78,7 @@ void main() { final host = cupertino ? 'Cupertino' : 'Material'; testWidgets( - '$host narrow header keeps native back/title and readable model', + '$host narrow header keeps native back/title and compact model icon', (tester) async { _useNarrowText(tester); final semantics = tester.ensureSemantics(); @@ -124,19 +119,22 @@ void main() { // One floating row of separate pieces: the round Back, the title pill // (which is the information control and holds the title), then the - // model in the trailing pill. + // selector island in the trailing row. double centerY(Finder finder) => tester.getCenter(finder).dy; expect((centerY(back) - centerY(info)).abs(), lessThan(16)); - expect( - tester.getTopLeft(model).dy, - greaterThanOrEqualTo(tester.getBottomLeft(info).dy), - ); + expect((centerY(model) - centerY(info)).abs(), lessThan(16)); expect(find.descendant(of: info, matching: title), findsOneWidget); double right(Finder finder) => tester.getTopRight(finder).dx; expect(right(back), lessThanOrEqualTo(tester.getTopLeft(info).dx)); + expect(find.byIcon(Icons.memory_outlined), findsOneWidget); + if (!cupertino) { + final semantics = tester.getSemantics(model); + expect(semantics.label, contains('Change model')); + expect(semantics.label, contains('currently')); + } expect( find.textContaining('an-extremely-long-recorded-model-id'), - findsOneWidget, + findsNothing, ); await tester.tap(back); @@ -199,21 +197,43 @@ void main() { final actions = find.byKey(const Key('chat-actions-island')); expect(selectors, findsOneWidget); expect(actions, findsOneWidget); - if (width / 2 >= 800) { - expect( - tester.getTopRight(selectors).dx, - lessThan(tester.getTopLeft(actions).dx), - ); - } else { - expect( - tester.getTopLeft(selectors).dy, - greaterThanOrEqualTo(tester.getBottomLeft(actions).dy), - ); - } + expect( + (tester.getCenter(selectors).dy - tester.getCenter(actions).dy) + .abs(), + lessThan(16), + ); expect(find.byKey(const Key('chat-next')), findsNothing); expect(find.text('Next chat'), findsNothing); expect(find.byKey(const Key('chat-model')), findsOneWidget); expect(find.byKey(const Key('chat-mode')), findsOneWidget); + if (width < 600) { + expect(find.text('model-a'), findsNothing); + expect(find.text('Ask before making changes'), findsNothing); + expect(find.byIcon(Icons.memory_outlined), findsOneWidget); + expect( + find.byIcon( + cupertino + ? CupertinoIcons.shield_lefthalf_fill + : Icons.shield_outlined, + ), + findsOneWidget, + ); + if (!cupertino) { + expect( + tester.getSemantics(find.byKey(const Key('chat-model'))).label, + contains('Change model, currently'), + ); + expect( + tester.getSemantics(find.byKey(const Key('chat-mode'))).label, + contains('Change mode, currently'), + ); + } + expect( + (tester.getCenter(selectors).dy - tester.getCenter(actions).dy) + .abs(), + lessThan(16), + ); + } for (final key in ['chat-model', 'chat-mode']) { expect( tester.getSize(find.byKey(Key(key))).width,