@devicai/ui 0.44.0 → 0.46.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,8 @@
1
- import { jsx, jsxs } from 'react/jsx-runtime';
2
- import { useState, useMemo, useRef, useEffect, useCallback } from 'react';
1
+ import { jsxs, jsx } from 'react/jsx-runtime';
2
+ import { useState, useMemo, useEffect, useRef, useCallback } from 'react';
3
3
  import { createPortal } from 'react-dom';
4
4
  import { isDarkTheme, themeVars } from '../theme.js';
5
+ import { ConnectFieldsForm } from './ConnectFieldsForm.js';
5
6
  import { IntegrationLogo } from './IntegrationLogo.js';
6
7
  import { useIntegrations } from './useIntegrations.js';
7
8
 
@@ -35,6 +36,21 @@ function accountLabel(account) {
35
36
  return account.status.toLowerCase();
36
37
  return `connected ${when.toLocaleDateString()}`;
37
38
  }
39
+ /**
40
+ * The scheme the server would pick, given no explicit choice: the one asking
41
+ * for least setup.
42
+ *
43
+ * Mirrors the engine's own preference deliberately. It is only used to decide
44
+ * whether to open a popup or a form before asking, and being wrong is
45
+ * recoverable — the form sends its scheme explicitly, and a redirect that
46
+ * arrives anyway is still honoured.
47
+ */
48
+ function preferredScheme(schemes) {
49
+ if (!schemes?.length)
50
+ return undefined;
51
+ const friction = (s) => (s.composioManaged ? 0 : 1);
52
+ return [...schemes].sort((a, b) => friction(a) - friction(b))[0];
53
+ }
38
54
  function matches(integration, query) {
39
55
  const q = query.trim().toLowerCase();
40
56
  if (!q)
@@ -78,8 +94,48 @@ function IntegrationsModal({ isOpen, onClose, assistantId, tenantId, subtenantId
78
94
  const [busyApp, setBusyApp] = useState(null);
79
95
  /** Authorization URL surfaced as a link when the popup was blocked. */
80
96
  const [blockedUrl, setBlockedUrl] = useState(null);
97
+ /** The app whose credentials are being asked for, and every way it can be
98
+ * connected. `setup` is present when the server named what was missing. */
99
+ const [setupPrompt, setSetupPrompt] = useState(null);
100
+ /**
101
+ * How each offered app can be connected, read once the listing arrives.
102
+ *
103
+ * Loaded ahead of the click rather than on it: knowing whether an app needs
104
+ * a browser is what decides between opening a popup and opening a form, and
105
+ * that decision has to be made *inside* the user's gesture — a popup opened
106
+ * after an await is blocked.
107
+ */
108
+ const [authByApp, setAuthByApp] = useState({});
109
+ /** Failure from the last submit, shown inside the credentials dialog. */
110
+ const [formError, setFormError] = useState(null);
81
111
  const [query, setQuery] = useState("");
82
112
  const visible = useMemo(() => integrations.filter((i) => matches(i, query)), [integrations, query]);
113
+ // Resolved from the listing rather than stored in the prompt: the dialog
114
+ // stays open across a refresh, and a copy taken when it opened would go
115
+ // stale — showing "Not connected" on an app that just connected.
116
+ const promptIntegration = useMemo(() => integrations.find((i) => i.app === setupPrompt?.app), [integrations, setupPrompt?.app]);
117
+ // One request per offered app, once the listing is in. They are small,
118
+ // cached server-side, and nothing waits on them: a click that lands before
119
+ // its answer simply falls back to asking the server, as it did before.
120
+ useEffect(() => {
121
+ if (!isOpen || !client || !integrations.length)
122
+ return;
123
+ let cancelled = false;
124
+ void Promise.all(integrations.map(async (integration) => {
125
+ try {
126
+ const { schemes } = await client.getIntegrationAuth(integration.app, scope);
127
+ if (!cancelled && schemes?.length) {
128
+ setAuthByApp((prev) => ({ ...prev, [integration.app]: schemes }));
129
+ }
130
+ }
131
+ catch {
132
+ // Not knowing is survivable — the click path handles it.
133
+ }
134
+ }));
135
+ return () => {
136
+ cancelled = true;
137
+ };
138
+ }, [isOpen, client, integrations, scope]);
83
139
  // Report the listing without making the caller's identity part of the
84
140
  // dependency: an inline arrow would fire this on every render.
85
141
  const onChangeRef = useRef(onChange);
@@ -96,6 +152,7 @@ function IntegrationsModal({ isOpen, onClose, assistantId, tenantId, subtenantId
96
152
  if (isOpen && !wasOpenRef.current) {
97
153
  setBlockedUrl(null);
98
154
  setActionError(null);
155
+ setSetupPrompt(null);
99
156
  setQuery("");
100
157
  // The very first open of an uncontrolled modal is already covered by the
101
158
  // hook switching on; asking again here would double every first open.
@@ -108,17 +165,24 @@ function IntegrationsModal({ isOpen, onClose, assistantId, tenantId, subtenantId
108
165
  // owner is exactly what this must not do.
109
166
  // eslint-disable-next-line react-hooks/exhaustive-deps
110
167
  }, [isOpen]);
111
- // Escape closes
168
+ // Escape closes — the credentials dialog first, when one is open. Closing
169
+ // everything from under a half-typed key would be its own small disaster.
112
170
  useEffect(() => {
113
171
  if (!isOpen)
114
172
  return;
115
173
  const onKey = (e) => {
116
- if (e.key === "Escape")
117
- onClose();
174
+ if (e.key !== "Escape")
175
+ return;
176
+ if (setupPrompt) {
177
+ setSetupPrompt(null);
178
+ setFormError(null);
179
+ return;
180
+ }
181
+ onClose();
118
182
  };
119
183
  document.addEventListener("keydown", onKey);
120
184
  return () => document.removeEventListener("keydown", onKey);
121
- }, [isOpen, onClose]);
185
+ }, [isOpen, onClose, setupPrompt]);
122
186
  /** The round trip currently in flight, if any. */
123
187
  const pendingRef = useRef(null);
124
188
  const popupRef = useRef(null);
@@ -159,19 +223,50 @@ function IntegrationsModal({ isOpen, onClose, assistantId, tenantId, subtenantId
159
223
  if (pollRef.current !== null)
160
224
  window.clearInterval(pollRef.current);
161
225
  }, []);
162
- const handleConnect = async (integration) => {
163
- if (!client || busyApp)
226
+ /**
227
+ * Connects an app, asking for credentials only if it needs them.
228
+ *
229
+ * Optimistic: the request goes out first, and the form appears only when the
230
+ * server answers that something is missing. Most apps take an API key rather
231
+ * than an OAuth round trip, so this is the path that used to fail outright.
232
+ */
233
+ const handleConnect = async (integration, values) => {
234
+ if (!client || (busyApp && busyApp !== integration.app))
164
235
  return;
165
236
  setActionError(null);
166
237
  setBlockedUrl(null);
238
+ // Ask before doing anything when the app is known to take credentials and
239
+ // no browser is involved. Connecting first would flash an empty popup and
240
+ // spend a request that can only fail — the user has not been asked yet.
241
+ const known = authByApp[integration.app];
242
+ const scheme = values
243
+ ? known?.find((s) => s.mode === values.authScheme)
244
+ : preferredScheme(known);
245
+ if (!values && scheme && !scheme.redirect && scheme.accountFields.length) {
246
+ setSetupPrompt({ app: integration.app, schemes: known });
247
+ return;
248
+ }
167
249
  setBusyApp(integration.app);
168
250
  const nonce = newNonce();
169
251
  const returnTo = `${window.location.origin}/?devic_oauth=${nonce}`;
170
- // Opened empty inside the click, navigated once the URL is known.
171
- const popup = window.open("", "devic-oauth", "width=520,height=680,menubar=no,toolbar=no");
252
+ // Opened empty inside the click, navigated once the URL is known — browsers
253
+ // only honour `window.open` inside the gesture that triggered it. Skipped
254
+ // when the scheme in hand needs no browser at all.
255
+ const popup = scheme && !scheme.redirect
256
+ ? null
257
+ : window.open("", "devic-oauth", "width=520,height=680,menubar=no,toolbar=no");
172
258
  try {
173
- const { authorizationUrl } = await client.connectIntegration(integration.app, { ...scope, returnTo });
259
+ const { connected, authorizationUrl } = await client.connectIntegration(integration.app, { ...scope, returnTo, ...values });
260
+ // Nothing to authorise: the key the user typed is the account. Close the
261
+ // window that was opened in case it was needed and re-read the listing.
262
+ if (connected || !authorizationUrl) {
263
+ popup?.close();
264
+ setSetupPrompt(null);
265
+ finishConnect();
266
+ return;
267
+ }
174
268
  pendingRef.current = { app: integration.app, returnTo };
269
+ setSetupPrompt(null);
175
270
  if (popup && !popup.closed) {
176
271
  popupRef.current = popup;
177
272
  popup.location.href = authorizationUrl;
@@ -193,8 +288,47 @@ function IntegrationsModal({ isOpen, onClose, assistantId, tenantId, subtenantId
193
288
  catch (err) {
194
289
  popup?.close();
195
290
  pendingRef.current = null;
196
- setActionError(err instanceof Error ? err.message : String(err));
197
291
  setBusyApp(null);
292
+ const message = err instanceof Error ? err.message : String(err);
293
+ const setup = err?.setupRequired;
294
+ if (setup) {
295
+ await openSetupForm(integration, setup);
296
+ return;
297
+ }
298
+ // While the form is up its own failures belong in it, next to the fields
299
+ // that caused them — a message behind a dialog is a message nobody reads.
300
+ if (setupPrompt?.app === integration.app)
301
+ setFormError(message);
302
+ else
303
+ setActionError(message);
304
+ }
305
+ };
306
+ /**
307
+ * Opens the credentials form for an app that needs one.
308
+ *
309
+ * `stage: "app"` is not the end user's to fix — it means the developer who
310
+ * embedded this widget has not registered an application with the provider
311
+ * yet. Asking a stranger for someone else's client secret would be both
312
+ * useless and a good way to teach them to hand credentials to a form, so it
313
+ * is reported as unavailable instead.
314
+ */
315
+ const openSetupForm = async (integration, setup) => {
316
+ if (setup.stage === "app") {
317
+ setActionError(`${integration.name} is not available yet — it still needs to be set up ` +
318
+ `by the app's provider.`);
319
+ return;
320
+ }
321
+ try {
322
+ const schemes = authByApp[integration.app] ??
323
+ (await client.getIntegrationAuth(integration.app, scope)).schemes;
324
+ if (!schemes.length)
325
+ throw new Error(setup.message);
326
+ setAuthByApp((prev) => ({ ...prev, [integration.app]: schemes }));
327
+ setFormError(null);
328
+ setSetupPrompt({ app: integration.app, setup, schemes });
329
+ }
330
+ catch (err) {
331
+ setActionError(err instanceof Error ? err.message : String(err));
198
332
  }
199
333
  };
200
334
  const handleDisconnect = async (app, account) => {
@@ -219,27 +353,30 @@ function IntegrationsModal({ isOpen, onClose, assistantId, tenantId, subtenantId
219
353
  // The variables go on the overlay, not on the modal: the backdrop is part
220
354
  // of the dialog, and a portal inherits nothing from the drawer that opened
221
355
  // it.
222
- jsx("div", { className: "devic-int-overlay", style: themeVars(theme), "data-dark": isDarkTheme(theme), onClick: onClose, children: jsxs("div", { className: "devic-int-modal", role: "dialog", "aria-modal": "true", "aria-label": title, onClick: (e) => e.stopPropagation(), children: [jsxs("div", { className: "devic-int-header", children: [jsxs("h3", { className: "devic-int-title", children: [jsx(PlugIcon, {}), title] }), jsx("button", { className: "devic-int-close", onClick: onClose, type: "button", "aria-label": "Close", children: "\u00D7" })] }), jsxs("div", { className: "devic-int-search", children: [jsx(SearchIcon, {}), jsx("input", { type: "search", value: query, onChange: (e) => setQuery(e.target.value), placeholder: searchPlaceholder, "aria-label": searchPlaceholder, autoComplete: "off" })] }), jsxs("div", { className: "devic-int-body", children: [error && jsx("div", { className: "devic-int-error", children: error }), blockedUrl && (jsxs("div", { className: "devic-int-notice", children: ["Your browser blocked the pop-up.", " ", jsx("a", { href: blockedUrl.url, target: "_blank", rel: "noopener noreferrer", onClick: () => {
223
- pendingRef.current = null;
224
- setBlockedUrl(null);
225
- }, children: "Open the authorisation page" }), " ", "and come back \u2014 then use Refresh."] })), loading && integrations.length === 0 ? (jsx("div", { className: "devic-int-loading", children: "Loading apps\u2026" })) : integrations.length === 0 ? (jsx("div", { className: "devic-int-empty", children: "No apps available here yet." })) : visible.length === 0 ? (jsxs("div", { className: "devic-int-empty", children: ["No apps match \u201C", query.trim(), "\u201D."] })) : (jsx("div", { className: "devic-int-grid", children: visible.map((integration) => {
226
- const cardState = stateOf(integration);
227
- const busy = busyApp === integration.app;
228
- return (jsxs("div", { className: "devic-int-card", "data-state": cardState.key, children: [jsxs("div", { className: "devic-int-card-head", children: [jsx(IntegrationLogo, { integration: integration }), jsxs("span", { className: "devic-int-state", children: [jsx("span", { className: "devic-int-dot", "data-ok": cardState.key === "connected", "data-off": cardState.key === "disconnected", "aria-hidden": "true" }), cardState.label] })] }), jsx("div", { className: "devic-int-name", title: integration.name, children: integration.name }), integration.description && (jsx("div", { className: "devic-int-description", title: integration.description, children: integration.description })), jsx("button", { type: "button", className: `devic-int-btn devic-int-btn-block${cardState.key === "connected"
229
- ? ""
230
- : " devic-int-btn-primary"}`, onClick: () => handleConnect(integration), disabled: busy || !!busyApp, title: cardState.key === "connected"
231
- ? "Sign in with a different account. The one connected now is replaced."
232
- : undefined, children: busy
233
- ? "Waiting…"
234
- : cardState.key === "disconnected"
235
- ? "Connect"
236
- : cardState.key === "reconnect"
237
- ? "Reconnect"
238
- : // Not "Add account": one account per app is all
239
- // the assistant can use, and connecting again
240
- // retires the previous one.
241
- "Switch account" }), integration.accounts.length > 0 && (jsx("ul", { className: "devic-int-accounts", children: integration.accounts.map((account) => (jsxs("li", { className: "devic-int-account", children: [jsx("span", { className: "devic-int-dot", "data-ok": !account.needsReconnect, "aria-hidden": "true" }), jsxs("span", { className: "devic-int-account-label", children: [accountLabel(account), account.needsReconnect && (jsxs("span", { className: "devic-int-account-warn", children: [" ", "\u00B7 reconnect required"] }))] }), jsx("button", { type: "button", className: "devic-int-unlink", onClick: () => handleDisconnect(integration.app, account), disabled: !!busyApp, title: "Disconnect this account", "aria-label": `Disconnect ${integration.name}`, children: "\u00D7" })] }, account.id))) }))] }, integration.app));
242
- }) }))] }), jsxs("div", { className: "devic-int-footer", children: [jsx("span", { children: "Only you can see and use the accounts you connect here." }), jsx("button", { type: "button", className: "devic-int-btn devic-int-btn-small", onClick: () => void refresh(true), disabled: loading || !!busyApp, children: "Refresh" })] })] }) }), document.body);
356
+ jsxs("div", { className: "devic-int-overlay", style: themeVars(theme), "data-dark": isDarkTheme(theme), onClick: onClose, children: [jsxs("div", { className: "devic-int-modal", role: "dialog", "aria-modal": "true", "aria-label": title, onClick: (e) => e.stopPropagation(), children: [jsxs("div", { className: "devic-int-header", children: [jsxs("h3", { className: "devic-int-title", children: [jsx(PlugIcon, {}), title] }), jsx("button", { className: "devic-int-close", onClick: onClose, type: "button", "aria-label": "Close", children: "\u00D7" })] }), jsxs("div", { className: "devic-int-search", children: [jsx(SearchIcon, {}), jsx("input", { type: "search", value: query, onChange: (e) => setQuery(e.target.value), placeholder: searchPlaceholder, "aria-label": searchPlaceholder, autoComplete: "off" })] }), jsxs("div", { className: "devic-int-body", children: [error && jsx("div", { className: "devic-int-error", children: error }), blockedUrl && (jsxs("div", { className: "devic-int-notice", children: ["Your browser blocked the pop-up.", " ", jsx("a", { href: blockedUrl.url, target: "_blank", rel: "noopener noreferrer", onClick: () => {
357
+ pendingRef.current = null;
358
+ setBlockedUrl(null);
359
+ }, children: "Open the authorisation page" }), " ", "and come back \u2014 then use Refresh."] })), loading && integrations.length === 0 ? (jsx("div", { className: "devic-int-loading", children: "Loading apps\u2026" })) : integrations.length === 0 ? (jsx("div", { className: "devic-int-empty", children: "No apps available here yet." })) : visible.length === 0 ? (jsxs("div", { className: "devic-int-empty", children: ["No apps match \u201C", query.trim(), "\u201D."] })) : (jsx("div", { className: "devic-int-grid", children: visible.map((integration) => {
360
+ const cardState = stateOf(integration);
361
+ const busy = busyApp === integration.app;
362
+ return (jsxs("div", { className: "devic-int-card", "data-state": cardState.key, children: [jsxs("div", { className: "devic-int-card-head", children: [jsx(IntegrationLogo, { integration: integration }), jsxs("span", { className: "devic-int-state", children: [jsx("span", { className: "devic-int-dot", "data-ok": cardState.key === "connected", "data-off": cardState.key === "disconnected", "aria-hidden": "true" }), cardState.label] })] }), jsx("div", { className: "devic-int-name", title: integration.name, children: integration.name }), integration.description && (jsx("div", { className: "devic-int-description", title: integration.description, children: integration.description })), jsx("button", { type: "button", className: `devic-int-btn devic-int-btn-block${cardState.key === "connected"
363
+ ? ""
364
+ : " devic-int-btn-primary"}`, onClick: () => handleConnect(integration), disabled: busy || !!busyApp, title: cardState.key === "connected"
365
+ ? "Sign in with a different account. The one connected now is replaced."
366
+ : undefined, children: busy
367
+ ? "Waiting…"
368
+ : cardState.key === "disconnected"
369
+ ? "Connect"
370
+ : cardState.key === "reconnect"
371
+ ? "Reconnect"
372
+ : // Not "Add account": one account per app is all
373
+ // the assistant can use, and connecting again
374
+ // retires the previous one.
375
+ "Switch account" }), integration.accounts.length > 0 && (jsx("ul", { className: "devic-int-accounts", children: integration.accounts.map((account) => (jsxs("li", { className: "devic-int-account", children: [jsx("span", { className: "devic-int-dot", "data-ok": !account.needsReconnect, "aria-hidden": "true" }), jsxs("span", { className: "devic-int-account-label", children: [accountLabel(account), account.needsReconnect && (jsxs("span", { className: "devic-int-account-warn", children: [" ", "\u00B7 reconnect required"] }))] }), jsx("button", { type: "button", className: "devic-int-unlink", onClick: () => handleDisconnect(integration.app, account), disabled: !!busyApp, title: "Disconnect this account", "aria-label": `Disconnect ${integration.name}`, children: "\u00D7" })] }, account.id))) }))] }, integration.app));
376
+ }) }))] }), jsxs("div", { className: "devic-int-footer", children: [jsx("span", { children: "Only you can see and use the accounts you connect here." }), jsx("button", { type: "button", className: "devic-int-btn devic-int-btn-small", onClick: () => void refresh(true), disabled: loading || !!busyApp, children: "Refresh" })] })] }), setupPrompt && promptIntegration && (jsx(ConnectFieldsForm, { integration: promptIntegration, schemes: setupPrompt.schemes, initialScheme: setupPrompt.setup?.authScheme, onlyFields: setupPrompt.setup?.fields, submitting: busyApp === setupPrompt.app, error: formError, theme: theme, onCancel: () => {
377
+ setSetupPrompt(null);
378
+ setFormError(null);
379
+ }, onSubmit: (values) => handleConnect(promptIntegration, values) }))] }), document.body);
243
380
  }
244
381
 
245
382
  export { IntegrationsModal };
@@ -1 +1 @@
1
- {"version":3,"file":"IntegrationsModal.js","sources":["../../../../src/components/IntegrationsModal/IntegrationsModal.tsx"],"sourcesContent":["import {\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n type JSX,\n} from \"react\";\nimport { createPortal } from \"react-dom\";\nimport type { Integration, IntegrationAccount } from \"../../api/types\";\nimport { isDarkTheme, themeVars, type DevicTheme } from \"../theme\";\nimport { IntegrationLogo } from \"./IntegrationLogo\";\nimport { useIntegrations, type IntegrationsState } from \"./useIntegrations\";\nimport \"./IntegrationsModal.css\";\n\n/** Message the OAuth callback page posts back to this window when it is done. */\ninterface CallbackMessage {\n source?: string;\n type?: string;\n app?: string;\n status?: string;\n returnTo?: string;\n}\n\nexport interface IntegrationsModalProps {\n /** Whether the modal is visible. */\n isOpen: boolean;\n onClose: () => void;\n /** Assistant whose offered apps are shown. */\n assistantId: string;\n /** Tenant of the end user (falls back to the provider's tenantId). */\n tenantId?: string;\n /** Subtenant of the end user (falls back to the provider's subtenantId). */\n subtenantId?: string;\n /** API key override (falls back to the provider's). */\n apiKey?: string;\n /** Base URL override (falls back to the provider's). */\n baseUrl?: string;\n /** Modal title. @default \"Connected apps\" */\n title?: string;\n /** Search field placeholder. @default \"Search connected apps\" */\n searchPlaceholder?: string;\n /** Called after an account is connected or disconnected. */\n onChange?: (integrations: Integration[]) => void;\n /**\n * Colours and font. Same names as the drawer's style options, and the drawer\n * passes its own down — a dialog opening in the default light palette over a\n * themed application is the one thing this must not do.\n */\n theme?: DevicTheme;\n /**\n * Listing loaded elsewhere (see `useIntegrations`). The drawer already has to\n * load it to decide whether its button exists, and passing it down is what\n * keeps opening the modal from asking for the very same thing again.\n */\n state?: IntegrationsState;\n}\n\nfunction PlugIcon(): JSX.Element {\n return (\n <svg\n width=\"16\"\n height=\"16\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n aria-hidden=\"true\"\n >\n <path d=\"M12 22v-5\" />\n <path d=\"M9 8V2\" />\n <path d=\"M15 8V2\" />\n <path d=\"M18 8v5a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V8Z\" />\n </svg>\n );\n}\n\nfunction SearchIcon(): JSX.Element {\n return (\n <svg\n width=\"14\"\n height=\"14\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n aria-hidden=\"true\"\n >\n <circle cx=\"11\" cy=\"11\" r=\"7\" />\n <path d=\"m20 20-3.5-3.5\" />\n </svg>\n );\n}\n\n/** A random value tying an OAuth round trip to the window that started it. */\nfunction newNonce(): string {\n const c = typeof crypto !== \"undefined\" ? crypto : undefined;\n if (c?.randomUUID) return c.randomUUID();\n return `${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;\n}\n\n/** How the card describes an app at a glance. */\nfunction stateOf(integration: Integration): {\n key: \"connected\" | \"reconnect\" | \"disconnected\";\n label: string;\n} {\n if (integration.connected) return { key: \"connected\", label: \"Connected\" };\n if (integration.accounts.some((a) => a.needsReconnect)) {\n return { key: \"reconnect\", label: \"Needs reconnection\" };\n }\n return { key: \"disconnected\", label: \"Not connected\" };\n}\n\nfunction accountLabel(account: IntegrationAccount): string {\n if (!account.connectedAt) return account.status.toLowerCase();\n const when = new Date(account.connectedAt);\n if (Number.isNaN(when.getTime())) return account.status.toLowerCase();\n return `connected ${when.toLocaleDateString()}`;\n}\n\nfunction matches(integration: Integration, query: string): boolean {\n const q = query.trim().toLowerCase();\n if (!q) return true;\n return (\n integration.name.toLowerCase().includes(q) ||\n integration.app.toLowerCase().includes(q) ||\n (integration.description ?? \"\").toLowerCase().includes(q)\n );\n}\n\n/**\n * Modal where the END USER of an application manages their *own* third-party\n * accounts: the apps the developer offered to tenants of this assistant, each\n * with the accounts this tenant has connected, and the buttons to add or\n * remove one.\n *\n * Backed by `/api/v1/tenant-integrations`, which resolves the tenant\n * server-side, so what is listed here is only ever this tenant's — never the\n * workspace-wide accounts an admin connected, and never another tenant's.\n *\n * Connecting opens the provider's consent screen in a popup. The popup is\n * opened empty *before* the request that produces its URL, because browsers\n * only honour `window.open` inside the gesture that triggered it: opening it\n * after the round trip is what gets it blocked. When it is blocked anyway, the\n * URL is offered as a link instead.\n */\nexport function IntegrationsModal({\n isOpen,\n onClose,\n assistantId,\n tenantId,\n subtenantId,\n apiKey,\n baseUrl,\n title = \"Connected apps\",\n searchPlaceholder = \"Search connected apps\",\n onChange,\n theme,\n state,\n}: IntegrationsModalProps): JSX.Element | null {\n // Hooks cannot be skipped, so the fallback is always built and only fetches\n // when nobody handed a listing down.\n const own = useIntegrations({\n assistantId,\n tenantId,\n subtenantId,\n apiKey,\n baseUrl,\n enabled: isOpen && !state,\n });\n const { integrations, loading, error: loadError, refresh, client, scope } =\n state ?? own;\n\n /** Errors from connecting or disconnecting, kept apart from load failures. */\n const [actionError, setActionError] = useState<string | null>(null);\n const error = actionError ?? loadError;\n /** App slug with a connect/disconnect in flight, so only its card is busy. */\n const [busyApp, setBusyApp] = useState<string | null>(null);\n /** Authorization URL surfaced as a link when the popup was blocked. */\n const [blockedUrl, setBlockedUrl] = useState<{ app: string; url: string } | null>(\n null\n );\n const [query, setQuery] = useState(\"\");\n\n const visible = useMemo(\n () => integrations.filter((i) => matches(i, query)),\n [integrations, query]\n );\n\n // Report the listing without making the caller's identity part of the\n // dependency: an inline arrow would fire this on every render.\n const onChangeRef = useRef(onChange);\n onChangeRef.current = onChange;\n useEffect(() => {\n if (integrations.length) onChangeRef.current?.(integrations);\n }, [integrations]);\n\n // Reopening starts clean, and re-reads: accounts may have been connected or\n // revoked elsewhere since the last look.\n const wasOpenRef = useRef(false);\n const openedBeforeRef = useRef(false);\n useEffect(() => {\n if (isOpen && !wasOpenRef.current) {\n setBlockedUrl(null);\n setActionError(null);\n setQuery(\"\");\n // The very first open of an uncontrolled modal is already covered by the\n // hook switching on; asking again here would double every first open.\n if (state || openedBeforeRef.current) void refresh();\n openedBeforeRef.current = true;\n }\n wasOpenRef.current = isOpen;\n // `state.refresh` is stable per scope; re-running on every render of the\n // owner is exactly what this must not do.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [isOpen]);\n\n // Escape closes\n useEffect(() => {\n if (!isOpen) return;\n const onKey = (e: KeyboardEvent) => {\n if (e.key === \"Escape\") onClose();\n };\n document.addEventListener(\"keydown\", onKey);\n return () => document.removeEventListener(\"keydown\", onKey);\n }, [isOpen, onClose]);\n\n /** The round trip currently in flight, if any. */\n const pendingRef = useRef<{ app: string; returnTo: string } | null>(null);\n const popupRef = useRef<Window | null>(null);\n const pollRef = useRef<number | null>(null);\n\n const finishConnect = useCallback(() => {\n if (pollRef.current !== null) {\n window.clearInterval(pollRef.current);\n pollRef.current = null;\n }\n pendingRef.current = null;\n popupRef.current = null;\n setBusyApp(null);\n void refresh(true);\n }, [refresh]);\n\n // The callback page tells us it is done. Treat the message as a nudge, never\n // as the result: what is displayed comes from re-reading the server, so a\n // forged message can at worst cause one redundant fetch.\n useEffect(() => {\n if (!isOpen) return;\n const onMessage = (event: MessageEvent) => {\n const data = event.data as CallbackMessage | undefined;\n if (!data || data.source !== \"devic\") return;\n if (data.type !== \"integration-connected\") return;\n const pending = pendingRef.current;\n if (!pending || data.returnTo !== pending.returnTo) return;\n popupRef.current?.close();\n finishConnect();\n };\n window.addEventListener(\"message\", onMessage);\n return () => window.removeEventListener(\"message\", onMessage);\n }, [isOpen, finishConnect]);\n\n // Stop polling if the modal goes away mid-flow.\n useEffect(\n () => () => {\n if (pollRef.current !== null) window.clearInterval(pollRef.current);\n },\n []\n );\n\n const handleConnect = async (integration: Integration) => {\n if (!client || busyApp) return;\n setActionError(null);\n setBlockedUrl(null);\n setBusyApp(integration.app);\n\n const nonce = newNonce();\n const returnTo = `${window.location.origin}/?devic_oauth=${nonce}`;\n // Opened empty inside the click, navigated once the URL is known.\n const popup = window.open(\n \"\",\n \"devic-oauth\",\n \"width=520,height=680,menubar=no,toolbar=no\"\n );\n\n try {\n const { authorizationUrl } = await client.connectIntegration(\n integration.app,\n { ...scope, returnTo }\n );\n pendingRef.current = { app: integration.app, returnTo };\n if (popup && !popup.closed) {\n popupRef.current = popup;\n popup.location.href = authorizationUrl;\n // The user may close the popup without the callback ever posting back\n // — a cancelled consent screen, or a provider that lands somewhere\n // else. Watching for the close is what keeps the card from staying\n // busy forever.\n pollRef.current = window.setInterval(() => {\n if (popup.closed) finishConnect();\n }, 700);\n } else {\n // Blocked (Safari, in-app browsers, extensions): hand over the URL.\n setBlockedUrl({ app: integration.app, url: authorizationUrl });\n setBusyApp(null);\n }\n } catch (err) {\n popup?.close();\n pendingRef.current = null;\n setActionError(err instanceof Error ? err.message : String(err));\n setBusyApp(null);\n }\n };\n\n const handleDisconnect = async (app: string, account: IntegrationAccount) => {\n if (!client || busyApp) return;\n setBusyApp(app);\n setActionError(null);\n try {\n await client.disconnectIntegration(account.id, scope);\n await refresh(true);\n } catch (err) {\n setActionError(err instanceof Error ? err.message : String(err));\n } finally {\n setBusyApp(null);\n }\n };\n\n if (!isOpen) return null;\n\n return createPortal(\n // The variables go on the overlay, not on the modal: the backdrop is part\n // of the dialog, and a portal inherits nothing from the drawer that opened\n // it.\n <div\n className=\"devic-int-overlay\"\n style={themeVars(theme)}\n data-dark={isDarkTheme(theme)}\n onClick={onClose}\n >\n <div\n className=\"devic-int-modal\"\n role=\"dialog\"\n aria-modal=\"true\"\n aria-label={title}\n onClick={(e) => e.stopPropagation()}\n >\n <div className=\"devic-int-header\">\n <h3 className=\"devic-int-title\">\n <PlugIcon />\n {title}\n </h3>\n <button\n className=\"devic-int-close\"\n onClick={onClose}\n type=\"button\"\n aria-label=\"Close\"\n >\n ×\n </button>\n </div>\n\n <div className=\"devic-int-search\">\n <SearchIcon />\n <input\n type=\"search\"\n value={query}\n onChange={(e) => setQuery(e.target.value)}\n placeholder={searchPlaceholder}\n aria-label={searchPlaceholder}\n autoComplete=\"off\"\n />\n </div>\n\n <div className=\"devic-int-body\">\n {error && <div className=\"devic-int-error\">{error}</div>}\n\n {blockedUrl && (\n <div className=\"devic-int-notice\">\n Your browser blocked the pop-up.{\" \"}\n <a\n href={blockedUrl.url}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n onClick={() => {\n pendingRef.current = null;\n setBlockedUrl(null);\n }}\n >\n Open the authorisation page\n </a>{\" \"}\n and come back — then use Refresh.\n </div>\n )}\n\n {loading && integrations.length === 0 ? (\n <div className=\"devic-int-loading\">Loading apps…</div>\n ) : integrations.length === 0 ? (\n <div className=\"devic-int-empty\">No apps available here yet.</div>\n ) : visible.length === 0 ? (\n <div className=\"devic-int-empty\">\n No apps match “{query.trim()}”.\n </div>\n ) : (\n <div className=\"devic-int-grid\">\n {visible.map((integration) => {\n const cardState = stateOf(integration);\n const busy = busyApp === integration.app;\n return (\n <div\n key={integration.app}\n className=\"devic-int-card\"\n data-state={cardState.key}\n >\n <div className=\"devic-int-card-head\">\n <IntegrationLogo integration={integration} />\n <span className=\"devic-int-state\">\n <span\n className=\"devic-int-dot\"\n data-ok={cardState.key === \"connected\"}\n data-off={cardState.key === \"disconnected\"}\n aria-hidden=\"true\"\n />\n {cardState.label}\n </span>\n </div>\n\n <div className=\"devic-int-name\" title={integration.name}>\n {integration.name}\n </div>\n\n {integration.description && (\n <div\n className=\"devic-int-description\"\n title={integration.description}\n >\n {integration.description}\n </div>\n )}\n\n <button\n type=\"button\"\n className={`devic-int-btn devic-int-btn-block${\n cardState.key === \"connected\"\n ? \"\"\n : \" devic-int-btn-primary\"\n }`}\n onClick={() => handleConnect(integration)}\n disabled={busy || !!busyApp}\n title={\n cardState.key === \"connected\"\n ? \"Sign in with a different account. The one connected now is replaced.\"\n : undefined\n }\n >\n {busy\n ? \"Waiting…\"\n : cardState.key === \"disconnected\"\n ? \"Connect\"\n : cardState.key === \"reconnect\"\n ? \"Reconnect\"\n : // Not \"Add account\": one account per app is all\n // the assistant can use, and connecting again\n // retires the previous one.\n \"Switch account\"}\n </button>\n\n {integration.accounts.length > 0 && (\n <ul className=\"devic-int-accounts\">\n {integration.accounts.map((account) => (\n <li key={account.id} className=\"devic-int-account\">\n <span\n className=\"devic-int-dot\"\n data-ok={!account.needsReconnect}\n aria-hidden=\"true\"\n />\n <span className=\"devic-int-account-label\">\n {accountLabel(account)}\n {account.needsReconnect && (\n <span className=\"devic-int-account-warn\">\n {\" \"}\n · reconnect required\n </span>\n )}\n </span>\n <button\n type=\"button\"\n className=\"devic-int-unlink\"\n onClick={() =>\n handleDisconnect(integration.app, account)\n }\n disabled={!!busyApp}\n title=\"Disconnect this account\"\n aria-label={`Disconnect ${integration.name}`}\n >\n ×\n </button>\n </li>\n ))}\n </ul>\n )}\n </div>\n );\n })}\n </div>\n )}\n </div>\n\n <div className=\"devic-int-footer\">\n <span>Only you can see and use the accounts you connect here.</span>\n <button\n type=\"button\"\n className=\"devic-int-btn devic-int-btn-small\"\n onClick={() => void refresh(true)}\n disabled={loading || !!busyApp}\n >\n Refresh\n </button>\n </div>\n </div>\n </div>,\n document.body\n );\n}\n\nexport default IntegrationsModal;\n"],"names":["_jsxs","_jsx"],"mappings":";;;;;;;AA0DA,SAAS,QAAQ,GAAA;AACf,IAAA,QACEA,IAAA,CAAA,KAAA,EAAA,EACE,KAAK,EAAC,IAAI,EACV,MAAM,EAAC,IAAI,EACX,OAAO,EAAC,WAAW,EACnB,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,KACrBA,IAAA,CAAA,MAAA,EAAA,EAAM,SAAS,EAAC,wBAAwB,EAAA,QAAA,EAAA,CACrC,GAAG,EAAA,2BAAA,CAAA,EAAA,CAEC,CACR,CAAA,EAAA,CACI,EACPC,GAAA,CAAA,QAAA,EAAA,EACE,IAAI,EAAC,QAAQ,EACb,SAAS,EAAC,kBAAkB,EAC5B,OAAO,EAAE,MACP,gBAAgB,CAAC,WAAW,CAAC,GAAG,EAAE,OAAO,CAAC,EAE5C,QAAQ,EAAE,CAAC,CAAC,OAAO,EACnB,KAAK,EAAC,yBAAyB,EAAA,YAAA,EACnB,CAAA,WAAA,EAAc,WAAW,CAAC,IAAI,CAAA,CAAE,EAAA,QAAA,EAAA,QAAA,EAAA,CAGrC,CAAA,EAAA,EA1BF,OAAO,CAAC,EAAE,CA2Bd,CACN,CAAC,EAAA,CACC,CACN,CAAA,EAAA,EA1FI,WAAW,CAAC,GAAG,CA2FhB;4BAEV,CAAC,CAAC,GACE,CACP,CAAA,EAAA,CACG,EAEND,IAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,kBAAkB,EAAA,QAAA,EAAA,CAC/BC,GAAA,CAAA,MAAA,EAAA,EAAA,QAAA,EAAA,yDAAA,EAAA,CAAoE,EACpEA,GAAA,CAAA,QAAA,EAAA,EACE,IAAI,EAAC,QAAQ,EACb,SAAS,EAAC,mCAAmC,EAC7C,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,EACjC,QAAQ,EAAE,OAAO,IAAI,CAAC,CAAC,OAAO,EAAA,QAAA,EAAA,SAAA,EAAA,CAGvB,IACL,CAAA,EAAA,CACF,EAAA,CACF,EACN,QAAQ,CAAC,IAAI,CACd;AACH;;;;"}
1
+ {"version":3,"file":"IntegrationsModal.js","sources":["../../../../src/components/IntegrationsModal/IntegrationsModal.tsx"],"sourcesContent":["import {\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n type JSX,\n} from \"react\";\nimport { createPortal } from \"react-dom\";\nimport type { DevicApiError } from \"../../api/client\";\nimport type {\n Integration,\n IntegrationAccount,\n IntegrationAuthScheme,\n IntegrationSetupRequired,\n} from \"../../api/types\";\nimport { isDarkTheme, themeVars, type DevicTheme } from \"../theme\";\nimport { ConnectFieldsForm } from \"./ConnectFieldsForm\";\nimport { IntegrationLogo } from \"./IntegrationLogo\";\nimport { useIntegrations, type IntegrationsState } from \"./useIntegrations\";\nimport \"./IntegrationsModal.css\";\n\n/** Message the OAuth callback page posts back to this window when it is done. */\ninterface CallbackMessage {\n source?: string;\n type?: string;\n app?: string;\n status?: string;\n returnTo?: string;\n}\n\nexport interface IntegrationsModalProps {\n /** Whether the modal is visible. */\n isOpen: boolean;\n onClose: () => void;\n /** Assistant whose offered apps are shown. */\n assistantId: string;\n /** Tenant of the end user (falls back to the provider's tenantId). */\n tenantId?: string;\n /** Subtenant of the end user (falls back to the provider's subtenantId). */\n subtenantId?: string;\n /** API key override (falls back to the provider's). */\n apiKey?: string;\n /** Base URL override (falls back to the provider's). */\n baseUrl?: string;\n /** Modal title. @default \"Connected apps\" */\n title?: string;\n /** Search field placeholder. @default \"Search connected apps\" */\n searchPlaceholder?: string;\n /** Called after an account is connected or disconnected. */\n onChange?: (integrations: Integration[]) => void;\n /**\n * Colours and font. Same names as the drawer's style options, and the drawer\n * passes its own down — a dialog opening in the default light palette over a\n * themed application is the one thing this must not do.\n */\n theme?: DevicTheme;\n /**\n * Listing loaded elsewhere (see `useIntegrations`). The drawer already has to\n * load it to decide whether its button exists, and passing it down is what\n * keeps opening the modal from asking for the very same thing again.\n */\n state?: IntegrationsState;\n}\n\nfunction PlugIcon(): JSX.Element {\n return (\n <svg\n width=\"16\"\n height=\"16\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n aria-hidden=\"true\"\n >\n <path d=\"M12 22v-5\" />\n <path d=\"M9 8V2\" />\n <path d=\"M15 8V2\" />\n <path d=\"M18 8v5a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V8Z\" />\n </svg>\n );\n}\n\nfunction SearchIcon(): JSX.Element {\n return (\n <svg\n width=\"14\"\n height=\"14\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n aria-hidden=\"true\"\n >\n <circle cx=\"11\" cy=\"11\" r=\"7\" />\n <path d=\"m20 20-3.5-3.5\" />\n </svg>\n );\n}\n\n/** A random value tying an OAuth round trip to the window that started it. */\nfunction newNonce(): string {\n const c = typeof crypto !== \"undefined\" ? crypto : undefined;\n if (c?.randomUUID) return c.randomUUID();\n return `${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;\n}\n\n/** How the card describes an app at a glance. */\nfunction stateOf(integration: Integration): {\n key: \"connected\" | \"reconnect\" | \"disconnected\";\n label: string;\n} {\n if (integration.connected) return { key: \"connected\", label: \"Connected\" };\n if (integration.accounts.some((a) => a.needsReconnect)) {\n return { key: \"reconnect\", label: \"Needs reconnection\" };\n }\n return { key: \"disconnected\", label: \"Not connected\" };\n}\n\nfunction accountLabel(account: IntegrationAccount): string {\n if (!account.connectedAt) return account.status.toLowerCase();\n const when = new Date(account.connectedAt);\n if (Number.isNaN(when.getTime())) return account.status.toLowerCase();\n return `connected ${when.toLocaleDateString()}`;\n}\n\n/**\n * The scheme the server would pick, given no explicit choice: the one asking\n * for least setup.\n *\n * Mirrors the engine's own preference deliberately. It is only used to decide\n * whether to open a popup or a form before asking, and being wrong is\n * recoverable — the form sends its scheme explicitly, and a redirect that\n * arrives anyway is still honoured.\n */\nfunction preferredScheme(\n schemes?: IntegrationAuthScheme[]\n): IntegrationAuthScheme | undefined {\n if (!schemes?.length) return undefined;\n const friction = (s: IntegrationAuthScheme) => (s.composioManaged ? 0 : 1);\n return [...schemes].sort((a, b) => friction(a) - friction(b))[0];\n}\n\nfunction matches(integration: Integration, query: string): boolean {\n const q = query.trim().toLowerCase();\n if (!q) return true;\n return (\n integration.name.toLowerCase().includes(q) ||\n integration.app.toLowerCase().includes(q) ||\n (integration.description ?? \"\").toLowerCase().includes(q)\n );\n}\n\n/**\n * Modal where the END USER of an application manages their *own* third-party\n * accounts: the apps the developer offered to tenants of this assistant, each\n * with the accounts this tenant has connected, and the buttons to add or\n * remove one.\n *\n * Backed by `/api/v1/tenant-integrations`, which resolves the tenant\n * server-side, so what is listed here is only ever this tenant's — never the\n * workspace-wide accounts an admin connected, and never another tenant's.\n *\n * Connecting opens the provider's consent screen in a popup. The popup is\n * opened empty *before* the request that produces its URL, because browsers\n * only honour `window.open` inside the gesture that triggered it: opening it\n * after the round trip is what gets it blocked. When it is blocked anyway, the\n * URL is offered as a link instead.\n */\nexport function IntegrationsModal({\n isOpen,\n onClose,\n assistantId,\n tenantId,\n subtenantId,\n apiKey,\n baseUrl,\n title = \"Connected apps\",\n searchPlaceholder = \"Search connected apps\",\n onChange,\n theme,\n state,\n}: IntegrationsModalProps): JSX.Element | null {\n // Hooks cannot be skipped, so the fallback is always built and only fetches\n // when nobody handed a listing down.\n const own = useIntegrations({\n assistantId,\n tenantId,\n subtenantId,\n apiKey,\n baseUrl,\n enabled: isOpen && !state,\n });\n const { integrations, loading, error: loadError, refresh, client, scope } =\n state ?? own;\n\n /** Errors from connecting or disconnecting, kept apart from load failures. */\n const [actionError, setActionError] = useState<string | null>(null);\n const error = actionError ?? loadError;\n /** App slug with a connect/disconnect in flight, so only its card is busy. */\n const [busyApp, setBusyApp] = useState<string | null>(null);\n /** Authorization URL surfaced as a link when the popup was blocked. */\n const [blockedUrl, setBlockedUrl] = useState<{ app: string; url: string } | null>(\n null\n );\n /** The app whose credentials are being asked for, and every way it can be\n * connected. `setup` is present when the server named what was missing. */\n const [setupPrompt, setSetupPrompt] = useState<{\n app: string;\n schemes: IntegrationAuthScheme[];\n setup?: IntegrationSetupRequired;\n } | null>(null);\n /**\n * How each offered app can be connected, read once the listing arrives.\n *\n * Loaded ahead of the click rather than on it: knowing whether an app needs\n * a browser is what decides between opening a popup and opening a form, and\n * that decision has to be made *inside* the user's gesture — a popup opened\n * after an await is blocked.\n */\n const [authByApp, setAuthByApp] = useState<\n Record<string, IntegrationAuthScheme[]>\n >({});\n /** Failure from the last submit, shown inside the credentials dialog. */\n const [formError, setFormError] = useState<string | null>(null);\n const [query, setQuery] = useState(\"\");\n\n const visible = useMemo(\n () => integrations.filter((i) => matches(i, query)),\n [integrations, query]\n );\n\n // Resolved from the listing rather than stored in the prompt: the dialog\n // stays open across a refresh, and a copy taken when it opened would go\n // stale — showing \"Not connected\" on an app that just connected.\n const promptIntegration = useMemo(\n () => integrations.find((i) => i.app === setupPrompt?.app),\n [integrations, setupPrompt?.app]\n );\n\n // One request per offered app, once the listing is in. They are small,\n // cached server-side, and nothing waits on them: a click that lands before\n // its answer simply falls back to asking the server, as it did before.\n useEffect(() => {\n if (!isOpen || !client || !integrations.length) return;\n let cancelled = false;\n void Promise.all(\n integrations.map(async (integration) => {\n try {\n const { schemes } = await client.getIntegrationAuth(\n integration.app,\n scope\n );\n if (!cancelled && schemes?.length) {\n setAuthByApp((prev) => ({ ...prev, [integration.app]: schemes }));\n }\n } catch {\n // Not knowing is survivable — the click path handles it.\n }\n })\n );\n return () => {\n cancelled = true;\n };\n }, [isOpen, client, integrations, scope]);\n\n // Report the listing without making the caller's identity part of the\n // dependency: an inline arrow would fire this on every render.\n const onChangeRef = useRef(onChange);\n onChangeRef.current = onChange;\n useEffect(() => {\n if (integrations.length) onChangeRef.current?.(integrations);\n }, [integrations]);\n\n // Reopening starts clean, and re-reads: accounts may have been connected or\n // revoked elsewhere since the last look.\n const wasOpenRef = useRef(false);\n const openedBeforeRef = useRef(false);\n useEffect(() => {\n if (isOpen && !wasOpenRef.current) {\n setBlockedUrl(null);\n setActionError(null);\n setSetupPrompt(null);\n setQuery(\"\");\n // The very first open of an uncontrolled modal is already covered by the\n // hook switching on; asking again here would double every first open.\n if (state || openedBeforeRef.current) void refresh();\n openedBeforeRef.current = true;\n }\n wasOpenRef.current = isOpen;\n // `state.refresh` is stable per scope; re-running on every render of the\n // owner is exactly what this must not do.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [isOpen]);\n\n // Escape closes — the credentials dialog first, when one is open. Closing\n // everything from under a half-typed key would be its own small disaster.\n useEffect(() => {\n if (!isOpen) return;\n const onKey = (e: KeyboardEvent) => {\n if (e.key !== \"Escape\") return;\n if (setupPrompt) {\n setSetupPrompt(null);\n setFormError(null);\n return;\n }\n onClose();\n };\n document.addEventListener(\"keydown\", onKey);\n return () => document.removeEventListener(\"keydown\", onKey);\n }, [isOpen, onClose, setupPrompt]);\n\n /** The round trip currently in flight, if any. */\n const pendingRef = useRef<{ app: string; returnTo: string } | null>(null);\n const popupRef = useRef<Window | null>(null);\n const pollRef = useRef<number | null>(null);\n\n const finishConnect = useCallback(() => {\n if (pollRef.current !== null) {\n window.clearInterval(pollRef.current);\n pollRef.current = null;\n }\n pendingRef.current = null;\n popupRef.current = null;\n setBusyApp(null);\n void refresh(true);\n }, [refresh]);\n\n // The callback page tells us it is done. Treat the message as a nudge, never\n // as the result: what is displayed comes from re-reading the server, so a\n // forged message can at worst cause one redundant fetch.\n useEffect(() => {\n if (!isOpen) return;\n const onMessage = (event: MessageEvent) => {\n const data = event.data as CallbackMessage | undefined;\n if (!data || data.source !== \"devic\") return;\n if (data.type !== \"integration-connected\") return;\n const pending = pendingRef.current;\n if (!pending || data.returnTo !== pending.returnTo) return;\n popupRef.current?.close();\n finishConnect();\n };\n window.addEventListener(\"message\", onMessage);\n return () => window.removeEventListener(\"message\", onMessage);\n }, [isOpen, finishConnect]);\n\n // Stop polling if the modal goes away mid-flow.\n useEffect(\n () => () => {\n if (pollRef.current !== null) window.clearInterval(pollRef.current);\n },\n []\n );\n\n /**\n * Connects an app, asking for credentials only if it needs them.\n *\n * Optimistic: the request goes out first, and the form appears only when the\n * server answers that something is missing. Most apps take an API key rather\n * than an OAuth round trip, so this is the path that used to fail outright.\n */\n const handleConnect = async (\n integration: Integration,\n values?: { authScheme: string; accountFields: Record<string, string> }\n ) => {\n if (!client || (busyApp && busyApp !== integration.app)) return;\n setActionError(null);\n setBlockedUrl(null);\n\n // Ask before doing anything when the app is known to take credentials and\n // no browser is involved. Connecting first would flash an empty popup and\n // spend a request that can only fail — the user has not been asked yet.\n const known = authByApp[integration.app];\n const scheme = values\n ? known?.find((s) => s.mode === values.authScheme)\n : preferredScheme(known);\n if (!values && scheme && !scheme.redirect && scheme.accountFields.length) {\n setSetupPrompt({ app: integration.app, schemes: known! });\n return;\n }\n\n setBusyApp(integration.app);\n\n const nonce = newNonce();\n const returnTo = `${window.location.origin}/?devic_oauth=${nonce}`;\n // Opened empty inside the click, navigated once the URL is known — browsers\n // only honour `window.open` inside the gesture that triggered it. Skipped\n // when the scheme in hand needs no browser at all.\n const popup =\n scheme && !scheme.redirect\n ? null\n : window.open(\n \"\",\n \"devic-oauth\",\n \"width=520,height=680,menubar=no,toolbar=no\"\n );\n\n try {\n const { connected, authorizationUrl } = await client.connectIntegration(\n integration.app,\n { ...scope, returnTo, ...values }\n );\n\n // Nothing to authorise: the key the user typed is the account. Close the\n // window that was opened in case it was needed and re-read the listing.\n if (connected || !authorizationUrl) {\n popup?.close();\n setSetupPrompt(null);\n finishConnect();\n return;\n }\n\n pendingRef.current = { app: integration.app, returnTo };\n setSetupPrompt(null);\n if (popup && !popup.closed) {\n popupRef.current = popup;\n popup.location.href = authorizationUrl;\n // The user may close the popup without the callback ever posting back\n // — a cancelled consent screen, or a provider that lands somewhere\n // else. Watching for the close is what keeps the card from staying\n // busy forever.\n pollRef.current = window.setInterval(() => {\n if (popup.closed) finishConnect();\n }, 700);\n } else {\n // Blocked (Safari, in-app browsers, extensions): hand over the URL.\n setBlockedUrl({ app: integration.app, url: authorizationUrl });\n setBusyApp(null);\n }\n } catch (err) {\n popup?.close();\n pendingRef.current = null;\n setBusyApp(null);\n const message = err instanceof Error ? err.message : String(err);\n const setup = (err as DevicApiError)?.setupRequired;\n if (setup) {\n await openSetupForm(integration, setup);\n return;\n }\n // While the form is up its own failures belong in it, next to the fields\n // that caused them — a message behind a dialog is a message nobody reads.\n if (setupPrompt?.app === integration.app) setFormError(message);\n else setActionError(message);\n }\n };\n\n /**\n * Opens the credentials form for an app that needs one.\n *\n * `stage: \"app\"` is not the end user's to fix — it means the developer who\n * embedded this widget has not registered an application with the provider\n * yet. Asking a stranger for someone else's client secret would be both\n * useless and a good way to teach them to hand credentials to a form, so it\n * is reported as unavailable instead.\n */\n const openSetupForm = async (\n integration: Integration,\n setup: IntegrationSetupRequired\n ) => {\n if (setup.stage === \"app\") {\n setActionError(\n `${integration.name} is not available yet — it still needs to be set up ` +\n `by the app's provider.`\n );\n return;\n }\n try {\n const schemes =\n authByApp[integration.app] ??\n (await client!.getIntegrationAuth(integration.app, scope)).schemes;\n if (!schemes.length) throw new Error(setup.message);\n setAuthByApp((prev) => ({ ...prev, [integration.app]: schemes }));\n setFormError(null);\n setSetupPrompt({ app: integration.app, setup, schemes });\n } catch (err) {\n setActionError(err instanceof Error ? err.message : String(err));\n }\n };\n\n const handleDisconnect = async (app: string, account: IntegrationAccount) => {\n if (!client || busyApp) return;\n setBusyApp(app);\n setActionError(null);\n try {\n await client.disconnectIntegration(account.id, scope);\n await refresh(true);\n } catch (err) {\n setActionError(err instanceof Error ? err.message : String(err));\n } finally {\n setBusyApp(null);\n }\n };\n\n if (!isOpen) return null;\n\n return createPortal(\n // The variables go on the overlay, not on the modal: the backdrop is part\n // of the dialog, and a portal inherits nothing from the drawer that opened\n // it.\n <div\n className=\"devic-int-overlay\"\n style={themeVars(theme)}\n data-dark={isDarkTheme(theme)}\n onClick={onClose}\n >\n <div\n className=\"devic-int-modal\"\n role=\"dialog\"\n aria-modal=\"true\"\n aria-label={title}\n onClick={(e) => e.stopPropagation()}\n >\n <div className=\"devic-int-header\">\n <h3 className=\"devic-int-title\">\n <PlugIcon />\n {title}\n </h3>\n <button\n className=\"devic-int-close\"\n onClick={onClose}\n type=\"button\"\n aria-label=\"Close\"\n >\n ×\n </button>\n </div>\n\n <div className=\"devic-int-search\">\n <SearchIcon />\n <input\n type=\"search\"\n value={query}\n onChange={(e) => setQuery(e.target.value)}\n placeholder={searchPlaceholder}\n aria-label={searchPlaceholder}\n autoComplete=\"off\"\n />\n </div>\n\n <div className=\"devic-int-body\">\n {error && <div className=\"devic-int-error\">{error}</div>}\n\n {blockedUrl && (\n <div className=\"devic-int-notice\">\n Your browser blocked the pop-up.{\" \"}\n <a\n href={blockedUrl.url}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n onClick={() => {\n pendingRef.current = null;\n setBlockedUrl(null);\n }}\n >\n Open the authorisation page\n </a>{\" \"}\n and come back — then use Refresh.\n </div>\n )}\n\n {loading && integrations.length === 0 ? (\n <div className=\"devic-int-loading\">Loading apps…</div>\n ) : integrations.length === 0 ? (\n <div className=\"devic-int-empty\">No apps available here yet.</div>\n ) : visible.length === 0 ? (\n <div className=\"devic-int-empty\">\n No apps match “{query.trim()}”.\n </div>\n ) : (\n <div className=\"devic-int-grid\">\n {visible.map((integration) => {\n const cardState = stateOf(integration);\n const busy = busyApp === integration.app;\n return (\n <div\n key={integration.app}\n className=\"devic-int-card\"\n data-state={cardState.key}\n >\n <div className=\"devic-int-card-head\">\n <IntegrationLogo integration={integration} />\n <span className=\"devic-int-state\">\n <span\n className=\"devic-int-dot\"\n data-ok={cardState.key === \"connected\"}\n data-off={cardState.key === \"disconnected\"}\n aria-hidden=\"true\"\n />\n {cardState.label}\n </span>\n </div>\n\n <div className=\"devic-int-name\" title={integration.name}>\n {integration.name}\n </div>\n\n {integration.description && (\n <div\n className=\"devic-int-description\"\n title={integration.description}\n >\n {integration.description}\n </div>\n )}\n\n <button\n type=\"button\"\n className={`devic-int-btn devic-int-btn-block${\n cardState.key === \"connected\"\n ? \"\"\n : \" devic-int-btn-primary\"\n }`}\n onClick={() => handleConnect(integration)}\n disabled={busy || !!busyApp}\n title={\n cardState.key === \"connected\"\n ? \"Sign in with a different account. The one connected now is replaced.\"\n : undefined\n }\n >\n {busy\n ? \"Waiting…\"\n : cardState.key === \"disconnected\"\n ? \"Connect\"\n : cardState.key === \"reconnect\"\n ? \"Reconnect\"\n : // Not \"Add account\": one account per app is all\n // the assistant can use, and connecting again\n // retires the previous one.\n \"Switch account\"}\n </button>\n\n {integration.accounts.length > 0 && (\n <ul className=\"devic-int-accounts\">\n {integration.accounts.map((account) => (\n <li key={account.id} className=\"devic-int-account\">\n <span\n className=\"devic-int-dot\"\n data-ok={!account.needsReconnect}\n aria-hidden=\"true\"\n />\n <span className=\"devic-int-account-label\">\n {accountLabel(account)}\n {account.needsReconnect && (\n <span className=\"devic-int-account-warn\">\n {\" \"}\n · reconnect required\n </span>\n )}\n </span>\n <button\n type=\"button\"\n className=\"devic-int-unlink\"\n onClick={() =>\n handleDisconnect(integration.app, account)\n }\n disabled={!!busyApp}\n title=\"Disconnect this account\"\n aria-label={`Disconnect ${integration.name}`}\n >\n ×\n </button>\n </li>\n ))}\n </ul>\n )}\n </div>\n );\n })}\n </div>\n )}\n </div>\n\n <div className=\"devic-int-footer\">\n <span>Only you can see and use the accounts you connect here.</span>\n <button\n type=\"button\"\n className=\"devic-int-btn devic-int-btn-small\"\n onClick={() => void refresh(true)}\n disabled={loading || !!busyApp}\n >\n Refresh\n </button>\n </div>\n </div>\n\n {/* Its own dialog, over this one: the fields and a provider's\n explanation of where to find a key do not fit in a card of a grid. */}\n {setupPrompt && promptIntegration && (\n <ConnectFieldsForm\n integration={promptIntegration}\n schemes={setupPrompt.schemes}\n initialScheme={setupPrompt.setup?.authScheme}\n onlyFields={setupPrompt.setup?.fields}\n submitting={busyApp === setupPrompt.app}\n error={formError}\n theme={theme}\n onCancel={() => {\n setSetupPrompt(null);\n setFormError(null);\n }}\n onSubmit={(values) => handleConnect(promptIntegration, values)}\n />\n )}\n </div>,\n document.body\n );\n}\n\nexport default I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AAW,CAAC,OAAO,EAC5B,aAAa,EAAE,WAAW,CAAC,KAAK,EAAE,UAAU,EAC5C,UAAU,EAAE,WAAW,CAAC,KAAK,EAAE,MAAM,EACrC,UAAU,EAAE,OAAO,KAAK,WAAW,CAAC,GAAG,EACvC,KAAK,EAAE,SAAS,EAChB,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,MAAK;oBACb,cAAc,CAAC,IAAI,CAAC;oBACpB,YAAY,CAAC,IAAI,CAAC;gBACpB,CAAC,EACD,QAAQ,EAAE,CAAC,MAAM,KAAK,aAAa,CAAC,iBAAiB,EAAE,MAAM,CAAC,GAC9D,CACH,CAAA,EAAA,CACG,EACN,QAAQ,CAAC,IAAI,CACd;AACH;;;;"}
@@ -24,7 +24,7 @@ export type { UseDevicChatOptions, UseDevicChatResult, UsePollingOptions, UsePol
24
24
  export { DevicApiClient, DevicApiError } from './api/client';
25
25
  export type { DevicApiClientConfig, TenantSessionToken } from './api/client';
26
26
  export { AgentThreadState, } from './api/types';
27
- export type { ChatMessage, ChatFile, MessageContent, ToolCall, ToolCallResponse, ProcessMessageDto, AssistantResponse, AsyncResponse, RealtimeChatHistory, RealtimeStatus, ChatHistory, AssistantSpecialization, ModelInterfaceTool, ModelInterfaceToolSchema, ResponseWidgetProps, ResponseWidgetConfig, PreviousMessage, ApiError, ConversationSummary, FeedbackSubmission, FeedbackEntry, AgentThreadDto, AgentTaskDto, AgentDto, HandOffToolResponse, ToolGroupCall, ToolGroupConfig, WhisperTranscriptionResponse, TenantLimitExceeded, TenantUsage, TenantUsageRule, TenantUsageHistoryRow, TenantUsageHistoryQuery, RecalledMemoryRecord, RecalledMemoryFact, RecalledMemoryEntity, RecalledMemoryTurn, CoreMemorySnapshot, CoreMemoryEntry, CoreMemoryLimits, CoreMemoryList, Integration, IntegrationAccount, } from './api/types';
27
+ export type { ChatMessage, ChatFile, MessageContent, ToolCall, ToolCallResponse, ProcessMessageDto, AssistantResponse, AsyncResponse, RealtimeChatHistory, RealtimeStatus, ChatHistory, AssistantSpecialization, ModelInterfaceTool, ModelInterfaceToolSchema, ResponseWidgetProps, ResponseWidgetConfig, PreviousMessage, ApiError, ConversationSummary, FeedbackSubmission, FeedbackEntry, AgentThreadDto, AgentTaskDto, AgentDto, HandOffToolResponse, ToolGroupCall, ToolGroupConfig, WhisperTranscriptionResponse, TenantLimitExceeded, TenantUsage, TenantUsageRule, TenantUsageHistoryRow, TenantUsageHistoryQuery, RecalledMemoryRecord, RecalledMemoryFact, RecalledMemoryEntity, RecalledMemoryTurn, CoreMemorySnapshot, CoreMemoryEntry, CoreMemoryLimits, CoreMemoryList, Integration, IntegrationAccount, IntegrationAuthField, IntegrationAuthScheme, IntegrationSetupRequired, } from './api/types';
28
28
  export { MessageActions, FeedbackModal } from './components/Feedback';
29
29
  export type { MessageActionsProps, FeedbackModalProps, FeedbackState, FeedbackTheme } from './components/Feedback';
30
30
  export { generateId, deepMerge, debounce, throttle, formatFileSize, storage, segmentToolCalls } from './utils';