Answer Claude questions in your own words, or dismiss them

Claude's question forms now accept a free-text answer beside the
offered options and can be dismissed. A dismissal tells Claude the
operator will reply in the chat instead, the card's button reads
Dismiss, and the composer takes the keyboard so the reply can be typed
at once.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-25 00:02:59 +00:00
parent 4c82a9637e
commit bfccf39671
5 changed files with 52 additions and 6 deletions
@@ -7,6 +7,7 @@ import 'chat_question_card_fields.dart';
import 'chat_question_card_model.dart';
import 'chat_question_recorded_answers.dart';
import 'chat_question_validation.dart';
import 'composer_focus_request.dart';
/// One recorded agent question as a native card.
///
@@ -117,7 +118,14 @@ class _ChatQuestionCardState extends State<ChatQuestionCard> {
_sending = true;
_localError = '';
});
// Read before the await: the card leaves the tree once answered.
final composer = ChatComposerFocusScope.maybeOf(context);
await widget.onSubmit(const {}, action);
// A dismissed question is answered in the chat: the composer takes the
// keyboard so the reply can be typed straight away.
if (action == 'decline' && widget.form['kind'] == 'question') {
composer?.requests.request(composer.sessionId);
}
if (mounted) setState(() => _sending = false);
}
@@ -177,6 +185,11 @@ class _ChatQuestionCardState extends State<ChatQuestionCard> {
sending: _sending,
onSubmit: _submit,
onAction: _action,
// A dismissed question tells the agent the operator will reply in
// the chat instead.
declineLabel: widget.form['kind'] == 'question'
? 'Dismiss'
: 'Decline',
),
],
],
@@ -12,6 +12,7 @@ Widget chatQuestionControls({
required bool sending,
required VoidCallback onSubmit,
required void Function(String action) onAction,
String declineLabel = 'Decline',
}) {
final canDecline = actions is List && actions.contains('decline');
final canCancel = actions is List && actions.contains('cancel');
@@ -26,7 +27,7 @@ Widget chatQuestionControls({
if (canDecline)
TextButton(
onPressed: sending ? null : () => onAction('decline'),
child: const Text('Decline'),
child: Text(declineLabel),
),
if (canCancel)
TextButton(
@@ -9,6 +9,7 @@ import 'package:pipelines_app/features/chat/conversation/chat_question_validatio
import 'package:pipelines_app/features/chat/conversation/chat_thread_view.dart';
import 'chat_thread_fixtures.dart';
import 'package:pipelines_app/features/chat/conversation/composer_focus_request.dart';
Widget materialHost(Widget child) => MaterialApp(
theme: ThemeData(platform: TargetPlatform.android),
@@ -286,7 +287,8 @@ void main() {
),
),
);
await tester.tap(find.text('Decline'));
// A question's decline dismisses it so the reply goes in the chat.
await tester.tap(find.text('Dismiss'));
await tester.pumpAndSettle();
await tester.tap(find.text('Cancel question'));
await tester.pumpAndSettle();
@@ -295,6 +297,27 @@ void main() {
},
);
testWidgets('dismissing a question sends the reply to the composer', (
tester,
) async {
final requests = ChatComposerFocusRequests();
await tester.pumpWidget(
scrollHost(
ChatComposerFocusScope(
sessionId: 's',
requests: requests,
child: ChatQuestionCard(
form: question(),
onSubmit: (sent, action) async {},
),
),
),
);
await tester.tap(find.text('Dismiss'));
await tester.pumpAndSettle();
expect(requests.take('s'), isTrue);
});
testWidgets(
'an all-external form confirms completion without field answers',
(tester) async {