Skip to content

Commit b8a829f

Browse files
committed
fix(web): question options show their shortcut key, aligned with the header
1 parent 5fb26b9 commit b8a829f

1 file changed

Lines changed: 19 additions & 12 deletions

File tree

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

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
} from "../../pendingUserInput";
99
import { Checkbox } from "../ui/checkbox";
1010
import { Collapsible, CollapsiblePanel, CollapsibleTrigger } from "../ui/collapsible";
11+
import { Kbd } from "../ui/kbd";
1112
import { cn } from "~/lib/utils";
1213
import { ComposerBanner } from "./ComposerBanner";
1314
import ChatMarkdown from "../ChatMarkdown";
@@ -191,7 +192,6 @@ const ComposerPendingUserInputCard = memo(function ComposerPendingUserInputCard(
191192
}
192193
data-pending-user-input-toggle={isCollapsed ? "collapsed" : "expanded"}
193194
>
194-
<ComposerBanner.Icon />
195195
<ComposerBanner.Content>
196196
<span className="shrink-0 font-medium text-muted-foreground">
197197
{activeQuestion.header}
@@ -204,9 +204,9 @@ const ComposerPendingUserInputCard = memo(function ComposerPendingUserInputCard(
204204
</ComposerBanner.Content>
205205
<ComposerBanner.Actions>
206206
{prompt.questions.length > 1 ? (
207-
<span className="text-3xs font-medium text-muted-foreground tabular-nums">
207+
<ComposerBanner.Count>
208208
{questionIndex + 1}/{prompt.questions.length}
209-
</span>
209+
</ComposerBanner.Count>
210210
) : null}
211211
<ComposerBanner.ToggleIcon expanded={!isCollapsed} />
212212
{prompt.dismissible ? (
@@ -233,7 +233,7 @@ const ComposerPendingUserInputCard = memo(function ComposerPendingUserInputCard(
233233
</CollapsibleTrigger>
234234
<CollapsiblePanel>
235235
<ComposerBanner.Scroll>
236-
<ComposerBanner.Body className="pe-1 pb-1 wrap-anywhere">
236+
<ComposerBanner.Body className="ps-2 pb-1 wrap-anywhere sm:ps-1.5">
237237
<ChatMarkdown
238238
text={activeQuestion.question}
239239
cwd={cwd}
@@ -243,7 +243,8 @@ const ComposerPendingUserInputCard = memo(function ComposerPendingUserInputCard(
243243
{activeQuestion.multiSelect ? (
244244
<p className="mt-1 text-secondary-label text-xs">Select one or more options.</p>
245245
) : null}
246-
<div className="mt-2 space-y-0.5">
246+
{/* Rows span the header row's width so the radios align with the question text and the shortcut column sits under the dismiss button. */}
247+
<div className="-ms-2 mt-2 space-y-0.5 sm:-ms-1.5">
247248
{activeQuestion.options.map((option, index) => {
248249
const optionValue = option.value ?? option.label;
249250
const isOptimisticallySelected =
@@ -252,26 +253,32 @@ const ComposerPendingUserInputCard = memo(function ComposerPendingUserInputCard(
252253
const isSelected =
253254
isOptimisticallySelected || draftSelectedOptions?.[index] === true;
254255
const className = cn(
255-
"group flex w-full items-center gap-2.5 rounded-md bg-transparent 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+
"group flex w-full items-start gap-2.5 rounded-md bg-transparent py-2 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",
256257
isSelected ? "text-foreground" : "text-foreground/70 hover:bg-muted/30",
257258
(disabled || isResponding) && "opacity-50 cursor-not-allowed",
258259
!disabled && !isResponding && "cursor-pointer",
259260
);
261+
// The h-5 slots match the label's line box, so the indicator and shortcut stay on its first line.
260262
const content = (
261263
<>
262-
{activeQuestion.multiSelect ? (
263-
<span className="pointer-events-none flex">
264+
<span className="pointer-events-none flex h-5 shrink-0 items-center">
265+
{activeQuestion.multiSelect ? (
264266
<Checkbox checked={isSelected} tabIndex={-1} aria-hidden />
265-
</span>
266-
) : (
267-
<OptionRadio checked={isSelected} />
268-
)}
267+
) : (
268+
<OptionRadio checked={isSelected} />
269+
)}
270+
</span>
269271
<div className="min-w-0 flex-1 flex flex-col gap-0.5">
270272
<span className="text-sm font-medium">{option.label}</span>
271273
{option.description && option.description !== option.label ? (
272274
<span className="text-secondary-label text-2xs">{option.description}</span>
273275
) : null}
274276
</div>
277+
{index < 9 ? (
278+
<span className="flex h-5 w-7 shrink-0 items-center justify-center sm:w-6">
279+
<Kbd>{index + 1}</Kbd>
280+
</span>
281+
) : null}
275282
</>
276283
);
277284
return (

0 commit comments

Comments
 (0)