diff --git a/app/lib/features/chat/ui/transcript/chat_message_view.dart b/app/lib/features/chat/ui/transcript/chat_message_view.dart index ab8183c3..1dc18194 100644 --- a/app/lib/features/chat/ui/transcript/chat_message_view.dart +++ b/app/lib/features/chat/ui/transcript/chat_message_view.dart @@ -216,13 +216,25 @@ class ChatMessageView extends StatelessWidget { ), // A little air between the one-line turn status and the answer. if (content.isNotEmpty) const SizedBox(height: 6), - if (content.isNotEmpty) answer, - if (footer.isNotEmpty) - Wrap( - key: const Key('chat-message-footer'), - spacing: 8, - crossAxisAlignment: WrapCrossAlignment.center, - children: footer, + if (content.isNotEmpty || footer.isNotEmpty) + Padding( + padding: const EdgeInsets.symmetric( + horizontal: chatAgentContentInset, + ), + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + if (content.isNotEmpty) answer, + if (footer.isNotEmpty) + Wrap( + key: const Key('chat-message-footer'), + spacing: 8, + crossAxisAlignment: WrapCrossAlignment.center, + children: footer, + ), + ], + ), ), ], ); diff --git a/app/lib/features/chat/ui/transcript/chat_turn_activity_view.dart b/app/lib/features/chat/ui/transcript/chat_turn_activity_view.dart index 1b44cbeb..8e1e65a9 100644 --- a/app/lib/features/chat/ui/transcript/chat_turn_activity_view.dart +++ b/app/lib/features/chat/ui/transcript/chat_turn_activity_view.dart @@ -9,6 +9,9 @@ import '../sessions/chat_adaptive.dart'; import 'chat_response_pending.dart'; import 'chat_turn_activity_details.dart'; +/// The activity control's content inset is shared with the rest of the reply. +const chatAgentContentInset = 8.0; + /// A stable one-line turn status; only this small subtree ticks, never the /// transcript. The same disclosure and live records survive tool transitions. class ChatTurnActivityView extends StatefulWidget { @@ -172,29 +175,35 @@ class _ChatTurnActivityViewState extends State { ), ], ); + final button = cupertino + ? CupertinoButton( + key: const Key('chat-turn-activity'), + minimumSize: Size.zero, + padding: const EdgeInsets.all(chatAgentContentInset), + onPressed: _open, + child: content, + ) + : TextButton( + key: const Key('chat-turn-activity'), + style: TextButton.styleFrom( + minimumSize: Size.zero, + padding: const EdgeInsets.all(chatAgentContentInset), + tapTargetSize: MaterialTapTargetSize.shrinkWrap, + alignment: AlignmentDirectional.centerStart, + ), + onPressed: _open, + child: content, + ); return Semantics( button: true, label: '$label, expand for details', excludeSemantics: true, onTap: _open, - child: cupertino - ? CupertinoButton( - key: const Key('chat-turn-activity'), - padding: EdgeInsets.zero, - onPressed: _open, - child: content, - ) - : TextButton( - key: const Key('chat-turn-activity'), - // No inset of its own: the line starts at the answer's edge, - // which no longer sits inside a padded bubble. - style: TextButton.styleFrom( - padding: EdgeInsets.zero, - alignment: AlignmentDirectional.centerStart, - ), - onPressed: _open, - child: content, - ), + child: Align( + alignment: AlignmentDirectional.centerStart, + widthFactor: 1, + child: button, + ), ); } } diff --git a/app/test/features/chat/ui/transcript/chat_message_layout_test.dart b/app/test/features/chat/ui/transcript/chat_message_layout_test.dart index b6e0fac1..6be8b33b 100644 --- a/app/test/features/chat/ui/transcript/chat_message_layout_test.dart +++ b/app/test/features/chat/ui/transcript/chat_message_layout_test.dart @@ -73,10 +73,24 @@ void main() { of: find.byKey(const Key('chat-turn-activity')), matching: find.byType(Text), ); - expect( - tester.getTopLeft(activity.first).dx, - tester.getTopLeft(find.text('First paragraph.')).dx, + final activityTextRect = tester.getRect(activity.first); + final answerTextRect = tester.getRect(find.text('First paragraph.')); + expect(activityTextRect.left, closeTo(answerTextRect.left, 0.5)); + + final activityRect = tester.getRect( + find.byKey(const Key('chat-turn-activity')), ); + final activityContentRect = tester.getRect( + find.descendant( + of: find.byKey(const Key('chat-turn-activity')), + matching: find.byType(Row), + ), + ); + expect(activityTextRect.left - activityRect.left, closeTo(8, 0.5)); + expect(activityContentRect.left - activityRect.left, closeTo(8, 0.5)); + expect(activityContentRect.top - activityRect.top, closeTo(8, 0.5)); + expect(activityRect.right - activityContentRect.right, closeTo(8, 0.5)); + expect(activityRect.bottom - activityContentRect.bottom, closeTo(8, 0.5)); }); testWidgets('a finished reply copies its answer text ($style)', (