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 {
+6 -2
View File
@@ -625,7 +625,7 @@ func (c *Chat) Answer(ctx context.Context, request protocol.ChatAnswerRequest) e
deny := request.Action == "cancel" || request.Action == "decline"
var response any
if deny {
response = map[string]any{"behavior": "deny", "message": "The operator declined to answer"}
response = map[string]any{"behavior": "deny", "message": "The operator dismissed the question and will reply in the chat instead; wait for their message."}
} else {
answers := map[string]string{}
for index, question := range form.questions {
@@ -837,7 +837,10 @@ func (s *session) receiveQuestion(p *process, requestID string, request toolRequ
s.receivePermission(p, requestID, toolRequest{ToolName: "AskUserQuestion", Input: request.Input})
return
}
form := protocol.ChatForm{ID: requestID, SessionID: s.id, Kind: "question", Title: "Claude asked a question"}
// Claude's question tool always takes an answer of the operator's own
// beside its options, and a dismissed question goes back as a denial, so
// every field accepts free text and the form can be declined.
form := protocol.ChatForm{ID: requestID, SessionID: s.id, Kind: "question", Title: "Claude asked a question", Actions: []string{"accept", "decline"}}
questions := make([]string, 0, len(payload.Questions))
for index, question := range payload.Questions {
questions = append(questions, question.Question)
@@ -846,6 +849,7 @@ func (s *session) receiveQuestion(p *process, requestID string, request toolRequ
Title: question.Question,
Type: "string",
Required: true,
Custom: true,
}
if question.Header != "" {
form.Title = question.Header
+7 -2
View File
@@ -6,6 +6,7 @@ import (
"encoding/json"
"os"
"path/filepath"
"slices"
"strings"
"testing"
"time"
@@ -224,13 +225,17 @@ func TestQuestionBecomesAFormAndAnswerReturnsToCLI(t *testing.T) {
if form.Kind != "question" || len(form.Fields) != 1 || len(form.Fields[0].Options) != 2 {
t.Fatalf("form: %+v", form)
}
if err := chat.Answer(context.Background(), protocol.ChatAnswerRequest{SessionID: session.ID, FormID: form.ID, Answers: map[string]any{"q0": "Alpha"}}); err != nil {
// The operator may answer in their own words or dismiss the question.
if !form.Fields[0].Custom || !slices.Contains(form.Actions, "decline") {
t.Fatalf("a Claude question must take a custom answer and a dismissal: %+v", form)
}
if err := chat.Answer(context.Background(), protocol.ChatAnswerRequest{SessionID: session.ID, FormID: form.ID, Answers: map[string]any{"q0": "Neither, use the cache"}}); err != nil {
t.Fatal(err)
}
waitFrame(t, frames, "answered tool", func(frame protocol.ChatEventFrame) bool {
return frame.Kind == protocol.ChatEventTool && frame.Part != nil && frame.Part.State != nil &&
frame.Part.State.Status == protocol.ChatToolCompleted && len(frame.Part.State.Content) == 1 &&
strings.Contains(frame.Part.State.Content[0].Text, "Alpha")
strings.Contains(frame.Part.State.Content[0].Text, "Neither, use the cache")
})
waitStepEnded(t, frames)
if forms, _ := chat.Forms(context.Background(), session.ID); len(forms) != 0 {