From f72c46d599d26c74a1c07104bcd22eab4c08870f Mon Sep 17 00:00:00 2001 From: Alan Silva Date: Wed, 25 Nov 2026 00:10:13 +0000 Subject: [PATCH] Make the open chat unmistakable in the chat list The open chat's row now has a strong fill in its colour, a full outline with a thick leading bar, a bold title and a pointer on its trailing edge toward the conversation shown beside the list. A selected chat that is not shown keeps a lighter fill; a chat visible in another pane keeps its thin bar. Co-Authored-By: Claude Opus 5.5 --- .../ui/sessions/chat_visibility_marker.dart | 110 ++++++++++++++---- .../chat/ui/sessions/session_row_content.dart | 3 + .../sessions/chat_active_selection_test.dart | 7 +- .../chat/ui/sessions/chat_color_test.dart | 11 +- .../sessions/chat_visibility_marker_test.dart | 6 +- 5 files changed, 98 insertions(+), 39 deletions(-) diff --git a/app/lib/features/chat/ui/sessions/chat_visibility_marker.dart b/app/lib/features/chat/ui/sessions/chat_visibility_marker.dart index c9439f8c..d7d4b895 100644 --- a/app/lib/features/chat/ui/sessions/chat_visibility_marker.dart +++ b/app/lib/features/chat/ui/sessions/chat_visibility_marker.dart @@ -20,38 +20,100 @@ class ChatVisibilityMarker extends StatelessWidget { final Widget child; @override - Widget build(BuildContext context) => Semantics( - label: visible && active - ? 'Active chat' - : visible - ? 'Visible chat' - : null, - child: AnimatedContainer( + Widget build(BuildContext context) { + final dark = chatColorDarkSurface(context); + // The open chat: selected and shown beside the list. + final open = active && visible; + final row = AnimatedContainer( key: ValueKey('chat-visibility-$sessionId'), duration: MediaQuery.disableAnimationsOf(context) ? Duration.zero : const Duration(milliseconds: 220), curve: Curves.easeInOut, + // The open chat is unmistakable: a strong fill in its colour, a full + // outline, a thick leading bar and (below) a pointer toward the + // conversation shown beside the list. A chat visible elsewhere keeps a + // thin leading bar. decoration: BoxDecoration( - gradient: LinearGradient( - begin: AlignmentDirectional.centerStart, - end: AlignmentDirectional.centerEnd, - colors: [ - color.withValues( - alpha: active ? (chatColorDarkSurface(context) ? .30 : .22) : 0, - ), - color.withValues(alpha: active ? .06 : 0), - ], - ), + color: open + ? color.withValues(alpha: dark ? .40 : .28) + : active + ? color.withValues(alpha: dark ? .30 : .22) + : null, ), foregroundDecoration: BoxDecoration( - border: BorderDirectional( - start: visible - ? BorderSide(color: color, width: active ? 10 : 3) - : BorderSide.none, - ), + border: open + ? BorderDirectional( + start: BorderSide(color: color, width: 8), + top: BorderSide(color: color, width: 2), + end: BorderSide(color: color, width: 2), + bottom: BorderSide(color: color, width: 2), + ) + : BorderDirectional( + start: visible + ? BorderSide(color: color, width: 3) + : BorderSide.none, + ), ), child: child, - ), - ); + ); + return Semantics( + label: visible && active + ? 'Active chat' + : visible + ? 'Visible chat' + : null, + selected: active, + // Always a Stack, so selecting a chat never rebuilds its row. + child: Stack( + children: [ + row, + if (open) + PositionedDirectional( + end: 0, + top: 0, + bottom: 0, + child: IgnorePointer( + child: Center( + child: CustomPaint( + key: Key('chat-active-pointer-$sessionId'), + size: const Size(9, 18), + painter: _Pointer( + color: color, + rtl: Directionality.of(context) == TextDirection.rtl, + ), + ), + ), + ), + ), + ], + ), + ); + } +} + +/// A small triangle on the row's trailing edge, pointing toward the open +/// conversation beside the list. +class _Pointer extends CustomPainter { + const _Pointer({required this.color, required this.rtl}); + + final Color color; + final bool rtl; + + @override + void paint(Canvas canvas, Size size) { + final path = rtl + ? (Path() + ..moveTo(size.width, 0) + ..lineTo(0, size.height / 2) + ..lineTo(size.width, size.height)) + : (Path() + ..moveTo(0, 0) + ..lineTo(size.width, size.height / 2) + ..lineTo(0, size.height)); + canvas.drawPath(path..close(), Paint()..color = color); + } + + @override + bool shouldRepaint(_Pointer old) => old.color != color || old.rtl != rtl; } diff --git a/app/lib/features/chat/ui/sessions/session_row_content.dart b/app/lib/features/chat/ui/sessions/session_row_content.dart index 91ef77bf..0e15b405 100644 --- a/app/lib/features/chat/ui/sessions/session_row_content.dart +++ b/app/lib/features/chat/ui/sessions/session_row_content.dart @@ -143,6 +143,9 @@ class ChatSessionRow extends StatelessWidget { title: Text.rich( TextSpan( text: chatSessionTitle(session), + style: selected + ? const TextStyle(fontWeight: FontWeight.w800) + : null, children: [ if (session['starred'] == true) WidgetSpan( diff --git a/app/test/features/chat/ui/sessions/chat_active_selection_test.dart b/app/test/features/chat/ui/sessions/chat_active_selection_test.dart index 4b91c26c..11e5ccad 100644 --- a/app/test/features/chat/ui/sessions/chat_active_selection_test.dart +++ b/app/test/features/chat/ui/sessions/chat_active_selection_test.dart @@ -63,11 +63,8 @@ void main() { final highlight = tester.widget( find.byKey(ValueKey('chat-visibility-$id')), ); - final gradient = - (highlight.decoration as BoxDecoration).gradient! - as LinearGradient; - expect(gradient.colors.first.a > 0, active); - expect(gradient.colors.last.a > 0, active); + final fill = (highlight.decoration as BoxDecoration).color; + expect(fill != null && fill.a > 0, active); } expectRow('a', true); diff --git a/app/test/features/chat/ui/sessions/chat_color_test.dart b/app/test/features/chat/ui/sessions/chat_color_test.dart index e1cd9cac..d82fdd40 100644 --- a/app/test/features/chat/ui/sessions/chat_color_test.dart +++ b/app/test/features/chat/ui/sessions/chat_color_test.dart @@ -215,14 +215,11 @@ void main() { final highlight = tester.widget( find.byKey(const ValueKey('chat-visibility-s1')), ); - final gradient = - (highlight.decoration as BoxDecoration).gradient! as LinearGradient; - expect(gradient.colors.first.a, greaterThan(gradient.colors.last.a)); + // The selected row is filled in its own colour. + final fill = (highlight.decoration as BoxDecoration).color!; + expect(fill.a, greaterThan(0)); final context = tester.element(find.byType(ChatSessionRow)); - expect( - gradient.colors.first.withValues(alpha: 1), - chatColorShade(context, 'amber'), - ); + expect(fill.withValues(alpha: 1), chatColorShade(context, 'amber')); expect(find.byKey(appListRowAccentKey), findsNothing); expect(find.byKey(const ValueKey('chat-visibility-s1')), findsOneWidget); }); diff --git a/app/test/features/chat/ui/sessions/chat_visibility_marker_test.dart b/app/test/features/chat/ui/sessions/chat_visibility_marker_test.dart index ab8b569b..8a7a86d2 100644 --- a/app/test/features/chat/ui/sessions/chat_visibility_marker_test.dart +++ b/app/test/features/chat/ui/sessions/chat_visibility_marker_test.dart @@ -79,9 +79,9 @@ void main() { await tester.pump(); await tester.pump(const Duration(milliseconds: 100)); expect(edge(tester, 'on').width, greaterThan(3)); - expect(edge(tester, 'on').width, lessThan(10)); + expect(edge(tester, 'on').width, lessThan(8)); await tester.pumpAndSettle(); - expect(edge(tester, 'on').width, 10); + expect(edge(tester, 'on').width, 8); update(() => active = false); await tester.pumpAndSettle(); expect(edge(tester, 'on').width, 3); @@ -128,7 +128,7 @@ void main() { await tester.tap(find.byTooltip('New chat')); expect(newChatPressed, isTrue); expect(find.byTooltip('Expand chat list'), findsOneWidget); - expect(edge(tester, 'a').width, 10); + expect(edge(tester, 'a').width, 8); expect(edge(tester, 'b').width, 3); expect(edge(tester, 'c').style, BorderStyle.none); final avatars = tester