MCPcopy Index your code
hub / github.com/codeaashu/claude-code / ElicitationFormDialog

Function ElicitationFormDialog

src/components/mcp/ElicitationDialog.tsx:143–983  ·  view source on GitHub ↗
({
  event,
  onResponse
}: {
  event: ElicitationRequestEvent;
  onResponse: Props['onResponse'];
})

Source from the content-addressed store, hash-verified

141 return t1;
142}
143function ElicitationFormDialog({
144 event,
145 onResponse
146}: {
147 event: ElicitationRequestEvent;
148 onResponse: Props['onResponse'];
149}): React.ReactNode {
150 const {
151 serverName,
152 signal
153 } = event;
154 const request = event.params as ElicitRequestFormParams;
155 const {
156 message,
157 requestedSchema
158 } = request;
159 const hasFields = Object.keys(requestedSchema.properties).length > 0;
160 const [focusedButton, setFocusedButton] = useState<'accept' | 'decline' | null>(hasFields ? null : 'accept');
161 const [formValues, setFormValues] = useState<Record<string, string | number | boolean | string[]>>(() => {
162 const initialValues: Record<string, string | number | boolean | string[]> = {};
163 if (requestedSchema.properties) {
164 for (const [propName, propSchema] of Object.entries(requestedSchema.properties)) {
165 if (typeof propSchema === 'object' && propSchema !== null) {
166 if (propSchema.default !== undefined) {
167 initialValues[propName] = propSchema.default;
168 }
169 }
170 }
171 }
172 return initialValues;
173 });
174 const [validationErrors, setValidationErrors] = useState<Record<string, string>>(() => {
175 const initialErrors: Record<string, string> = {};
176 for (const [propName_0, propSchema_0] of Object.entries(requestedSchema.properties)) {
177 if (isTextField(propSchema_0) && propSchema_0?.default !== undefined) {
178 const validation = validateElicitationInput(String(propSchema_0.default), propSchema_0);
179 if (!validation.isValid && validation.error) {
180 initialErrors[propName_0] = validation.error;
181 }
182 }
183 }
184 return initialErrors;
185 });
186 useEffect(() => {
187 if (!signal) return;
188 const handleAbort = () => {
189 onResponse('cancel');
190 };
191 if (signal.aborted) {
192 handleAbort();
193 return;
194 }
195 signal.addEventListener('abort', handleAbort);
196 return () => {
197 signal.removeEventListener('abort', handleAbort);
198 };
199 }, [signal, onResponse]);
200 const schemaFields = useMemo(() => {

Callers

nothing calls this directly

Calls 15

isTextFieldFunction · 0.85
validateElicitationInputFunction · 0.85
handleAbortFunction · 0.85
useTerminalSizeFunction · 0.85
isEnumSchemaFunction · 0.85
useRegisterOverlayFunction · 0.85
useNotifyAfterTimeoutFunction · 0.85
useKeybindingFunction · 0.85
useInputFunction · 0.85
isMultiSelectEnumSchemaFunction · 0.85
getMultiSelectValuesFunction · 0.85
validateMultiSelectFunction · 0.85

Tested by

no test coverage detected