Render agent questions as markdown

A question's text, its description and its options' descriptions now
use the transcript's markdown renderer (bold, code, lists, links) in
the card's own text styles; tapping an option's formatted description
still selects it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-25 15:23:24 +00:00
parent 03688f0c1f
commit 509d4c624f
5 changed files with 93 additions and 6 deletions
@@ -345,6 +345,57 @@ void main() {
variant: TargetPlatformVariant.only(TargetPlatform.linux),
);
testWidgets('a question and its option descriptions render markdown', (
tester,
) async {
await tester.pumpWidget(
scrollHost(
ChatQuestionCard(
form: {
'id': 'q',
'kind': 'question',
'fields': [
{
'key': 'q0',
'title': 'Use **Postgres** or `sqlite`?',
'type': 'string',
'options': [
{
'value': 'A',
'label': 'A',
'description': 'Keeps **all** data',
},
],
},
],
},
onSubmit: (answers, action) async {},
),
),
);
await tester.pumpAndSettle();
// The markers are formatting, never shown as text.
expect(find.textContaining('**', findRichText: true), findsNothing);
expect(find.textContaining('`', findRichText: true), findsNothing);
// Bold wraps its words in a span of its own (visitChildren skips spans
// without text, so walk them directly).
final bold = <String>[];
void walk(InlineSpan span) {
if (span is! TextSpan) return;
if (span.style?.fontWeight == FontWeight.bold) {
bold.add(span.toPlainText());
}
for (final child in span.children ?? const <InlineSpan>[]) {
walk(child);
}
}
for (final text in tester.widgetList<RichText>(find.byType(RichText))) {
walk(text.text);
}
expect(bold, containsAll(['Postgres', 'all']));
});
testWidgets('dismissing a question sends the reply to the composer', (
tester,
) async {