feat(app): chat reasoning is a chip beside the tool chip, opening its own sheet

This commit is contained in:
2026-10-23 16:22:31 +01:00
parent 7539a7a552
commit f2aa559d0e
5 changed files with 202 additions and 174 deletions
@@ -124,22 +124,24 @@ void main() {
expect(find.textContaining('"payload": 7'), findsNothing);
expect(find.text('plain future text'), findsOneWidget);
// As the web: reasoning is a quiet line above the answer, the answer
// keeps its own order in the bubble, and the tool calls are one chip below.
// The answer keeps its own order in the bubble; reasoning and the tool
// calls are two chips in one row below it.
double top(String text) => tester.getTopLeft(find.text(text)).dy;
expect(top('Reasoning'), lessThan(top('First answer')));
expect(top('First answer'), lessThan(top('Second answer')));
expect(
top('Second answer'),
lessThan(top('Unrecognised part: future_part')),
);
expect(top('Unrecognised part: future_part'), lessThan(top('1 tool')));
expect(top('Unrecognised part: future_part'), lessThan(top('Reasoning')));
await tester.ensureVisible(find.text('Reasoning'));
await tester.pumpAndSettle();
await tester.tap(find.text('Reasoning'));
await tester.pumpAndSettle();
expect(find.text('private reasoning'), findsOneWidget);
await tester.tapAt(const Offset(10, 10));
await tester.pumpAndSettle();
// The chip opens the calls; a call opens to its formatted input.
await tester.ensureVisible(find.text('1 tool'));
@@ -159,6 +161,48 @@ void main() {
expect(find.textContaining('"payload": 7'), findsOneWidget);
});
for (final cupertino in [false, true]) {
testWidgets('reasoning and tool chips share one row below the answer '
'(${cupertino ? 'cupertino' : 'material'})', (tester) async {
// The test font draws every glyph as a full square, so the chips need
// more room than real text does on a phone.
tester.view.physicalSize = const Size(800, 844);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.reset);
await tester.pumpWidget(
_host(
_assistant([
{'type': 'reasoning', 'text': 'first thought'},
{'type': 'text', 'text': 'The answer'},
{'type': 'reasoning', 'text': 'second thought'},
{
'type': 'tool',
'name': 'shell',
'state': {'status': 'completed'},
},
]),
cupertino: cupertino,
),
);
await tester.pumpAndSettle();
final reasoning = tester.getRect(find.text('Reasoning · 2 steps'));
final tools = tester.getRect(find.text('1 tool'));
expect(
reasoning.top,
greaterThan(tester.getRect(find.text('The answer')).bottom),
);
expect(reasoning.center.dy, moreOrLessEquals(tools.center.dy));
expect(reasoning.right, lessThan(tools.left));
// Like the tool chip, it opens a sheet with every step.
await tester.tap(find.text('Reasoning · 2 steps'));
await tester.pumpAndSettle();
expect(find.text('first thought'), findsOneWidget);
expect(find.text('second thought'), findsOneWidget);
});
}
testWidgets(
'Material disclosure bodies start at the label edge at 1x and 2x',
(tester) async {
@@ -169,19 +213,20 @@ void main() {
await tester.pumpWidget(
_host(
_assistant([
{'type': 'reasoning', 'text': 'short thought'},
{'type': 'future_part', 'payload': 'short thought'},
]),
scale: scale,
),
);
await tester.pumpAndSettle();
await tester.tap(find.text('Reasoning'));
await tester.tap(find.text('Unrecognised part: future_part'));
await tester.pumpAndSettle();
final label = tester.getTopLeft(find.text('Reasoning'));
final body = tester.getTopLeft(find.text('short thought'));
expect(body.dx, label.dx, reason: 'short reasoning body at ${scale}x');
expect(find.text('short thought'), findsOneWidget);
final label = tester.getTopLeft(
find.text('Unrecognised part: future_part'),
);
final body = tester.getTopLeft(find.textContaining('short thought'));
expect(body.dx, label.dx, reason: 'disclosure body at ${scale}x');
}
},
);
@@ -253,6 +298,8 @@ void main() {
await tester.tap(find.text('Reasoning'));
await tester.pumpAndSettle();
expect(find.text('thought'), findsOneWidget);
await tester.tapAt(const Offset(10, 10));
await tester.pumpAndSettle();
await tester.tap(find.text('1 tool'));
await tester.pumpAndSettle();
@@ -269,7 +316,7 @@ void main() {
await tester.pumpWidget(
_host(
_assistant([
{'type': 'reasoning', 'text': 'thought'},
{'type': 'future_part', 'payload': 'thought'},
]),
cupertino: true,
),
@@ -277,13 +324,13 @@ void main() {
await tester.pumpAndSettle();
Tristate state() => tester
.getSemantics(find.bySemanticsLabel('Reasoning'))
.getSemantics(find.bySemanticsLabel('Unrecognised part: future_part'))
.getSemanticsData()
.flagsCollection
.isExpanded;
expect(state(), Tristate.isFalse);
await tester.tap(find.text('Reasoning'));
await tester.tap(find.text('Unrecognised part: future_part'));
await tester.pumpAndSettle();
expect(state(), Tristate.isTrue);
handle.dispose();
@@ -335,10 +382,9 @@ void main() {
await tester.pumpAndSettle();
final row = tester.getRect(find.byType(ChatMessageView));
final bubble = tester.getRect(
find.ancestor(
of: find.text('Ada phone'),
matching: find.byType(Material),
).first,
find
.ancestor(of: find.text('Ada phone'), matching: find.byType(Material))
.first,
);
expect(bubble.width, lessThanOrEqualTo(row.width * 0.85 + 0.5));
expect(bubble.right, closeTo(row.right, 1));