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(
+22
View File
@@ -0,0 +1,22 @@
# Chat and stage-debug delivery
User authorized lifting deployment/APK restrictions for these fixes. No device
tests or phone installation are authorized/claimed; deployment is web + APK feed.
| Item | Source | Verification | Landing | Deployment |
| --- | --- | --- | --- | --- |
| Send follow-ups while busy | Composer keeps Send beside a separate Stop; server queues without interruption | Both UI hosts: repeat follow-ups, pending-ack duplicate guard, newer draft preservation, 320px/2x text. 14 composer widget tests pass; attachment-send tests passed; server queued-prompt regression passes | Pending manager commit | Pending combined release |
| Streamed reasoning | Independent reasoning worktree | Pending | Pending | Pending |
| Collapsed stage input/output | Independent stage-debug worktree | Pending | Pending | Pending |
| Exact-visit raw input/output/memory/session debugging | Independent stage-debug worktree | Pending | Pending | Pending |
## Build recovery
The prior navigation APK build failed, not merely timed out: Docker's retained
`oom` event identifies container `bc23c00f17d7`, and Gradle reports its daemon
disappeared. Docker has 8,321,232,896 bytes total; the Flutter template allowed
an 8 GiB Gradle heap plus separate Kotlin daemons, metaspace and workers.
`app/docker/build.sh` now limits only its private copied Android build tree:
3 GiB Gradle heap, 1 GiB metaspace, two workers, in-process Kotlin compiler,
no parallel Gradle projects or file watcher. Host Android settings unchanged.
`sh -n app/docker/build.sh` passes; actual APK validation pending combined build.
@@ -1,4 +1,7 @@
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/features/chat/conversation/chat_composer_bar.dart';
@@ -18,34 +21,35 @@ void main() {
tearDown(() => gateway.close());
testWidgets('Stop replaces Send while running and interrupts this session', (
tester,
) async {
await tester.pumpWidget(
composerThread(gateway, newOperationId: nextOperation),
);
await tester.pumpAndSettle();
expect(find.byTooltip(chatSendLabel), findsOneWidget);
testWidgets(
'Stop stays beside Send while running and interrupts this session',
(tester) async {
await tester.pumpWidget(
composerThread(gateway, newOperationId: nextOperation),
);
await tester.pumpAndSettle();
expect(find.byTooltip(chatSendLabel), findsOneWidget);
gateway.emitEvent(chatStepFrame('running'));
await tester.pump();
await tester.pump();
gateway.emitEvent(chatStepFrame('running'));
await tester.pump();
await tester.pump();
expect(find.byTooltip(chatSendLabel), findsNothing);
expect(find.byTooltip(chatStopLabel), findsOneWidget);
final button = tester.widget<IconButton>(
find.byKey(const Key('chat-composer-primary')),
);
final scheme = Theme.of(
tester.element(find.byKey(const Key('chat-composer-primary'))),
).colorScheme;
expect(button.style?.backgroundColor?.resolve({}), scheme.error);
expect(find.byTooltip(chatSendLabel), findsOneWidget);
expect(find.byTooltip(chatStopLabel), findsOneWidget);
final button = tester.widget<IconButton>(
find.byKey(const Key('chat-composer-stop')),
);
final scheme = Theme.of(
tester.element(find.byKey(const Key('chat-composer-stop'))),
).colorScheme;
expect(button.style?.backgroundColor?.resolve({}), scheme.error);
await tester.tap(find.byKey(const Key('chat-composer-primary')));
await tester.pumpAndSettle();
expect(gateway.interruptBodies.single, {'session_id': 's'});
expect(gateway.promptBodies, isEmpty);
});
await tester.tap(find.byKey(const Key('chat-composer-stop')));
await tester.pumpAndSettle();
expect(gateway.interruptBodies.single, {'session_id': 's'});
expect(gateway.promptBodies, isEmpty);
},
);
testWidgets('the queued notice is a polite line and clears on a frame', (
tester,
@@ -108,6 +112,83 @@ void main() {
});
for (final cupertino in [false, true]) {
testWidgets(
'running send waits only for its acknowledgement and keeps newer draft '
'(${cupertino ? 'cupertino' : 'material'})',
(tester) async {
final reply = Completer<Map<String, dynamic>>();
gateway.prompt = (_, _) => reply.future;
await tester.pumpWidget(
composerThread(
gateway,
cupertino: cupertino,
newOperationId: nextOperation,
),
);
await tester.pumpAndSettle();
gateway.emitEvent(chatStepFrame('running'));
await tester.pump();
await tester.pump();
final field = find.byKey(const Key('chat-composer-field'));
await tester.enterText(field, 'Queue this');
await tester.pump();
await tester.tap(find.byKey(const Key('chat-composer-primary')));
await tester.pump();
await tester.enterText(field, 'Newer draft');
await tester.pump();
// Keyboard submit shares the sending guard: no duplicate in flight.
await tester.sendKeyDownEvent(LogicalKeyboardKey.controlLeft);
await tester.sendKeyEvent(LogicalKeyboardKey.enter);
await tester.sendKeyUpEvent(LogicalKeyboardKey.controlLeft);
await tester.pump();
expect(gateway.promptBodies, hasLength(1));
reply.complete({'chat_queued': true});
await tester.pumpAndSettle();
expect(fieldText(tester), 'Newer draft');
expect(find.byKey(const Key('chat-composer-stop')), findsOneWidget);
expect(gateway.interruptBodies, isEmpty);
},
);
testWidgets('send follow-ups during a running turn without interrupting '
'(${cupertino ? 'cupertino' : 'material'})', (tester) async {
gateway.prompt = (_, _) async => {'chat_queued': true};
await tester.pumpWidget(
composerThread(
gateway,
cupertino: cupertino,
newOperationId: nextOperation,
),
);
await tester.pumpAndSettle();
gateway.emitEvent(chatStepFrame('running'));
await tester.pump();
await tester.pump();
for (final text in ['First follow-up', 'Second follow-up']) {
await tester.enterText(
find.byKey(const Key('chat-composer-field')),
text,
);
await tester.pump();
expect(find.byKey(const Key('chat-composer-stop')), findsOneWidget);
await tester.tap(find.byKey(const Key('chat-composer-primary')));
await tester.pumpAndSettle();
expect(fieldText(tester), '');
expect(find.text(chatQueuedNotice), findsOneWidget);
}
expect(gateway.promptBodies.map((body) => body['text']), [
'First follow-up',
'Second follow-up',
]);
expect(gateway.promptBodies.map((body) => body['operation_id']), [
'op/1',
'op/2',
]);
expect(gateway.interruptBodies, isEmpty);
expect(find.byKey(const Key('chat-composer-stop')), findsOneWidget);
});
testWidgets('the composer wraps at 320 logical px with 2x text '
'(${cupertino ? 'cupertino' : 'material'})', (tester) async {
tester.view.physicalSize = const Size(640, 1200);
@@ -140,9 +221,14 @@ void main() {
);
await tester.pump();
gateway.emitEvent(chatStepFrame('running'));
await tester.pump();
await tester.pump();
expect(tester.takeException(), isNull);
expect(find.byKey(const Key('chat-composer')), findsOneWidget);
expect(find.byKey(const Key('chat-composer-primary')), findsOneWidget);
expect(find.byKey(const Key('chat-composer-stop')), findsOneWidget);
});
}
}