@devicai/ui 0.45.0 → 0.47.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.
- package/README.md +39 -0
- package/dist/cjs/components/ChatDrawer/ChatDrawer.js +19 -1
- package/dist/cjs/components/ChatDrawer/ChatDrawer.js.map +1 -1
- package/dist/cjs/components/ChatDrawer/ChatInput.js +2 -2
- package/dist/cjs/components/ChatDrawer/ChatInput.js.map +1 -1
- package/dist/cjs/components/IntegrationsModal/ConnectFieldsForm.js +28 -15
- package/dist/cjs/components/IntegrationsModal/ConnectFieldsForm.js.map +1 -1
- package/dist/cjs/components/IntegrationsModal/IntegrationsModal.js +117 -34
- package/dist/cjs/components/IntegrationsModal/IntegrationsModal.js.map +1 -1
- package/dist/cjs/components/IntegrationsModal/IntegrationsToggle.js +80 -0
- package/dist/cjs/components/IntegrationsModal/IntegrationsToggle.js.map +1 -0
- package/dist/cjs/hooks/useDevicChat.js +12 -1
- package/dist/cjs/hooks/useDevicChat.js.map +1 -1
- package/dist/cjs/index.js +2 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/styles.css +1 -1
- package/dist/esm/components/ChatDrawer/ChatDrawer.js +19 -1
- package/dist/esm/components/ChatDrawer/ChatDrawer.js.map +1 -1
- package/dist/esm/components/ChatDrawer/ChatDrawer.types.d.ts +26 -0
- package/dist/esm/components/ChatDrawer/ChatInput.js +2 -2
- package/dist/esm/components/ChatDrawer/ChatInput.js.map +1 -1
- package/dist/esm/components/IntegrationsModal/ConnectFieldsForm.d.ts +14 -5
- package/dist/esm/components/IntegrationsModal/ConnectFieldsForm.js +29 -16
- package/dist/esm/components/IntegrationsModal/ConnectFieldsForm.js.map +1 -1
- package/dist/esm/components/IntegrationsModal/IntegrationsModal.js +119 -36
- package/dist/esm/components/IntegrationsModal/IntegrationsModal.js.map +1 -1
- package/dist/esm/components/IntegrationsModal/IntegrationsToggle.d.ts +35 -0
- package/dist/esm/components/IntegrationsModal/IntegrationsToggle.js +78 -0
- package/dist/esm/components/IntegrationsModal/IntegrationsToggle.js.map +1 -0
- package/dist/esm/components/IntegrationsModal/index.d.ts +2 -0
- package/dist/esm/hooks/useDevicChat.d.ts +16 -0
- package/dist/esm/hooks/useDevicChat.js +12 -1
- package/dist/esm/hooks/useDevicChat.js.map +1 -1
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/styles.css +1 -1
- package/package.json +1 -1
|
@@ -38,6 +38,21 @@ function accountLabel(account) {
|
|
|
38
38
|
return account.status.toLowerCase();
|
|
39
39
|
return `connected ${when.toLocaleDateString()}`;
|
|
40
40
|
}
|
|
41
|
+
/**
|
|
42
|
+
* The scheme the server would pick, given no explicit choice: the one asking
|
|
43
|
+
* for least setup.
|
|
44
|
+
*
|
|
45
|
+
* Mirrors the engine's own preference deliberately. It is only used to decide
|
|
46
|
+
* whether to open a popup or a form before asking, and being wrong is
|
|
47
|
+
* recoverable — the form sends its scheme explicitly, and a redirect that
|
|
48
|
+
* arrives anyway is still honoured.
|
|
49
|
+
*/
|
|
50
|
+
function preferredScheme(schemes) {
|
|
51
|
+
if (!schemes?.length)
|
|
52
|
+
return undefined;
|
|
53
|
+
const friction = (s) => (s.composioManaged ? 0 : 1);
|
|
54
|
+
return [...schemes].sort((a, b) => friction(a) - friction(b))[0];
|
|
55
|
+
}
|
|
41
56
|
function matches(integration, query) {
|
|
42
57
|
const q = query.trim().toLowerCase();
|
|
43
58
|
if (!q)
|
|
@@ -81,12 +96,48 @@ function IntegrationsModal({ isOpen, onClose, assistantId, tenantId, subtenantId
|
|
|
81
96
|
const [busyApp, setBusyApp] = React.useState(null);
|
|
82
97
|
/** Authorization URL surfaced as a link when the popup was blocked. */
|
|
83
98
|
const [blockedUrl, setBlockedUrl] = React.useState(null);
|
|
84
|
-
/** The app whose credentials are being asked for,
|
|
85
|
-
*
|
|
86
|
-
* where the user pressed Connect. */
|
|
99
|
+
/** The app whose credentials are being asked for, and every way it can be
|
|
100
|
+
* connected. `setup` is present when the server named what was missing. */
|
|
87
101
|
const [setupPrompt, setSetupPrompt] = React.useState(null);
|
|
102
|
+
/**
|
|
103
|
+
* How each offered app can be connected, read once the listing arrives.
|
|
104
|
+
*
|
|
105
|
+
* Loaded ahead of the click rather than on it: knowing whether an app needs
|
|
106
|
+
* a browser is what decides between opening a popup and opening a form, and
|
|
107
|
+
* that decision has to be made *inside* the user's gesture — a popup opened
|
|
108
|
+
* after an await is blocked.
|
|
109
|
+
*/
|
|
110
|
+
const [authByApp, setAuthByApp] = React.useState({});
|
|
111
|
+
/** Failure from the last submit, shown inside the credentials dialog. */
|
|
112
|
+
const [formError, setFormError] = React.useState(null);
|
|
88
113
|
const [query, setQuery] = React.useState("");
|
|
89
114
|
const visible = React.useMemo(() => integrations.filter((i) => matches(i, query)), [integrations, query]);
|
|
115
|
+
// Resolved from the listing rather than stored in the prompt: the dialog
|
|
116
|
+
// stays open across a refresh, and a copy taken when it opened would go
|
|
117
|
+
// stale — showing "Not connected" on an app that just connected.
|
|
118
|
+
const promptIntegration = React.useMemo(() => integrations.find((i) => i.app === setupPrompt?.app), [integrations, setupPrompt?.app]);
|
|
119
|
+
// One request per offered app, once the listing is in. They are small,
|
|
120
|
+
// cached server-side, and nothing waits on them: a click that lands before
|
|
121
|
+
// its answer simply falls back to asking the server, as it did before.
|
|
122
|
+
React.useEffect(() => {
|
|
123
|
+
if (!isOpen || !client || !integrations.length)
|
|
124
|
+
return;
|
|
125
|
+
let cancelled = false;
|
|
126
|
+
void Promise.all(integrations.map(async (integration) => {
|
|
127
|
+
try {
|
|
128
|
+
const { schemes } = await client.getIntegrationAuth(integration.app, scope);
|
|
129
|
+
if (!cancelled && schemes?.length) {
|
|
130
|
+
setAuthByApp((prev) => ({ ...prev, [integration.app]: schemes }));
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
catch {
|
|
134
|
+
// Not knowing is survivable — the click path handles it.
|
|
135
|
+
}
|
|
136
|
+
}));
|
|
137
|
+
return () => {
|
|
138
|
+
cancelled = true;
|
|
139
|
+
};
|
|
140
|
+
}, [isOpen, client, integrations, scope]);
|
|
90
141
|
// Report the listing without making the caller's identity part of the
|
|
91
142
|
// dependency: an inline arrow would fire this on every render.
|
|
92
143
|
const onChangeRef = React.useRef(onChange);
|
|
@@ -116,17 +167,24 @@ function IntegrationsModal({ isOpen, onClose, assistantId, tenantId, subtenantId
|
|
|
116
167
|
// owner is exactly what this must not do.
|
|
117
168
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
118
169
|
}, [isOpen]);
|
|
119
|
-
// Escape closes
|
|
170
|
+
// Escape closes — the credentials dialog first, when one is open. Closing
|
|
171
|
+
// everything from under a half-typed key would be its own small disaster.
|
|
120
172
|
React.useEffect(() => {
|
|
121
173
|
if (!isOpen)
|
|
122
174
|
return;
|
|
123
175
|
const onKey = (e) => {
|
|
124
|
-
if (e.key
|
|
125
|
-
|
|
176
|
+
if (e.key !== "Escape")
|
|
177
|
+
return;
|
|
178
|
+
if (setupPrompt) {
|
|
179
|
+
setSetupPrompt(null);
|
|
180
|
+
setFormError(null);
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
onClose();
|
|
126
184
|
};
|
|
127
185
|
document.addEventListener("keydown", onKey);
|
|
128
186
|
return () => document.removeEventListener("keydown", onKey);
|
|
129
|
-
}, [isOpen, onClose]);
|
|
187
|
+
}, [isOpen, onClose, setupPrompt]);
|
|
130
188
|
/** The round trip currently in flight, if any. */
|
|
131
189
|
const pendingRef = React.useRef(null);
|
|
132
190
|
const popupRef = React.useRef(null);
|
|
@@ -179,13 +237,26 @@ function IntegrationsModal({ isOpen, onClose, assistantId, tenantId, subtenantId
|
|
|
179
237
|
return;
|
|
180
238
|
setActionError(null);
|
|
181
239
|
setBlockedUrl(null);
|
|
240
|
+
// Ask before doing anything when the app is known to take credentials and
|
|
241
|
+
// no browser is involved. Connecting first would flash an empty popup and
|
|
242
|
+
// spend a request that can only fail — the user has not been asked yet.
|
|
243
|
+
const known = authByApp[integration.app];
|
|
244
|
+
const scheme = values
|
|
245
|
+
? known?.find((s) => s.mode === values.authScheme)
|
|
246
|
+
: preferredScheme(known);
|
|
247
|
+
if (!values && scheme && !scheme.redirect && scheme.accountFields.length) {
|
|
248
|
+
setSetupPrompt({ app: integration.app, schemes: known });
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
182
251
|
setBusyApp(integration.app);
|
|
183
252
|
const nonce = newNonce();
|
|
184
253
|
const returnTo = `${window.location.origin}/?devic_oauth=${nonce}`;
|
|
185
|
-
// Opened empty inside the click, navigated once the URL is known
|
|
186
|
-
//
|
|
187
|
-
//
|
|
188
|
-
const popup =
|
|
254
|
+
// Opened empty inside the click, navigated once the URL is known — browsers
|
|
255
|
+
// only honour `window.open` inside the gesture that triggered it. Skipped
|
|
256
|
+
// when the scheme in hand needs no browser at all.
|
|
257
|
+
const popup = scheme && !scheme.redirect
|
|
258
|
+
? null
|
|
259
|
+
: window.open("", "devic-oauth", "width=520,height=680,menubar=no,toolbar=no");
|
|
189
260
|
try {
|
|
190
261
|
const { connected, authorizationUrl } = await client.connectIntegration(integration.app, { ...scope, returnTo, ...values });
|
|
191
262
|
// Nothing to authorise: the key the user typed is the account. Close the
|
|
@@ -220,12 +291,18 @@ function IntegrationsModal({ isOpen, onClose, assistantId, tenantId, subtenantId
|
|
|
220
291
|
popup?.close();
|
|
221
292
|
pendingRef.current = null;
|
|
222
293
|
setBusyApp(null);
|
|
294
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
223
295
|
const setup = err?.setupRequired;
|
|
224
296
|
if (setup) {
|
|
225
297
|
await openSetupForm(integration, setup);
|
|
226
298
|
return;
|
|
227
299
|
}
|
|
228
|
-
|
|
300
|
+
// While the form is up its own failures belong in it, next to the fields
|
|
301
|
+
// that caused them — a message behind a dialog is a message nobody reads.
|
|
302
|
+
if (setupPrompt?.app === integration.app)
|
|
303
|
+
setFormError(message);
|
|
304
|
+
else
|
|
305
|
+
setActionError(message);
|
|
229
306
|
}
|
|
230
307
|
};
|
|
231
308
|
/**
|
|
@@ -244,9 +321,12 @@ function IntegrationsModal({ isOpen, onClose, assistantId, tenantId, subtenantId
|
|
|
244
321
|
return;
|
|
245
322
|
}
|
|
246
323
|
try {
|
|
247
|
-
const
|
|
324
|
+
const schemes = authByApp[integration.app] ??
|
|
325
|
+
(await client.getIntegrationAuth(integration.app, scope)).schemes;
|
|
248
326
|
if (!schemes.length)
|
|
249
327
|
throw new Error(setup.message);
|
|
328
|
+
setAuthByApp((prev) => ({ ...prev, [integration.app]: schemes }));
|
|
329
|
+
setFormError(null);
|
|
250
330
|
setSetupPrompt({ app: integration.app, setup, schemes });
|
|
251
331
|
}
|
|
252
332
|
catch (err) {
|
|
@@ -275,27 +355,30 @@ function IntegrationsModal({ isOpen, onClose, assistantId, tenantId, subtenantId
|
|
|
275
355
|
// The variables go on the overlay, not on the modal: the backdrop is part
|
|
276
356
|
// of the dialog, and a portal inherits nothing from the drawer that opened
|
|
277
357
|
// it.
|
|
278
|
-
jsxRuntime.
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
358
|
+
jsxRuntime.jsxs("div", { className: "devic-int-overlay", style: theme.themeVars(theme$1), "data-dark": theme.isDarkTheme(theme$1), onClick: onClose, children: [jsxRuntime.jsxs("div", { className: "devic-int-modal", role: "dialog", "aria-modal": "true", "aria-label": title, onClick: (e) => e.stopPropagation(), children: [jsxRuntime.jsxs("div", { className: "devic-int-header", children: [jsxRuntime.jsxs("h3", { className: "devic-int-title", children: [jsxRuntime.jsx(PlugIcon, {}), title] }), jsxRuntime.jsx("button", { className: "devic-int-close", onClick: onClose, type: "button", "aria-label": "Close", children: "\u00D7" })] }), jsxRuntime.jsxs("div", { className: "devic-int-search", children: [jsxRuntime.jsx(SearchIcon, {}), jsxRuntime.jsx("input", { type: "search", value: query, onChange: (e) => setQuery(e.target.value), placeholder: searchPlaceholder, "aria-label": searchPlaceholder, autoComplete: "off" })] }), jsxRuntime.jsxs("div", { className: "devic-int-body", children: [error && jsxRuntime.jsx("div", { className: "devic-int-error", children: error }), blockedUrl && (jsxRuntime.jsxs("div", { className: "devic-int-notice", children: ["Your browser blocked the pop-up.", " ", jsxRuntime.jsx("a", { href: blockedUrl.url, target: "_blank", rel: "noopener noreferrer", onClick: () => {
|
|
359
|
+
pendingRef.current = null;
|
|
360
|
+
setBlockedUrl(null);
|
|
361
|
+
}, children: "Open the authorisation page" }), " ", "and come back \u2014 then use Refresh."] })), loading && integrations.length === 0 ? (jsxRuntime.jsx("div", { className: "devic-int-loading", children: "Loading apps\u2026" })) : integrations.length === 0 ? (jsxRuntime.jsx("div", { className: "devic-int-empty", children: "No apps available here yet." })) : visible.length === 0 ? (jsxRuntime.jsxs("div", { className: "devic-int-empty", children: ["No apps match \u201C", query.trim(), "\u201D."] })) : (jsxRuntime.jsx("div", { className: "devic-int-grid", children: visible.map((integration) => {
|
|
362
|
+
const cardState = stateOf(integration);
|
|
363
|
+
const busy = busyApp === integration.app;
|
|
364
|
+
return (jsxRuntime.jsxs("div", { className: "devic-int-card", "data-state": cardState.key, children: [jsxRuntime.jsxs("div", { className: "devic-int-card-head", children: [jsxRuntime.jsx(IntegrationLogo.IntegrationLogo, { integration: integration }), jsxRuntime.jsxs("span", { className: "devic-int-state", children: [jsxRuntime.jsx("span", { className: "devic-int-dot", "data-ok": cardState.key === "connected", "data-off": cardState.key === "disconnected", "aria-hidden": "true" }), cardState.label] })] }), jsxRuntime.jsx("div", { className: "devic-int-name", title: integration.name, children: integration.name }), integration.description && (jsxRuntime.jsx("div", { className: "devic-int-description", title: integration.description, children: integration.description })), jsxRuntime.jsx("button", { type: "button", className: `devic-int-btn devic-int-btn-block${cardState.key === "connected"
|
|
365
|
+
? ""
|
|
366
|
+
: " devic-int-btn-primary"}`, onClick: () => handleConnect(integration), disabled: busy || !!busyApp, title: cardState.key === "connected"
|
|
367
|
+
? "Sign in with a different account. The one connected now is replaced."
|
|
368
|
+
: undefined, children: busy
|
|
369
|
+
? "Waiting…"
|
|
370
|
+
: cardState.key === "disconnected"
|
|
371
|
+
? "Connect"
|
|
372
|
+
: cardState.key === "reconnect"
|
|
373
|
+
? "Reconnect"
|
|
374
|
+
: // Not "Add account": one account per app is all
|
|
375
|
+
// the assistant can use, and connecting again
|
|
376
|
+
// retires the previous one.
|
|
377
|
+
"Switch account" }), integration.accounts.length > 0 && (jsxRuntime.jsx("ul", { className: "devic-int-accounts", children: integration.accounts.map((account) => (jsxRuntime.jsxs("li", { className: "devic-int-account", children: [jsxRuntime.jsx("span", { className: "devic-int-dot", "data-ok": !account.needsReconnect, "aria-hidden": "true" }), jsxRuntime.jsxs("span", { className: "devic-int-account-label", children: [accountLabel(account), account.needsReconnect && (jsxRuntime.jsxs("span", { className: "devic-int-account-warn", children: [" ", "\u00B7 reconnect required"] }))] }), jsxRuntime.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));
|
|
378
|
+
}) }))] }), jsxRuntime.jsxs("div", { className: "devic-int-footer", children: [jsxRuntime.jsx("span", { children: "Only you can see and use the accounts you connect here." }), jsxRuntime.jsx("button", { type: "button", className: "devic-int-btn devic-int-btn-small", onClick: () => void refresh(true), disabled: loading || !!busyApp, children: "Refresh" })] })] }), setupPrompt && promptIntegration && (jsxRuntime.jsx(ConnectFieldsForm.ConnectFieldsForm, { integration: promptIntegration, schemes: setupPrompt.schemes, initialScheme: setupPrompt.setup?.authScheme, onlyFields: setupPrompt.setup?.fields, submitting: busyApp === setupPrompt.app, error: formError, theme: theme$1, onCancel: () => {
|
|
379
|
+
setSetupPrompt(null);
|
|
380
|
+
setFormError(null);
|
|
381
|
+
}, onSubmit: (values) => handleConnect(promptIntegration, values) }))] }), document.body);
|
|
299
382
|
}
|
|
300
383
|
|
|
301
384
|
exports.IntegrationsModal = 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 { 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\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, with what the server asked\n * and every way it can be connected. Rendered inside that app's own card,\n * where the user pressed Connect. */\n const [setupPrompt, setSetupPrompt] = useState<{\n app: string;\n setup: IntegrationSetupRequired;\n schemes: IntegrationAuthScheme[];\n } | 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 // 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\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 /**\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 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. Both\n // entry points are gestures — the card's button and the form's submit —\n // so this holds on the retry too.\n const popup = 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 setup = (err as DevicApiError)?.setupRequired;\n if (setup) {\n await openSetupForm(integration, setup);\n return;\n }\n setActionError(err instanceof Error ? err.message : String(err));\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 } = await client!.getIntegrationAuth(\n integration.app,\n scope\n );\n if (!schemes.length) throw new Error(setup.message);\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 {/* The form replaces this app's button rather than opening\n a dialog of its own: it belongs to the card the user\n pressed, and the modal is already a dialog. */}\n {setupPrompt?.app === integration.app ? (\n <ConnectFieldsForm\n integration={integration}\n schemes={setupPrompt.schemes}\n initialScheme={setupPrompt.setup.authScheme}\n onlyFields={setupPrompt.setup.fields}\n submitting={busy}\n onCancel={() => setSetupPrompt(null)}\n onSubmit={(values) => handleConnect(integration, values)}\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\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","theme","useIntegrations","useState","useMemo","useRef","useEffect","useCallback","createPortal","themeVars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N,CAAC,EAAA,CACC,CACN,CAAA,EAAA,EAzGI,WAAW,CAAC,GAAG,CA0GhB;4BAEV,CAAC,CAAC,GACE,CACP,CAAA,EAAA,CACG,EAEND,eAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,kBAAkB,EAAA,QAAA,EAAA,CAC/BC,cAAA,CAAA,MAAA,EAAA,EAAA,QAAA,EAAA,yDAAA,EAAA,CAAoE,EACpEA,cAAA,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 IntegrationsModal;\n"],"names":["_jsxs","_jsx","theme","useIntegrations","useState","useMemo","useEffect","useRef","useCallback","createPortal","themeVars","isDarkTheme","IntegrationLogo","ConnectFieldsForm"],"mappings":";;;;;;;;;;AAiEA,SAAS,QAAQ,GAAA;AACf,IAAA,QACEA,eAAA,CAAA,KAAA,EAAA,EACE,KAAK,EAAC,IAAI,EACV,MAAM,EAAC,IAAI,EACX,OAAO,EAAC,WAAW,EACnB,IAAI,EAAC,MAAM,EACX,MAAM,EAAC,cAAc,EACrB,WAAW,EAAC,GAAG,EACf,aAAa,EAAC,OAAO,EACrB,cAAc,EAAC,OAAO,EAAA,aAAA,EACV,MAAM,EAAA,QAAA,EAAA,CAElBC,cAAA,CAAA,MAAA,EAAA,EAAM,CAAC,EAAC,WAAW,EAAA,CAAG,EACtBA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MAAM,CAAC,GAC9D,CACH,CAAA,EAAA,CACG,EACN,QAAQ,CAAC,IAAI,CACd;AACH;;;;"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
var React = require('react');
|
|
5
|
+
var IntegrationLogo = require('./IntegrationLogo.js');
|
|
6
|
+
|
|
7
|
+
/** A plug, matching the weight of the attach and mic icons beside it. */
|
|
8
|
+
function PlugIcon() {
|
|
9
|
+
return (jsxRuntime.jsxs("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: [jsxRuntime.jsx("path", { d: "M9 2v6" }), jsxRuntime.jsx("path", { d: "M15 2v6" }), jsxRuntime.jsx("path", { d: "M6 8h12v3a6 6 0 0 1-12 0z" }), jsxRuntime.jsx("path", { d: "M12 17v5" })] }));
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Which apps the assistant may reach on the next message.
|
|
13
|
+
*
|
|
14
|
+
* Only apps the end user has actually connected appear: an app they have not
|
|
15
|
+
* set up is not something they can switch off, and listing it here would turn
|
|
16
|
+
* this into a second, worse version of the connect dialog.
|
|
17
|
+
*
|
|
18
|
+
* The choice lives in the caller and travels with each message. Nothing is
|
|
19
|
+
* remembered on the server and nothing is disconnected — switching Gmail off
|
|
20
|
+
* for a question about a spreadsheet must not cost an OAuth round trip to
|
|
21
|
+
* undo, which is the whole reason this exists next to the composer rather than
|
|
22
|
+
* inside the apps dialog.
|
|
23
|
+
*/
|
|
24
|
+
function IntegrationsToggle({ state, disabled, onChange, onManage, label = "Apps in this chat", dark = false, busy = false, className = "", }) {
|
|
25
|
+
const [open, setOpen] = React.useState(false);
|
|
26
|
+
const ref = React.useRef(null);
|
|
27
|
+
const connected = React.useMemo(() => state.integrations.filter((i) => i.connected), [state.integrations]);
|
|
28
|
+
// Closing on an outside click and on Escape, the two ways every popover is
|
|
29
|
+
// expected to close. Bound only while open so a drawer full of these costs
|
|
30
|
+
// nothing when they are all shut.
|
|
31
|
+
React.useEffect(() => {
|
|
32
|
+
if (!open)
|
|
33
|
+
return;
|
|
34
|
+
const onPointerDown = (e) => {
|
|
35
|
+
if (!ref.current?.contains(e.target))
|
|
36
|
+
setOpen(false);
|
|
37
|
+
};
|
|
38
|
+
const onKeyDown = (e) => {
|
|
39
|
+
if (e.key === "Escape") {
|
|
40
|
+
e.stopPropagation();
|
|
41
|
+
setOpen(false);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
document.addEventListener("mousedown", onPointerDown);
|
|
45
|
+
document.addEventListener("keydown", onKeyDown, true);
|
|
46
|
+
return () => {
|
|
47
|
+
document.removeEventListener("mousedown", onPointerDown);
|
|
48
|
+
document.removeEventListener("keydown", onKeyDown, true);
|
|
49
|
+
};
|
|
50
|
+
}, [open]);
|
|
51
|
+
// An end user with nothing connected has nothing to switch: the button would
|
|
52
|
+
// open an empty box. It appears the moment they connect their first app.
|
|
53
|
+
if (!state.offered || connected.length === 0)
|
|
54
|
+
return null;
|
|
55
|
+
const off = new Set(disabled);
|
|
56
|
+
const offCount = connected.filter((i) => off.has(i.app)).length;
|
|
57
|
+
const toggle = (integration) => {
|
|
58
|
+
const next = new Set(off);
|
|
59
|
+
if (next.has(integration.app))
|
|
60
|
+
next.delete(integration.app);
|
|
61
|
+
else
|
|
62
|
+
next.add(integration.app);
|
|
63
|
+
// Only apps still on offer are kept: carrying a slug for an app the user
|
|
64
|
+
// has since disconnected would silently switch it off again if they ever
|
|
65
|
+
// reconnected it.
|
|
66
|
+
onChange(connected.filter((i) => next.has(i.app)).map((i) => i.app));
|
|
67
|
+
};
|
|
68
|
+
return (jsxRuntime.jsxs("div", { className: `devic-int-toggle ${className}`.trim(), "data-dark": dark, ref: ref, children: [jsxRuntime.jsxs("button", { type: "button", className: "devic-input-btn devic-int-toggle-btn", onClick: () => setOpen((v) => !v), disabled: busy, title: offCount
|
|
69
|
+
? `${label} — ${offCount} switched off`
|
|
70
|
+
: label, "aria-label": label, "aria-expanded": open, "aria-haspopup": "dialog", "data-some-off": offCount > 0 || undefined, children: [jsxRuntime.jsx(PlugIcon, {}), offCount > 0 && (jsxRuntime.jsx("span", { className: "devic-int-toggle-badge", "aria-hidden": "true", children: offCount }))] }), open && (jsxRuntime.jsxs("div", { className: "devic-int-toggle-popover", role: "dialog", "aria-label": label, children: [jsxRuntime.jsxs("div", { className: "devic-int-toggle-head", children: [jsxRuntime.jsx("strong", { children: label }), jsxRuntime.jsx("span", { children: "Switched off here, an app sits out your next message. It stays connected." })] }), jsxRuntime.jsx("ul", { className: "devic-int-toggle-list", children: connected.map((integration) => {
|
|
71
|
+
const on = !off.has(integration.app);
|
|
72
|
+
return (jsxRuntime.jsx("li", { children: jsxRuntime.jsxs("label", { className: "devic-int-toggle-row", children: [jsxRuntime.jsxs("span", { className: "devic-int-toggle-app", children: [jsxRuntime.jsx(IntegrationLogo.IntegrationLogo, { integration: integration }), jsxRuntime.jsx("span", { className: "devic-int-toggle-name", children: integration.name })] }), jsxRuntime.jsx("input", { type: "checkbox", className: "devic-int-toggle-switch", checked: on, onChange: () => toggle(integration), "aria-label": `Use ${integration.name} in this chat` })] }) }, integration.app));
|
|
73
|
+
}) }), onManage && (jsxRuntime.jsx("button", { type: "button", className: "devic-int-toggle-manage", onClick: () => {
|
|
74
|
+
setOpen(false);
|
|
75
|
+
onManage();
|
|
76
|
+
}, children: "Manage connected apps" }))] }))] }));
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
exports.IntegrationsToggle = IntegrationsToggle;
|
|
80
|
+
//# sourceMappingURL=IntegrationsToggle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IntegrationsToggle.js","sources":["../../../../../src/components/IntegrationsModal/IntegrationsToggle.tsx"],"sourcesContent":["import { useEffect, useMemo, useRef, useState, type JSX } from \"react\";\nimport type { Integration } from \"../../api/types\";\nimport { IntegrationLogo } from \"./IntegrationLogo\";\nimport type { IntegrationsState } from \"./useIntegrations\";\nimport \"./IntegrationsModal.css\";\n\nexport interface IntegrationsToggleProps {\n /** Shared listing (see `useIntegrations`). */\n state: IntegrationsState;\n /** Slugs currently switched off. */\n disabled: string[];\n /** Called with the full new list of switched-off slugs. */\n onChange: (disabled: string[]) => void;\n /** Opens the connected-apps modal, to connect one more. */\n onManage?: () => void;\n /** Tooltip and accessible name. @default \"Apps in this chat\" */\n label?: string;\n /** Light-on-dark, for a dark composer. */\n dark?: boolean;\n /** Disables the control while a message is in flight. */\n busy?: boolean;\n className?: string;\n}\n\n/** A plug, matching the weight of the attach and mic icons beside it. */\nfunction PlugIcon(): JSX.Element {\n return (\n <svg\n width=\"18\"\n height=\"18\"\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=\"M9 2v6\" />\n <path d=\"M15 2v6\" />\n <path d=\"M6 8h12v3a6 6 0 0 1-12 0z\" />\n <path d=\"M12 17v5\" />\n </svg>\n );\n}\n\n/**\n * Which apps the assistant may reach on the next message.\n *\n * Only apps the end user has actually connected appear: an app they have not\n * set up is not something they can switch off, and listing it here would turn\n * this into a second, worse version of the connect dialog.\n *\n * The choice lives in the caller and travels with each message. Nothing is\n * remembered on the server and nothing is disconnected — switching Gmail off\n * for a question about a spreadsheet must not cost an OAuth round trip to\n * undo, which is the whole reason this exists next to the composer rather than\n * inside the apps dialog.\n */\nexport function IntegrationsToggle({\n state,\n disabled,\n onChange,\n onManage,\n label = \"Apps in this chat\",\n dark = false,\n busy = false,\n className = \"\",\n}: IntegrationsToggleProps): JSX.Element | null {\n const [open, setOpen] = useState(false);\n const ref = useRef<HTMLDivElement>(null);\n\n const connected = useMemo(\n () => state.integrations.filter((i) => i.connected),\n [state.integrations]\n );\n\n // Closing on an outside click and on Escape, the two ways every popover is\n // expected to close. Bound only while open so a drawer full of these costs\n // nothing when they are all shut.\n useEffect(() => {\n if (!open) return;\n const onPointerDown = (e: MouseEvent) => {\n if (!ref.current?.contains(e.target as Node)) setOpen(false);\n };\n const onKeyDown = (e: KeyboardEvent) => {\n if (e.key === \"Escape\") {\n e.stopPropagation();\n setOpen(false);\n }\n };\n document.addEventListener(\"mousedown\", onPointerDown);\n document.addEventListener(\"keydown\", onKeyDown, true);\n return () => {\n document.removeEventListener(\"mousedown\", onPointerDown);\n document.removeEventListener(\"keydown\", onKeyDown, true);\n };\n }, [open]);\n\n // An end user with nothing connected has nothing to switch: the button would\n // open an empty box. It appears the moment they connect their first app.\n if (!state.offered || connected.length === 0) return null;\n\n const off = new Set(disabled);\n const offCount = connected.filter((i) => off.has(i.app)).length;\n\n const toggle = (integration: Integration) => {\n const next = new Set(off);\n if (next.has(integration.app)) next.delete(integration.app);\n else next.add(integration.app);\n // Only apps still on offer are kept: carrying a slug for an app the user\n // has since disconnected would silently switch it off again if they ever\n // reconnected it.\n onChange(connected.filter((i) => next.has(i.app)).map((i) => i.app));\n };\n\n return (\n <div\n className={`devic-int-toggle ${className}`.trim()}\n data-dark={dark}\n ref={ref}\n >\n <button\n type=\"button\"\n className=\"devic-input-btn devic-int-toggle-btn\"\n onClick={() => setOpen((v) => !v)}\n disabled={busy}\n title={\n offCount\n ? `${label} — ${offCount} switched off`\n : label\n }\n aria-label={label}\n aria-expanded={open}\n aria-haspopup=\"dialog\"\n data-some-off={offCount > 0 || undefined}\n >\n <PlugIcon />\n {offCount > 0 && (\n <span className=\"devic-int-toggle-badge\" aria-hidden=\"true\">\n {offCount}\n </span>\n )}\n </button>\n\n {open && (\n <div className=\"devic-int-toggle-popover\" role=\"dialog\" aria-label={label}>\n <div className=\"devic-int-toggle-head\">\n <strong>{label}</strong>\n <span>\n Switched off here, an app sits out your next message. It stays\n connected.\n </span>\n </div>\n\n <ul className=\"devic-int-toggle-list\">\n {connected.map((integration) => {\n const on = !off.has(integration.app);\n return (\n <li key={integration.app}>\n <label className=\"devic-int-toggle-row\">\n <span className=\"devic-int-toggle-app\">\n <IntegrationLogo integration={integration} />\n <span className=\"devic-int-toggle-name\">\n {integration.name}\n </span>\n </span>\n <input\n type=\"checkbox\"\n className=\"devic-int-toggle-switch\"\n checked={on}\n onChange={() => toggle(integration)}\n aria-label={`Use ${integration.name} in this chat`}\n />\n </label>\n </li>\n );\n })}\n </ul>\n\n {onManage && (\n <button\n type=\"button\"\n className=\"devic-int-toggle-manage\"\n onClick={() => {\n setOpen(false);\n onManage();\n }}\n >\n Manage connected apps\n </button>\n )}\n </div>\n )}\n </div>\n );\n}\n\nexport default IntegrationsToggle;\n"],"names":["_jsxs","_jsx","useState","useRef","useMemo","useEffect","IntegrationLogo"],"mappings":";;;;;;AAwBA;AACA,SAAS,QAAQ,GAAA;AACf,IAAA,QACEA,eAAA,CAAA,KAAA,EAAA,EACE,KAAK,EAAC,IAAI,EACV,MAAM,EAAC,IAAI,EACX,OAAO,EAAC,WAAW,EACnB,IAAI,EAAC,MAAM,EACX,MAAM,EAAC,cAAc,EACrB,WAAW,EAAC,GAAG,EACf,aAAa,EAAC,OAAO,EACrB,cAAc,EAAC,OAAO,EAAA,aAAA,EACV,MAAM,EAAA,QAAA,EAAA,CAElBC,cAAA,CAAA,MAAA,EAAA,EAAM,CAAC,EAAC,QAAQ,EAAA,CAAG,EACnBA,cAAA,CAAA,MAAA,EAAA,EAAM,CAAC,EAAC,SAAS,EAAA,CAAG,EACpBA,cAAA,CAAA,MAAA,EAAA,EAAM,CAAC,EAAC,2BAA2B,EAAA,CAAG,EACtCA,cAAA,CAAA,MAAA,EAAA,EAAM,CAAC,EAAC,UAAU,EAAA,CAAG,CAAA,EAAA,CACjB;AAEV;AAEA;;;;;;;;;;;;AAYG;AACG,SAAU,kBAAkB,CAAC,EACjC,KAAK,EACL,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,KAAK,GAAG,mBA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O,EAAE,EAAE,EACX,QAAQ,EAAE,MAAM,MAAM,CAAC,WAAW,CAAC,EAAA,YAAA,EACvB,CAAA,IAAA,EAAO,WAAW,CAAC,IAAI,CAAA,aAAA,CAAe,EAAA,CAClD,CAAA,EAAA,CACI,EAAA,EAfD,WAAW,CAAC,GAAG,CAgBnB;AAET,wBAAA,CAAC,CAAC,EAAA,CACC,EAEJ,QAAQ,KACPA,2BACE,IAAI,EAAC,QAAQ,EACb,SAAS,EAAC,yBAAyB,EACnC,OAAO,EAAE,MAAK;4BACZ,OAAO,CAAC,KAAK,CAAC;AACd,4BAAA,QAAQ,EAAE;AACZ,wBAAA,CAAC,sCAGM,CACV,CAAA,EAAA,CACG,CACP,CAAA,EAAA,CACG;AAEV;;;;"}
|
|
@@ -37,7 +37,7 @@ const DEFAULT_HANDOFF_POLL_INTERVAL_MS = 5000;
|
|
|
37
37
|
* ```
|
|
38
38
|
*/
|
|
39
39
|
function useDevicChat(options) {
|
|
40
|
-
const { assistantId, chatUid: initialChatUid, apiKey: propsApiKey, baseUrl: propsBaseUrl, tenantId, tenantMetadata, subtenantId, subtenantMetadata, tags, enabledTools, modelInterfaceTools = [], pollingInterval: propsPollingInterval, onMessageSent, onMessageReceived, onToolCall, onError, onChatCreated, onFileUpload, debug: propsDebug, } = options;
|
|
40
|
+
const { assistantId, chatUid: initialChatUid, apiKey: propsApiKey, baseUrl: propsBaseUrl, tenantId, tenantMetadata, subtenantId, subtenantMetadata, tags, enabledTools, disabledIntegrations, modelInterfaceTools = [], pollingInterval: propsPollingInterval, onMessageSent, onMessageReceived, onToolCall, onError, onChatCreated, onFileUpload, debug: propsDebug, } = options;
|
|
41
41
|
// Get context (may be null if not wrapped in provider)
|
|
42
42
|
const context = DevicContext.useOptionalDevicContext();
|
|
43
43
|
// Resolve configuration
|
|
@@ -425,6 +425,13 @@ function useDevicChat(options) {
|
|
|
425
425
|
return merged.length > 0 ? { tags: merged } : {};
|
|
426
426
|
})(),
|
|
427
427
|
enabledTools,
|
|
428
|
+
// The end user's own apps that sit this message out. Sent only when
|
|
429
|
+
// some are switched off: an older API ignores the field, and there is
|
|
430
|
+
// no reason to put an empty array in every request.
|
|
431
|
+
...(() => {
|
|
432
|
+
const off = sendOptions?.disabledIntegrations ?? disabledIntegrations;
|
|
433
|
+
return off?.length ? { disabledIntegrations: off } : {};
|
|
434
|
+
})(),
|
|
428
435
|
// Include model interface tools if any
|
|
429
436
|
...(toolSchemas.length > 0 && { tools: toolSchemas }),
|
|
430
437
|
// Link to the speech-to-text transcript that seeded this message, if any
|
|
@@ -467,6 +474,10 @@ function useDevicChat(options) {
|
|
|
467
474
|
chatUid,
|
|
468
475
|
assistantId,
|
|
469
476
|
enabledTools,
|
|
477
|
+
// Without this, the callback keeps the list from the render that created
|
|
478
|
+
// it: switching an app off would not take effect until something else
|
|
479
|
+
// happened to rebuild it.
|
|
480
|
+
disabledIntegrations,
|
|
470
481
|
resolvedTenantId,
|
|
471
482
|
resolvedTenantMetadata,
|
|
472
483
|
resolvedSubtenantId,
|