MCPcopy
hub / github.com/kagent-dev/kagent / toggleChoice

Function toggleChoice

ui/src/components/chat/AskUserDisplay.tsx:53–69  ·  view source on GitHub ↗
(qIdx: number, choice: string)

Source from the content-addressed store, hash-verified

51 const [isSubmitting, setIsSubmitting] = useState(false);
52
53 const toggleChoice = (qIdx: number, choice: string) => {
54 if (isResolved || isSubmitting || !onSubmit) return;
55 setSelectedChoices(prev => {
56 const next = prev.map(s => [...s]);
57 const q = questions[qIdx];
58 const isMultiple = q.multiple ?? false;
59 if (next[qIdx].includes(choice)) {
60 next[qIdx] = next[qIdx].filter(c => c !== choice);
61 } else if (isMultiple) {
62 next[qIdx] = [...next[qIdx], choice];
63 } else {
64 // Single-select: deselect others
65 next[qIdx] = [choice];
66 }
67 return next;
68 });
69 };
70
71 const setFreeText = (qIdx: number, value: string) => {
72 setFreeTextAnswers(prev => {

Callers 1

AskUserDisplayFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected