merge(app): land chat-stop-notice
This commit is contained in:
@@ -32,6 +32,9 @@ const String chatCommandNoticeLabel = 'Command';
|
|||||||
const String chatCommandFailedLabel = 'Command failed';
|
const String chatCommandFailedLabel = 'Command failed';
|
||||||
const String chatCommandDismissLabel = 'Dismiss command notice';
|
const String chatCommandDismissLabel = 'Dismiss command notice';
|
||||||
|
|
||||||
|
/// The web's line after `/stop`'s interrupt was accepted.
|
||||||
|
const String chatStopCommandNotice = 'Stopping the running turn…';
|
||||||
|
|
||||||
/// Shown while the reply says this prompt waits behind the running turn.
|
/// Shown while the reply says this prompt waits behind the running turn.
|
||||||
const String chatQueuedNotice =
|
const String chatQueuedNotice =
|
||||||
'Queued — it will send when the current turn finishes.';
|
'Queued — it will send when the current turn finishes.';
|
||||||
@@ -292,7 +295,7 @@ class _ChatComposerBarState extends State<ChatComposerBar> {
|
|||||||
} else if (command.name == chatCommandStop) {
|
} else if (command.name == chatCommandStop) {
|
||||||
_consumeCommandDraft();
|
_consumeCommandDraft();
|
||||||
if (widget.running) {
|
if (widget.running) {
|
||||||
unawaited(widget.composer.stop());
|
unawaited(_stopFromCommand());
|
||||||
} else {
|
} else {
|
||||||
_showCommandNotice('No turn is running in this chat.', failed: true);
|
_showCommandNotice('No turn is running in this chat.', failed: true);
|
||||||
}
|
}
|
||||||
@@ -316,6 +319,14 @@ class _ChatComposerBarState extends State<ChatComposerBar> {
|
|||||||
_focus.requestFocus();
|
_focus.requestFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// `/stop`'s accepted interrupt reports the web's line; a refusal is the
|
||||||
|
/// composer's own error.
|
||||||
|
Future<void> _stopFromCommand() async {
|
||||||
|
await widget.composer.stop();
|
||||||
|
if (!mounted || widget.composer.error != null) return;
|
||||||
|
_showCommandNotice(chatStopCommandNotice);
|
||||||
|
}
|
||||||
|
|
||||||
void _consumeCommandDraft() {
|
void _consumeCommandDraft() {
|
||||||
_text.clear();
|
_text.clear();
|
||||||
unawaited(widget.composer.setDraft(''));
|
unawaited(widget.composer.setDraft(''));
|
||||||
|
|||||||
@@ -300,6 +300,7 @@ void main() {
|
|||||||
]);
|
]);
|
||||||
expect(fieldText(tester), '');
|
expect(fieldText(tester), '');
|
||||||
expect(gateway.promptBodies, isEmpty);
|
expect(gateway.promptBodies, isEmpty);
|
||||||
|
expect(find.text('Stopping the running turn…'), findsOneWidget);
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('a command picked from the palette is never sent either', (
|
testWidgets('a command picked from the palette is never sent either', (
|
||||||
|
|||||||
Reference in New Issue
Block a user