MCPcopy Create free account
hub / github.com/tiann/hapi / AskUserQuestionView

Function AskUserQuestionView

web/src/components/ToolCard/views/AskUserQuestionView.tsx:118–176  ·  view source on GitHub ↗
(props: ToolViewProps)

Source from the content-addressed store, hash-verified

116}
117
118export function AskUserQuestionView(props: ToolViewProps) {
119 const parsed = isCursorAskQuestionToolName(props.block.tool.name)
120 ? parseCursorAskQuestionInput(props.block.tool.input)
121 : parseAskUserQuestionInput(props.block.tool.input)
122 const questions = parsed.questions
123 const rawAnswers = props.block.tool.permission?.answers ?? undefined
124 const answers = normalizeAnswers(rawAnswers)
125 const hasAnswers = answers && Object.keys(answers).length > 0
126
127 // When questions array is empty but answers exist (fallback path),
128 // render the answers directly
129 if (questions.length === 0) {
130 if (hasAnswers && answers) {
131 return renderFreeformAnswers(answers, 0)
132 }
133 return null
134 }
135
136 return (
137 <div className="flex flex-col gap-4">
138 {questions.map((q, idx) => {
139 const isMulti = q.multiSelect
140
141 return (
142 <div key={idx} className="flex flex-col gap-3">
143 {q.question ? (
144 <div className={askUserQuestionQuoteClassName}>
145 <MarkdownRenderer content={q.question} />
146 </div>
147 ) : null}
148
149 {q.options.length > 0 ? (
150 <div className="flex flex-col gap-1.5">
151 {q.options.map((opt, optIdx) => {
152 const isSelected = isAnswerSelected(answers, idx, opt.label)
153 return (
154 <AnswerOptionCard
155 key={optIdx}
156 isMulti={isMulti}
157 isSelected={isSelected}
158 title={opt.label}
159 description={opt.description ?? undefined}
160 showControl={Boolean(hasAnswers)}
161 />
162 )
163 })}
164
165 {hasAnswers && renderOtherAnswers(answers, idx, q.options, isMulti)}
166 </div>
167 ) : hasAnswers && answers ? (
168 // Freeform question (no options) - show the answer directly
169 renderFreeformAnswers(answers, idx)
170 ) : null}
171 </div>
172 )
173 })}
174 </div>
175 )

Callers

nothing calls this directly

Calls 7

normalizeAnswersFunction · 0.85
renderFreeformAnswersFunction · 0.85
isAnswerSelectedFunction · 0.85
renderOtherAnswersFunction · 0.85

Tested by

no test coverage detected