Thicken the running highlight while the composer has focus

The focus ring outlines the pill in the same colour, hiding the 2 px
highlight; draw it 4 px wide over a focused field.
This commit is contained in:
2026-11-12 14:15:48 +00:00
parent ff39114e4f
commit 677d202ae7
3 changed files with 54 additions and 5 deletions
@@ -1004,10 +1004,14 @@ class _ChatComposerBarState extends State<ChatComposerBar> {
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,
),
),
),
),
@@ -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<ComposerRunningBorder> createState() => _ComposerRunningBorderState();
}
@@ -76,6 +84,9 @@ class _ComposerRunningBorderState extends State<ComposerRunningBorder>
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;
}
@@ -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<ComposerRunningBorder>(
find.byType(ComposerRunningBorder),
);
tester
.widgetList<EditableText>(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 {