feat(app): chat reasoning is a chip beside the tool chip, opening its own sheet
This commit is contained in:
@@ -132,125 +132,10 @@ void main() {
|
||||
expect(find.text('Load older'), findsNothing);
|
||||
});
|
||||
|
||||
// Paging prepends messages, so an unkeyed transcript would reuse the element
|
||||
// at a message's old index: the operator's open reasoning would move to the
|
||||
// previous answer, or be dropped when `Load older` disappears.
|
||||
for (final cupertino in [false, true]) {
|
||||
testWidgets(
|
||||
'an open reasoning block stays on its answer while has_more remains '
|
||||
'($cupertino)',
|
||||
(tester) async {
|
||||
final gateway = FakeChatGateway();
|
||||
addTearDown(gateway.close);
|
||||
var reads = 0;
|
||||
gateway.history = (_) async => ++reads == 1
|
||||
? pagedChatPage(
|
||||
'a2',
|
||||
'NEWEST reasoning body that belongs to the newest answer.',
|
||||
cursor: 'opaque/older',
|
||||
hasMore: true,
|
||||
)
|
||||
: pagedChatPage(
|
||||
'a1',
|
||||
'OLDER reasoning body that must not steal the newest disclosure.',
|
||||
cursor: 'opaque/older-2',
|
||||
hasMore: true,
|
||||
);
|
||||
|
||||
await tester.pumpWidget(
|
||||
(cupertino ? cupertinoHost : host)(
|
||||
ChatThreadView(gateway: gateway, sessionId: 's', onBack: () {}),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
await tester.tap(find.text('Reasoning'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(
|
||||
find.text('NEWEST reasoning body that belongs to the newest answer.'),
|
||||
findsOneWidget,
|
||||
);
|
||||
|
||||
await tester.tap(find.text('Load older'));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// Both answers are present; only the one the operator opened is open.
|
||||
expect(find.text('Reasoning'), findsNWidgets(2));
|
||||
expect(find.text('Load older'), findsOneWidget);
|
||||
expect(
|
||||
find.text('NEWEST reasoning body that belongs to the newest answer.'),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(
|
||||
find.text(
|
||||
'OLDER reasoning body that must not steal the newest disclosure.',
|
||||
),
|
||||
findsNothing,
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
testWidgets(
|
||||
'an open reasoning block survives the removal of Load older ($cupertino)',
|
||||
(tester) async {
|
||||
final gateway = FakeChatGateway();
|
||||
addTearDown(gateway.close);
|
||||
var reads = 0;
|
||||
gateway.history = (_) async => ++reads == 1
|
||||
? pagedChatPage(
|
||||
'a2',
|
||||
'NEWEST reasoning body that belongs to the newest answer.',
|
||||
cursor: 'opaque/older',
|
||||
hasMore: true,
|
||||
)
|
||||
: pagedChatPage(
|
||||
'a1',
|
||||
'OLDER reasoning body that must not steal the newest disclosure.',
|
||||
cursor: '',
|
||||
hasMore: false,
|
||||
);
|
||||
|
||||
await tester.pumpWidget(
|
||||
(cupertino ? cupertinoHost : host)(
|
||||
ChatThreadView(gateway: gateway, sessionId: 's', onBack: () {}),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
await tester.tap(find.text('Reasoning'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(
|
||||
find.text('NEWEST reasoning body that belongs to the newest answer.'),
|
||||
findsOneWidget,
|
||||
);
|
||||
|
||||
await tester.tap(find.text('Load older'));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.text('Reasoning'), findsNWidgets(2));
|
||||
expect(find.text('Load older'), findsNothing);
|
||||
expect(
|
||||
find.text('NEWEST reasoning body that belongs to the newest answer.'),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(
|
||||
find.text(
|
||||
'OLDER reasoning body that must not steal the newest disclosure.',
|
||||
),
|
||||
findsNothing,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
// The repository's own paged-history fixture pages consecutive assistant
|
||||
// messages, so an older page can prepend into the one folded turn. Its first
|
||||
// message id changes; the row must still be the same element and keep the
|
||||
// operator's open disclosure.
|
||||
for (final cupertino in [false, true]) {
|
||||
for (final keepsControl in [true, false]) {
|
||||
testWidgets(
|
||||
'an open reasoning block in a folded assistant turn survives paging '
|
||||
'a folded assistant turn counts every reasoning step across paging '
|
||||
'(keeps Load older: $keepsControl, $cupertino)',
|
||||
(tester) async {
|
||||
final gateway = FakeChatGateway();
|
||||
@@ -283,28 +168,24 @@ void main() {
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// The turn's reasoning is one quiet block above its answer, as on
|
||||
// the web; it counts the steps it holds.
|
||||
// The turn's reasoning is one chip below its answer; it counts the
|
||||
// steps of every message folded into the turn.
|
||||
expect(find.text('Reasoning · 2 steps'), findsOneWidget);
|
||||
await tester.tap(find.text('Reasoning · 2 steps'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(
|
||||
find.textContaining('NEWEST folded reasoning body.'),
|
||||
findsOneWidget,
|
||||
);
|
||||
|
||||
await tester.tap(find.text('Load older'));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// All four assistant messages now fold into the same turn, and the
|
||||
// open block stays open while it grows.
|
||||
expect(find.text('Reasoning · 4 steps'), findsOneWidget);
|
||||
await tester.tap(find.text('Reasoning · 4 steps'));
|
||||
await tester.pumpAndSettle();
|
||||
for (final body in [
|
||||
'NEWEST folded reasoning body.',
|
||||
'OLDEST folded reasoning body.',
|
||||
]) {
|
||||
expect(find.textContaining(body), findsOneWidget, reason: body);
|
||||
expect(find.text(body), findsOneWidget, reason: body);
|
||||
}
|
||||
Navigator.of(tester.element(find.text('NEWEST folded reasoning body.'))).pop();
|
||||
await tester.pumpAndSettle();
|
||||
expect(
|
||||
find.text('Load older'),
|
||||
keepsControl ? findsOneWidget : findsNothing,
|
||||
|
||||
Reference in New Issue
Block a user