feat(app): add native chat transcript message row
Render one transcriptRows row with native controls: role-labelled user and agent messages, verbatim user text, client and attachment names (own name, URI basename, else file), ordered agent parts, and collapsed reasoning, tool and unknown-part bodies using ExpansionTile or a Cupertino disclosure. Blank known parts draw nothing so they no longer fall through to the unknown-part disclosure; closed bodies build lazily. Adds focused widget tests, the fixture probe pair and the C2 evidence note.
This commit is contained in:
@@ -0,0 +1,82 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
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';
|
||||
|
||||
const _style = String.fromEnvironment(
|
||||
'CHAT_MESSAGE_PROBE_STYLE',
|
||||
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.
|
||||
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 = ListView(
|
||||
padding: const EdgeInsets.all(16),
|
||||
children: [for (final row in rows) ChatMessageView(row: row)],
|
||||
);
|
||||
if (_style == 'cupertino') {
|
||||
runApp(
|
||||
CupertinoApp(
|
||||
theme: const CupertinoThemeData(brightness: Brightness.dark),
|
||||
home: CupertinoPageScaffold(child: SafeArea(child: content)),
|
||||
),
|
||||
);
|
||||
return;
|
||||
}
|
||||
runApp(
|
||||
MaterialApp(
|
||||
theme: ThemeData(
|
||||
brightness: Brightness.dark,
|
||||
platform: TargetPlatform.android,
|
||||
),
|
||||
home: Scaffold(body: SafeArea(child: content)),
|
||||
),
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user