MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / ConnectDialog

Function ConnectDialog

packages/react/src/pages/integrations.tsx:167–308  ·  view source on GitHub ↗
(props: { open: boolean; onOpenChange: (open: boolean) => void })

Source from the content-addressed store, hash-verified

165};
166
167export function ConnectDialog(props: { open: boolean; onOpenChange: (open: boolean) => void }) {
168 const integrationPlugins = useIntegrationPlugins();
169 const doDetect = useAtomSet(detectIntegration, { mode: "promiseExit" });
170 const navigate = useNavigate();
171
172 const [query, setQuery] = useState("");
173 const [detecting, setDetecting] = useState(false);
174 const [error, setError] = useState<string | null>(null);
175
176 const isUrl = looksLikeUrl(query);
177 const presetSearch = isUrl ? "" : query;
178
179 const closeAndReset = useCallback(() => {
180 setQuery("");
181 setError(null);
182 setDetecting(false);
183 props.onOpenChange(false);
184 }, [props]);
185
186 const handleDetect = useCallback(async () => {
187 const trimmed = query.trim();
188 if (!trimmed) return;
189 setDetecting(true);
190 setError(null);
191 // Detection is read-only — it inspects a URL and returns candidates without
192 // mutating the catalog, so it invalidates nothing.
193 const exit = await doDetect({
194 payload: { url: trimmed },
195 reactivityKeys: [],
196 });
197 if (Exit.isFailure(exit)) {
198 trackEvent("integration_detect_submitted", { success: false });
199 setError("Detection failed. Try adding an integration manually.");
200 setDetecting(false);
201 return;
202 }
203 const results = exit.value;
204 if (results.length === 0) {
205 trackEvent("integration_detect_submitted", { success: false });
206 setError("Could not detect an integration type from this URL. Try adding manually.");
207 setDetecting(false);
208 return;
209 }
210 const detected = bestDetection(results);
211 if (!detected) {
212 trackEvent("integration_detect_submitted", { success: false });
213 setError("Could not detect an integration type from this URL. Try adding manually.");
214 setDetecting(false);
215 return;
216 }
217 trackEvent("integration_detect_submitted", {
218 success: true,
219 detected_kind: detected.kind,
220 confidence: detected.confidence,
221 });
222 const pluginKey = KIND_TO_PLUGIN_KEY[detected.kind] ?? detected.kind;
223 if (integrationPlugins.some((p) => p.key === pluginKey)) {
224 trackEvent("integration_add_started", { plugin_key: pluginKey, via: "detect" });

Callers

nothing calls this directly

Calls 4

useIntegrationPluginsFunction · 0.90
trackEventFunction · 0.90
looksLikeUrlFunction · 0.85
bestDetectionFunction · 0.85

Tested by

no test coverage detected