77 derivePendingUserInputProgress ,
88 type PendingUserInputDraftAnswer ,
99} from "../../pendingUserInput" ;
10- import { CheckIcon } from "lucide-react " ;
10+ import { CheckboxMark } from "../ui/checkbox " ;
1111import { Collapsible , CollapsiblePanel , CollapsibleTrigger } from "../ui/collapsible" ;
12+ import { Kbd } from "../ui/kbd" ;
1213import { cn } from "~/lib/utils" ;
1314import { ComposerBanner } from "./ComposerBanner" ;
1415import ChatMarkdown from "../ChatMarkdown" ;
@@ -189,23 +190,24 @@ const ComposerPendingUserInputCard = memo(function ComposerPendingUserInputCard(
189190 isCollapsed ? "Show the question and its options" : "Hide the question and its options"
190191 }
191192 data-pending-user-input-toggle = { isCollapsed ? "collapsed" : "expanded" }
193+ className = "px-4 pt-1.5"
192194 >
193- < ComposerBanner . Icon />
194195 < ComposerBanner . Content >
195- < span className = "shrink-0 font-medium text-muted-foreground" >
196- { activeQuestion . header }
197- </ span >
196+ < span className = "shrink-0 text-muted-foreground" > { activeQuestion . header } </ span >
198197 { isCollapsed ? (
199- < span className = "min-w-0 flex-1 truncate text-secondary-label" >
200- { activeQuestion . question }
201- </ span >
198+ < >
199+ < ComposerBanner . Separator />
200+ < span className = "min-w-0 flex-1 truncate text-secondary-label" >
201+ { activeQuestion . question }
202+ </ span >
203+ </ >
202204 ) : null }
203205 </ ComposerBanner . Content >
204- < ComposerBanner . Actions >
206+ < ComposerBanner . Actions className = "gap-0" >
205207 { prompt . questions . length > 1 ? (
206- < span className = "text-3xs font-medium text-muted-foreground tabular-nums" >
208+ < ComposerBanner . Count >
207209 { questionIndex + 1 } /{ prompt . questions . length }
208- </ span >
210+ </ ComposerBanner . Count >
209211 ) : null }
210212 < ComposerBanner . ToggleIcon expanded = { ! isCollapsed } />
211213 { prompt . dismissible ? (
@@ -232,58 +234,56 @@ const ComposerPendingUserInputCard = memo(function ComposerPendingUserInputCard(
232234 </ CollapsibleTrigger >
233235 < CollapsiblePanel >
234236 < ComposerBanner . Scroll >
235- < ComposerBanner . Body className = "pe-1 pb-1 wrap-anywhere" >
237+ < ComposerBanner . Body className = "ps-6 pe-4 pb-1 wrap-anywhere sm:ps-5.5 " >
236238 < ChatMarkdown
237239 text = { activeQuestion . question }
238240 cwd = { cwd }
239241 threadRef = { threadRef }
240- className = "text-foreground/85"
242+ className = "pt-2 text-foreground/85"
241243 />
242- { activeQuestion . multiSelect ? (
243- < p className = "mt-1 text-secondary-label text-xs" > Select one or more options.</ p >
244- ) : null }
245- < div className = "mt-2 space-y-0.5" >
244+ { /* Rows span the header row's width so the radios align with the question text and the shortcut column sits under the dismiss button. */ }
245+ < div className = "-ms-2 mt-1.5 sm:-ms-1.5" >
246246 { activeQuestion . options . map ( ( option , index ) => {
247247 const optionValue = option . value ?? option . label ;
248248 const isOptimisticallySelected =
249249 optimisticSingleSelect ?. questionId === activeQuestion . id &&
250250 optimisticSingleSelect . optionValue === optionValue ;
251251 const isSelected =
252252 isOptimisticallySelected || draftSelectedOptions ?. [ index ] === true ;
253- const shortcutKey = index < 9 ? index + 1 : null ;
254253 const className = cn (
255- "group flex w-full items-center gap-2 rounded-md px-2.5 py-2 text-left outline-none transition-colors duration-150 focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-primary/25" ,
256- isSelected
257- ? "bg-muted/55 text-foreground"
258- : "bg-transparent text-foreground/85 hover:bg-muted/30" ,
254+ "group flex w-full items-start gap-2.5 rounded-md bg-transparent py-1.5 ps-2 text-left sm:ps-1.5 outline-none transition-colors duration-150 focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-primary/25" ,
255+ isSelected ? "text-foreground" : "text-foreground/70 hover:bg-muted/30" ,
259256 ( disabled || isResponding ) && "opacity-50 cursor-not-allowed" ,
260257 ! disabled && ! isResponding && "cursor-pointer" ,
261258 ) ;
259+ // The h-5 slots match the label's line box, so the indicator and shortcut stay on its first line.
262260 const content = (
263261 < >
262+ < span className = "pointer-events-none flex h-5 shrink-0 items-center" >
263+ { activeQuestion . multiSelect ? (
264+ < CheckboxMark checked = { isSelected } />
265+ ) : (
266+ < OptionRadio checked = { isSelected } />
267+ ) }
268+ </ span >
264269 < div className = "min-w-0 flex-1 flex flex-col gap-0.5" >
265270 < span className = "text-sm font-medium" > { option . label } </ span >
266271 { option . description && option . description !== option . label ? (
267272 < span className = "text-secondary-label text-2xs" > { option . description } </ span >
268273 ) : null }
269274 </ div >
270- { isSelected ? (
271- < CheckIcon className = "size-3.5 shrink-0 text-primary" />
272- ) : shortcutKey !== null ? (
273- < kbd
274- className = { cn (
275- "flex size-5 shrink-0 items-center justify-center text-3xs font-medium text-muted-foreground tabular-nums" ,
276- ) }
277- >
278- { shortcutKey }
279- </ kbd >
275+ { index < 9 ? (
276+ < span className = "flex h-5 w-7 shrink-0 items-center justify-center sm:w-6" >
277+ < Kbd > { index + 1 } </ Kbd >
278+ </ span >
280279 ) : null }
281280 </ >
282281 ) ;
283282 return (
284283 < button
285284 key = { `${ activeQuestion . id } :${ optionValue } ` }
286285 type = "button"
286+ aria-pressed = { isSelected }
287287 disabled = { disabled || isResponding }
288288 onClick = { ( ) => {
289289 handleOptionSelection ( activeQuestion . id , optionValue ) ;
@@ -301,3 +301,21 @@ const ComposerPendingUserInputCard = memo(function ComposerPendingUserInputCard(
301301 </ Collapsible >
302302 ) ;
303303} ) ;
304+
305+ // Drawn with ui/radio-group's look instead of using its Radio: Radio only checks inside a
306+ // RadioGroup, whose arrow keys select options and would trip the single-select auto-advance.
307+ function OptionRadio ( { checked } : { checked : boolean } ) {
308+ return (
309+ < span
310+ aria-hidden
311+ className = { cn (
312+ "relative inline-flex size-4.5 shrink-0 items-center justify-center rounded-full border border-input bg-background not-dark:bg-clip-padding sm:size-4 dark:bg-input/32" ,
313+ checked ? "shadow-none" : "shadow-xs/5" ,
314+ ) }
315+ >
316+ { checked ? (
317+ < span className = "-inset-px absolute flex items-center justify-center rounded-full bg-primary before:size-2 before:rounded-full before:bg-primary-foreground sm:before:size-1.5" />
318+ ) : null }
319+ </ span >
320+ ) ;
321+ }
0 commit comments