Skip to content

Commit 0896472

Browse files
fix(clients): Claude question option previews are shown under their option
AskUserQuestion option previews reached the client but neither the web question card nor the mobile card rendered them. Each preview is now shown as Markdown under its option, always visible, so nothing changes height on hover. Fixes #33127 AI-assisted; verified with the tests and tools listed above.
1 parent a4a779b commit 0896472

3 files changed

Lines changed: 73 additions & 51 deletions

File tree

‎apps/mobile/src/features/threads/PendingUserInputCard.tsx‎

Lines changed: 46 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -279,43 +279,55 @@ export function PendingUserInputCard(props: PendingUserInputCardProps) {
279279
const description =
280280
option.description !== option.label ? option.description : undefined;
281281
return (
282-
<Pressable
283-
key={optionValue}
284-
accessibilityRole={question.multiSelect ? "checkbox" : "radio"}
285-
accessibilityState={{ checked: selected, disabled: responseDisabled }}
286-
disabled={responseDisabled}
287-
className={cn(
288-
"min-h-12 w-full rounded-2xl border px-3.5 py-3",
289-
selected ? "border-primary bg-primary/10" : "border-border bg-input",
290-
)}
291-
onPress={() =>
292-
props.onSelectOption(
293-
props.pendingUserInput.requestId,
294-
question,
295-
optionValue,
296-
)
297-
}
298-
>
299-
<View className="min-w-0 flex-1 gap-0.5">
300-
<Text
301-
className={cn(
302-
"font-t3-bold text-sm",
303-
selected ? "text-foreground" : "text-foreground-secondary",
304-
)}
305-
style={proseDirectionStyle(option.label, setDirection)}
306-
>
307-
{option.label}
308-
</Text>
309-
{description ? (
282+
<View key={optionValue} className="gap-1.5">
283+
<Pressable
284+
accessibilityRole={question.multiSelect ? "checkbox" : "radio"}
285+
accessibilityState={{ checked: selected, disabled: responseDisabled }}
286+
disabled={responseDisabled}
287+
className={cn(
288+
"min-h-12 w-full rounded-2xl border px-3.5 py-3",
289+
selected ? "border-primary bg-primary/10" : "border-border bg-input",
290+
)}
291+
onPress={() =>
292+
props.onSelectOption(
293+
props.pendingUserInput.requestId,
294+
question,
295+
optionValue,
296+
)
297+
}
298+
>
299+
<View className="min-w-0 flex-1 gap-0.5">
310300
<Text
311-
className="font-sans text-sm leading-5 text-foreground-muted"
312-
style={proseDirectionStyle(description, setDirection)}
301+
className={cn(
302+
"font-t3-bold text-sm",
303+
selected ? "text-foreground" : "text-foreground-secondary",
304+
)}
305+
style={proseDirectionStyle(option.label, setDirection)}
313306
>
314-
{description}
307+
{option.label}
315308
</Text>
316-
) : null}
317-
</View>
318-
</Pressable>
309+
{description ? (
310+
<Text
311+
className="font-sans text-sm leading-5 text-foreground-muted"
312+
style={proseDirectionStyle(description, setDirection)}
313+
>
314+
{description}
315+
</Text>
316+
) : null}
317+
</View>
318+
</Pressable>
319+
{option.preview ? (
320+
<View className="px-3.5">
321+
<QuestionText
322+
markdown={option.preview}
323+
environmentId={props.environmentId}
324+
threadId={props.threadId}
325+
workspaceRoot={props.workspaceRoot}
326+
setDirection={setDirection}
327+
/>
328+
</View>
329+
) : null}
330+
</View>
319331
);
320332
})}
321333
</View>

‎apps/web/src/components/chat/ComposerPendingUserInputPanel.tsx‎

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -310,19 +310,29 @@ const ComposerPendingUserInputCard = memo(function ComposerPendingUserInputCard(
310310
) : null}
311311
</>
312312
);
313+
// The preview sits outside the button: it can hold links, and a click on a single-select option advances.
313314
return (
314-
<button
315-
key={`${activeQuestion.id}:${optionValue}`}
316-
type="button"
317-
aria-pressed={isSelected}
318-
disabled={disabled || isResponding}
319-
onClick={() => {
320-
handleOptionSelection(activeQuestion.id, optionValue);
321-
}}
322-
className={className}
323-
>
324-
{content}
325-
</button>
315+
<div key={`${activeQuestion.id}:${optionValue}`}>
316+
<button
317+
type="button"
318+
aria-pressed={isSelected}
319+
disabled={disabled || isResponding}
320+
onClick={() => {
321+
handleOptionSelection(activeQuestion.id, optionValue);
322+
}}
323+
className={className}
324+
>
325+
{content}
326+
</button>
327+
{option.preview ? (
328+
<ChatMarkdown
329+
text={option.preview}
330+
cwd={cwd}
331+
threadRef={threadRef}
332+
className="ps-9 pe-2 pb-1.5 text-xs text-foreground/70 sm:ps-8"
333+
/>
334+
) : null}
335+
</div>
326336
);
327337
})}
328338
</div>

‎apps/web/src/pendingUserInput.ts‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ export function threadContextsReferencedByAnswer(
3232
return threadContexts.filter((record) => referencedIds.has(record.contextId));
3333
}
3434

35-
export interface PendingUserInputProgress {
35+
export interface PendingUserInputProgress<Q extends UserInputQuestion = UserInputQuestion> {
3636
questionIndex: number;
37-
activeQuestion: UserInputQuestion | null;
37+
activeQuestion: Q | null;
3838
activeDraft: PendingUserInputDraftAnswer | undefined;
3939
selectedOptionValues: ReadonlyArray<string>;
4040
customAnswer: string;
@@ -73,11 +73,11 @@ function countAnsweredPendingUserInputQuestions(
7373
}, 0);
7474
}
7575

76-
export function derivePendingUserInputProgress(
77-
questions: ReadonlyArray<UserInputQuestion>,
76+
export function derivePendingUserInputProgress<Q extends UserInputQuestion>(
77+
questions: ReadonlyArray<Q>,
7878
draftAnswers: Record<string, PendingUserInputDraftAnswer>,
7979
questionIndex: number,
80-
): PendingUserInputProgress {
80+
): PendingUserInputProgress<Q> {
8181
const normalizedQuestionIndex =
8282
questions.length === 0 ? 0 : Math.max(0, Math.min(questionIndex, questions.length - 1));
8383
const activeQuestion = questions[normalizedQuestionIndex] ?? null;

0 commit comments

Comments
 (0)