fix(app): keep Send available while a chat turn runs

This commit is contained in:
2026-10-24 01:57:46 +01:00
parent 7f88f14a52
commit 91854148dd
3 changed files with 146 additions and 34 deletions
@@ -42,8 +42,8 @@ const String chatStopCommandNotice = 'Stopping the running turn…';
const String chatQueuedNotice =
'Queued — it will send when the current turn finishes.';
/// The foot of one conversation: a native multiline field and one primary
/// Send/Stop control, driven by the landed [ChatComposerController].
/// The foot of one conversation: a native multiline field and Send control,
/// with a separate Stop while a turn runs, driven by [ChatComposerController].
///
/// The field owns only its [TextEditingController] and focus; the durable draft
/// text lives in the composer controller, so a live transcript rebuild never
@@ -78,7 +78,7 @@ class ChatComposerBar extends StatefulWidget {
/// session (null) keeps those commands on the unavailable report.
final ChatCommandActions? commands;
/// The thread controller's running bit; it alone decides Send versus Stop.
/// The thread controller's running bit; shows Stop without hiding Send.
final bool running;
/// The host picker seam; production uses [hostChatAttachmentPicker].
@@ -608,6 +608,10 @@ class _ChatComposerBarState extends State<ChatComposerBar> {
),
),
const SizedBox(width: 8),
if (widget.running) ...[
_primary(context, cupertino, stop: true),
const SizedBox(width: 4),
],
_primary(context, cupertino),
],
),
@@ -899,9 +903,8 @@ class _ChatComposerBarState extends State<ChatComposerBar> {
);
}
Widget _primary(BuildContext context, bool cupertino) {
Widget _primary(BuildContext context, bool cupertino, {bool stop = false}) {
final composer = widget.composer;
final stop = widget.running;
final enabled = stop
? !composer.stopping
: !_uploading && !composer.sending && composer.draft.trim().isNotEmpty;
@@ -920,16 +923,17 @@ class _ChatComposerBarState extends State<ChatComposerBar> {
}
}
// One icon control, named Send or Stop for assistive technology: a send
// arrow, or a stop square in the error colour while a turn runs.
// Sending while the turn runs uses the server's existing queued-prompt path.
// Stopping is always a separate, explicitly named action.
final label = stop ? chatStopLabel : chatSendLabel;
final key = Key(stop ? 'chat-composer-stop' : 'chat-composer-primary');
if (cupertino) {
return Semantics(
button: true,
label: label,
excludeSemantics: true,
child: CupertinoButton.filled(
key: const Key('chat-composer-primary'),
key: key,
sizeStyle: CupertinoButtonSize.small,
color: stop ? CupertinoColors.systemRed.resolveFrom(context) : null,
onPressed: enabled ? press : null,
@@ -942,7 +946,7 @@ class _ChatComposerBarState extends State<ChatComposerBar> {
}
final scheme = Theme.of(context).colorScheme;
return IconButton.filled(
key: const Key('chat-composer-primary'),
key: key,
tooltip: label,
style: stop
? IconButton.styleFrom(