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

Function ConnectDialog

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

Source from the content-addressed store, hash-verified

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