214bbbc54f
Keep the existing Material terminal and chat-shell behavior while removing live Cupertino widgets, icon metadata, and alternate-host branches. Retain only the documented optional compatibility parameters until remaining callers migrate.
49 lines
1.7 KiB
Dart
49 lines
1.7 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
import '../conversation/chat_card_styles.dart';
|
|
import 'chat_shell_command.dart';
|
|
import 'chat_shell_run.dart';
|
|
|
|
/// A command's state at the card's top end: the host's activity indicator
|
|
/// while it runs, then a status chip (exit code, stopped, interrupted) with
|
|
/// how long it ran. The words carry the state; colour only repeats it.
|
|
class ChatShellStatus extends StatelessWidget {
|
|
const ChatShellStatus({super.key, required this.run});
|
|
|
|
final ChatShellRun run;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
if (run.running) {
|
|
return Semantics(
|
|
key: const Key('chat-shell-run-running'),
|
|
label: chatShellStatusLabel(run),
|
|
// As tall as the line of text beside it, at any text scale.
|
|
child: SizedBox.square(
|
|
dimension: MediaQuery.textScalerOf(context).scale(20),
|
|
child: const CircularProgressIndicator(strokeWidth: 2),
|
|
),
|
|
);
|
|
}
|
|
final label = run.durationMs > 0
|
|
? '${chatShellStatusLabel(run)} · ${chatShellDuration(run.durationMs)}'
|
|
: chatShellStatusLabel(run);
|
|
final color = switch (run.state) {
|
|
ChatShellRunState.succeeded => Theme.of(context).colorScheme.primary,
|
|
ChatShellRunState.failed => chatCardErrorColor(context, false),
|
|
_ => chatCardSecondaryColor(context, false),
|
|
};
|
|
final icon = switch (run.state) {
|
|
ChatShellRunState.succeeded => Icons.check_circle_outline,
|
|
ChatShellRunState.failed => Icons.error_outline,
|
|
_ => Icons.stop_circle_outlined,
|
|
};
|
|
return Chip(
|
|
key: const Key('chat-shell-run-status'),
|
|
avatar: Icon(icon, color: color),
|
|
label: Text(label),
|
|
visualDensity: VisualDensity.compact,
|
|
);
|
|
}
|
|
}
|