feat(app): show a recorded chat activity sequence as one line
Lift recorded activity/compaction parts out of an assistant turn into a single activity row before the answer. Running kinds use the web's phase words; terminal records keep the label the server recorded.
This commit is contained in:
@@ -254,18 +254,7 @@ class _ChatThreadViewState extends State<ChatThreadView> {
|
||||
Padding(
|
||||
key: ValueKey<String>(keys[index]),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
child:
|
||||
rows[index]['kind'] == 'permission' ||
|
||||
rows[index]['kind'] == 'question'
|
||||
? ChatTranscriptCard(
|
||||
row: rows[index],
|
||||
onPermissionDecision: _controller.replyPermission,
|
||||
onQuestionAnswer: _controller.answerQuestion,
|
||||
)
|
||||
: ChatMessageView(
|
||||
row: rows[index],
|
||||
textBuilder: chatMarkdownText,
|
||||
),
|
||||
child: _transcriptRow(rows[index]),
|
||||
),
|
||||
if (_controller.running && !awaiting)
|
||||
Padding(
|
||||
@@ -289,6 +278,19 @@ class _ChatThreadViewState extends State<ChatThreadView> {
|
||||
},
|
||||
);
|
||||
|
||||
Widget _transcriptRow(JsonMap row) {
|
||||
final kind = '${row['kind'] ?? ''}';
|
||||
if (kind == 'activity') return _ChatActivityLine(row: row);
|
||||
if (kind == 'permission' || kind == 'question') {
|
||||
return ChatTranscriptCard(
|
||||
row: row,
|
||||
onPermissionDecision: _controller.replyPermission,
|
||||
onQuestionAnswer: _controller.answerQuestion,
|
||||
);
|
||||
}
|
||||
return ChatMessageView(row: row, textBuilder: chatMarkdownText);
|
||||
}
|
||||
|
||||
Widget _backButton(bool cupertino) => cupertino
|
||||
? CupertinoButton(
|
||||
padding: const EdgeInsetsDirectional.fromSTEB(8, 0, 8, 0),
|
||||
@@ -308,3 +310,69 @@ class _ChatThreadViewState extends State<ChatThreadView> {
|
||||
label: const Text('Back to chats'),
|
||||
);
|
||||
}
|
||||
|
||||
/// One recorded activity line for a turn.
|
||||
///
|
||||
/// The line is a summary, not a control: expansion belongs to the later overlay
|
||||
/// slice. Its wording and state come from the recorded row, and the icon only
|
||||
/// repeats that state with theme roles, so an unknown kind or state is still
|
||||
/// readable without colour.
|
||||
class _ChatActivityLine extends StatelessWidget {
|
||||
const _ChatActivityLine({required this.row});
|
||||
|
||||
final JsonMap row;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final cupertino =
|
||||
chatControlsStyleOf(context) == ChatControlsStyle.cupertino;
|
||||
final state = '${row['state'] ?? ''}'.trim().toLowerCase();
|
||||
final failed = state == 'failed' || state == 'error';
|
||||
final running = state == 'running';
|
||||
final completed =
|
||||
state == 'completed' || state == 'ended' || state == 'succeeded';
|
||||
final secondary = cupertino
|
||||
? CupertinoColors.secondaryLabel.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.onSurfaceVariant;
|
||||
final color = failed
|
||||
? (cupertino
|
||||
? CupertinoColors.systemRed.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.error)
|
||||
: secondary;
|
||||
final style =
|
||||
(cupertino
|
||||
? CupertinoTheme.of(context).textTheme.textStyle
|
||||
: Theme.of(context).textTheme.bodySmall)
|
||||
?.copyWith(color: color);
|
||||
final icon = failed
|
||||
? (cupertino
|
||||
? CupertinoIcons.exclamationmark_circle
|
||||
: Icons.error_outline)
|
||||
: running
|
||||
? (cupertino ? CupertinoIcons.arrow_2_circlepath : Icons.sync)
|
||||
: completed
|
||||
? (cupertino
|
||||
? CupertinoIcons.check_mark_circled
|
||||
: Icons.check_circle_outline)
|
||||
: (cupertino ? CupertinoIcons.circle : Icons.circle_outlined);
|
||||
final label = '${row['label'] ?? ''}'.trim();
|
||||
return Semantics(
|
||||
container: true,
|
||||
label: label,
|
||||
value: state,
|
||||
child: ExcludeSemantics(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 6),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Icon(icon, color: color),
|
||||
const SizedBox(width: 8),
|
||||
Expanded(child: Text(label, style: style)),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user