Preserve activity row layout changes

This commit is contained in:
2026-10-31 23:39:27 +00:00
parent b80c267dd7
commit 49afcba2d3
3 changed files with 63 additions and 28 deletions
@@ -216,13 +216,25 @@ class ChatMessageView extends StatelessWidget {
), ),
// A little air between the one-line turn status and the answer. // A little air between the one-line turn status and the answer.
if (content.isNotEmpty) const SizedBox(height: 6), if (content.isNotEmpty) const SizedBox(height: 6),
if (content.isNotEmpty) answer, if (content.isNotEmpty || footer.isNotEmpty)
if (footer.isNotEmpty) Padding(
Wrap( padding: const EdgeInsets.symmetric(
key: const Key('chat-message-footer'), horizontal: chatAgentContentInset,
spacing: 8, ),
crossAxisAlignment: WrapCrossAlignment.center, child: Column(
children: footer, 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,
),
],
),
), ),
], ],
); );
@@ -9,6 +9,9 @@ import '../sessions/chat_adaptive.dart';
import 'chat_response_pending.dart'; import 'chat_response_pending.dart';
import 'chat_turn_activity_details.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 /// A stable one-line turn status; only this small subtree ticks, never the
/// transcript. The same disclosure and live records survive tool transitions. /// transcript. The same disclosure and live records survive tool transitions.
class ChatTurnActivityView extends StatefulWidget { class ChatTurnActivityView extends StatefulWidget {
@@ -172,29 +175,35 @@ class _ChatTurnActivityViewState extends State<ChatTurnActivityView> {
), ),
], ],
); );
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( return Semantics(
button: true, button: true,
label: '$label, expand for details', label: '$label, expand for details',
excludeSemantics: true, excludeSemantics: true,
onTap: _open, onTap: _open,
child: cupertino child: Align(
? CupertinoButton( alignment: AlignmentDirectional.centerStart,
key: const Key('chat-turn-activity'), widthFactor: 1,
padding: EdgeInsets.zero, child: button,
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,
),
); );
} }
} }
@@ -73,10 +73,24 @@ void main() {
of: find.byKey(const Key('chat-turn-activity')), of: find.byKey(const Key('chat-turn-activity')),
matching: find.byType(Text), matching: find.byType(Text),
); );
expect( final activityTextRect = tester.getRect(activity.first);
tester.getTopLeft(activity.first).dx, final answerTextRect = tester.getRect(find.text('First paragraph.'));
tester.getTopLeft(find.text('First paragraph.')).dx, 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)', ( testWidgets('a finished reply copies its answer text ($style)', (