Question answers: no shaking while typing; Enter sends, Shift+Enter breaks

Typing in a question card's answer box asked the transcript to reveal
the caret on every keystroke; the split, bottom-following transcript
jumped and followed back, so the conversation shook. The request now
stops at the card, which is on screen while the operator types.

A free-text answer now behaves like the chat composer: it grows to six
lines, Enter sends it (desktop and web keyboards) and Shift+Enter
breaks the line; an open IME candidate keeps its Enter.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-25 10:30:30 +00:00
parent a59b80fb48
commit 33874005c4
5 changed files with 156 additions and 2 deletions
@@ -1,6 +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/core/api_gateway.dart';
import 'package:pipelines_app/features/chat/conversation/chat_question_card.dart';
@@ -297,6 +298,53 @@ void main() {
},
);
testWidgets(
'Enter sends a typed answer; Shift+Enter breaks the line',
(tester) async {
final sent = <Map<String, dynamic>>[];
await tester.pumpWidget(
scrollHost(
ChatQuestionCard(
form: {
'id': 'q',
'kind': 'question',
'actions': ['accept', 'decline'],
'fields': [
{
'key': 'q0',
'title': 'Which one?',
'type': 'string',
'required': true,
'custom': true,
'options': [
{'value': 'A', 'label': 'A'},
],
},
],
},
onSubmit: (answers, action) async => sent.add(answers),
),
),
);
final box = find.byKey(const ValueKey<String>('chat-question-input-q0'));
await tester.tap(box);
await tester.enterText(box, 'first line');
await tester.sendKeyDownEvent(LogicalKeyboardKey.shiftLeft);
await tester.sendKeyEvent(LogicalKeyboardKey.enter);
await tester.sendKeyUpEvent(LogicalKeyboardKey.shiftLeft);
await tester.pump();
expect(tester.widget<TextField>(box).controller!.text, 'first line\n');
expect(sent, isEmpty);
await tester.enterText(box, 'first line\nsecond');
await tester.sendKeyEvent(LogicalKeyboardKey.enter);
await tester.pumpAndSettle();
expect(sent, [
{'q0': 'first line\nsecond'},
]);
},
variant: TargetPlatformVariant.only(TargetPlatform.linux),
);
testWidgets('dismissing a question sends the reply to the composer', (
tester,
) async {