diff --git a/app/lib/features/chat/conversation/chat_composer_bar.dart b/app/lib/features/chat/conversation/chat_composer_bar.dart index 4dd8281a..fc7e9671 100644 --- a/app/lib/features/chat/conversation/chat_composer_bar.dart +++ b/app/lib/features/chat/conversation/chat_composer_bar.dart @@ -1004,10 +1004,14 @@ class _ChatComposerBarState extends State { if (widget.running) Positioned.fill( child: IgnorePointer( - child: ComposerRunningBorder( - shape: _pillShape, - primary: accent, - tertiary: Theme.of(context).colorScheme.tertiary, + child: ListenableBuilder( + listenable: _focus, + builder: (context, _) => ComposerRunningBorder( + shape: _pillShape, + primary: accent, + tertiary: Theme.of(context).colorScheme.tertiary, + focused: _focus.hasFocus, + ), ), ), ), diff --git a/app/lib/features/chat/conversation/composer_running_border.dart b/app/lib/features/chat/conversation/composer_running_border.dart index 41e44cc2..e64c2a87 100644 --- a/app/lib/features/chat/conversation/composer_running_border.dart +++ b/app/lib/features/chat/conversation/composer_running_border.dart @@ -18,8 +18,13 @@ class ComposerRunningBorder extends StatefulWidget { required this.shape, required this.primary, required this.tertiary, + this.focused = false, }); + /// The field has focus, so its focus ring already outlines the pill in the + /// same colour; the highlight is drawn thicker to stay visible over it. + final bool focused; + /// The pill's shape, so the highlight follows its edge. final OutlinedBorder shape; final Color primary; @@ -31,6 +36,9 @@ class ComposerRunningBorder extends StatefulWidget { /// The stroke width of the highlight, drawn just inside the pill's edge. static const double strokeWidth = 2; + /// The stroke width over a focused field, wider than its focus ring. + static const double focusedStrokeWidth = 4; + @override State createState() => _ComposerRunningBorderState(); } @@ -76,6 +84,9 @@ class _ComposerRunningBorderState extends State shape: widget.shape, primary: widget.primary, tertiary: widget.tertiary, + width: widget.focused + ? ComposerRunningBorder.focusedStrokeWidth + : ComposerRunningBorder.strokeWidth, lap: _reduced ? null : _lap, ), ), @@ -87,9 +98,13 @@ class _RunningBorderPainter extends CustomPainter { required this.shape, required this.primary, required this.tertiary, + required this.width, required this.lap, }) : super(repaint: lap); + /// The highlight's stroke width. + final double width; + final OutlinedBorder shape; final Color primary; final Color tertiary; @@ -102,7 +117,6 @@ class _RunningBorderPainter extends CustomPainter { final progress = lap?.value; // Reduced motion: no highlight; the normal static border shows alone. if (progress == null || size.isEmpty) return; - const width = ComposerRunningBorder.strokeWidth; final outline = shape.getOuterPath((Offset.zero & size).deflate(width / 2)); final line = Paint() ..style = PaintingStyle.stroke @@ -124,5 +138,6 @@ class _RunningBorderPainter extends CustomPainter { oldDelegate.shape != shape || oldDelegate.primary != primary || oldDelegate.tertiary != tertiary || + oldDelegate.width != width || oldDelegate.lap != lap; } diff --git a/app/test/features/chat/conversation/chat_composer_running_test.dart b/app/test/features/chat/conversation/chat_composer_running_test.dart index d4ecb483..5ac13b23 100644 --- a/app/test/features/chat/conversation/chat_composer_running_test.dart +++ b/app/test/features/chat/conversation/chat_composer_running_test.dart @@ -4,6 +4,8 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:pipelines_app/features/chat/conversation/chat_command_palette.dart'; import 'package:pipelines_app/features/chat/conversation/chat_composer_bar.dart'; import 'package:pipelines_app/features/chat/conversation/chat_escape_stop.dart'; +import 'package:pipelines_app/features/chat/conversation/composer_focus_ring.dart'; +import 'package:pipelines_app/features/chat/conversation/composer_running_border.dart'; import 'chat_composer_bar_fixtures.dart'; import 'chat_thread_fixtures.dart'; @@ -60,6 +62,34 @@ void main() { expect(tester.binding.transientCallbackCount, 0); }); + testWidgets('a focused field draws the highlight thicker than its ring', ( + tester, + ) async { + _reducedMotion(false); + final gateway = await _pumpThread(tester); + await _startTurn(tester, gateway); + ComposerRunningBorder border() => tester.widget( + find.byType(ComposerRunningBorder), + ); + tester + .widgetList(find.byType(EditableText)) + .firstWhere((field) => field.focusNode.debugLabel == 'chat-composer') + .focusNode + .requestFocus(); + await tester.pump(); + await tester.pump(); + expect(border().focused, isTrue); + expect( + ComposerRunningBorder.focusedStrokeWidth, + greaterThan(ComposerFocusRing.ringWidth), + ); + FocusManager.instance.primaryFocus?.unfocus(); + await tester.pump(); + await tester.pump(); + expect(border().focused, isFalse); + await _endTurn(tester, gateway); + }); + testWidgets('reduced motion draws the static border and never ticks', ( tester, ) async {