Make chat reasoning a footer chip that opens a live sheet like tools
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
@@ -9,8 +11,9 @@ const _style = String.fromEnvironment(
|
||||
defaultValue: 'material',
|
||||
);
|
||||
|
||||
/// Visible fixture for one user row and one folded assistant turn. The unknown
|
||||
/// part and the tool body start collapsed so the browser probe has to open them.
|
||||
/// Visible fixture for one user row, one folded assistant turn and one live
|
||||
/// turn whose newest reasoning step grows every half second. The unknown part
|
||||
/// and the tool body start collapsed so the browser probe has to open them.
|
||||
void main() {
|
||||
final rows = transcriptRows([
|
||||
{
|
||||
@@ -57,10 +60,7 @@ void main() {
|
||||
],
|
||||
},
|
||||
]);
|
||||
final content = ListView(
|
||||
padding: const EdgeInsets.all(16),
|
||||
children: [for (final row in rows) ChatMessageView(row: row)],
|
||||
);
|
||||
final content = _LiveTranscript(rows: rows);
|
||||
if (_style == 'cupertino') {
|
||||
runApp(
|
||||
CupertinoApp(
|
||||
@@ -80,3 +80,59 @@ void main() {
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// The fixture rows plus a streaming turn, rebuilt on each tick the way the
|
||||
/// thread repaints a live delta.
|
||||
class _LiveTranscript extends StatefulWidget {
|
||||
const _LiveTranscript({required this.rows});
|
||||
|
||||
final List<Map<String, dynamic>> rows;
|
||||
|
||||
@override
|
||||
State<_LiveTranscript> createState() => _LiveTranscriptState();
|
||||
}
|
||||
|
||||
class _LiveTranscriptState extends State<_LiveTranscript> {
|
||||
int _tick = 0;
|
||||
late final Timer _timer;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_timer = Timer.periodic(
|
||||
const Duration(milliseconds: 500),
|
||||
(_) => setState(() => _tick++),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_timer.cancel();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final live = {
|
||||
...transcriptRows([
|
||||
{
|
||||
'id': 'probe-live',
|
||||
'role': 'assistant',
|
||||
'parts': [
|
||||
{'type': 'reasoning', 'id': 'r1', 'text': 'Live step one settled.'},
|
||||
{'type': 'text', 'id': 't1', 'text': 'Live answer so far.'},
|
||||
{'type': 'reasoning', 'id': 'r2', 'text': 'Live tick $_tick.'},
|
||||
],
|
||||
},
|
||||
]).single,
|
||||
'streaming': true,
|
||||
};
|
||||
return ListView(
|
||||
padding: const EdgeInsets.all(16),
|
||||
children: [
|
||||
for (final row in [...widget.rows, live])
|
||||
ChatMessageView(key: ValueKey(row['key']), row: row),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -376,6 +376,50 @@ try {
|
||||
await assertOcr(openTool, text);
|
||||
}
|
||||
|
||||
// Dismiss the tool sheet, then bring the live turn into view.
|
||||
for (const type of ['mousePressed', 'mouseReleased']) {
|
||||
await send('Input.dispatchMouseEvent', { type, x: 10, y: 10, button: 'left', clickCount: 1 }, session);
|
||||
}
|
||||
await delay(800);
|
||||
await send('Input.dispatchMouseEvent', { type: 'mouseWheel', x: 195, y: 420, deltaX: 0, deltaY: 3000 }, session);
|
||||
await delay(800);
|
||||
const liveName = 'Reasoning · 2 steps, expand for details';
|
||||
await requireNode(liveName);
|
||||
const liveChip = await capture(`${style}-live-chip`);
|
||||
await assertOcr(liveChip, 'Live answer so far');
|
||||
await assertOcr(liveChip, 'Reasoning');
|
||||
// The open sheet follows the live turn: its newest step keeps growing.
|
||||
// A real pointer tap on the chip's own node (the smallest one carrying its
|
||||
// name; its row group repeats the text).
|
||||
const chipNode = (await nodes())
|
||||
.filter((node) => node.label === liveName || node.text === liveName)
|
||||
.sort((a, b) => a.w * a.h - b.w * b.h)[0];
|
||||
for (const type of ['mousePressed', 'mouseReleased']) {
|
||||
await send('Input.dispatchMouseEvent', {
|
||||
type,
|
||||
x: chipNode.x + chipNode.w / 2,
|
||||
y: chipNode.y + chipNode.h / 2,
|
||||
button: 'left',
|
||||
clickCount: 1,
|
||||
}, session);
|
||||
}
|
||||
await delay(800);
|
||||
const tickOf = async (path) => {
|
||||
const match = (await ocr(path)).match(/Live tick (\d+)/);
|
||||
if (!match) throw new Error(`OCR of ${path} shows no live tick`);
|
||||
return Number(match[1]);
|
||||
};
|
||||
const liveA = await capture(`${style}-live-sheet-a`);
|
||||
await assertOcr(liveA, 'Live step one settled');
|
||||
const first = await tickOf(liveA);
|
||||
await delay(2000);
|
||||
const liveB = await capture(`${style}-live-sheet-b`);
|
||||
const second = await tickOf(liveB);
|
||||
evidence.checks.push({ check: 'open reasoning sheet follows live deltas', first, second });
|
||||
if (second <= first) {
|
||||
throw new Error(`Open sheet did not follow live deltas: ${first} then ${second}`);
|
||||
}
|
||||
|
||||
const report = JSON.stringify(evidence, null, 2);
|
||||
await writeFile(join(out, `${style}-evidence.json`), report);
|
||||
console.log(report);
|
||||
|
||||
Reference in New Issue
Block a user