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

Function ConnectDialog

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

Source from the content-addressed store, hash-verified

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