merge(app): land reasoning chip
This commit is contained in:
@@ -188,8 +188,8 @@ class ChatMessageView extends StatelessWidget {
|
|||||||
return widgets;
|
return widgets;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The agent turn as the web lays it out: its reasoning as a quiet line
|
/// The agent turn: the answer in the bubble, then one row with its reasoning
|
||||||
/// above the answer, the answer in the bubble, and one tool chip below.
|
/// and tool-call chips, each opening its own sheet.
|
||||||
Widget _agentTurn(BuildContext context, List<Widget> content, Widget bubble) {
|
Widget _agentTurn(BuildContext context, List<Widget> content, Widget bubble) {
|
||||||
final parts = _partsOf(row);
|
final parts = _partsOf(row);
|
||||||
final reasoning = [
|
final reasoning = [
|
||||||
@@ -206,16 +206,16 @@ class ChatMessageView extends StatelessWidget {
|
|||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
if (reasoning.isNotEmpty)
|
|
||||||
NativeDisclosure(
|
|
||||||
key: const Key('chat-reasoning'),
|
|
||||||
label: reasoning.length == 1
|
|
||||||
? 'Reasoning'
|
|
||||||
: 'Reasoning · ${reasoning.length} steps',
|
|
||||||
childBuilder: (context) => SelectableText(reasoning.join('\n\n')),
|
|
||||||
),
|
|
||||||
if (content.isNotEmpty) bubble,
|
if (content.isNotEmpty) bubble,
|
||||||
if (tools.isNotEmpty) ChatToolCallsChip(calls: tools),
|
// Reasoning and tool calls share one quiet row below the answer.
|
||||||
|
if (reasoning.isNotEmpty || tools.isNotEmpty)
|
||||||
|
Wrap(
|
||||||
|
spacing: 8,
|
||||||
|
children: [
|
||||||
|
if (reasoning.isNotEmpty) ChatReasoningChip(steps: reasoning),
|
||||||
|
if (tools.isNotEmpty) ChatToolCallsChip(calls: tools),
|
||||||
|
],
|
||||||
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,6 +41,73 @@ class ChatToolCallsChip extends StatelessWidget {
|
|||||||
size: 14,
|
size: 14,
|
||||||
color: color,
|
color: color,
|
||||||
);
|
);
|
||||||
|
return _TurnChip(
|
||||||
|
chipKey: const Key('chat-tool-chip'),
|
||||||
|
leading: leading,
|
||||||
|
label: label,
|
||||||
|
color: color,
|
||||||
|
semanticsLabel: calls.length == 1
|
||||||
|
? '1 tool call, expand for details'
|
||||||
|
: '${calls.length} tool calls, expand for details',
|
||||||
|
sheet: _ToolCallsSheet(calls: calls),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// A turn's reasoning as a chip beside its tool chip, the same way: `Reasoning`
|
||||||
|
/// or `Reasoning · N steps`, opening a sheet with the steps.
|
||||||
|
class ChatReasoningChip extends StatelessWidget {
|
||||||
|
const ChatReasoningChip({super.key, required this.steps});
|
||||||
|
|
||||||
|
final List<String> steps;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final cupertino =
|
||||||
|
chatControlsStyleOf(context) == ChatControlsStyle.cupertino;
|
||||||
|
final color = cupertino
|
||||||
|
? CupertinoColors.secondaryLabel.resolveFrom(context)
|
||||||
|
: Theme.of(context).colorScheme.onSurfaceVariant;
|
||||||
|
final label = steps.length == 1
|
||||||
|
? 'Reasoning'
|
||||||
|
: 'Reasoning · ${steps.length} steps';
|
||||||
|
return _TurnChip(
|
||||||
|
chipKey: const Key('chat-reasoning-chip'),
|
||||||
|
leading: Icon(
|
||||||
|
cupertino ? CupertinoIcons.lightbulb : Icons.lightbulb_outline,
|
||||||
|
size: 14,
|
||||||
|
color: color,
|
||||||
|
),
|
||||||
|
label: label,
|
||||||
|
color: color,
|
||||||
|
semanticsLabel: '$label, expand for details',
|
||||||
|
sheet: _ReasoningSheet(label: label, steps: steps),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The quiet chip shell both turn summaries share, and its native sheet.
|
||||||
|
class _TurnChip extends StatelessWidget {
|
||||||
|
const _TurnChip({
|
||||||
|
required this.chipKey,
|
||||||
|
required this.leading,
|
||||||
|
required this.label,
|
||||||
|
required this.color,
|
||||||
|
required this.semanticsLabel,
|
||||||
|
required this.sheet,
|
||||||
|
});
|
||||||
|
|
||||||
|
final Key chipKey;
|
||||||
|
final Widget leading;
|
||||||
|
final String label;
|
||||||
|
final Color color;
|
||||||
|
final String semanticsLabel;
|
||||||
|
final Widget sheet;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final cupertino =
|
||||||
|
chatControlsStyleOf(context) == ChatControlsStyle.cupertino;
|
||||||
final content = Row(
|
final content = Row(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
@@ -59,22 +126,20 @@ class ChatToolCallsChip extends StatelessWidget {
|
|||||||
// The child's own action is excluded with its label, so the node
|
// The child's own action is excluded with its label, so the node
|
||||||
// carries the activation for assistive technology.
|
// carries the activation for assistive technology.
|
||||||
onTap: () => _open(context, cupertino),
|
onTap: () => _open(context, cupertino),
|
||||||
label: calls.length == 1
|
label: semanticsLabel,
|
||||||
? '1 tool call, expand for details'
|
|
||||||
: '${calls.length} tool calls, expand for details',
|
|
||||||
excludeSemantics: true,
|
excludeSemantics: true,
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.only(top: 2),
|
padding: const EdgeInsets.only(top: 2),
|
||||||
child: cupertino
|
child: cupertino
|
||||||
? CupertinoButton(
|
? CupertinoButton(
|
||||||
key: const Key('chat-tool-chip'),
|
key: chipKey,
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 4, vertical: 4),
|
padding: const EdgeInsets.symmetric(horizontal: 4, vertical: 4),
|
||||||
minimumSize: Size.zero,
|
minimumSize: Size.zero,
|
||||||
onPressed: () => _open(context, cupertino),
|
onPressed: () => _open(context, cupertino),
|
||||||
child: content,
|
child: content,
|
||||||
)
|
)
|
||||||
: InkWell(
|
: InkWell(
|
||||||
key: const Key('chat-tool-chip'),
|
key: chipKey,
|
||||||
borderRadius: BorderRadius.circular(8),
|
borderRadius: BorderRadius.circular(8),
|
||||||
onTap: () => _open(context, cupertino),
|
onTap: () => _open(context, cupertino),
|
||||||
child: Padding(
|
child: Padding(
|
||||||
@@ -90,7 +155,6 @@ class ChatToolCallsChip extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _open(BuildContext context, bool cupertino) {
|
Future<void> _open(BuildContext context, bool cupertino) {
|
||||||
final sheet = _ToolCallsSheet(calls: calls);
|
|
||||||
if (cupertino) {
|
if (cupertino) {
|
||||||
return showCupertinoModalPopup<void>(
|
return showCupertinoModalPopup<void>(
|
||||||
context: context,
|
context: context,
|
||||||
@@ -107,6 +171,49 @@ class ChatToolCallsChip extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class _ReasoningSheet extends StatelessWidget {
|
||||||
|
const _ReasoningSheet({required this.label, required this.steps});
|
||||||
|
|
||||||
|
final String label;
|
||||||
|
final List<String> steps;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final cupertino =
|
||||||
|
chatControlsStyleOf(context) == ChatControlsStyle.cupertino;
|
||||||
|
final style = cupertino
|
||||||
|
? CupertinoTheme.of(context).textTheme.textStyle
|
||||||
|
: Theme.of(context).textTheme.bodyMedium;
|
||||||
|
return DefaultTextStyle.merge(
|
||||||
|
style: style,
|
||||||
|
child: ConstrainedBox(
|
||||||
|
constraints: BoxConstraints(
|
||||||
|
maxHeight: MediaQuery.sizeOf(context).height * 0.8,
|
||||||
|
),
|
||||||
|
child: ListView(
|
||||||
|
key: const Key('chat-reasoning-sheet'),
|
||||||
|
shrinkWrap: true,
|
||||||
|
padding: const EdgeInsets.fromLTRB(16, 8, 16, 16),
|
||||||
|
children: [
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(bottom: 8),
|
||||||
|
child: Text(
|
||||||
|
label,
|
||||||
|
style: const TextStyle(fontWeight: FontWeight.w600),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
for (final (index, step) in steps.indexed)
|
||||||
|
Padding(
|
||||||
|
padding: EdgeInsets.only(top: index == 0 ? 0 : 12),
|
||||||
|
child: SelectableText(step),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class _ToolCallsSheet extends StatelessWidget {
|
class _ToolCallsSheet extends StatelessWidget {
|
||||||
const _ToolCallsSheet({required this.calls});
|
const _ToolCallsSheet({required this.calls});
|
||||||
|
|
||||||
|
|||||||
@@ -132,125 +132,10 @@ void main() {
|
|||||||
expect(find.text('Load older'), findsNothing);
|
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 cupertino in [false, true]) {
|
||||||
for (final keepsControl in [true, false]) {
|
for (final keepsControl in [true, false]) {
|
||||||
testWidgets(
|
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)',
|
'(keeps Load older: $keepsControl, $cupertino)',
|
||||||
(tester) async {
|
(tester) async {
|
||||||
final gateway = FakeChatGateway();
|
final gateway = FakeChatGateway();
|
||||||
@@ -283,28 +168,24 @@ void main() {
|
|||||||
);
|
);
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
// The turn's reasoning is one quiet block above its answer, as on
|
// The turn's reasoning is one chip below its answer; it counts the
|
||||||
// the web; it counts the steps it holds.
|
// steps of every message folded into the turn.
|
||||||
expect(find.text('Reasoning · 2 steps'), findsOneWidget);
|
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.tap(find.text('Load older'));
|
||||||
await tester.pumpAndSettle();
|
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);
|
expect(find.text('Reasoning · 4 steps'), findsOneWidget);
|
||||||
|
await tester.tap(find.text('Reasoning · 4 steps'));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
for (final body in [
|
for (final body in [
|
||||||
'NEWEST folded reasoning body.',
|
'NEWEST folded reasoning body.',
|
||||||
'OLDEST 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(
|
expect(
|
||||||
find.text('Load older'),
|
find.text('Load older'),
|
||||||
keepsControl ? findsOneWidget : findsNothing,
|
keepsControl ? findsOneWidget : findsNothing,
|
||||||
|
|||||||
@@ -124,22 +124,24 @@ void main() {
|
|||||||
expect(find.textContaining('"payload": 7'), findsNothing);
|
expect(find.textContaining('"payload": 7'), findsNothing);
|
||||||
expect(find.text('plain future text'), findsOneWidget);
|
expect(find.text('plain future text'), findsOneWidget);
|
||||||
|
|
||||||
// As the web: reasoning is a quiet line above the answer, the answer
|
// The answer keeps its own order in the bubble; reasoning and the tool
|
||||||
// keeps its own order in the bubble, and the tool calls are one chip below.
|
// calls are two chips in one row below it.
|
||||||
double top(String text) => tester.getTopLeft(find.text(text)).dy;
|
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('First answer'), lessThan(top('Second answer')));
|
||||||
expect(
|
expect(
|
||||||
top('Second answer'),
|
top('Second answer'),
|
||||||
lessThan(top('Unrecognised part: future_part')),
|
lessThan(top('Unrecognised part: future_part')),
|
||||||
);
|
);
|
||||||
expect(top('Unrecognised part: future_part'), lessThan(top('1 tool')));
|
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.ensureVisible(find.text('Reasoning'));
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
await tester.tap(find.text('Reasoning'));
|
await tester.tap(find.text('Reasoning'));
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
expect(find.text('private reasoning'), findsOneWidget);
|
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.
|
// The chip opens the calls; a call opens to its formatted input.
|
||||||
await tester.ensureVisible(find.text('1 tool'));
|
await tester.ensureVisible(find.text('1 tool'));
|
||||||
@@ -159,6 +161,48 @@ void main() {
|
|||||||
expect(find.textContaining('"payload": 7'), findsOneWidget);
|
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(
|
testWidgets(
|
||||||
'Material disclosure bodies start at the label edge at 1x and 2x',
|
'Material disclosure bodies start at the label edge at 1x and 2x',
|
||||||
(tester) async {
|
(tester) async {
|
||||||
@@ -169,19 +213,20 @@ void main() {
|
|||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
_host(
|
_host(
|
||||||
_assistant([
|
_assistant([
|
||||||
{'type': 'reasoning', 'text': 'short thought'},
|
{'type': 'future_part', 'payload': 'short thought'},
|
||||||
]),
|
]),
|
||||||
scale: scale,
|
scale: scale,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
await tester.tap(find.text('Reasoning'));
|
await tester.tap(find.text('Unrecognised part: future_part'));
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
final label = tester.getTopLeft(find.text('Reasoning'));
|
final label = tester.getTopLeft(
|
||||||
final body = tester.getTopLeft(find.text('short thought'));
|
find.text('Unrecognised part: future_part'),
|
||||||
expect(body.dx, label.dx, reason: 'short reasoning body at ${scale}x');
|
);
|
||||||
expect(find.text('short thought'), findsOneWidget);
|
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.tap(find.text('Reasoning'));
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
expect(find.text('thought'), findsOneWidget);
|
expect(find.text('thought'), findsOneWidget);
|
||||||
|
await tester.tapAt(const Offset(10, 10));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
await tester.tap(find.text('1 tool'));
|
await tester.tap(find.text('1 tool'));
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
@@ -269,7 +316,7 @@ void main() {
|
|||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
_host(
|
_host(
|
||||||
_assistant([
|
_assistant([
|
||||||
{'type': 'reasoning', 'text': 'thought'},
|
{'type': 'future_part', 'payload': 'thought'},
|
||||||
]),
|
]),
|
||||||
cupertino: true,
|
cupertino: true,
|
||||||
),
|
),
|
||||||
@@ -277,13 +324,13 @@ void main() {
|
|||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
Tristate state() => tester
|
Tristate state() => tester
|
||||||
.getSemantics(find.bySemanticsLabel('Reasoning'))
|
.getSemantics(find.bySemanticsLabel('Unrecognised part: future_part'))
|
||||||
.getSemanticsData()
|
.getSemanticsData()
|
||||||
.flagsCollection
|
.flagsCollection
|
||||||
.isExpanded;
|
.isExpanded;
|
||||||
expect(state(), Tristate.isFalse);
|
expect(state(), Tristate.isFalse);
|
||||||
|
|
||||||
await tester.tap(find.text('Reasoning'));
|
await tester.tap(find.text('Unrecognised part: future_part'));
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
expect(state(), Tristate.isTrue);
|
expect(state(), Tristate.isTrue);
|
||||||
handle.dispose();
|
handle.dispose();
|
||||||
@@ -335,10 +382,9 @@ void main() {
|
|||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
final row = tester.getRect(find.byType(ChatMessageView));
|
final row = tester.getRect(find.byType(ChatMessageView));
|
||||||
final bubble = tester.getRect(
|
final bubble = tester.getRect(
|
||||||
find.ancestor(
|
find
|
||||||
of: find.text('Ada phone'),
|
.ancestor(of: find.text('Ada phone'), matching: find.byType(Material))
|
||||||
matching: find.byType(Material),
|
.first,
|
||||||
).first,
|
|
||||||
);
|
);
|
||||||
expect(bubble.width, lessThanOrEqualTo(row.width * 0.85 + 0.5));
|
expect(bubble.width, lessThanOrEqualTo(row.width * 0.85 + 0.5));
|
||||||
expect(bubble.right, closeTo(row.right, 1));
|
expect(bubble.right, closeTo(row.right, 1));
|
||||||
|
|||||||
@@ -312,7 +312,7 @@ try {
|
|||||||
for (const name of [
|
for (const name of [
|
||||||
'User message',
|
'User message',
|
||||||
'Assistant message',
|
'Assistant message',
|
||||||
'Reasoning',
|
'Reasoning, expand for details',
|
||||||
'1 tool call, expand for details',
|
'1 tool call, expand for details',
|
||||||
'Unrecognised part: future_part',
|
'Unrecognised part: future_part',
|
||||||
'Ada phone',
|
'Ada phone',
|
||||||
@@ -347,22 +347,16 @@ try {
|
|||||||
throw new Error(`Closed disclosure leaked ${JSON.stringify(hidden)}`);
|
throw new Error(`Closed disclosure leaked ${JSON.stringify(hidden)}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const reasoning = await requireNode('Reasoning');
|
// Reasoning is a chip beside the tool chip; it opens a sheet.
|
||||||
evidence.checks.push({
|
await click('Reasoning, expand for details');
|
||||||
check: 'closed disclosures expose their collapsed state',
|
|
||||||
host: style,
|
|
||||||
ariaExpanded: reasoning.expanded,
|
|
||||||
});
|
|
||||||
|
|
||||||
await click('Reasoning');
|
|
||||||
const openReasoning = await capture(`${style}-reasoning-expanded`);
|
const openReasoning = await capture(`${style}-reasoning-expanded`);
|
||||||
await assertOcr(openReasoning, 'The user asked for exact text');
|
await assertOcr(openReasoning, 'The user asked for exact text');
|
||||||
const openReasoningNode = await requireNode('Reasoning');
|
// Dismiss the sheet through its barrier.
|
||||||
if (style === 'cupertino' && openReasoningNode.expanded !== 'true') {
|
for (const type of ['mousePressed', 'mouseReleased']) {
|
||||||
throw new Error(
|
await send('Input.dispatchMouseEvent', { type, x: 10, y: 10, button: 'left', clickCount: 1 }, session);
|
||||||
`Cupertino reasoning did not announce aria-expanded=true: ${JSON.stringify(openReasoningNode)}`,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
await delay(800);
|
||||||
|
|
||||||
await click('Unrecognised part: future_part');
|
await click('Unrecognised part: future_part');
|
||||||
const openUnknown = await capture(`${style}-unknown-expanded`);
|
const openUnknown = await capture(`${style}-unknown-expanded`);
|
||||||
for (const text of ['future_part', 'payload', 'kept', 'count']) {
|
for (const text of ['future_part', 'payload', 'kept', 'count']) {
|
||||||
|
|||||||
Reference in New Issue
Block a user