@devicai/ui 0.57.0 → 0.58.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 +162 -0
- package/dist/cjs/api/types.js.map +1 -1
- package/dist/cjs/components/AICommandBar/AICommandBar.js +10 -7
- package/dist/cjs/components/AICommandBar/AICommandBar.js.map +1 -1
- package/dist/cjs/components/AICommandBar/useAICommandBar.js +7 -5
- package/dist/cjs/components/AICommandBar/useAICommandBar.js.map +1 -1
- package/dist/cjs/components/AIElementWrapper/AIElementWrapper.js +17 -14
- package/dist/cjs/components/AIElementWrapper/AIElementWrapper.js.map +1 -1
- package/dist/cjs/components/AIElementWrapper/useAIElementWrapper.js +7 -5
- package/dist/cjs/components/AIElementWrapper/useAIElementWrapper.js.map +1 -1
- package/dist/cjs/components/AIGenerationButton/AIGenerationButton.js +11 -6
- package/dist/cjs/components/AIGenerationButton/AIGenerationButton.js.map +1 -1
- package/dist/cjs/components/AIGenerationButton/useAIGenerationButton.js +6 -4
- package/dist/cjs/components/AIGenerationButton/useAIGenerationButton.js.map +1 -1
- package/dist/cjs/components/ChatDrawer/ChatDrawer.js +26 -12
- package/dist/cjs/components/ChatDrawer/ChatDrawer.js.map +1 -1
- package/dist/cjs/components/ChatDrawer/ChatInput.js +21 -15
- package/dist/cjs/components/ChatDrawer/ChatInput.js.map +1 -1
- package/dist/cjs/components/ChatDrawer/ChatMessages.js +54 -13
- package/dist/cjs/components/ChatDrawer/ChatMessages.js.map +1 -1
- package/dist/cjs/components/ChatDrawer/CompactionWidget.js +13 -4
- package/dist/cjs/components/ChatDrawer/CompactionWidget.js.map +1 -1
- package/dist/cjs/components/ChatDrawer/ConversationSelector.js +6 -4
- package/dist/cjs/components/ChatDrawer/ConversationSelector.js.map +1 -1
- package/dist/cjs/components/ChatDrawer/GuardrailNotice.js +40 -0
- package/dist/cjs/components/ChatDrawer/GuardrailNotice.js.map +1 -0
- package/dist/cjs/components/ChatDrawer/HandoffSubagentWidget.js +3 -1
- package/dist/cjs/components/ChatDrawer/HandoffSubagentWidget.js.map +1 -1
- package/dist/cjs/components/ChatDrawer/LimitBanner.js +19 -9
- package/dist/cjs/components/ChatDrawer/LimitBanner.js.map +1 -1
- package/dist/cjs/components/ChatDrawer/QueueNotice.js +19 -7
- package/dist/cjs/components/ChatDrawer/QueueNotice.js.map +1 -1
- package/dist/cjs/components/ChatDrawer/RecalledMemoriesWidget.js +17 -5
- package/dist/cjs/components/ChatDrawer/RecalledMemoriesWidget.js.map +1 -1
- package/dist/cjs/components/ChatDrawer/ReferenceChip.js +3 -1
- package/dist/cjs/components/ChatDrawer/ReferenceChip.js.map +1 -1
- package/dist/cjs/components/ChatDrawer/UsageBar.js +23 -18
- package/dist/cjs/components/ChatDrawer/UsageBar.js.map +1 -1
- package/dist/cjs/components/CoreMemoryModal/CoreMemoryModal.js +20 -9
- package/dist/cjs/components/CoreMemoryModal/CoreMemoryModal.js.map +1 -1
- package/dist/cjs/components/Feedback/FeedbackModal.js +5 -1
- package/dist/cjs/components/Feedback/FeedbackModal.js.map +1 -1
- package/dist/cjs/components/Feedback/MessageActions.js +3 -1
- package/dist/cjs/components/Feedback/MessageActions.js.map +1 -1
- package/dist/cjs/components/IntegrationsModal/ConnectFieldsForm.js +12 -8
- package/dist/cjs/components/IntegrationsModal/ConnectFieldsForm.js.map +1 -1
- package/dist/cjs/components/IntegrationsModal/IntegrationsHint.js +5 -3
- package/dist/cjs/components/IntegrationsModal/IntegrationsHint.js.map +1 -1
- package/dist/cjs/components/IntegrationsModal/IntegrationsLauncher.js +12 -3
- package/dist/cjs/components/IntegrationsModal/IntegrationsLauncher.js.map +1 -1
- package/dist/cjs/components/IntegrationsModal/IntegrationsPanel.js +34 -24
- package/dist/cjs/components/IntegrationsModal/IntegrationsPanel.js.map +1 -1
- package/dist/cjs/components/IntegrationsModal/IntegrationsToggle.js +15 -6
- package/dist/cjs/components/IntegrationsModal/IntegrationsToggle.js.map +1 -1
- package/dist/cjs/components/IntegrationsModal/McpConnectForm.js +15 -7
- package/dist/cjs/components/IntegrationsModal/McpConnectForm.js.map +1 -1
- package/dist/cjs/components/IntegrationsModal/McpServersSection.js +32 -19
- package/dist/cjs/components/IntegrationsModal/McpServersSection.js.map +1 -1
- package/dist/cjs/components/IntegrationsModal/useIntegrations.js +3 -1
- package/dist/cjs/components/IntegrationsModal/useIntegrations.js.map +1 -1
- package/dist/cjs/components/IntegrationsModal/useTenantMcp.js +3 -1
- package/dist/cjs/components/IntegrationsModal/useTenantMcp.js.map +1 -1
- package/dist/cjs/components/ThreadStateTag/ThreadStateTag.js +63 -40
- package/dist/cjs/components/ThreadStateTag/ThreadStateTag.js.map +1 -1
- package/dist/cjs/hooks/useDevicChat.js +11 -5
- package/dist/cjs/hooks/useDevicChat.js.map +1 -1
- package/dist/cjs/hooks/useSpeechRecording.js +8 -4
- package/dist/cjs/hooks/useSpeechRecording.js.map +1 -1
- package/dist/cjs/i18n/translate.js +48 -0
- package/dist/cjs/i18n/translate.js.map +1 -0
- package/dist/cjs/i18n/useTranslations.js +57 -0
- package/dist/cjs/i18n/useTranslations.js.map +1 -0
- package/dist/cjs/index.js +11 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/provider/DevicProvider.js +3 -1
- package/dist/cjs/provider/DevicProvider.js.map +1 -1
- package/dist/cjs/styles.css +1 -1
- package/dist/esm/api/types.d.ts +10 -1
- package/dist/esm/api/types.js.map +1 -1
- package/dist/esm/components/AICommandBar/AICommandBar.js +11 -8
- package/dist/esm/components/AICommandBar/AICommandBar.js.map +1 -1
- package/dist/esm/components/AICommandBar/AICommandBar.types.d.ts +10 -0
- package/dist/esm/components/AICommandBar/useAICommandBar.js +7 -5
- package/dist/esm/components/AICommandBar/useAICommandBar.js.map +1 -1
- package/dist/esm/components/AIElementWrapper/AIElementWrapper.js +17 -14
- package/dist/esm/components/AIElementWrapper/AIElementWrapper.js.map +1 -1
- package/dist/esm/components/AIElementWrapper/AIElementWrapper.types.d.ts +10 -0
- package/dist/esm/components/AIElementWrapper/useAIElementWrapper.js +7 -5
- package/dist/esm/components/AIElementWrapper/useAIElementWrapper.js.map +1 -1
- package/dist/esm/components/AIGenerationButton/AIGenerationButton.js +12 -7
- package/dist/esm/components/AIGenerationButton/AIGenerationButton.js.map +1 -1
- package/dist/esm/components/AIGenerationButton/AIGenerationButton.types.d.ts +10 -0
- package/dist/esm/components/AIGenerationButton/useAIGenerationButton.js +6 -4
- package/dist/esm/components/AIGenerationButton/useAIGenerationButton.js.map +1 -1
- package/dist/esm/components/ChatDrawer/ChatDrawer.js +27 -13
- package/dist/esm/components/ChatDrawer/ChatDrawer.js.map +1 -1
- package/dist/esm/components/ChatDrawer/ChatDrawer.types.d.ts +33 -0
- package/dist/esm/components/ChatDrawer/ChatInput.js +21 -15
- package/dist/esm/components/ChatDrawer/ChatInput.js.map +1 -1
- package/dist/esm/components/ChatDrawer/ChatMessages.d.ts +1 -1
- package/dist/esm/components/ChatDrawer/ChatMessages.js +54 -13
- package/dist/esm/components/ChatDrawer/ChatMessages.js.map +1 -1
- package/dist/esm/components/ChatDrawer/CompactionWidget.js +13 -4
- package/dist/esm/components/ChatDrawer/CompactionWidget.js.map +1 -1
- package/dist/esm/components/ChatDrawer/ConversationSelector.js +6 -4
- package/dist/esm/components/ChatDrawer/ConversationSelector.js.map +1 -1
- package/dist/esm/components/ChatDrawer/GuardrailNotice.d.ts +36 -0
- package/dist/esm/components/ChatDrawer/GuardrailNotice.js +38 -0
- package/dist/esm/components/ChatDrawer/GuardrailNotice.js.map +1 -0
- package/dist/esm/components/ChatDrawer/HandoffSubagentWidget.js +3 -1
- package/dist/esm/components/ChatDrawer/HandoffSubagentWidget.js.map +1 -1
- package/dist/esm/components/ChatDrawer/LimitBanner.js +19 -9
- package/dist/esm/components/ChatDrawer/LimitBanner.js.map +1 -1
- package/dist/esm/components/ChatDrawer/QueueNotice.js +19 -7
- package/dist/esm/components/ChatDrawer/QueueNotice.js.map +1 -1
- package/dist/esm/components/ChatDrawer/RecalledMemoriesWidget.js +17 -5
- package/dist/esm/components/ChatDrawer/RecalledMemoriesWidget.js.map +1 -1
- package/dist/esm/components/ChatDrawer/ReferenceChip.js +3 -1
- package/dist/esm/components/ChatDrawer/ReferenceChip.js.map +1 -1
- package/dist/esm/components/ChatDrawer/UsageBar.js +23 -18
- package/dist/esm/components/ChatDrawer/UsageBar.js.map +1 -1
- package/dist/esm/components/ChatDrawer/index.d.ts +2 -0
- package/dist/esm/components/CoreMemoryModal/CoreMemoryModal.js +20 -9
- package/dist/esm/components/CoreMemoryModal/CoreMemoryModal.js.map +1 -1
- package/dist/esm/components/Feedback/FeedbackModal.js +5 -1
- package/dist/esm/components/Feedback/FeedbackModal.js.map +1 -1
- package/dist/esm/components/Feedback/MessageActions.js +3 -1
- package/dist/esm/components/Feedback/MessageActions.js.map +1 -1
- package/dist/esm/components/IntegrationsModal/ConnectFieldsForm.js +12 -8
- package/dist/esm/components/IntegrationsModal/ConnectFieldsForm.js.map +1 -1
- package/dist/esm/components/IntegrationsModal/IntegrationsHint.js +5 -3
- package/dist/esm/components/IntegrationsModal/IntegrationsHint.js.map +1 -1
- package/dist/esm/components/IntegrationsModal/IntegrationsLauncher.js +12 -3
- package/dist/esm/components/IntegrationsModal/IntegrationsLauncher.js.map +1 -1
- package/dist/esm/components/IntegrationsModal/IntegrationsPanel.d.ts +1 -1
- package/dist/esm/components/IntegrationsModal/IntegrationsPanel.js +34 -24
- package/dist/esm/components/IntegrationsModal/IntegrationsPanel.js.map +1 -1
- package/dist/esm/components/IntegrationsModal/IntegrationsToggle.d.ts +1 -1
- package/dist/esm/components/IntegrationsModal/IntegrationsToggle.js +15 -6
- package/dist/esm/components/IntegrationsModal/IntegrationsToggle.js.map +1 -1
- package/dist/esm/components/IntegrationsModal/McpConnectForm.js +15 -7
- package/dist/esm/components/IntegrationsModal/McpConnectForm.js.map +1 -1
- package/dist/esm/components/IntegrationsModal/McpServersSection.js +32 -19
- package/dist/esm/components/IntegrationsModal/McpServersSection.js.map +1 -1
- package/dist/esm/components/IntegrationsModal/useIntegrations.js +3 -1
- package/dist/esm/components/IntegrationsModal/useIntegrations.js.map +1 -1
- package/dist/esm/components/IntegrationsModal/useTenantMcp.js +3 -1
- package/dist/esm/components/IntegrationsModal/useTenantMcp.js.map +1 -1
- package/dist/esm/components/ThreadStateTag/ThreadStateTag.js +63 -40
- package/dist/esm/components/ThreadStateTag/ThreadStateTag.js.map +1 -1
- package/dist/esm/hooks/useDevicChat.js +12 -6
- package/dist/esm/hooks/useDevicChat.js.map +1 -1
- package/dist/esm/hooks/useSpeechRecording.js +8 -4
- package/dist/esm/hooks/useSpeechRecording.js.map +1 -1
- package/dist/esm/i18n/index.d.ts +4 -0
- package/dist/esm/i18n/translate.d.ts +23 -0
- package/dist/esm/i18n/translate.js +43 -0
- package/dist/esm/i18n/translate.js.map +1 -0
- package/dist/esm/i18n/types.d.ts +27 -0
- package/dist/esm/i18n/useTranslations.d.ts +32 -0
- package/dist/esm/i18n/useTranslations.js +53 -0
- package/dist/esm/i18n/useTranslations.js.map +1 -0
- package/dist/esm/index.d.ts +4 -2
- package/dist/esm/index.js +3 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/provider/DevicProvider.d.ts +1 -1
- package/dist/esm/provider/DevicProvider.js +3 -1
- package/dist/esm/provider/DevicProvider.js.map +1 -1
- package/dist/esm/provider/types.d.ts +33 -0
- package/dist/esm/styles.css +1 -1
- package/package.json +1 -1
|
@@ -7,6 +7,7 @@ import { IntegrationLogo } from './IntegrationLogo.js';
|
|
|
7
7
|
import { useIntegrations } from './useIntegrations.js';
|
|
8
8
|
import { McpServersSection } from './McpServersSection.js';
|
|
9
9
|
import { useTenantMcp } from './useTenantMcp.js';
|
|
10
|
+
import { useTranslations } from '../../i18n/useTranslations.js';
|
|
10
11
|
|
|
11
12
|
function PlugIcon() {
|
|
12
13
|
return (jsxs("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: [jsx("path", { d: "M12 22v-5" }), jsx("path", { d: "M9 8V2" }), jsx("path", { d: "M15 8V2" }), jsx("path", { d: "M18 8v5a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V8Z" })] }));
|
|
@@ -22,21 +23,24 @@ function newNonce() {
|
|
|
22
23
|
return `${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;
|
|
23
24
|
}
|
|
24
25
|
/** How the card describes an app at a glance. */
|
|
25
|
-
function stateOf(integration) {
|
|
26
|
-
if (integration.connected)
|
|
27
|
-
return { key: "connected", label: "Connected" };
|
|
26
|
+
function stateOf(t, integration) {
|
|
27
|
+
if (integration.connected) {
|
|
28
|
+
return { key: "connected", label: t("Connected") };
|
|
29
|
+
}
|
|
28
30
|
if (integration.accounts.some((a) => a.needsReconnect)) {
|
|
29
|
-
return { key: "reconnect", label: "Needs reconnection" };
|
|
31
|
+
return { key: "reconnect", label: t("Needs reconnection") };
|
|
30
32
|
}
|
|
31
|
-
return { key: "disconnected", label: "Not connected" };
|
|
33
|
+
return { key: "disconnected", label: t("Not connected") };
|
|
32
34
|
}
|
|
33
|
-
function accountLabel(account) {
|
|
35
|
+
function accountLabel(t, account) {
|
|
36
|
+
// The status comes from the provider, so it is passed through the dictionary
|
|
37
|
+
// as-is rather than assumed to be one of a known set.
|
|
34
38
|
if (!account.connectedAt)
|
|
35
|
-
return account.status.toLowerCase();
|
|
39
|
+
return t(account.status.toLowerCase());
|
|
36
40
|
const when = new Date(account.connectedAt);
|
|
37
41
|
if (Number.isNaN(when.getTime()))
|
|
38
|
-
return account.status.toLowerCase();
|
|
39
|
-
return
|
|
42
|
+
return t(account.status.toLowerCase());
|
|
43
|
+
return t("connected {date}", { date: when.toLocaleDateString() });
|
|
40
44
|
}
|
|
41
45
|
/**
|
|
42
46
|
* The scheme the server would pick, given no explicit choice: the one asking
|
|
@@ -83,7 +87,12 @@ function matches(integration, query) {
|
|
|
83
87
|
* after the round trip is what gets it blocked. When it is blocked anyway, the
|
|
84
88
|
* URL is offered as a link instead.
|
|
85
89
|
*/
|
|
86
|
-
function IntegrationsPanel({ assistantId, tenantId, subtenantId, apiKey, baseUrl, title
|
|
90
|
+
function IntegrationsPanel({ assistantId, tenantId, subtenantId, apiKey, baseUrl, title: titleProp, searchPlaceholder: searchPlaceholderProp, onChange, theme, state, mcpState, active = true, showHeader = true, showSearch = true, showFooter = true, onClose, className, dialog = false, }) {
|
|
91
|
+
const t = useTranslations();
|
|
92
|
+
// The host's own wording wins; with none, the defaults go through the
|
|
93
|
+
// dictionary like every other text in the panel.
|
|
94
|
+
const title = titleProp ?? t("Connected apps");
|
|
95
|
+
const searchPlaceholder = searchPlaceholderProp ?? t("Search connected apps");
|
|
87
96
|
// Hooks cannot be skipped, so the fallback is always built and only fetches
|
|
88
97
|
// when nobody handed a listing down.
|
|
89
98
|
const own = useIntegrations({
|
|
@@ -345,8 +354,7 @@ function IntegrationsPanel({ assistantId, tenantId, subtenantId, apiKey, baseUrl
|
|
|
345
354
|
*/
|
|
346
355
|
const openSetupForm = async (integration, setup) => {
|
|
347
356
|
if (setup.stage === "app") {
|
|
348
|
-
setActionError(
|
|
349
|
-
`by the app's provider.`);
|
|
357
|
+
setActionError(t("{app} is not available yet — it still needs to be set up by the app's provider.", { app: integration.name }));
|
|
350
358
|
return;
|
|
351
359
|
}
|
|
352
360
|
try {
|
|
@@ -393,37 +401,39 @@ function IntegrationsPanel({ assistantId, tenantId, subtenantId, apiKey, baseUrl
|
|
|
393
401
|
className ?? "",
|
|
394
402
|
]
|
|
395
403
|
.filter(Boolean)
|
|
396
|
-
.join(" "), style: themeVars(theme), "data-dark": dark, role: dialog ? "dialog" : "region", "aria-modal": dialog || undefined, "aria-label": title, onClick: dialog ? (e) => e.stopPropagation() : undefined, children: [showHeader && (jsxs("div", { className: "devic-int-header", children: [jsxs("h3", { className: "devic-int-title", children: [jsx(PlugIcon, {}), title] }), onClose && (jsx("button", { className: "devic-int-close", onClick: onClose, type: "button", "aria-label": "Close", children: "\u00D7" }))] })), showSearch && (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: () => {
|
|
404
|
+
.join(" "), style: themeVars(theme), "data-dark": dark, role: dialog ? "dialog" : "region", "aria-modal": dialog || undefined, "aria-label": title, onClick: dialog ? (e) => e.stopPropagation() : undefined, children: [showHeader && (jsxs("div", { className: "devic-int-header", children: [jsxs("h3", { className: "devic-int-title", children: [jsx(PlugIcon, {}), title] }), onClose && (jsx("button", { className: "devic-int-close", onClick: onClose, type: "button", "aria-label": t("Close"), children: "\u00D7" }))] })), showSearch && (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: [t("Your browser blocked the pop-up."), " ", jsx("a", { href: blockedUrl.url, target: "_blank", rel: "noopener noreferrer", onClick: () => {
|
|
397
405
|
pendingRef.current = null;
|
|
398
406
|
setBlockedUrl(null);
|
|
399
|
-
}, children: "Open the authorisation page" }), " ", "and come back
|
|
407
|
+
}, children: t("Open the authorisation page") }), " ", t("and come back — then use Refresh.")] })), loading && integrations.length === 0 ? (
|
|
400
408
|
// Silent while the MCP section is what this assistant offers: a
|
|
401
409
|
// spinner labelled "Loading apps" over a list of servers describes
|
|
402
410
|
// something that is not happening.
|
|
403
|
-
appsRefusalIsNoise ? null : (jsx("div", { className: "devic-int-loading", children: "Loading apps
|
|
411
|
+
appsRefusalIsNoise ? null : (jsx("div", { className: "devic-int-loading", children: t("Loading apps…") }))) : integrations.length === 0 ? (
|
|
404
412
|
// Silent when MCP servers are the whole offer: "no apps available"
|
|
405
413
|
// over a list of servers reads as a broken panel.
|
|
406
|
-
mcp.offered ? null : (jsx("div", { className: "devic-int-empty", children: "No apps available here yet." }))) : visible.length === 0 ? (
|
|
407
|
-
const cardState = stateOf(integration);
|
|
414
|
+
mcp.offered ? null : (jsx("div", { className: "devic-int-empty", children: t("No apps available here yet.") }))) : visible.length === 0 ? (jsx("div", { className: "devic-int-empty", children: t("No apps match “{query}”.", { query: query.trim() }) })) : (jsx("div", { className: "devic-int-grid", children: visible.map((integration) => {
|
|
415
|
+
const cardState = stateOf(t, integration);
|
|
408
416
|
const busy = busyApp === integration.app;
|
|
409
417
|
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"
|
|
410
418
|
? ""
|
|
411
419
|
: " devic-int-btn-primary"}`, onClick: () => handleConnect(integration), disabled: busy || !!busyApp, title: cardState.key === "connected"
|
|
412
|
-
? "Sign in with a different account. The one connected now is replaced."
|
|
420
|
+
? t("Sign in with a different account. The one connected now is replaced.")
|
|
413
421
|
: undefined, children: busy
|
|
414
|
-
? "Waiting…"
|
|
422
|
+
? t("Waiting…")
|
|
415
423
|
: cardState.key === "disconnected"
|
|
416
|
-
? "Connect"
|
|
424
|
+
? t("Connect")
|
|
417
425
|
: cardState.key === "reconnect"
|
|
418
|
-
? "Reconnect"
|
|
426
|
+
? t("Reconnect")
|
|
419
427
|
: // Not "Add account": one account per app is all
|
|
420
428
|
// the assistant can use, and connecting again
|
|
421
429
|
// retires the previous one.
|
|
422
|
-
"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":
|
|
423
|
-
|
|
430
|
+
t("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(t, account), account.needsReconnect && (jsxs("span", { className: "devic-int-account-warn", children: [" ", "\u00B7 ", t("reconnect required")] }))] }), jsx("button", { type: "button", className: "devic-int-unlink", onClick: () => handleDisconnect(integration.app, account), disabled: !!busyApp, title: t("Disconnect this account"), "aria-label": t("Disconnect {app}", {
|
|
431
|
+
app: integration.name,
|
|
432
|
+
}), children: "\u00D7" })] }, account.id))) }))] }, integration.app));
|
|
433
|
+
}) }))] }), mcp.offered && (jsx("div", { className: "devic-int-body devic-int-body-secondary", children: jsx(McpServersSection, { state: mcp, theme: theme, query: query }) })), showFooter && (jsxs("div", { className: "devic-int-footer", children: [jsx("span", { children: t("Only you can see and use the accounts you connect here.") }), jsx("button", { type: "button", className: "devic-int-btn devic-int-btn-small", onClick: () => {
|
|
424
434
|
void refresh(true);
|
|
425
435
|
void mcp.refresh();
|
|
426
|
-
}, disabled: loading || mcp.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: () => {
|
|
436
|
+
}, disabled: loading || mcp.loading || !!busyApp, children: t("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: () => {
|
|
427
437
|
setSetupPrompt(null);
|
|
428
438
|
setFormError(null);
|
|
429
439
|
}, onSubmit: (values) => handleConnect(promptIntegration, values) }))] }));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IntegrationsPanel.js","sources":["../../../../src/components/IntegrationsModal/IntegrationsPanel.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 { McpServersSection } from \"./McpServersSection\";\nimport { useTenantMcp, type TenantMcpState } from \"./useTenantMcp\";\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 IntegrationsPanelProps {\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 /** Heading text, and the accessible name of the region. @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 * Embedded in a page the same applies for a different reason: the panel\n * renders in its own variables and inherits nothing from the surface around\n * it, so a host with its own palette has to say so here.\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 * MCP listing loaded elsewhere, same reasoning as `state`. When absent this\n * loads its own — and only while on screen, so an assistant that offers no\n * MCP servers costs one refusal and nothing more.\n */\n mcpState?: TenantMcpState;\n /**\n * Whether the panel is on screen. Renders nothing and asks for nothing while\n * false, without dropping what it already knows — which is how the modal\n * closes without paying for the whole listing again on the next open.\n *\n * @default true\n */\n active?: boolean;\n /**\n * The heading, with the plug icon and the title. Turn it off to put the\n * panel under a heading of your own.\n *\n * @default true\n */\n showHeader?: boolean;\n /** The search field. @default true */\n showSearch?: boolean;\n /**\n * The footer, with the privacy note and the Refresh button. Off, nothing else\n * re-reads the listing on demand — keep `state` yourself and call its\n * `refresh` if you drive it from your own control.\n *\n * @default true\n */\n showFooter?: boolean;\n /**\n * Shown as a close button in the header, and called when Escape is pressed.\n * The modal is what usually passes it; embedded, only pass it if the panel\n * is dismissible.\n */\n onClose?: () => void;\n className?: string;\n /**\n * Render inside the modal's backdrop, in a portal on `document.body`.\n *\n * This is what `IntegrationsModal` is, and that component is the one to use\n * — it exists here because both forms share every line of what follows.\n */\n dialog?: boolean;\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 * 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 * The same panel serves both shapes it is asked for. `IntegrationsModal` is\n * this with `dialog`, opened from the drawer's header; on its own it drops into\n * a settings page as an ordinary block, which is the form a host wants when\n * connecting apps is a section of their product rather than an interruption of\n * a chat.\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 IntegrationsPanel({\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 mcpState,\n active = true,\n showHeader = true,\n showSearch = true,\n showFooter = true,\n onClose,\n className,\n dialog = false,\n}: IntegrationsPanelProps): 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: active && !state,\n });\n const {\n integrations,\n loading,\n error: loadError,\n offered: appsOffered,\n refresh,\n client,\n scope,\n } = state ?? own;\n\n // Same shape as above: always built (hooks cannot be skipped), fetching only\n // when nobody handed a listing down.\n const ownMcp = useTenantMcp({\n assistantId,\n tenantId,\n subtenantId,\n apiKey,\n baseUrl,\n enabled: active && !mcpState,\n });\n const mcp = mcpState ?? ownMcp;\n\n /** Errors from connecting or disconnecting, kept apart from load failures. */\n const [actionError, setActionError] = useState<string | null>(null);\n // An assistant may offer MCP servers and no apps at all, and then the apps\n // endpoint answers \"not for you\" — an ordinary answer, not a failure. Showing\n // it would put a red panel above a section that is working perfectly. The\n // refusal is still surfaced when there is nothing else on offer, because then\n // an empty dialog with no explanation is worse.\n const appsRefusalIsNoise = !appsOffered && mcp.offered;\n const error = actionError ?? (appsRefusalIsNoise ? null : 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 (!active || !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 }, [active, 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 (active && !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 if (mcpState || openedBeforeRef.current) void mcp.refresh();\n openedBeforeRef.current = true;\n }\n wasOpenRef.current = active;\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 }, [active]);\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 //\n // Embedded in a page there is usually nothing to close after that, and the\n // key is left alone rather than swallowed: a panel that is part of the page\n // has no business answering for the whole document.\n useEffect(() => {\n if (!active) 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 }, [active, 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 (!active) 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 }, [active, 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 (!active) return null;\n\n const dark = isDarkTheme(theme);\n\n const panel = (\n // The variables go here rather than on the backdrop, because this is the\n // one element both shapes have: as a dialog it renders in a portal that\n // inherits nothing from the drawer that opened it, and embedded it must\n // not inherit the host's either — the colours it draws in are the ones\n // `theme` names, and nothing else.\n <div\n className={[\n \"devic-int-panel\",\n dialog ? \"devic-int-modal\" : \"\",\n className ?? \"\",\n ]\n .filter(Boolean)\n .join(\" \")}\n style={themeVars(theme)}\n data-dark={dark}\n role={dialog ? \"dialog\" : \"region\"}\n aria-modal={dialog || undefined}\n aria-label={title}\n onClick={dialog ? (e) => e.stopPropagation() : undefined}\n >\n {showHeader && (\n <div className=\"devic-int-header\">\n <h3 className=\"devic-int-title\">\n <PlugIcon />\n {title}\n </h3>\n {onClose && (\n <button\n className=\"devic-int-close\"\n onClick={onClose}\n type=\"button\"\n aria-label=\"Close\"\n >\n ×\n </button>\n )}\n </div>\n )}\n\n {showSearch && (\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\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 // Silent while the MCP section is what this assistant offers: a\n // spinner labelled \"Loading apps\" over a list of servers describes\n // something that is not happening.\n appsRefusalIsNoise ? null : (\n <div className=\"devic-int-loading\">Loading apps…</div>\n )\n ) : integrations.length === 0 ? (\n // Silent when MCP servers are the whole offer: \"no apps available\"\n // over a list of servers reads as a broken panel.\n mcp.offered ? null : (\n <div className=\"devic-int-empty\">No apps available here yet.</div>\n )\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 {/* Below the apps, in the same panel: to the end user these are one\n question — what can I plug into this chat — and two panels would\n mean finding out which of them a thing lives in. */}\n {mcp.offered && (\n <div className=\"devic-int-body devic-int-body-secondary\">\n <McpServersSection state={mcp} theme={theme} query={query} />\n </div>\n )}\n\n {showFooter && (\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={() => {\n void refresh(true);\n void mcp.refresh();\n }}\n disabled={loading || mcp.loading || !!busyApp}\n >\n Refresh\n </button>\n </div>\n )}\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 Rendered inside the panel rather than beside it, so that a click on\n its backdrop is stopped here — reaching the modal's own backdrop is\n what used to close everything from under a half-typed key. */}\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 );\n\n if (!dialog) return panel;\n\n return createPortal(\n <div className=\"devic-int-overlay\" onClick={onClose}>\n {panel}\n </div>,\n document.body\n );\n}\n\nexport default IntegrationsPanel;\n"],"names":["_jsxs","_jsx"],"mappings":";;;;;;;;;;AAiHA,SAAS,QAAQ,GAAA;AACf,IAAA,QACEA,IAAA,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,GAAA,CAAA,MAAA,EAAA,EAAM,CAAC,EAAC,WAAW,EAAA,CAAG,EACtBA,GAAA,CAAA,MAAA,EAAA,EAAM,CAAC,EAAC,QAAQ,EAAA,CAAG,EACnBA,GAAA,CAAA,MAAA,EAAA,EAAM,CAAC,EAAC,SAAS,EAAA,CAAG,EACpBA,GAAA,CAAA,MAAA,EAAA,EAAM,CAAC,EAAC,2CAA2C,EAAA,CAAG,CAAA,EAAA,CAClD;AAEV;AAEA,SAAS,UAAU,GAAA;IACjB,QACED,IAAA,CAAA,KAAA,EAAA,EACE,KAAK,EAAC,IAAI,EACV,MAAM,EAAC,IAAI,EACX,OAAO,E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GAAA,CAAA,QAAA,EAAA,EACE,IAAI,EAAC,QAAQ,EACb,SAAS,EAAC,mCAAmC,EAC7C,OAAO,EAAE,MAAK;AACZ,4BAAA,KAAK,OAAO,CAAC,IAAI,CAAC;AAClB,4BAAA,KAAK,GAAG,CAAC,OAAO,EAAE;AACpB,wBAAA,CAAC,EACD,QAAQ,EAAE,OAAO,IAAI,GAAG,CAAC,OAAO,IAAI,CAAC,CAAC,OAAO,EAAA,QAAA,EAAA,SAAA,EAAA,CAGtC,IACL,CACP,EAOA,WAAW,IAAI,iBAAiB,KAC/BA,GAAA,CAAC,iBAAiB,EAAA,EAChB,WAAW,EAAE,iBAAiB,EAC9B,OAAO,EAAE,WAAW,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;AACpB,gBAAA,CAAC,EACD,QAAQ,EAAE,CAAC,MAAM,KAAK,aAAa,CAAC,iBAAiB,EAAE,MAAM,CAAC,GAC9D,CACH,CAAA,EAAA,CACG,CACP;AAED,IAAA,IAAI,CAAC,MAAM;AAAE,QAAA,OAAO,KAAK;AAEzB,IAAA,OAAO,YAAY,CACjBA,GAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,mBAAmB,EAAC,OAAO,EAAE,OAAO,EAAA,QAAA,EAChD,KAAK,EAAA,CACF,EACN,QAAQ,CAAC,IAAI,CACd;AACH;;"}
|
|
1
|
+
{"version":3,"file":"IntegrationsPanel.js","sources":["../../../../src/components/IntegrationsModal/IntegrationsPanel.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 { McpServersSection } from \"./McpServersSection\";\nimport { useTenantMcp, type TenantMcpState } from \"./useTenantMcp\";\nimport { useTranslations, type Translator } from \"../../i18n\";\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 IntegrationsPanelProps {\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 /** Heading text, and the accessible name of the region. @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 * Embedded in a page the same applies for a different reason: the panel\n * renders in its own variables and inherits nothing from the surface around\n * it, so a host with its own palette has to say so here.\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 * MCP listing loaded elsewhere, same reasoning as `state`. When absent this\n * loads its own — and only while on screen, so an assistant that offers no\n * MCP servers costs one refusal and nothing more.\n */\n mcpState?: TenantMcpState;\n /**\n * Whether the panel is on screen. Renders nothing and asks for nothing while\n * false, without dropping what it already knows — which is how the modal\n * closes without paying for the whole listing again on the next open.\n *\n * @default true\n */\n active?: boolean;\n /**\n * The heading, with the plug icon and the title. Turn it off to put the\n * panel under a heading of your own.\n *\n * @default true\n */\n showHeader?: boolean;\n /** The search field. @default true */\n showSearch?: boolean;\n /**\n * The footer, with the privacy note and the Refresh button. Off, nothing else\n * re-reads the listing on demand — keep `state` yourself and call its\n * `refresh` if you drive it from your own control.\n *\n * @default true\n */\n showFooter?: boolean;\n /**\n * Shown as a close button in the header, and called when Escape is pressed.\n * The modal is what usually passes it; embedded, only pass it if the panel\n * is dismissible.\n */\n onClose?: () => void;\n className?: string;\n /**\n * Render inside the modal's backdrop, in a portal on `document.body`.\n *\n * This is what `IntegrationsModal` is, and that component is the one to use\n * — it exists here because both forms share every line of what follows.\n */\n dialog?: boolean;\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(\n t: Translator,\n integration: Integration\n): {\n key: \"connected\" | \"reconnect\" | \"disconnected\";\n label: string;\n} {\n if (integration.connected) {\n return { key: \"connected\", label: t(\"Connected\") };\n }\n if (integration.accounts.some((a) => a.needsReconnect)) {\n return { key: \"reconnect\", label: t(\"Needs reconnection\") };\n }\n return { key: \"disconnected\", label: t(\"Not connected\") };\n}\n\nfunction accountLabel(t: Translator, account: IntegrationAccount): string {\n // The status comes from the provider, so it is passed through the dictionary\n // as-is rather than assumed to be one of a known set.\n if (!account.connectedAt) return t(account.status.toLowerCase());\n const when = new Date(account.connectedAt);\n if (Number.isNaN(when.getTime())) return t(account.status.toLowerCase());\n return t(\"connected {date}\", { date: 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 * 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 * The same panel serves both shapes it is asked for. `IntegrationsModal` is\n * this with `dialog`, opened from the drawer's header; on its own it drops into\n * a settings page as an ordinary block, which is the form a host wants when\n * connecting apps is a section of their product rather than an interruption of\n * a chat.\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 IntegrationsPanel({\n assistantId,\n tenantId,\n subtenantId,\n apiKey,\n baseUrl,\n title: titleProp,\n searchPlaceholder: searchPlaceholderProp,\n onChange,\n theme,\n state,\n mcpState,\n active = true,\n showHeader = true,\n showSearch = true,\n showFooter = true,\n onClose,\n className,\n dialog = false,\n}: IntegrationsPanelProps): JSX.Element | null {\n const t = useTranslations();\n // The host's own wording wins; with none, the defaults go through the\n // dictionary like every other text in the panel.\n const title = titleProp ?? t(\"Connected apps\");\n const searchPlaceholder = searchPlaceholderProp ?? t(\"Search connected apps\");\n\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: active && !state,\n });\n const {\n integrations,\n loading,\n error: loadError,\n offered: appsOffered,\n refresh,\n client,\n scope,\n } = state ?? own;\n\n // Same shape as above: always built (hooks cannot be skipped), fetching only\n // when nobody handed a listing down.\n const ownMcp = useTenantMcp({\n assistantId,\n tenantId,\n subtenantId,\n apiKey,\n baseUrl,\n enabled: active && !mcpState,\n });\n const mcp = mcpState ?? ownMcp;\n\n /** Errors from connecting or disconnecting, kept apart from load failures. */\n const [actionError, setActionError] = useState<string | null>(null);\n // An assistant may offer MCP servers and no apps at all, and then the apps\n // endpoint answers \"not for you\" — an ordinary answer, not a failure. Showing\n // it would put a red panel above a section that is working perfectly. The\n // refusal is still surfaced when there is nothing else on offer, because then\n // an empty dialog with no explanation is worse.\n const appsRefusalIsNoise = !appsOffered && mcp.offered;\n const error = actionError ?? (appsRefusalIsNoise ? null : 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 (!active || !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 }, [active, 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 (active && !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 if (mcpState || openedBeforeRef.current) void mcp.refresh();\n openedBeforeRef.current = true;\n }\n wasOpenRef.current = active;\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 }, [active]);\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 //\n // Embedded in a page there is usually nothing to close after that, and the\n // key is left alone rather than swallowed: a panel that is part of the page\n // has no business answering for the whole document.\n useEffect(() => {\n if (!active) 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 }, [active, 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 (!active) 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 }, [active, 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 t(\n \"{app} is not available yet — it still needs to be set up by the app's provider.\",\n { app: integration.name }\n )\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 (!active) return null;\n\n const dark = isDarkTheme(theme);\n\n const panel = (\n // The variables go here rather than on the backdrop, because this is the\n // one element both shapes have: as a dialog it renders in a portal that\n // inherits nothing from the drawer that opened it, and embedded it must\n // not inherit the host's either — the colours it draws in are the ones\n // `theme` names, and nothing else.\n <div\n className={[\n \"devic-int-panel\",\n dialog ? \"devic-int-modal\" : \"\",\n className ?? \"\",\n ]\n .filter(Boolean)\n .join(\" \")}\n style={themeVars(theme)}\n data-dark={dark}\n role={dialog ? \"dialog\" : \"region\"}\n aria-modal={dialog || undefined}\n aria-label={title}\n onClick={dialog ? (e) => e.stopPropagation() : undefined}\n >\n {showHeader && (\n <div className=\"devic-int-header\">\n <h3 className=\"devic-int-title\">\n <PlugIcon />\n {title}\n </h3>\n {onClose && (\n <button\n className=\"devic-int-close\"\n onClick={onClose}\n type=\"button\"\n aria-label={t(\"Close\")}\n >\n ×\n </button>\n )}\n </div>\n )}\n\n {showSearch && (\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\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 {t(\"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 {t(\"Open the authorisation page\")}\n </a>{\" \"}\n {t(\"and come back — then use Refresh.\")}\n </div>\n )}\n\n {loading && integrations.length === 0 ? (\n // Silent while the MCP section is what this assistant offers: a\n // spinner labelled \"Loading apps\" over a list of servers describes\n // something that is not happening.\n appsRefusalIsNoise ? null : (\n <div className=\"devic-int-loading\">{t(\"Loading apps…\")}</div>\n )\n ) : integrations.length === 0 ? (\n // Silent when MCP servers are the whole offer: \"no apps available\"\n // over a list of servers reads as a broken panel.\n mcp.offered ? null : (\n <div className=\"devic-int-empty\">\n {t(\"No apps available here yet.\")}\n </div>\n )\n ) : visible.length === 0 ? (\n <div className=\"devic-int-empty\">\n {t(\"No apps match “{query}”.\", { query: query.trim() })}\n </div>\n ) : (\n <div className=\"devic-int-grid\">\n {visible.map((integration) => {\n const cardState = stateOf(t, 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 ? t(\n \"Sign in with a different account. The one connected now is replaced.\"\n )\n : undefined\n }\n >\n {busy\n ? t(\"Waiting…\")\n : cardState.key === \"disconnected\"\n ? t(\"Connect\")\n : cardState.key === \"reconnect\"\n ? t(\"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 t(\"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(t, account)}\n {account.needsReconnect && (\n <span className=\"devic-int-account-warn\">\n {\" \"}\n · {t(\"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={t(\"Disconnect this account\")}\n aria-label={t(\"Disconnect {app}\", {\n app: integration.name,\n })}\n >\n ×\n </button>\n </li>\n ))}\n </ul>\n )}\n </div>\n );\n })}\n </div>\n )}\n </div>\n\n {/* Below the apps, in the same panel: to the end user these are one\n question — what can I plug into this chat — and two panels would\n mean finding out which of them a thing lives in. */}\n {mcp.offered && (\n <div className=\"devic-int-body devic-int-body-secondary\">\n <McpServersSection state={mcp} theme={theme} query={query} />\n </div>\n )}\n\n {showFooter && (\n <div className=\"devic-int-footer\">\n <span>\n {t(\"Only you can see and use the accounts you connect here.\")}\n </span>\n <button\n type=\"button\"\n className=\"devic-int-btn devic-int-btn-small\"\n onClick={() => {\n void refresh(true);\n void mcp.refresh();\n }}\n disabled={loading || mcp.loading || !!busyApp}\n >\n {t(\"Refresh\")}\n </button>\n </div>\n )}\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 Rendered inside the panel rather than beside it, so that a click on\n its backdrop is stopped here — reaching the modal's own backdrop is\n what used to close everything from under a half-typed key. */}\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 );\n\n if (!dialog) return panel;\n\n return createPortal(\n <div className=\"devic-int-overlay\" onClick={onClose}>\n {panel}\n </div>,\n document.body\n );\n}\n\nexport default IntegrationsPanel;\n"],"names":["_jsxs","_jsx"],"mappings":";;;;;;;;;;;AAkHA,SAAS,QAAQ,GAAA;AACf,IAAA,QACEA,IAAA,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,GAAA,CAAA,MAAA,EAAA,EAAM,CAAC,EAAC,WAAW,EAAA,CAAG,EACtBA,GAAA,CAAA,MAAA,EAAA,EAAM,CAAC,EAAC,QAAQ,EAAA,CAAG,EACnBA,GAAA,CAAA,MAAA,EAAA,EAAM,CAAC,EAAC,SAAS,EAAA,CAAG,EACpBA,GAAA,CAAA,MAAA,EAAA,EAAM,CAAC,EAAC,2CAA2C,EAAA,CAAG,CAAA,EAAA,CAClD;AAEV;AAEA,SAAS,UAAU,GAAA;IACjB,QACED,IAAA,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,GAAA,CAAA,QAAA,EAAA,EAAQ,EAAE,EAAC,IAAI,EAAC,EAAE,EAAC,IAAI,EAAC,CAAC,EAAC,GAAG,EAAA,CAAG,EAChCA,GAAA,CAAA,MAAA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P;AAED,IAAA,IAAI,CAAC,MAAM;AAAE,QAAA,OAAO,KAAK;AAEzB,IAAA,OAAO,YAAY,CACjBA,GAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,mBAAmB,EAAC,OAAO,EAAE,OAAO,EAAA,QAAA,EAChD,KAAK,EAAA,CACF,EACN,QAAQ,CAAC,IAAI,CACd;AACH;;"}
|
|
@@ -50,5 +50,5 @@ export interface IntegrationsToggleProps {
|
|
|
50
50
|
* undo, which is the whole reason this exists next to the composer rather than
|
|
51
51
|
* inside the apps dialog.
|
|
52
52
|
*/
|
|
53
|
-
export declare function IntegrationsToggle({ state, mcp, disabled, onChange, onManage, label, dark, busy, loading, className, }: IntegrationsToggleProps): JSX.Element | null;
|
|
53
|
+
export declare function IntegrationsToggle({ state, mcp, disabled, onChange, onManage, label: labelProp, dark, busy, loading, className, }: IntegrationsToggleProps): JSX.Element | null;
|
|
54
54
|
export default IntegrationsToggle;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
2
|
import { useState, useRef, useMemo, useEffect } from 'react';
|
|
3
3
|
import { IntegrationLogo } from './IntegrationLogo.js';
|
|
4
|
+
import { useTranslations } from '../../i18n/useTranslations.js';
|
|
4
5
|
|
|
5
6
|
/** A plug, matching the weight of the attach and mic icons beside it. */
|
|
6
7
|
function PlugIcon() {
|
|
@@ -26,7 +27,9 @@ function McpBadge({ server }) {
|
|
|
26
27
|
* undo, which is the whole reason this exists next to the composer rather than
|
|
27
28
|
* inside the apps dialog.
|
|
28
29
|
*/
|
|
29
|
-
function IntegrationsToggle({ state, mcp, disabled, onChange, onManage, label
|
|
30
|
+
function IntegrationsToggle({ state, mcp, disabled, onChange, onManage, label: labelProp, dark = false, busy = false, loading = false, className = "", }) {
|
|
31
|
+
const t = useTranslations();
|
|
32
|
+
const label = labelProp ?? t("Apps in this chat");
|
|
30
33
|
const [open, setOpen] = useState(false);
|
|
31
34
|
const ref = useRef(null);
|
|
32
35
|
const connected = useMemo(() => state.integrations.filter((i) => i.connected), [state.integrations]);
|
|
@@ -87,16 +90,22 @@ function IntegrationsToggle({ state, mcp, disabled, onChange, onManage, label =
|
|
|
87
90
|
onChange(liveIds.filter((candidate) => next.has(candidate)));
|
|
88
91
|
};
|
|
89
92
|
return (jsxs("div", { className: `devic-int-toggle ${className}`.trim(), "data-dark": dark, ref: ref, children: [jsxs("button", { type: "button", className: "devic-input-btn devic-int-toggle-btn", onClick: () => setOpen((v) => !v), disabled: busy, title: offCount
|
|
90
|
-
?
|
|
91
|
-
: label, "aria-label": label, "aria-expanded": open, "aria-haspopup": "dialog", "data-some-off": offCount > 0 || undefined, children: [jsx(PlugIcon, {}), offCount > 0 && (jsx("span", { className: "devic-int-toggle-badge", "aria-hidden": "true", children: offCount }))] }), open && (jsxs("div", { className: "devic-int-toggle-popover", role: "dialog", "aria-label": label, children: [jsxs("div", { className: "devic-int-toggle-head", children: [jsx("strong", { children: label }),
|
|
93
|
+
? t("{label} — {count} switched off", { label, count: offCount })
|
|
94
|
+
: label, "aria-label": label, "aria-expanded": open, "aria-haspopup": "dialog", "data-some-off": offCount > 0 || undefined, children: [jsx(PlugIcon, {}), offCount > 0 && (jsx("span", { className: "devic-int-toggle-badge", "aria-hidden": "true", children: offCount }))] }), open && (jsxs("div", { className: "devic-int-toggle-popover", role: "dialog", "aria-label": label, children: [jsxs("div", { className: "devic-int-toggle-head", children: [jsx("strong", { children: label }), jsx("span", { children: hasMcp && !hasApps
|
|
95
|
+
? t("Switched off here, a server sits out your next message. It stays connected.")
|
|
96
|
+
: t("Switched off here, an app sits out your next message. It stays connected.") })] }), jsxs("ul", { className: "devic-int-toggle-list", children: [connected.map((integration) => (jsx("li", { children: jsxs("label", { className: "devic-int-toggle-row", children: [jsxs("span", { className: "devic-int-toggle-app", children: [jsx(IntegrationLogo, { integration: integration }), jsx("span", { className: "devic-int-toggle-name", children: integration.name })] }), jsx("input", { type: "checkbox", className: "devic-int-toggle-switch", checked: !off.has(integration.app), onChange: () => flip(integration.app), "aria-label": t("Use {app} in this chat", {
|
|
97
|
+
app: integration.name,
|
|
98
|
+
}) })] }) }, integration.app))), hasMcp && hasApps && (jsx("li", { className: "devic-int-toggle-group", "aria-hidden": "true", children: t("MCP servers") })), mcpServers.map((server) => {
|
|
92
99
|
const id = server.connection.toggleId;
|
|
93
|
-
return (jsx("li", { children: jsxs("label", { className: "devic-int-toggle-row", children: [jsxs("span", { className: "devic-int-toggle-app", children: [jsx(McpBadge, { server: server }), jsx("span", { className: "devic-int-toggle-name", children: server.name })] }), jsx("input", { type: "checkbox", className: "devic-int-toggle-switch", checked: !off.has(id), onChange: () => flip(id), "aria-label":
|
|
100
|
+
return (jsx("li", { children: jsxs("label", { className: "devic-int-toggle-row", children: [jsxs("span", { className: "devic-int-toggle-app", children: [jsx(McpBadge, { server: server }), jsx("span", { className: "devic-int-toggle-name", children: server.name })] }), jsx("input", { type: "checkbox", className: "devic-int-toggle-switch", checked: !off.has(id), onChange: () => flip(id), "aria-label": t("Use {server} in this chat", {
|
|
101
|
+
server: server.name,
|
|
102
|
+
}) })] }) }, id));
|
|
94
103
|
})] }), onManage && (jsx("button", { type: "button", className: "devic-int-toggle-manage", onClick: () => {
|
|
95
104
|
setOpen(false);
|
|
96
105
|
onManage();
|
|
97
106
|
}, children: hasMcp && !hasApps
|
|
98
|
-
? "Manage connected servers"
|
|
99
|
-
: "Manage connected apps" }))] }))] }));
|
|
107
|
+
? t("Manage connected servers")
|
|
108
|
+
: t("Manage connected apps") }))] }))] }));
|
|
100
109
|
}
|
|
101
110
|
|
|
102
111
|
export { IntegrationsToggle };
|
|
@@ -1 +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, TenantMcpServer } from \"../../api/types\";\nimport { IntegrationLogo } from \"./IntegrationLogo\";\nimport type { IntegrationsState } from \"./useIntegrations\";\nimport type { TenantMcpState } from \"./useTenantMcp\";\nimport \"./IntegrationsModal.css\";\n\nexport interface IntegrationsToggleProps {\n /** Shared listing (see `useIntegrations`). */\n state: IntegrationsState;\n /**\n * The tenant's own MCP servers, when the assistant offers them (see\n * `useTenantMcp`). Their connected servers are listed under the apps and\n * switch off the same way — a server the end user connected is as much\n * theirs to leave out of a message as an account is.\n */\n mcp?: TenantMcpState;\n /**\n * What is switched off right now. App slugs, and the `toggleId` of a\n * connected MCP server — one list, because that is what the message carries\n * and what the server keeps for the rest of the turn.\n */\n disabled: string[];\n /** Called with the full new list of switched-off entries. */\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 /**\n * Whether the requests that decide if this control exists are still running.\n *\n * Holds an inert plug in the row rather than letting the attach and mic\n * buttons shift sideways the moment the answer lands.\n */\n loading?: 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/** A server's own logo when it has one, its initial when it does not. */\nfunction McpBadge({ server }: { server: TenantMcpServer }): JSX.Element {\n if (server.logoUrl) {\n return (\n <img\n className=\"devic-int-toggle-mcp-logo\"\n src={server.logoUrl}\n alt=\"\"\n aria-hidden=\"true\"\n />\n );\n }\n return (\n <span\n className=\"devic-int-toggle-mcp-logo devic-int-toggle-mcp-fallback\"\n aria-hidden=\"true\"\n >\n {server.name.slice(0, 1).toUpperCase()}\n </span>\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 mcp,\n disabled,\n onChange,\n onManage,\n label = \"Apps in this chat\",\n dark = false,\n busy = false,\n loading = 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 // Connected and usable: one still waiting for its consent screen, or whose\n // last probe failed, contributes no tools, so switching it off would be\n // switching off nothing. It belongs in the panel that can fix it, not here.\n const mcpServers = useMemo(\n () =>\n (mcp?.servers ?? []).filter(\n (s) => s.connection?.status === \"active\" && !!s.connection.toggleId\n ),\n [mcp?.servers]\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 — or\n // their first MCP server, which is as switchable as an account is.\n const hasApps = state.offered && connected.length > 0;\n const hasMcp = !!mcp?.offered && mcpServers.length > 0;\n\n if (!hasApps && !hasMcp) {\n if (!loading) return null;\n // Still being decided: hold the slot, inert, so the row does not shift.\n return (\n <div className={`devic-int-toggle ${className}`.trim()} data-dark={dark}>\n <button\n type=\"button\"\n className=\"devic-input-btn devic-int-toggle-btn devic-int-toggle-btn-loading\"\n disabled\n aria-busy=\"true\"\n aria-label={`${label} (loading)`}\n title={label}\n >\n <PlugIcon />\n </button>\n </div>\n );\n }\n\n const off = new Set(disabled);\n\n /** Everything still on offer, so a stale entry can never survive a rewrite. */\n const liveIds = [\n ...connected.map((i) => i.app),\n ...mcpServers.map((s) => s.connection!.toggleId as string),\n ];\n const offCount = liveIds.filter((id) => off.has(id)).length;\n\n const flip = (id: string) => {\n const next = new Set(off);\n if (next.has(id)) next.delete(id);\n else next.add(id);\n // Only what is still on offer is kept: carrying an entry for an app or a\n // server the user has since disconnected would silently switch it off again\n // if they ever connected it back.\n onChange(liveIds.filter((candidate) => next.has(candidate)));\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, {hasMcp && !hasApps ? \"a server\" : \"an app\"}{\" \"}\n sits out your next message. It stays connected.\n </span>\n </div>\n\n <ul className=\"devic-int-toggle-list\">\n {connected.map((integration) => (\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={!off.has(integration.app)}\n onChange={() => flip(integration.app)}\n aria-label={`Use ${integration.name} in this chat`}\n />\n </label>\n </li>\n ))}\n\n {/* Named apart only when both kinds are present: with servers\n alone the heading would label the entire list. */}\n {hasMcp && hasApps && (\n <li className=\"devic-int-toggle-group\" aria-hidden=\"true\">\n MCP servers\n </li>\n )}\n\n {mcpServers.map((server) => {\n const id = server.connection!.toggleId as string;\n return (\n <li key={id}>\n <label className=\"devic-int-toggle-row\">\n <span className=\"devic-int-toggle-app\">\n <McpBadge server={server} />\n <span className=\"devic-int-toggle-name\">\n {server.name}\n </span>\n </span>\n <input\n type=\"checkbox\"\n className=\"devic-int-toggle-switch\"\n checked={!off.has(id)}\n onChange={() => flip(id)}\n aria-label={`Use ${server.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 {hasMcp && !hasApps\n ? \"Manage connected servers\"\n : \"Manage connected apps\"}\n </button>\n )}\n </div>\n )}\n </div>\n );\n}\n\nexport default IntegrationsToggle;\n"],"names":["_jsxs","_jsx"],"mappings":";;;;AA2CA;AACA,SAAS,QAAQ,GAAA;AACf,IAAA,QACEA,IAAA,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,Q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ACpCC,GAAA,CAAC,QAAQ,EAAA,EAAC,MAAM,EAAE,MAAM,EAAA,CAAI,EAC5BA,GAAA,CAAA,MAAA,EAAA,EAAM,SAAS,EAAC,uBAAuB,EAAA,QAAA,EACpC,MAAM,CAAC,IAAI,EAAA,CACP,CAAA,EAAA,CACF,EACPA,GAAA,CAAA,OAAA,EAAA,EACE,IAAI,EAAC,UAAU,EACf,SAAS,EAAC,yBAAyB,EACnC,OAAO,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,EACrB,QAAQ,EAAE,MAAM,IAAI,CAAC,EAAE,CAAC,EAAA,YAAA,EACZ,OAAO,MAAM,CAAC,IAAI,CAAA,aAAA,CAAe,GAC7C,CAAA,EAAA,CACI,EAAA,EAfD,EAAE,CAgBN;AAET,4BAAA,CAAC,CAAC,CAAA,EAAA,CACC,EAEJ,QAAQ,KACPA,gBACE,IAAI,EAAC,QAAQ,EACb,SAAS,EAAC,yBAAyB,EACnC,OAAO,EAAE,MAAK;4BACZ,OAAO,CAAC,KAAK,CAAC;AACd,4BAAA,QAAQ,EAAE;AACZ,wBAAA,CAAC,EAAA,QAAA,EAEA,MAAM,IAAI,CAAC;AACV,8BAAE;8BACA,uBAAuB,EAAA,CACpB,CACV,IACG,CACP,CAAA,EAAA,CACG;AAEV;;"}
|
|
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, TenantMcpServer } from \"../../api/types\";\nimport { IntegrationLogo } from \"./IntegrationLogo\";\nimport type { IntegrationsState } from \"./useIntegrations\";\nimport type { TenantMcpState } from \"./useTenantMcp\";\nimport { useTranslations } from \"../../i18n\";\nimport \"./IntegrationsModal.css\";\n\nexport interface IntegrationsToggleProps {\n /** Shared listing (see `useIntegrations`). */\n state: IntegrationsState;\n /**\n * The tenant's own MCP servers, when the assistant offers them (see\n * `useTenantMcp`). Their connected servers are listed under the apps and\n * switch off the same way — a server the end user connected is as much\n * theirs to leave out of a message as an account is.\n */\n mcp?: TenantMcpState;\n /**\n * What is switched off right now. App slugs, and the `toggleId` of a\n * connected MCP server — one list, because that is what the message carries\n * and what the server keeps for the rest of the turn.\n */\n disabled: string[];\n /** Called with the full new list of switched-off entries. */\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 /**\n * Whether the requests that decide if this control exists are still running.\n *\n * Holds an inert plug in the row rather than letting the attach and mic\n * buttons shift sideways the moment the answer lands.\n */\n loading?: 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/** A server's own logo when it has one, its initial when it does not. */\nfunction McpBadge({ server }: { server: TenantMcpServer }): JSX.Element {\n if (server.logoUrl) {\n return (\n <img\n className=\"devic-int-toggle-mcp-logo\"\n src={server.logoUrl}\n alt=\"\"\n aria-hidden=\"true\"\n />\n );\n }\n return (\n <span\n className=\"devic-int-toggle-mcp-logo devic-int-toggle-mcp-fallback\"\n aria-hidden=\"true\"\n >\n {server.name.slice(0, 1).toUpperCase()}\n </span>\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 mcp,\n disabled,\n onChange,\n onManage,\n label: labelProp,\n dark = false,\n busy = false,\n loading = false,\n className = \"\",\n}: IntegrationsToggleProps): JSX.Element | null {\n const t = useTranslations();\n const label = labelProp ?? t(\"Apps in this chat\");\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 // Connected and usable: one still waiting for its consent screen, or whose\n // last probe failed, contributes no tools, so switching it off would be\n // switching off nothing. It belongs in the panel that can fix it, not here.\n const mcpServers = useMemo(\n () =>\n (mcp?.servers ?? []).filter(\n (s) => s.connection?.status === \"active\" && !!s.connection.toggleId\n ),\n [mcp?.servers]\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 — or\n // their first MCP server, which is as switchable as an account is.\n const hasApps = state.offered && connected.length > 0;\n const hasMcp = !!mcp?.offered && mcpServers.length > 0;\n\n if (!hasApps && !hasMcp) {\n if (!loading) return null;\n // Still being decided: hold the slot, inert, so the row does not shift.\n return (\n <div className={`devic-int-toggle ${className}`.trim()} data-dark={dark}>\n <button\n type=\"button\"\n className=\"devic-input-btn devic-int-toggle-btn devic-int-toggle-btn-loading\"\n disabled\n aria-busy=\"true\"\n aria-label={`${label} (loading)`}\n title={label}\n >\n <PlugIcon />\n </button>\n </div>\n );\n }\n\n const off = new Set(disabled);\n\n /** Everything still on offer, so a stale entry can never survive a rewrite. */\n const liveIds = [\n ...connected.map((i) => i.app),\n ...mcpServers.map((s) => s.connection!.toggleId as string),\n ];\n const offCount = liveIds.filter((id) => off.has(id)).length;\n\n const flip = (id: string) => {\n const next = new Set(off);\n if (next.has(id)) next.delete(id);\n else next.add(id);\n // Only what is still on offer is kept: carrying an entry for an app or a\n // server the user has since disconnected would silently switch it off again\n // if they ever connected it back.\n onChange(liveIds.filter((candidate) => next.has(candidate)));\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 ? t(\"{label} — {count} switched off\", { label, count: offCount })\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 {hasMcp && !hasApps\n ? t(\n \"Switched off here, a server sits out your next message. It stays connected.\"\n )\n : t(\n \"Switched off here, an app sits out your next message. It stays connected.\"\n )}\n </span>\n </div>\n\n <ul className=\"devic-int-toggle-list\">\n {connected.map((integration) => (\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={!off.has(integration.app)}\n onChange={() => flip(integration.app)}\n aria-label={t(\"Use {app} in this chat\", {\n app: integration.name,\n })}\n />\n </label>\n </li>\n ))}\n\n {/* Named apart only when both kinds are present: with servers\n alone the heading would label the entire list. */}\n {hasMcp && hasApps && (\n <li className=\"devic-int-toggle-group\" aria-hidden=\"true\">\n {t(\"MCP servers\")}\n </li>\n )}\n\n {mcpServers.map((server) => {\n const id = server.connection!.toggleId as string;\n return (\n <li key={id}>\n <label className=\"devic-int-toggle-row\">\n <span className=\"devic-int-toggle-app\">\n <McpBadge server={server} />\n <span className=\"devic-int-toggle-name\">\n {server.name}\n </span>\n </span>\n <input\n type=\"checkbox\"\n className=\"devic-int-toggle-switch\"\n checked={!off.has(id)}\n onChange={() => flip(id)}\n aria-label={t(\"Use {server} in this chat\", {\n server: server.name,\n })}\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 {hasMcp && !hasApps\n ? t(\"Manage connected servers\")\n : t(\"Manage connected apps\")}\n </button>\n )}\n </div>\n )}\n </div>\n );\n}\n\nexport default IntegrationsToggle;\n"],"names":["_jsxs","_jsx"],"mappings":";;;;;AA4CA;AACA,SAAS,QAAQ,GAAA;AACf,IAAA,QACEA,IAAA,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,GAAA,CAAA,MAAA,EAAA,EAAM,CAAC,EAAC,QAAQ,EAAA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