Animate chat composer while turns run

Replace the running Stop button with an animated composer border and task spinner. Add Escape, slash-command, and touch-menu stopping paths with focused widget coverage, including reduced-motion behavior.
This commit is contained in:
2026-11-12 02:24:46 +00:00
parent e4f3ebdcab
commit f3a469c356
14 changed files with 997 additions and 300 deletions
@@ -42,6 +42,7 @@ import 'chat_background_tasks.dart';
import 'chat_command_actions.dart';
import 'chat_composer_bar.dart';
import 'chat_composer_controller.dart';
import 'chat_escape_stop.dart';
import 'chat_delivery_indicator.dart';
import 'chat_draft_store.dart';
import 'chat_effort_control.dart';
@@ -1383,7 +1384,13 @@ class _ChatThreadViewState extends State<ChatThreadView> {
// The bar and the jump control float over the transcript and the
// composer sits below it; the wheel over them scrolls it, as a page
// scrolls under fixed bars.
final column = VerticalWheelForwarder(controller: _scroll, child: page);
// Two Escape presses stop a running turn while the conversation has
// the keyboard; the wheel over the page still scrolls it.
final column = ChatEscapeStop(
running: _controller.running,
onStop: _stopTurn,
child: VerticalWheelForwarder(controller: _scroll, child: page),
);
final wideFiles =
_filesVisible && MediaQuery.sizeOf(context).width >= 700;
_reportCenterStageFilesWidth();
@@ -1479,6 +1486,15 @@ class _ChatThreadViewState extends State<ChatThreadView> {
],
moreActions: [
?widget.sidebarControl,
// Touch devices have no Escape key; the menu is their way to stop.
if (_controller.running)
ChatBarAction(
key: const Key('chat-thread-stop-menu'),
label: chatStopLabel,
identifier: 'chat-thread-stop',
onPressed: _stopTurn,
materialIcon: Icons.stop,
),
// A window's own title bar names the chat, and its narrow action
// bar has no room for the title that opens the details.
if (WindowScope.maybeOf(context) != null)
@@ -1534,6 +1550,9 @@ class _ChatThreadViewState extends State<ChatThreadView> {
onChanged: widget.onModeChanged,
);
/// Stops the running turn, as the composer's `/stop` does.
void _stopTurn() => unawaited(_composer.stop());
void _runShellFromMenu() => unawaited(
runChatShellFromMenu(context, _shellRuns, showNotice: _showCommandNotice),
);