Enhanced ChatGPT Clone: Features Agents, MCP, Skills, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini, Artifacts, AI model switching, message search, Code Interpreter, langchain, DALL-E-3, OpenAPI Actions, Functions, Secure Multi-User Auth, Presets, open-source for self-hosting. Active
TypeScript aianthropicartifactsawsazurechatgptchatgpt-cloneclaudeclonedeepseekgeminigooglegpt-5librechatmcpo1openairesponses-apivisionwebui
import { Check } from 'lucide-react';
import { cn, Button } from '@librechat/client';
import type { ReactNode } from 'react';
export interface AskOption {
label: string;
value: string;
}
/**
* The single option-row list shared by every `ask_user_question` surface
* (composer popover and chat card), so the same question looks and behaves
* identically wherever it renders. Numbered badges double as the popover's
* digit shortcuts; multi-select swaps the number for a check.
*
* Hover, focus-visible and disabled appearance come from the shared `Button`
* primitive rather than being recreated here, so these rows cannot drift from
* it. Only the row geometry and the selected fill stay local, both on
* semantic roles so a customized theme moves them too.
*/
export default function AskOptions({
options,
multiSelect,
checked,
selected,
selectedIsAnswer = false,
locked,
onActivate,
optionRefs,
listRef,
className,
}: {
options: AskOption[];
multiSelect: boolean;
checked: number[];
selected?: number | null;
/** `selected` is the recorded answer rather than a keyboard highlight, so a
* single-select row announces it as pressed. */
selectedIsAnswer?: boolean;
locked: boolean;
onActivate: (index: number) => void;
optionRefs?: React.MutableRefObject<(HTMLButtonElement | null)[]>;
listRef?: React.RefObject<HTMLDivElement>;
className?: string;
}): ReactNode {
return (
<div ref={listRef} className={className}>
{options.map((option, index) => {
/** A recorded single-select answer wears the same check as a ticked
* multi-select row; a keyboard highlight keeps its number. */
const isChecked = multiSelect
? checked.includes(index)
: selectedIsAnswer && selected === index;
return (
<Button
key={option.value}
ref={(el) => {
if (optionRefs) {
optionRefs.current[index] = el;
}
}}
variant="option"
data-selected={selected === index || undefined}
role={multiSelect ? 'checkbox' : undefined}
aria-checked={multiSelect ? isChecked : undefined}
aria-pressed={!multiSelect && selectedIsAnswer ? selected === index : undefined}
disabled={locked}
onClick={() => onActivate(index)}
>
<span
className={cn(
'text-2xs flex size-5 shrink-0 items-center justify-center rounded-md font-medium tabular-nums',
isChecked
? 'bg-surface-submit text-text-on-status'
: 'bg-surface-tertiary text-text-secondary',
)}
>
{isChecked ? <Check className="size-3.5" aria-hidden="true" /> : index + 1}
</span>
<span className="min-w-0 flex-1 [overflow-wrap:anywhere]">{option.label}</span>
</Button>
);
})}
</div>
);
}