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
@@ -6,6 +6,7 @@ import 'package:flutter/semantics.dart';
import '../../../../ui/adaptive/host.dart';
import '../sessions/chat_adaptive.dart';
import 'chat_markdown.dart';
import 'chat_message_bubble.dart';
/// Renders one assistant text part with native text widgets and the host's own
/// theme roles. Link activation is the caller's job: [onOpenLink] receives only
@@ -66,20 +67,31 @@ class _ChatMarkdownViewState extends State<ChatMarkdownView> {
if (_rendered != null) return _rendered!;
final cupertino =
chatControlsStyleOf(context) == ChatControlsStyle.cupertino;
final gap = chatParagraphGap(context);
final blocks = parseMarkdown(widget.text);
return _rendered = _selectable(
context,
Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
spacing: 8,
children: [
for (final block in parseMarkdown(widget.text))
_block(context, block, cupertino),
for (var index = 0; index < blocks.length; index += 1)
Padding(
padding: EdgeInsets.only(
top: index == 0 ? 0 : _gapAfter(blocks[index - 1], gap),
),
child: _block(context, blocks[index], cupertino),
),
],
),
);
}
/// Blocks are separated by an empty line of body text, like paragraphs;
/// a heading stays close to the content it introduces.
double _gapAfter(MarkdownBlock previous, double paragraphGap) =>
previous is MarkdownHeading ? 8 : paragraphGap;
/// Selection is provided by the native [SelectionArea]. A Cupertino-only app
/// has no `MaterialLocalizations`, which `SelectionArea` asserts on, so one
/// English default localization scope is added there for its context menu.