cf9f71f27c
Dismissed shell runs leave the transcript and fold into a "N commands" chip in the footer of the first answer at or after each run (the last answer for newer runs, or a row of its own without any answer). The chip opens the turn sheet (wide) or a full-screen page (narrow) listing the commands; each opens its output read-only with Copy output, Send to agent and Restore. On a wide conversation the answer's Copy button moves out of the footer into a 48 px gutter left of the reading column (chatCopyGutter), shown on hover or focus on desktops and always on touch; narrow widths keep it in the footer.
72 lines
2.1 KiB
Dart
72 lines
2.1 KiB
Dart
import 'dart:async';
|
|
|
|
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
|
|
import '../../../ui/adaptive/segmented_bar_overflow.dart';
|
|
import 'chat_shell_runs_controller.dart';
|
|
|
|
const String chatShellDismissLabel = 'Dismiss';
|
|
const String chatShellDismissAllLabel = 'Dismiss all finished commands';
|
|
|
|
/// The card's Dismiss button, offered once the command has finished.
|
|
class ChatShellDismissButton extends StatelessWidget {
|
|
const ChatShellDismissButton({
|
|
super.key,
|
|
required this.cupertino,
|
|
required this.onPressed,
|
|
});
|
|
|
|
final bool cupertino;
|
|
final VoidCallback onPressed;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
if (!cupertino) {
|
|
return IconButton(
|
|
key: const Key('chat-shell-run-dismiss'),
|
|
tooltip: chatShellDismissLabel,
|
|
icon: const Icon(Icons.close),
|
|
onPressed: onPressed,
|
|
);
|
|
}
|
|
return Semantics(
|
|
label: chatShellDismissLabel,
|
|
button: true,
|
|
excludeSemantics: true,
|
|
child: CupertinoButton(
|
|
key: const Key('chat-shell-run-dismiss'),
|
|
padding: const EdgeInsets.symmetric(horizontal: 8),
|
|
onPressed: onPressed,
|
|
child: const Icon(CupertinoIcons.xmark),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
/// The conversation's "Dismiss all finished commands" More menu entry.
|
|
Widget chatShellDismissAllMenuAction({required VoidCallback onPressed}) =>
|
|
SegmentedOverflowAction(
|
|
key: const ValueKey<String>('chat-shell-dismiss-all-action'),
|
|
overflowEntry: SegmentedOverflowEntry(
|
|
label: chatShellDismissAllLabel,
|
|
icon: Icons.clear_all,
|
|
onPressed: onPressed,
|
|
),
|
|
child: const SizedBox.shrink(),
|
|
);
|
|
|
|
/// Dismisses [ids] for every client of the chat. The card simply goes away;
|
|
/// no notice is shown. A refusal goes to [onRefused].
|
|
Future<void> dismissChatShellRuns(
|
|
BuildContext context,
|
|
ChatShellRunsController controller,
|
|
List<String> ids, {
|
|
required bool cupertino,
|
|
void Function(String refusal)? onRefused,
|
|
}) async {
|
|
if (ids.isEmpty) return;
|
|
final refusal = await controller.dismiss(ids);
|
|
if (refusal != null) onRefused?.call(refusal);
|
|
}
|