The best way to control Claude Code, Codex and more from any computer or phone
revert: "fix(clients): show question option previews" (#21933) (#22229)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Theo Browne committed
Oct 20, 2026 at 02:02 UTC
8eafe058ca7720219e9466e9c6ed8e59a2276dee
4 files changed
+17
-238
apps/mobile/src/features/threads/PendingUserInputCard.tsx
+9
-58
@@ -2,7 +2,7 @@ import { Button } from "../../components/ui/Button";
2
import { QuestionAttachments } from "./QuestionAttachments";
3
import type { RuntimeRequestId } from "@t3tools/contracts";
4
import type { ThreadUserInputQuestion } from "@t3tools/client-runtime/state/thread-requests";
5
-import { useCallback, useRef, useState } from "react";
5
+import { useCallback, useRef } from "react";
6
import { Platform, Pressable, ScrollView, View, type LayoutChangeEvent } from "react-native";
7
import Animated, {
8
Easing,
@@ -79,22 +79,6 @@ function QuestionText(props: { readonly markdown: string }) {
79
}
80
81
export function PendingUserInputCard(props: PendingUserInputCardProps) {
82
- const [focusedOption, setFocusedOption] = useState<{
83
- requestId: RuntimeRequestId;
84
- questionId: string;
85
- optionIndex: number;
86
- } | null>(null);
87
- const focusedQuestion = props.pendingUserInput.questions.find(
88
- (question) => question.id === focusedOption?.questionId,
89
- );
90
- if (
91
- focusedOption &&
92
- (focusedOption.requestId !== props.pendingUserInput.requestId ||
93
- !focusedQuestion ||
94
- (props.drafts[focusedQuestion.id]?.customAnswer?.trim().length ?? 0) > 0)
95
- ) {
96
- setFocusedOption(null);
97
- }
82
const questionCount = props.pendingUserInput.questions.length;
83
const canRespond = props.pendingUserInput.responseCapability !== "not_resumable";
84
const isResponding = props.respondingUserInputId === props.pendingUserInput.requestId;
@@ -254,19 +238,6 @@ export function PendingUserInputCard(props: PendingUserInputCardProps) {
238
) : null}
239
{props.pendingUserInput.questions.map((question) => {
240
const draft = props.drafts[question.id];
257
- const customAnswerActive = (draft?.customAnswer?.trim().length ?? 0) > 0;
258
- const selectedOptionValue = draft?.selectedOptionValues?.at(-1);
259
- const savedOptionMatches = question.options.filter(
260
- (option) => (option.value ?? option.label.trim()) === selectedOptionValue,
261
- );
262
- const previewOption = customAnswerActive
263
- ? undefined
264
- : focusedOption?.requestId === props.pendingUserInput.requestId &&
265
- focusedOption.questionId === question.id
266
- ? question.options[focusedOption.optionIndex]
267
- : savedOptionMatches.length === 1
268
- ? savedOptionMatches[0]
269
- : undefined;
241
return (
242
<View key={question.id} className="gap-2 pt-1">
243
<Text className="font-t3-bold text-xs uppercase tracking-[1px] text-foreground-muted">
@@ -274,16 +245,14 @@ export function PendingUserInputCard(props: PendingUserInputCardProps) {
245
</Text>
246
<QuestionText markdown={question.question} />
247
<View className="gap-2">
277
- {question.options.map((option, optionIndex) => {
248
+ {question.options.map((option) => {
249
const optionValue = option.value ?? option.label.trim();
250
const selected = isPendingUserInputOptionSelected(question, draft, optionValue);
251
const description =
252
option.description !== option.label ? option.description : undefined;
253
return (
254
<Pressable
284
- // Options keep their positions within a question and may share answer values.
285
- // oxlint-disable-next-line react/no-array-index-key
286
- key={`${question.id}:${optionIndex}`}
255
+ key={optionValue}
256
accessibilityRole={question.multiSelect ? "checkbox" : "radio"}
257
accessibilityState={{ checked: selected, disabled: responseDisabled }}
258
disabled={responseDisabled}
@@ -291,18 +260,13 @@ export function PendingUserInputCard(props: PendingUserInputCardProps) {
260
"min-h-12 w-full rounded-2xl border px-3.5 py-3",
261
selected ? "border-primary bg-primary/10" : "border-border bg-input",
262
)}
294
- onPress={() => {
295
- setFocusedOption({
296
- requestId: props.pendingUserInput.requestId,
297
- questionId: question.id,
298
- optionIndex,
299
- });
263
+ onPress={() =>
264
props.onSelectOption(
265
props.pendingUserInput.requestId,
266
question,
267
optionValue,
304
- );
305
- }}
268
+ )
269
+ }
270
>
271
<View className="min-w-0 flex-1 gap-0.5">
272
<Text
@@ -323,14 +287,6 @@ export function PendingUserInputCard(props: PendingUserInputCardProps) {
287
);
288
})}
289
</View>
326
- {previewOption?.preview?.trim() ? (
327
- <View className="gap-1.5 rounded-2xl border border-border bg-input p-3.5">
328
- <Text className="font-t3-bold text-xs text-foreground-muted">
329
- Preview · {previewOption.label}
330
- </Text>
331
- <QuestionText markdown={previewOption.preview} />
332
- </View>
333
- ) : null}
290
{question.allowCustomAnswer !== false ? (
291
<QuestionAttachments
292
requestId={props.pendingUserInput.requestId}
@@ -338,14 +294,9 @@ export function PendingUserInputCard(props: PendingUserInputCardProps) {
294
questions={props.pendingUserInput.questions}
295
disabled={responseDisabled}
296
value={draft?.customAnswer ?? ""}
341
- onChangeText={(value) => {
342
- setFocusedOption(null);
343
- props.onChangeCustomAnswer(
344
- props.pendingUserInput.requestId,
345
- question.id,
346
- value,
347
- );
348
- }}
297
+ onChangeText={(value) =>
298
+ props.onChangeCustomAnswer(props.pendingUserInput.requestId, question.id, value)
299
+ }
300
onInputFocusChange={props.onInputFocusChange}
301
/>
302
) : null}
apps/web/src/components/chat/ComposerPendingUserInputPanel.navigation.browser.test.tsx
+3
-127
@@ -11,11 +11,9 @@ import { createRoot, type Root } from "react-dom/client";
11
import { afterEach, beforeEach, expect, it, vi } from "vite-plus/test";
12
13
import {
14
- setPendingUserInputCustomAnswer,
14
togglePendingUserInputOptionSelection,
15
type PendingUserInputDraftAnswer,
16
} from "../../pendingUserInput";
18
-import type { PendingUserInput } from "../../session-logic";
17
18
vi.mock(import("../ChatMarkdown"), async (importOriginal) => ({
19
...(await importOriginal()),
@@ -42,48 +40,17 @@ const prompt = {
40
})),
41
};
42
45
-const previewPrompt = {
46
- ...prompt,
47
- questions: prompt.questions.map((question, index) => ({
48
- ...question,
49
- options: ["First", "Second"].map((label) => ({
50
- label,
51
- value: index === 1 ? label : "same-answer",
52
- description: "",
53
- preview: `Preview body: ${label}, question ${index + 1}`,
54
- })),
55
- })),
56
-};
57
-
58
-function Questions({
59
- initialIndex = 0,
60
- pendingPrompt = prompt,
61
-}: {
62
- initialIndex?: number;
63
- pendingPrompt?: PendingUserInput;
64
-}) {
43
+function Questions({ initialIndex = 0 }: { initialIndex?: number }) {
44
const [questionIndex, setQuestionIndex] = useState(initialIndex);
45
const [answers, setAnswers] = useState<Record<string, PendingUserInputDraftAnswer>>({});
67
- const question = pendingPrompt.questions[questionIndex]!;
46
const advance = () => setQuestionIndex(questionIndex + 1);
47
return (
48
<>
49
<output>{questionIndex}</output>
50
<button onClick={advance}>Next</button>
51
<button onClick={() => setQuestionIndex(questionIndex - 1)}>Previous</button>
74
- <input
75
- aria-label="Custom answer"
76
- value={answers[question.id]?.customAnswer ?? ""}
77
- onChange={(event) => {
78
- const value = event.currentTarget.value;
79
- setAnswers((existing) => ({
80
- ...existing,
81
- [question.id]: setPendingUserInputCustomAnswer(existing[question.id], value, question),
82
- }));
83
- }}
84
- />
52
<ComposerPendingUserInputPanel
86
- pendingUserInputs={[pendingPrompt]}
53
+ pendingUserInputs={[prompt]}
54
cwd="/repo"
55
threadRef={threadRef}
56
disabled={false}
@@ -92,7 +59,7 @@ function Questions({
59
questionIndex={questionIndex}
60
onAdvance={advance}
61
onToggleOption={(questionId, value) => {
95
- const question = pendingPrompt.questions.find((entry) => entry.id === questionId)!;
62
+ const question = prompt.questions.find((entry) => entry.id === questionId)!;
63
setAnswers((existing) => ({
64
...existing,
65
[questionId]: togglePendingUserInputOptionSelection(
@@ -325,94 +292,3 @@ it("isolates drafts by environment, thread and request and discards only resolve
292
);
293
}
294
});
328
-
329
-function expectPreview(text: string | null) {
330
- const previews = [...container.querySelectorAll("p")]
331
- .map((element) => element.textContent)
332
- .filter((content) => content?.startsWith("Preview body:"));
333
- expect(previews).toEqual(text === null ? [] : [`Preview body: ${text}`]);
334
-}
335
-
336
-async function typeCustomAnswer(value: string) {
337
- const input = container.querySelector("input")!;
338
- await act(async () => {
339
- input.focus();
340
- Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, "value")!.set!.call(input, value);
341
- input.dispatchEvent(new Event("input", { bubbles: true }));
342
- });
343
-}
344
-
345
-it("previews options by focus, click, and shortcut index but only restores unambiguous saved selections", async () => {
346
- await act(async () => root.render(<Questions pendingPrompt={previewPrompt} />));
347
- expectPreview("First, question 1");
348
-
349
- await act(async () => buttonWithText("Second").focus());
350
- expectPreview("Second, question 1");
351
- await act(async () => buttonWithText("First").focus());
352
- expectPreview("First, question 1");
353
-
354
- await act(async () => buttonWithText("Second").click());
355
- expectPreview("Second, question 1");
356
- await act(async () => document.dispatchEvent(new KeyboardEvent("keydown", { key: "1" })));
357
- expectPreview("First, question 1");
358
- await act(async () => document.dispatchEvent(new KeyboardEvent("keydown", { key: "2" })));
359
- expectPreview("Second, question 1");
360
-
361
- await act(async () => vi.advanceTimersByTime(200));
362
- expect(activeIndex()).toBe("1");
363
- expectPreview("First, question 2");
364
-
365
- await act(async () => buttonWithText("Second").focus());
366
- expectPreview("Second, question 2");
367
- await act(async () =>
368
- root.render(
369
- <Questions
370
- pendingPrompt={{ ...previewPrompt, requestId: RuntimeRequestId.make("replacement") }}
371
- />,
372
- ),
373
- );
374
- expectPreview("First, question 2");
375
-
376
- await act(async () => buttonWithText("Second").click());
377
- expectPreview("Second, question 2");
378
- await navigate("Next");
379
- expectPreview("First, question 3");
380
- await navigate("Previous");
381
- expectPreview("Second, question 2");
382
-
383
- await navigate("Previous");
384
- expectPreview(null);
385
- await act(async () =>
386
- root.render(
387
- <Questions
388
- pendingPrompt={{ ...previewPrompt, requestId: RuntimeRequestId.make("remounted") }}
389
- />,
390
- ),
391
- );
392
- expectPreview(null);
393
- await act(async () => buttonWithText("Second").click());
394
- expectPreview("Second, question 1");
395
-});
396
-
397
-it("hides and clears hovered or focused previews while a custom answer is active", async () => {
398
- await act(async () => root.render(<Questions pendingPrompt={previewPrompt} />));
399
- await act(async () =>
400
- buttonWithText("Second").dispatchEvent(new MouseEvent("mouseover", { bubbles: true })),
401
- );
402
- expectPreview("Second, question 1");
403
-
404
- await typeCustomAnswer("Use a different approach");
405
- expectPreview(null);
406
- await typeCustomAnswer("");
407
- expectPreview("First, question 1");
408
-
409
- await typeCustomAnswer("Use a different approach");
410
- await act(async () => buttonWithText("Second").focus());
411
- expectPreview(null);
412
- await act(async () =>
413
- buttonWithText("Second").dispatchEvent(new MouseEvent("mouseover", { bubbles: true })),
414
- );
415
- expectPreview(null);
416
- await typeCustomAnswer("");
417
- expectPreview("First, question 1");
418
-});
apps/web/src/components/chat/ComposerPendingUserInputPanel.tsx
+4
-51
@@ -91,10 +91,6 @@ const ComposerPendingUserInputCard = memo(function ComposerPendingUserInputCard(
91
questionId: string;
92
optionValue: string;
93
} | null>(null);
94
- const [focusedOption, setFocusedOption] = useState<{
95
- questionId: string;
96
- optionIndex: number;
97
- } | null>(null);
94
const [collapsedQuestionId, setCollapsedQuestionId] = useState<string | null>(null);
95
// The active question keys the shortcut listener, so it must keep its identity across renders.
96
const progress = derivePendingUserInputProgress(prompt.questions, answers, questionIndex);
@@ -106,23 +102,6 @@ const ComposerPendingUserInputCard = memo(function ComposerPendingUserInputCard(
102
!customAnswerActive && progress.selectedOptionValues.includes(option.value ?? option.label),
103
);
104
const isCollapsed = collapsedQuestionId !== null && collapsedQuestionId === activeQuestion?.id;
109
- const selectedOptionValue = progress.selectedOptionValues.at(-1);
110
- const savedOptionMatches = activeQuestion?.options.filter(
111
- (option) => (option.value ?? option.label) === selectedOptionValue,
112
- );
113
- const previewOption = customAnswerActive
114
- ? undefined
115
- : focusedOption && focusedOption.questionId === activeQuestion?.id
116
- ? activeQuestion?.options[focusedOption.optionIndex]
117
- : selectedOptionValue === undefined
118
- ? activeQuestion?.options[0]
119
- : savedOptionMatches?.length === 1
120
- ? savedOptionMatches[0]
121
- : undefined;
122
-
123
- if (focusedOption && (focusedOption.questionId !== activeQuestion?.id || customAnswerActive)) {
124
- setFocusedOption(null);
125
- }
105
106
// The optimistic pick is dropped once the draft confirms it or the question moves on.
107
if (
@@ -148,9 +127,8 @@ const ComposerPendingUserInputCard = memo(function ComposerPendingUserInputCard(
127
return clearAutoAdvance;
128
}, [activeQuestion?.id, disabled]);
129
151
- const handleOptionSelection = (questionId: string, optionValue: string, optionIndex: number) => {
130
+ const handleOptionSelection = (questionId: string, optionValue: string) => {
131
if (disabled || isResponding) return;
153
- setFocusedOption({ questionId, optionIndex });
132
if (activeQuestion?.multiSelect) {
133
onToggleOption(questionId, optionValue);
134
return;
@@ -189,7 +167,7 @@ const ComposerPendingUserInputCard = memo(function ComposerPendingUserInputCard(
167
const option = activeQuestion.options[optionIndex];
168
if (!option) return;
169
event.preventDefault();
192
- selectOptionFromShortcut(activeQuestion.id, option.value ?? option.label, optionIndex);
170
+ selectOptionFromShortcut(activeQuestion.id, option.value ?? option.label);
171
};
172
document.addEventListener("keydown", handler);
173
return () => document.removeEventListener("keydown", handler);
@@ -305,19 +283,11 @@ const ComposerPendingUserInputCard = memo(function ComposerPendingUserInputCard(
283
);
284
return (
285
<button
308
- // Options keep their positions within a question and may share answer values.
309
- // oxlint-disable-next-line react/no-array-index-key
310
- key={`${activeQuestion.id}:${index}`}
286
+ key={`${activeQuestion.id}:${optionValue}`}
287
type="button"
288
disabled={disabled || isResponding}
313
- onMouseEnter={() =>
314
- setFocusedOption({ questionId: activeQuestion.id, optionIndex: index })
315
- }
316
- onFocus={() =>
317
- setFocusedOption({ questionId: activeQuestion.id, optionIndex: index })
318
- }
289
onClick={() => {
320
- handleOptionSelection(activeQuestion.id, optionValue, index);
290
+ handleOptionSelection(activeQuestion.id, optionValue);
291
}}
292
className={className}
293
>
@@ -326,23 +296,6 @@ const ComposerPendingUserInputCard = memo(function ComposerPendingUserInputCard(
296
);
297
})}
298
</div>
329
- {previewOption?.preview?.trim() ? (
330
- <section
331
- aria-label={`Preview: ${previewOption.label}`}
332
- className="mt-2 min-w-0 rounded-md border border-border/60 bg-muted/25 p-2.5"
333
- >
334
- <p className="mb-1.5 text-3xs font-medium text-muted-foreground">
335
- Preview · {previewOption.label}
336
- </p>
337
- <ChatMarkdown
338
- key={`${activeQuestion.id}:${activeQuestion.options.indexOf(previewOption)}`}
339
- text={previewOption.preview}
340
- cwd={cwd}
341
- threadRef={threadRef}
342
- parseRawHtml={false}
343
- />
344
- </section>
345
- ) : null}
299
</ComposerBanner.Body>
300
</ComposerBanner.Scroll>
301
</CollapsiblePanel>
apps/web/src/pendingUserInput.ts
+1
-2
@@ -1,5 +1,4 @@
1
-import type { ThreadContextRecord } from "@t3tools/contracts";
2
-import type { ThreadUserInputQuestion as UserInputQuestion } from "@t3tools/client-runtime/state/thread-requests";
1
+import type { ThreadContextRecord, UserInputQuestion } from "@t3tools/contracts";
2
import { replaceComposerContextReferences } from "@t3tools/shared/composerContextReferences";
3
import { formatThreadLink } from "@t3tools/shared/threadLinks";
4