Separate chunked reply paragraphs with an empty-line gap

Consecutive text parts of an agent turn (including folded messages) and
markdown blocks within a part are now separated by ~0.9x the scaled body
font size; a heading stays 8px from what it introduces. Adds a ?paras=1
chunked reply to the composer probe and gap tests at 1x/2x.
This commit is contained in:
2026-10-31 17:05:10 +00:00
parent 9c4fd47a99
commit 9de87d5a2b
5 changed files with 241 additions and 5 deletions
@@ -228,10 +228,25 @@ class ChatMessageView extends StatelessWidget {
final widgets = <Widget>[];
final parts = _partsOf(row);
final seen = <String, int>{};
// Long replies arrive as several text parts (and folded messages); an
// empty line between consecutive ones keeps them reading as paragraphs.
final gap = chatParagraphGap(
context,
chatMessageTextStyle(context, _isCupertino(context))?.fontSize,
);
var previousText = false;
for (var index = 0; index < parts.length; index++) {
final part = parts[index];
final widget = _agentPart(context, part);
var widget = _agentPart(context, part);
if (widget == null) continue;
final text = _isTextPart(part);
if (text && previousText) {
widget = Padding(
padding: EdgeInsets.only(top: gap),
child: widget,
);
}
previousText = text;
// Part identity, not position, so an older assistant message that folds
// into the same turn can prepend its parts without moving an open
// disclosure. The enclosing row's identity is carried by ChatRowKeys; a
@@ -319,6 +334,11 @@ List<JsonMap> _partsOf(Map<dynamic, dynamic> source) {
.toList();
}
bool _isTextPart(JsonMap part) =>
(part['type'] == null || part['type'] == 'text') &&
part['text'] is String &&
(part['text'] as String).trim().isNotEmpty;
bool _isFile(JsonMap part) =>
part['type'] == 'file' &&
'${part['name'] ?? ''}${part['uri'] ?? ''}'.trim().isNotEmpty;