Files
pipelines/app/tool/chat_message_probe.dart
alan 13a5e1dee0 Remove Cupertino branches from probe fixtures
Keep the chat and graph fixtures aligned with the app's Material-only UI by removing alternate Cupertino hosts, imports, and query-controlled rendering paths. Preserve the existing Material scenarios and document the focused probe coverage.
2026-11-11 20:08:06 +00:00

124 lines
3.3 KiB
Dart

import 'dart:async';
import 'package:flutter/material.dart';
import 'package:pipelines_app/features/chat/domain/chat_transcript.dart';
import 'package:pipelines_app/features/chat/ui/transcript/chat_message_view.dart';
/// 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([
{
'id': 'probe-user',
'role': 'user',
'client': 'Ada phone',
'parts': [
{
'type': 'text',
'text':
'Please keep every word of this prompt, including the trailing '
'detail that wraps onto another line at a narrow width.',
},
{'type': 'file', 'name': 'plan.md', 'uri': '/workspace/plan.md'},
{'type': 'file', 'uri': '/workspace/results/report.csv'},
],
},
{
'id': 'probe-assistant',
'role': 'assistant',
'parts': [
{
'type': 'text',
'text': 'I checked the transcript and kept the original order.',
},
{
'type': 'reasoning',
'text':
'The user asked for exact text, so the raw string stays as sent.',
},
{
'type': 'tool',
'name': 'shell',
'state': {
'status': 'completed',
'input': {'command': 'ls -la'},
},
},
{'type': 'text', 'text': 'Second answer line after the tool call.'},
{
'type': 'future_part',
'payload': {'kept': true, 'count': 2},
},
],
},
]);
final content = _LiveTranscript(rows: rows);
runApp(
MaterialApp(
theme: ThemeData(
brightness: Brightness.dark,
platform: TargetPlatform.android,
),
home: Scaffold(body: SafeArea(child: content)),
),
);
}
/// 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),
],
);
}
}