@agent-native/dispatch 0.43.0-nightly-20261120212328 → 0.43.7
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/CHANGELOG.md +194 -174
- package/dist/actions/ask_app.d.ts +3 -0
- package/dist/actions/ask_app.js +7 -2
- package/dist/actions/ask_app.js.map +1 -1
- package/dist/actions/ask_app_status.d.ts +3 -0
- package/dist/actions/ask_app_status.js +5 -1
- package/dist/actions/ask_app_status.js.map +1 -1
- package/dist/actions/call_app_action.d.ts +1 -0
- package/dist/actions/call_app_action.js +21 -5
- package/dist/actions/call_app_action.js.map +1 -1
- package/dist/actions/create_embed_session.d.ts +3 -2
- package/dist/actions/create_embed_session.js +4 -2
- package/dist/actions/create_embed_session.js.map +1 -1
- package/dist/actions/create_workspace_app_embed_session.d.ts +3 -2
- package/dist/actions/create_workspace_app_embed_session.js +3 -1
- package/dist/actions/create_workspace_app_embed_session.js.map +1 -1
- package/dist/actions/delete-destination.d.ts +12 -12
- package/dist/actions/execute-action-suggestion.d.ts +44 -0
- package/dist/actions/execute-action-suggestion.d.ts.map +1 -0
- package/dist/actions/execute-action-suggestion.js +148 -0
- package/dist/actions/execute-action-suggestion.js.map +1 -0
- package/dist/actions/import-agent.d.ts +13 -13
- package/dist/actions/index.d.ts.map +1 -1
- package/dist/actions/index.js +5 -1
- package/dist/actions/index.js.map +1 -1
- package/dist/actions/list-connected-agents.js +3 -2
- package/dist/actions/list-connected-agents.js.map +1 -1
- package/dist/actions/list-workspace-connections.d.ts +1 -0
- package/dist/actions/list-workspace-connections.d.ts.map +1 -1
- package/dist/actions/list_app_actions.js +1 -1
- package/dist/actions/list_app_actions.js.map +1 -1
- package/dist/actions/list_apps.d.ts +2 -0
- package/dist/actions/list_apps.js +11 -3
- package/dist/actions/list_apps.js.map +1 -1
- package/dist/actions/navigate.js +1 -0
- package/dist/actions/navigate.js.map +1 -1
- package/dist/actions/open_app.d.ts +4 -0
- package/dist/actions/open_app.js +14 -6
- package/dist/actions/open_app.js.map +1 -1
- package/dist/actions/propose-action-suggestions.d.ts +45 -0
- package/dist/actions/propose-action-suggestions.d.ts.map +1 -0
- package/dist/actions/propose-action-suggestions.js +32 -0
- package/dist/actions/propose-action-suggestions.js.map +1 -0
- package/dist/actions/provider-api-register.d.ts +12 -12
- package/dist/actions/read_view.js +1 -1
- package/dist/actions/read_view.js.map +1 -1
- package/dist/actions/remember-pointer.js +1 -1
- package/dist/actions/remember-pointer.js.map +1 -1
- package/dist/actions/resolve-pointer.js +1 -1
- package/dist/actions/resolve-pointer.js.map +1 -1
- package/dist/actions/route-app-intent.d.ts +6 -0
- package/dist/actions/route-app-intent.js +79 -5
- package/dist/actions/route-app-intent.js.map +1 -1
- package/dist/actions/send-code-agent-remote-command.js +4 -0
- package/dist/actions/send-code-agent-remote-command.js.map +1 -1
- package/dist/actions/start-workspace-app-creation.js +1 -1
- package/dist/actions/start-workspace-app-creation.js.map +1 -1
- package/dist/actions/upsert-destination.d.ts +12 -12
- package/dist/actions/view-screen.d.ts +12 -1
- package/dist/actions/view-screen.js +53 -5
- package/dist/actions/view-screen.js.map +1 -1
- package/dist/components/chat-action-suggestions.d.ts +8 -0
- package/dist/components/chat-action-suggestions.d.ts.map +1 -0
- package/dist/components/chat-action-suggestions.js +191 -0
- package/dist/components/chat-action-suggestions.js.map +1 -0
- package/dist/components/chat-home-apps.d.ts.map +1 -1
- package/dist/components/chat-home-apps.js +1 -1
- package/dist/components/chat-home-apps.js.map +1 -1
- package/dist/components/google-broker-settings-group.d.ts +2 -0
- package/dist/components/google-broker-settings-group.d.ts.map +1 -0
- package/dist/components/google-broker-settings-group.js +53 -0
- package/dist/components/google-broker-settings-group.js.map +1 -0
- package/dist/components/layout/Layout.d.ts +4 -1
- package/dist/components/layout/Layout.d.ts.map +1 -1
- package/dist/components/layout/Layout.js +246 -69
- package/dist/components/layout/Layout.js.map +1 -1
- package/dist/components/messaging-setup-panel.d.ts.map +1 -1
- package/dist/components/messaging-setup-panel.js +47 -15
- package/dist/components/messaging-setup-panel.js.map +1 -1
- package/dist/components/workspace-app-host.d.ts +27 -4
- package/dist/components/workspace-app-host.d.ts.map +1 -1
- package/dist/components/workspace-app-host.js +355 -74
- package/dist/components/workspace-app-host.js.map +1 -1
- package/dist/config.d.ts +5 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js.map +1 -1
- package/dist/db/google-broker-admission.d.ts +36 -0
- package/dist/db/google-broker-admission.d.ts.map +1 -0
- package/dist/db/google-broker-admission.js +129 -0
- package/dist/db/google-broker-admission.js.map +1 -0
- package/dist/db/migrations.d.ts +1 -1
- package/dist/db/migrations.d.ts.map +1 -1
- package/dist/db/migrations.js +42 -0
- package/dist/db/migrations.js.map +1 -1
- package/dist/lib/action-suggestions.d.ts +20 -0
- package/dist/lib/action-suggestions.d.ts.map +1 -0
- package/dist/lib/action-suggestions.js +219 -0
- package/dist/lib/action-suggestions.js.map +1 -0
- package/dist/lib/chat-first-app-route.d.ts +11 -5
- package/dist/lib/chat-first-app-route.d.ts.map +1 -1
- package/dist/lib/chat-first-app-route.js +9 -5
- package/dist/lib/chat-first-app-route.js.map +1 -1
- package/dist/lib/chat-first-pane.d.ts +25 -1
- package/dist/lib/chat-first-pane.d.ts.map +1 -1
- package/dist/lib/chat-first-pane.js +67 -1
- package/dist/lib/chat-first-pane.js.map +1 -1
- package/dist/lib/data-intent.d.ts +3 -0
- package/dist/lib/data-intent.d.ts.map +1 -0
- package/dist/lib/data-intent.js +14 -0
- package/dist/lib/data-intent.js.map +1 -0
- package/dist/lib/dispatch-app-identity.d.ts +10 -0
- package/dist/lib/dispatch-app-identity.d.ts.map +1 -0
- package/dist/lib/dispatch-app-identity.js +18 -0
- package/dist/lib/dispatch-app-identity.js.map +1 -0
- package/dist/lib/other-apps.d.ts +15 -0
- package/dist/lib/other-apps.d.ts.map +1 -1
- package/dist/lib/other-apps.js +31 -0
- package/dist/lib/other-apps.js.map +1 -1
- package/dist/lib/workspace-app-frame-view.d.ts +15 -0
- package/dist/lib/workspace-app-frame-view.d.ts.map +1 -0
- package/dist/lib/workspace-app-frame-view.js +72 -0
- package/dist/lib/workspace-app-frame-view.js.map +1 -0
- package/dist/lib/workspace-apps.d.ts +5 -0
- package/dist/lib/workspace-apps.d.ts.map +1 -1
- package/dist/lib/workspace-apps.js +85 -23
- package/dist/lib/workspace-apps.js.map +1 -1
- package/dist/lib/workspace-apps.test.js +6 -0
- package/dist/lib/workspace-apps.test.js.map +1 -1
- package/dist/routes/pages/_index.d.ts +2 -2
- package/dist/routes/pages/chat.d.ts.map +1 -1
- package/dist/routes/pages/chat.js +33 -2
- package/dist/routes/pages/chat.js.map +1 -1
- package/dist/routes/pages/settings-page.d.ts +1 -1
- package/dist/routes/pages/settings-page.d.ts.map +1 -1
- package/dist/routes/pages/settings-page.js +3 -2
- package/dist/routes/pages/settings-page.js.map +1 -1
- package/dist/server/index.d.ts +4 -1
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +5 -5
- package/dist/server/index.js.map +1 -1
- package/dist/server/lib/action-suggestions.d.ts +41 -0
- package/dist/server/lib/action-suggestions.d.ts.map +1 -0
- package/dist/server/lib/action-suggestions.js +94 -0
- package/dist/server/lib/action-suggestions.js.map +1 -0
- package/dist/server/lib/app-action-result.d.ts +5 -0
- package/dist/server/lib/app-action-result.d.ts.map +1 -1
- package/dist/server/lib/app-action-result.js +7 -0
- package/dist/server/lib/app-action-result.js.map +1 -1
- package/dist/server/lib/app-creation-store.d.ts.map +1 -1
- package/dist/server/lib/app-creation-store.js +63 -13
- package/dist/server/lib/app-creation-store.js.map +1 -1
- package/dist/server/lib/curated-workspace-templates.d.ts.map +1 -1
- package/dist/server/lib/curated-workspace-templates.js +3 -0
- package/dist/server/lib/curated-workspace-templates.js.map +1 -1
- package/dist/server/lib/dispatch-config.d.ts +5 -0
- package/dist/server/lib/dispatch-config.d.ts.map +1 -0
- package/dist/server/lib/dispatch-config.js +11 -0
- package/dist/server/lib/dispatch-config.js.map +1 -0
- package/dist/server/lib/dispatch-pane-context.d.ts +11 -0
- package/dist/server/lib/dispatch-pane-context.d.ts.map +1 -0
- package/dist/server/lib/dispatch-pane-context.js +35 -0
- package/dist/server/lib/dispatch-pane-context.js.map +1 -0
- package/dist/server/lib/google-broker-provider.d.ts +41 -0
- package/dist/server/lib/google-broker-provider.d.ts.map +1 -0
- package/dist/server/lib/google-broker-provider.js +96 -0
- package/dist/server/lib/google-broker-provider.js.map +1 -0
- package/dist/server/lib/google-broker-rpc.d.ts +26 -0
- package/dist/server/lib/google-broker-rpc.d.ts.map +1 -0
- package/dist/server/lib/google-broker-rpc.js +52 -0
- package/dist/server/lib/google-broker-rpc.js.map +1 -0
- package/dist/server/lib/hosted-apps-settings.d.ts.map +1 -1
- package/dist/server/lib/hosted-apps-settings.js +4 -0
- package/dist/server/lib/hosted-apps-settings.js.map +1 -1
- package/dist/server/lib/mcp-app-discovery.d.ts +17 -0
- package/dist/server/lib/mcp-app-discovery.d.ts.map +1 -0
- package/dist/server/lib/mcp-app-discovery.js +231 -0
- package/dist/server/lib/mcp-app-discovery.js.map +1 -0
- package/dist/server/lib/mcp-gateway.d.ts +64 -21
- package/dist/server/lib/mcp-gateway.d.ts.map +1 -1
- package/dist/server/lib/mcp-gateway.js +730 -88
- package/dist/server/lib/mcp-gateway.js.map +1 -1
- package/dist/server/plugins/agent-chat.js +9 -7
- package/dist/server/plugins/agent-chat.js.map +1 -1
- package/dist/server/plugins/auth.d.ts.map +1 -1
- package/dist/server/plugins/auth.js +1 -0
- package/dist/server/plugins/auth.js.map +1 -1
- package/dist/server/plugins/db.d.ts.map +1 -1
- package/dist/server/plugins/db.js +0 -46
- package/dist/server/plugins/db.js.map +1 -1
- package/dist/server/plugins/integrations.d.ts.map +1 -1
- package/dist/server/plugins/integrations.js +4 -1
- package/dist/server/plugins/integrations.js.map +1 -1
- package/dist/shared/chat-first-pane.d.ts +24 -0
- package/dist/shared/chat-first-pane.d.ts.map +1 -1
- package/dist/shared/chat-first-pane.js +34 -0
- package/dist/shared/chat-first-pane.js.map +1 -1
- package/dist/shared/labs.d.ts +1 -0
- package/dist/shared/labs.d.ts.map +1 -1
- package/dist/shared/labs.js +7 -0
- package/dist/shared/labs.js.map +1 -1
- package/package.json +7 -6
- package/src/actions/action-suggestions.spec.ts +342 -0
- package/src/actions/app_actions.spec.ts +103 -0
- package/src/actions/ask_app.ts +9 -2
- package/src/actions/ask_app_status.ts +12 -1
- package/src/actions/call_app_action.ts +28 -8
- package/src/actions/create_embed_session.ts +8 -2
- package/src/actions/create_workspace_app_embed_session.ts +6 -1
- package/src/actions/execute-action-suggestion.ts +177 -0
- package/src/actions/index.spec.ts +6 -3
- package/src/actions/index.ts +5 -1
- package/src/actions/list-connected-agents.spec.ts +26 -1
- package/src/actions/list-connected-agents.ts +7 -4
- package/src/actions/list_app_actions.ts +1 -1
- package/src/actions/list_apps.spec.ts +58 -22
- package/src/actions/list_apps.ts +12 -5
- package/src/actions/navigate.ts +1 -0
- package/src/actions/open_app.spec.ts +17 -1
- package/src/actions/open_app.ts +21 -8
- package/src/actions/propose-action-suggestions.ts +42 -0
- package/src/actions/read_view.ts +1 -1
- package/src/actions/remember-pointer.ts +1 -1
- package/src/actions/resolve-pointer.ts +1 -1
- package/src/actions/route-app-intent.spec.ts +234 -5
- package/src/actions/route-app-intent.ts +89 -4
- package/src/actions/send-code-agent-remote-command.spec.ts +40 -0
- package/src/actions/send-code-agent-remote-command.ts +5 -0
- package/src/actions/start-workspace-app-creation.ts +1 -1
- package/src/actions/view-screen.bundle.spec.ts +15 -2
- package/src/actions/view-screen.spec.ts +81 -3
- package/src/actions/view-screen.ts +60 -4
- package/src/components/chat-action-suggestions.spec.tsx +362 -0
- package/src/components/chat-action-suggestions.tsx +432 -0
- package/src/components/chat-home-apps.spec.tsx +19 -0
- package/src/components/chat-home-apps.tsx +0 -1
- package/src/components/google-broker-settings-group.tsx +186 -0
- package/src/components/layout/Layout.spec.tsx +419 -28
- package/src/components/layout/Layout.tsx +304 -66
- package/src/components/messaging-setup-panel.spec.tsx +278 -4
- package/src/components/messaging-setup-panel.tsx +82 -19
- package/src/components/workspace-app-card.spec.tsx +79 -10
- package/src/components/workspace-app-chat-rail.spec.tsx +81 -3
- package/src/components/workspace-app-host.spec.tsx +269 -16
- package/src/components/workspace-app-host.tsx +464 -87
- package/src/config.ts +5 -0
- package/src/db/google-broker-admission.ts +160 -0
- package/src/db/migrations.spec.ts +165 -2
- package/src/db/migrations.ts +43 -1
- package/src/lib/action-suggestions.ts +267 -0
- package/src/lib/chat-first-app-route.spec.ts +15 -2
- package/src/lib/chat-first-app-route.ts +19 -7
- package/src/lib/chat-first-pane.spec.ts +71 -0
- package/src/lib/chat-first-pane.ts +101 -4
- package/src/lib/data-intent.spec.ts +21 -0
- package/src/lib/data-intent.ts +13 -0
- package/src/lib/dispatch-app-identity.ts +40 -0
- package/src/lib/other-apps.spec.ts +110 -1
- package/src/lib/other-apps.ts +41 -0
- package/src/lib/workspace-app-frame-view.spec.ts +13 -0
- package/src/lib/workspace-app-frame-view.ts +98 -0
- package/src/lib/workspace-apps.spec.ts +101 -0
- package/src/lib/workspace-apps.test.ts +18 -0
- package/src/lib/workspace-apps.ts +102 -24
- package/src/routes/pages/chat.spec.tsx +92 -1
- package/src/routes/pages/chat.tsx +41 -2
- package/src/routes/pages/settings-page.tsx +22 -17
- package/src/routes/pages/settings.spec.tsx +4 -0
- package/src/server/index.ts +6 -6
- package/src/server/lib/action-suggestions.ts +122 -0
- package/src/server/lib/app-action-result.ts +8 -0
- package/src/server/lib/app-creation-store.spec.ts +251 -0
- package/src/server/lib/app-creation-store.ts +72 -12
- package/src/server/lib/community-apps.spec.ts +19 -1
- package/src/server/lib/curated-workspace-templates.spec.ts +12 -0
- package/src/server/lib/curated-workspace-templates.ts +2 -0
- package/src/server/lib/dispatch-config.ts +15 -0
- package/src/server/lib/dispatch-pane-context.spec.ts +54 -0
- package/src/server/lib/dispatch-pane-context.ts +54 -0
- package/src/server/lib/google-broker-provider.ts +121 -0
- package/src/server/lib/google-broker-rpc.spec.ts +95 -0
- package/src/server/lib/google-broker-rpc.ts +107 -0
- package/src/server/lib/hosted-apps-settings.ts +4 -0
- package/src/server/lib/mcp-app-discovery.ts +318 -0
- package/src/server/lib/mcp-gateway.spec.ts +2252 -524
- package/src/server/lib/mcp-gateway.ts +1044 -181
- package/src/server/plugins/agent-chat.direct-mcp.spec.ts +84 -5
- package/src/server/plugins/agent-chat.ts +9 -7
- package/src/server/plugins/auth.spec.ts +5 -1
- package/src/server/plugins/auth.ts +1 -0
- package/src/server/plugins/db.ts +0 -51
- package/src/server/plugins/integrations.ts +4 -1
- package/src/shared/chat-first-pane.spec.ts +36 -0
- package/src/shared/chat-first-pane.ts +55 -0
- package/src/shared/labs.ts +8 -0
- package/src/server/plugins/agent-chat.spec.ts +0 -206
- package/src/server/plugins/integrations.spec.ts +0 -60
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
// @vitest-environment happy-dom
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
listIntegrationStatuses,
|
|
4
|
+
saveIntegrationEnvVars,
|
|
5
|
+
} from "@agent-native/core/client/integrations";
|
|
3
6
|
import React, { act } from "react";
|
|
4
7
|
import { createRoot, type Root } from "react-dom/client";
|
|
5
8
|
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
@@ -10,6 +13,7 @@ import { TooltipProvider } from "./ui/tooltip";
|
|
|
10
13
|
const clientState = vi.hoisted(() => ({
|
|
11
14
|
statuses: [] as any[],
|
|
12
15
|
envStatuses: [] as any[],
|
|
16
|
+
installations: [] as Record<string, unknown>[],
|
|
13
17
|
}));
|
|
14
18
|
|
|
15
19
|
const saveScope = vi.hoisted(() => ({
|
|
@@ -36,7 +40,9 @@ vi.mock("@agent-native/core/client/integrations", async () => ({
|
|
|
36
40
|
>("@agent-native/core/client/integrations")),
|
|
37
41
|
disconnectManagedIntegrationInstallation: vi.fn(() => Promise.resolve()),
|
|
38
42
|
listManagedIntegrationBudgets: vi.fn(() => Promise.resolve([])),
|
|
39
|
-
listManagedIntegrationInstallations: vi.fn(() =>
|
|
43
|
+
listManagedIntegrationInstallations: vi.fn(() =>
|
|
44
|
+
Promise.resolve(clientState.installations),
|
|
45
|
+
),
|
|
40
46
|
listManagedIntegrationScopes: vi.fn(() => Promise.resolve([])),
|
|
41
47
|
listIntegrationStatuses: vi.fn(() => Promise.resolve(clientState.statuses)),
|
|
42
48
|
listIntegrationEnvStatuses: vi.fn(() =>
|
|
@@ -61,9 +67,17 @@ vi.mock("@agent-native/core/client/i18n", () => ({
|
|
|
61
67
|
formatDate: (value: Date | number | string) =>
|
|
62
68
|
new Date(value).toLocaleDateString("en-US"),
|
|
63
69
|
}),
|
|
64
|
-
useT: () => (key: string) =>
|
|
70
|
+
useT: () => (key: string, values?: Record<string, unknown>) =>
|
|
65
71
|
(
|
|
66
72
|
({
|
|
73
|
+
"messaging.slackBotToken.rejectedStatus": "Token rejected",
|
|
74
|
+
"messaging.slackBotToken.rejectedTitle": "Slack rejected the bot token",
|
|
75
|
+
"messaging.slackBotToken.rejectedReason": "Slack answered {{code}}.",
|
|
76
|
+
"messaging.slackBotToken.rejectedFix":
|
|
77
|
+
"Reinstall the Slack app and save its new bot token, or connect the workspace with Add to Slack.",
|
|
78
|
+
"messaging.slackBotToken.rejected": "Rejected",
|
|
79
|
+
"messaging.slackBotToken.sharedRejected":
|
|
80
|
+
"The bot token this server provides doesn't work, so connect the workspace with Add to Slack.",
|
|
67
81
|
"messaging.managed.title": "Managed Slack workspaces",
|
|
68
82
|
"messaging.managed.description":
|
|
69
83
|
"Install managed Slack workspaces with channel identities.",
|
|
@@ -71,10 +85,13 @@ vi.mock("@agent-native/core/client/i18n", () => ({
|
|
|
71
85
|
"messaging.managed.agentManifestDescription":
|
|
72
86
|
"The Agent manifest enables Slack's Agent view and direct messages.",
|
|
73
87
|
"messaging.managed.addToSlack": "Add to Slack",
|
|
88
|
+
"messaging.managed.disconnect": "Disconnect",
|
|
74
89
|
"messaging.managed.requiredCredentials":
|
|
75
90
|
"Save the required Slack app credentials below to enable Add to Slack.",
|
|
76
91
|
}) as Record<string, string>
|
|
77
|
-
)[key]
|
|
92
|
+
)[key]?.replace(/\{\{(\w+)\}\}/g, (_, name: string) =>
|
|
93
|
+
String(values?.[name]),
|
|
94
|
+
) ?? key,
|
|
78
95
|
}));
|
|
79
96
|
|
|
80
97
|
vi.mock("@agent-native/core/integrations/catalog", () => ({
|
|
@@ -132,6 +149,7 @@ describe("MessagingSetupPanel", () => {
|
|
|
132
149
|
vi.stubGlobal("IS_REACT_ACT_ENVIRONMENT", true);
|
|
133
150
|
clientState.statuses = [];
|
|
134
151
|
clientState.envStatuses = [];
|
|
152
|
+
clientState.installations = [];
|
|
135
153
|
saveScope.scope = "user";
|
|
136
154
|
saveScope.canChoose = false;
|
|
137
155
|
vi.mocked(saveIntegrationEnvVars).mockClear();
|
|
@@ -283,6 +301,262 @@ describe("MessagingSetupPanel", () => {
|
|
|
283
301
|
expect(container.querySelectorAll("button").length).toBeGreaterThan(0);
|
|
284
302
|
expect(container.textContent).not.toContain("Save credentials");
|
|
285
303
|
});
|
|
304
|
+
|
|
305
|
+
it("shows when Slack rejects the saved bot token", async () => {
|
|
306
|
+
clientState.statuses = [
|
|
307
|
+
{
|
|
308
|
+
platform: "slack",
|
|
309
|
+
label: "Slack",
|
|
310
|
+
configured: true,
|
|
311
|
+
enabled: true,
|
|
312
|
+
details: {
|
|
313
|
+
hasToken: true,
|
|
314
|
+
botTokenHealth: "revoked",
|
|
315
|
+
botTokenError: "invalid_auth",
|
|
316
|
+
},
|
|
317
|
+
},
|
|
318
|
+
];
|
|
319
|
+
clientState.envStatuses = [
|
|
320
|
+
{
|
|
321
|
+
key: "SLACK_BOT_TOKEN",
|
|
322
|
+
label: "Slack Bot Token",
|
|
323
|
+
required: false,
|
|
324
|
+
configured: true,
|
|
325
|
+
},
|
|
326
|
+
];
|
|
327
|
+
|
|
328
|
+
await act(async () => {
|
|
329
|
+
root.render(
|
|
330
|
+
<TooltipProvider>
|
|
331
|
+
<MessagingSetupPanel />
|
|
332
|
+
</TooltipProvider>,
|
|
333
|
+
);
|
|
334
|
+
await Promise.resolve();
|
|
335
|
+
});
|
|
336
|
+
|
|
337
|
+
expect(container.textContent).toContain("Token rejected");
|
|
338
|
+
expect(container.textContent).not.toContain("Connected");
|
|
339
|
+
for (const label of ["Slack", "Credentials", "Slack Bot Token (legacy)"]) {
|
|
340
|
+
const trigger = [...container.querySelectorAll("button")].find((button) =>
|
|
341
|
+
button.textContent.includes(label),
|
|
342
|
+
);
|
|
343
|
+
await act(async () => {
|
|
344
|
+
trigger?.click();
|
|
345
|
+
await Promise.resolve();
|
|
346
|
+
});
|
|
347
|
+
}
|
|
348
|
+
expect(container.textContent).toContain("Slack rejected the bot token");
|
|
349
|
+
expect(container.textContent).toContain("Slack answered invalid_auth.");
|
|
350
|
+
expect(container.textContent).not.toContain("Messages are flowing");
|
|
351
|
+
expect(container.textContent).toContain("Rejected");
|
|
352
|
+
});
|
|
353
|
+
|
|
354
|
+
it("keeps a connected managed workspace's status when the legacy token is rejected", async () => {
|
|
355
|
+
clientState.statuses = [
|
|
356
|
+
{
|
|
357
|
+
platform: "slack",
|
|
358
|
+
label: "Slack",
|
|
359
|
+
configured: true,
|
|
360
|
+
enabled: true,
|
|
361
|
+
details: {
|
|
362
|
+
hasToken: true,
|
|
363
|
+
botTokenHealth: "revoked",
|
|
364
|
+
botTokenError: "invalid_auth",
|
|
365
|
+
},
|
|
366
|
+
},
|
|
367
|
+
];
|
|
368
|
+
clientState.envStatuses = [
|
|
369
|
+
{
|
|
370
|
+
key: "SLACK_BOT_TOKEN",
|
|
371
|
+
label: "Slack Bot Token",
|
|
372
|
+
required: false,
|
|
373
|
+
configured: true,
|
|
374
|
+
},
|
|
375
|
+
];
|
|
376
|
+
clientState.installations = [
|
|
377
|
+
{
|
|
378
|
+
id: "installation-1",
|
|
379
|
+
platform: "slack",
|
|
380
|
+
status: "connected",
|
|
381
|
+
health: "healthy",
|
|
382
|
+
teamId: "T123",
|
|
383
|
+
teamName: "Example workspace",
|
|
384
|
+
scopes: ["chat:write"],
|
|
385
|
+
updatedAt: "2026-11-26T12:00:00Z",
|
|
386
|
+
},
|
|
387
|
+
];
|
|
388
|
+
|
|
389
|
+
await act(async () => {
|
|
390
|
+
root.render(
|
|
391
|
+
<TooltipProvider>
|
|
392
|
+
<MessagingSetupPanel />
|
|
393
|
+
</TooltipProvider>,
|
|
394
|
+
);
|
|
395
|
+
await Promise.resolve();
|
|
396
|
+
});
|
|
397
|
+
|
|
398
|
+
expect(container.textContent).toContain("Connected");
|
|
399
|
+
expect(container.textContent).not.toContain("Token rejected");
|
|
400
|
+
for (const label of ["Slack", "Credentials", "Slack Bot Token (legacy)"]) {
|
|
401
|
+
const trigger = [...container.querySelectorAll("button")].find((button) =>
|
|
402
|
+
button.textContent.includes(label),
|
|
403
|
+
);
|
|
404
|
+
await act(async () => {
|
|
405
|
+
trigger?.click();
|
|
406
|
+
await Promise.resolve();
|
|
407
|
+
});
|
|
408
|
+
}
|
|
409
|
+
expect(container.textContent).toContain("Messages are flowing");
|
|
410
|
+
expect(container.textContent).not.toContain("Slack answered invalid_auth.");
|
|
411
|
+
expect(container.textContent).toContain("Rejected");
|
|
412
|
+
});
|
|
413
|
+
|
|
414
|
+
it("shows a rejected server-wide token as setup this workspace hasn't finished", async () => {
|
|
415
|
+
clientState.statuses = [
|
|
416
|
+
{
|
|
417
|
+
platform: "slack",
|
|
418
|
+
label: "Slack",
|
|
419
|
+
configured: false,
|
|
420
|
+
enabled: true,
|
|
421
|
+
details: {
|
|
422
|
+
hasToken: true,
|
|
423
|
+
botTokenShared: true,
|
|
424
|
+
botTokenHealth: "revoked",
|
|
425
|
+
botTokenError: "account_inactive",
|
|
426
|
+
},
|
|
427
|
+
},
|
|
428
|
+
];
|
|
429
|
+
clientState.envStatuses = [
|
|
430
|
+
{
|
|
431
|
+
key: "SLACK_BOT_TOKEN",
|
|
432
|
+
label: "Slack Bot Token",
|
|
433
|
+
required: false,
|
|
434
|
+
configured: true,
|
|
435
|
+
},
|
|
436
|
+
{
|
|
437
|
+
key: "SLACK_CLIENT_ID",
|
|
438
|
+
label: "Slack OAuth Client ID",
|
|
439
|
+
required: true,
|
|
440
|
+
configured: true,
|
|
441
|
+
},
|
|
442
|
+
];
|
|
443
|
+
|
|
444
|
+
await act(async () => {
|
|
445
|
+
root.render(
|
|
446
|
+
<TooltipProvider>
|
|
447
|
+
<MessagingSetupPanel />
|
|
448
|
+
</TooltipProvider>,
|
|
449
|
+
);
|
|
450
|
+
await Promise.resolve();
|
|
451
|
+
});
|
|
452
|
+
|
|
453
|
+
expect(container.textContent).toContain("Not configured");
|
|
454
|
+
expect(container.textContent).not.toContain("Token rejected");
|
|
455
|
+
expect(container.textContent).not.toContain("Connected");
|
|
456
|
+
for (const label of ["Slack", "Credentials", "Slack Bot Token (legacy)"]) {
|
|
457
|
+
const trigger = [...container.querySelectorAll("button")].find((button) =>
|
|
458
|
+
button.textContent.includes(label),
|
|
459
|
+
);
|
|
460
|
+
await act(async () => {
|
|
461
|
+
trigger?.click();
|
|
462
|
+
await Promise.resolve();
|
|
463
|
+
});
|
|
464
|
+
}
|
|
465
|
+
expect(container.textContent).toContain("Finish setup to connect");
|
|
466
|
+
expect(container.textContent).toContain("1 saved");
|
|
467
|
+
expect(container.textContent).not.toContain("Messages are flowing");
|
|
468
|
+
expect(container.textContent).not.toContain("Slack rejected the bot token");
|
|
469
|
+
expect(container.textContent).not.toContain("Reinstall the Slack app");
|
|
470
|
+
expect(container.textContent).toContain(
|
|
471
|
+
"Slack answered account_inactive. The bot token this server provides doesn't work",
|
|
472
|
+
);
|
|
473
|
+
expect(container.textContent).not.toContain("Rejected");
|
|
474
|
+
expect(
|
|
475
|
+
container.querySelector(
|
|
476
|
+
'input[placeholder="Enter Slack Bot Token (legacy)"]',
|
|
477
|
+
),
|
|
478
|
+
).not.toBeNull();
|
|
479
|
+
});
|
|
480
|
+
|
|
481
|
+
it("refreshes Slack's status after its last managed workspace is disconnected", async () => {
|
|
482
|
+
const details = {
|
|
483
|
+
hasToken: true,
|
|
484
|
+
botTokenShared: true,
|
|
485
|
+
botTokenHealth: "revoked",
|
|
486
|
+
botTokenError: "account_inactive",
|
|
487
|
+
};
|
|
488
|
+
clientState.statuses = [
|
|
489
|
+
{
|
|
490
|
+
platform: "slack",
|
|
491
|
+
label: "Slack",
|
|
492
|
+
configured: true,
|
|
493
|
+
enabled: true,
|
|
494
|
+
details,
|
|
495
|
+
},
|
|
496
|
+
];
|
|
497
|
+
clientState.installations = [
|
|
498
|
+
{
|
|
499
|
+
id: "installation-1",
|
|
500
|
+
platform: "slack",
|
|
501
|
+
status: "connected",
|
|
502
|
+
health: "healthy",
|
|
503
|
+
teamId: "T123",
|
|
504
|
+
teamName: "Example workspace",
|
|
505
|
+
scopes: ["chat:write"],
|
|
506
|
+
updatedAt: "2026-11-26T12:00:00Z",
|
|
507
|
+
},
|
|
508
|
+
];
|
|
509
|
+
|
|
510
|
+
await act(async () => {
|
|
511
|
+
root.render(
|
|
512
|
+
<TooltipProvider>
|
|
513
|
+
<MessagingSetupPanel />
|
|
514
|
+
</TooltipProvider>,
|
|
515
|
+
);
|
|
516
|
+
await Promise.resolve();
|
|
517
|
+
});
|
|
518
|
+
|
|
519
|
+
expect(container.textContent).toContain("Connected");
|
|
520
|
+
for (const label of ["Slack", "Managed Slack workspaces"]) {
|
|
521
|
+
const trigger = [...container.querySelectorAll("button")].find((button) =>
|
|
522
|
+
button.textContent.includes(label),
|
|
523
|
+
);
|
|
524
|
+
await act(async () => {
|
|
525
|
+
trigger?.click();
|
|
526
|
+
await Promise.resolve();
|
|
527
|
+
});
|
|
528
|
+
}
|
|
529
|
+
expect(container.textContent).toContain("Messages are flowing");
|
|
530
|
+
|
|
531
|
+
clientState.statuses = [
|
|
532
|
+
{
|
|
533
|
+
platform: "slack",
|
|
534
|
+
label: "Slack",
|
|
535
|
+
configured: false,
|
|
536
|
+
enabled: true,
|
|
537
|
+
details,
|
|
538
|
+
},
|
|
539
|
+
];
|
|
540
|
+
clientState.installations = [];
|
|
541
|
+
const disconnect = [...container.querySelectorAll("button")].find(
|
|
542
|
+
(button) => button.textContent === "Disconnect",
|
|
543
|
+
);
|
|
544
|
+
const statusReads = vi.mocked(listIntegrationStatuses).mock.calls.length;
|
|
545
|
+
await act(async () => {
|
|
546
|
+
disconnect?.click();
|
|
547
|
+
await vi.waitFor(() =>
|
|
548
|
+
expect(
|
|
549
|
+
vi.mocked(listIntegrationStatuses).mock.calls.length,
|
|
550
|
+
).toBeGreaterThan(statusReads),
|
|
551
|
+
);
|
|
552
|
+
});
|
|
553
|
+
|
|
554
|
+
expect(container.textContent).toContain("Not configured");
|
|
555
|
+
expect(container.textContent).toContain("Finish setup to connect");
|
|
556
|
+
expect(container.textContent).not.toContain("Connected");
|
|
557
|
+
expect(container.textContent).not.toContain("Messages are flowing");
|
|
558
|
+
});
|
|
559
|
+
|
|
286
560
|
async function openSlackCredentials() {
|
|
287
561
|
await act(async () => {
|
|
288
562
|
root.render(
|
|
@@ -155,11 +155,22 @@ function PublicValueReveal({ envKey: _envKey }: { envKey: string }) {
|
|
|
155
155
|
function ConnectionStatus({
|
|
156
156
|
configured,
|
|
157
157
|
enabled,
|
|
158
|
+
tokenRejected,
|
|
158
159
|
}: {
|
|
159
160
|
configured: boolean;
|
|
160
161
|
enabled: boolean;
|
|
162
|
+
tokenRejected: boolean;
|
|
161
163
|
}) {
|
|
162
|
-
|
|
164
|
+
const t = useT();
|
|
165
|
+
if (tokenRejected) {
|
|
166
|
+
return (
|
|
167
|
+
<StatusPill
|
|
168
|
+
tone="warning"
|
|
169
|
+
label={t("messaging.slackBotToken.rejectedStatus")}
|
|
170
|
+
/>
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
if (enabled && configured) {
|
|
163
174
|
return <StatusPill tone="success" label="Connected" />;
|
|
164
175
|
}
|
|
165
176
|
if (configured) {
|
|
@@ -373,6 +384,7 @@ export function MessagingSetupPanel() {
|
|
|
373
384
|
? testManagedIntegrationInstallation(installation.id)
|
|
374
385
|
: disconnectManagedIntegrationInstallation(installation.id));
|
|
375
386
|
setInstallations(await listManagedIntegrationInstallations("slack"));
|
|
387
|
+
setStatuses(await listIntegrationStatuses());
|
|
376
388
|
toast.success(
|
|
377
389
|
action === "test"
|
|
378
390
|
? t("messaging.managed.connectionChecked")
|
|
@@ -461,13 +473,24 @@ export function MessagingSetupPanel() {
|
|
|
461
473
|
>
|
|
462
474
|
{CHANNELS.map((platform) => {
|
|
463
475
|
const status = statusByPlatform.get(platform.id);
|
|
464
|
-
const
|
|
465
|
-
|
|
466
|
-
(
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
476
|
+
const managedWorkspaceConnected =
|
|
477
|
+
platform.id === "slack" &&
|
|
478
|
+
installations.some(
|
|
479
|
+
(installation) => installation.status === "connected",
|
|
480
|
+
);
|
|
481
|
+
const configured = !!status?.configured || managedWorkspaceConnected;
|
|
470
482
|
const enabled = !!status?.enabled;
|
|
483
|
+
const botTokenRevoked = status?.details?.botTokenHealth === "revoked";
|
|
484
|
+
const sharedBotTokenRejected =
|
|
485
|
+
botTokenRevoked && status.details?.botTokenShared === true;
|
|
486
|
+
const legacyBotTokenRejected =
|
|
487
|
+
botTokenRevoked && !sharedBotTokenRejected;
|
|
488
|
+
const botTokenRejected =
|
|
489
|
+
legacyBotTokenRejected && !managedWorkspaceConnected;
|
|
490
|
+
const botTokenError =
|
|
491
|
+
typeof status?.details?.botTokenError === "string"
|
|
492
|
+
? status.details.botTokenError
|
|
493
|
+
: null;
|
|
471
494
|
const envKeys = platform.credentialRequirements;
|
|
472
495
|
const primaryEnvKeys = envKeys.filter(
|
|
473
496
|
(envKey) => envKey.key !== "SLACK_BOT_TOKEN",
|
|
@@ -475,12 +498,15 @@ export function MessagingSetupPanel() {
|
|
|
475
498
|
const legacyEnvKeys = envKeys.filter(
|
|
476
499
|
(envKey) => envKey.key === "SLACK_BOT_TOKEN",
|
|
477
500
|
);
|
|
501
|
+
const credentialSaved = (key: string) =>
|
|
502
|
+
Boolean(envStatusByKey.get(key)?.configured) &&
|
|
503
|
+
!(sharedBotTokenRejected && key === "SLACK_BOT_TOKEN");
|
|
478
504
|
const missingRequiredCredentials = hasMissingRequiredCredentials(
|
|
479
505
|
envKeys,
|
|
480
506
|
(key) => Boolean(envStatusByKey.get(key)?.configured),
|
|
481
507
|
);
|
|
482
|
-
const configuredCredentialCount = envKeys.filter(
|
|
483
|
-
(envKey
|
|
508
|
+
const configuredCredentialCount = envKeys.filter((envKey) =>
|
|
509
|
+
credentialSaved(envKey.key),
|
|
484
510
|
).length;
|
|
485
511
|
const credentialSummary = envLoading
|
|
486
512
|
? "Checking saved credentials"
|
|
@@ -506,6 +532,7 @@ export function MessagingSetupPanel() {
|
|
|
506
532
|
<ConnectionStatus
|
|
507
533
|
configured={configured}
|
|
508
534
|
enabled={enabled}
|
|
535
|
+
tokenRejected={botTokenRejected}
|
|
509
536
|
/>
|
|
510
537
|
</div>
|
|
511
538
|
<p className="mt-1 truncate text-sm text-muted-foreground">
|
|
@@ -520,11 +547,13 @@ export function MessagingSetupPanel() {
|
|
|
520
547
|
<div className="flex flex-wrap items-center justify-between gap-3 py-3">
|
|
521
548
|
<div>
|
|
522
549
|
<p className="text-sm font-medium text-foreground">
|
|
523
|
-
{
|
|
524
|
-
? "
|
|
525
|
-
: configured
|
|
526
|
-
? "
|
|
527
|
-
:
|
|
550
|
+
{botTokenRejected
|
|
551
|
+
? t("messaging.slackBotToken.rejectedTitle")
|
|
552
|
+
: enabled && configured
|
|
553
|
+
? "Messages are flowing"
|
|
554
|
+
: configured
|
|
555
|
+
? "Ready to connect"
|
|
556
|
+
: "Finish setup to connect"}
|
|
528
557
|
</p>
|
|
529
558
|
<p className="mt-0.5 text-xs text-muted-foreground">
|
|
530
559
|
{envLoading ? (
|
|
@@ -533,6 +562,16 @@ export function MessagingSetupPanel() {
|
|
|
533
562
|
credentialSummary
|
|
534
563
|
)}
|
|
535
564
|
</p>
|
|
565
|
+
{botTokenRejected ? (
|
|
566
|
+
<p className="mt-1 text-xs text-amber-700 dark:text-amber-300">
|
|
567
|
+
{botTokenError
|
|
568
|
+
? `${t("messaging.slackBotToken.rejectedReason", {
|
|
569
|
+
code: botTokenError,
|
|
570
|
+
})} `
|
|
571
|
+
: null}
|
|
572
|
+
{t("messaging.slackBotToken.rejectedFix")}
|
|
573
|
+
</p>
|
|
574
|
+
) : null}
|
|
536
575
|
</div>
|
|
537
576
|
<div className="flex flex-wrap items-center gap-2">
|
|
538
577
|
{platform.id === "telegram" && configured ? (
|
|
@@ -931,9 +970,22 @@ export function MessagingSetupPanel() {
|
|
|
931
970
|
<p className="text-xs text-muted-foreground">
|
|
932
971
|
{legacyEnvKeys[0]?.helpText}
|
|
933
972
|
</p>
|
|
973
|
+
{sharedBotTokenRejected ? (
|
|
974
|
+
<p className="text-xs text-muted-foreground">
|
|
975
|
+
{botTokenError
|
|
976
|
+
? `${t(
|
|
977
|
+
"messaging.slackBotToken.rejectedReason",
|
|
978
|
+
{
|
|
979
|
+
code: botTokenError,
|
|
980
|
+
},
|
|
981
|
+
)} `
|
|
982
|
+
: null}
|
|
983
|
+
{t("messaging.slackBotToken.sharedRejected")}
|
|
984
|
+
</p>
|
|
985
|
+
) : null}
|
|
934
986
|
{legacyEnvKeys.map((envKey) => {
|
|
935
987
|
const envStatus = envStatusByKey.get(envKey.key);
|
|
936
|
-
const isConfigured =
|
|
988
|
+
const isConfigured = credentialSaved(envKey.key);
|
|
937
989
|
const helpText =
|
|
938
990
|
envKey.helpText ?? envStatus?.helpText;
|
|
939
991
|
const label =
|
|
@@ -951,9 +1003,21 @@ export function MessagingSetupPanel() {
|
|
|
951
1003
|
</div>
|
|
952
1004
|
<StatusPill
|
|
953
1005
|
tone={
|
|
954
|
-
isConfigured
|
|
1006
|
+
isConfigured && legacyBotTokenRejected
|
|
1007
|
+
? "warning"
|
|
1008
|
+
: isConfigured
|
|
1009
|
+
? "success"
|
|
1010
|
+
: "neutral"
|
|
1011
|
+
}
|
|
1012
|
+
label={
|
|
1013
|
+
isConfigured && legacyBotTokenRejected
|
|
1014
|
+
? t(
|
|
1015
|
+
"messaging.slackBotToken.rejected",
|
|
1016
|
+
)
|
|
1017
|
+
: isConfigured
|
|
1018
|
+
? "Saved"
|
|
1019
|
+
: "Not set"
|
|
955
1020
|
}
|
|
956
|
-
label={isConfigured ? "Saved" : "Not set"}
|
|
957
1021
|
/>
|
|
958
1022
|
</div>
|
|
959
1023
|
{!isConfigured ? (
|
|
@@ -974,8 +1038,7 @@ export function MessagingSetupPanel() {
|
|
|
974
1038
|
);
|
|
975
1039
|
})}
|
|
976
1040
|
{legacyEnvKeys.some(
|
|
977
|
-
(envKey) =>
|
|
978
|
-
!envStatusByKey.get(envKey.key)?.configured,
|
|
1041
|
+
(envKey) => !credentialSaved(envKey.key),
|
|
979
1042
|
) ? (
|
|
980
1043
|
<>
|
|
981
1044
|
{credentialScope.canChoose &&
|
|
@@ -381,7 +381,7 @@ describe("WorkspaceAppCard", () => {
|
|
|
381
381
|
const newTabItem = Array.from(
|
|
382
382
|
document.querySelectorAll<HTMLElement>('[role="menuitem"]'),
|
|
383
383
|
).find((item) =>
|
|
384
|
-
item.textContent
|
|
384
|
+
item.textContent.includes("dispatch.pages.chatFirstOpenInNewTab"),
|
|
385
385
|
);
|
|
386
386
|
expect(newTabItem).not.toBeUndefined();
|
|
387
387
|
expect(newTabItem?.getAttribute("href")).toBe(
|
|
@@ -528,8 +528,77 @@ describe("WorkspaceAppCard", () => {
|
|
|
528
528
|
});
|
|
529
529
|
|
|
530
530
|
it("keeps mounted workspace apps inline outside Builder", async () => {
|
|
531
|
+
await act(async () => {
|
|
532
|
+
root.render(
|
|
533
|
+
<MemoryRouter>
|
|
534
|
+
<LocationProbe />
|
|
535
|
+
<TooltipProvider>
|
|
536
|
+
<WorkspaceAppCard
|
|
537
|
+
app={{
|
|
538
|
+
id: "feedback-leaderboard",
|
|
539
|
+
name: "Feedback leaderboard",
|
|
540
|
+
path: "/feedback-leaderboard",
|
|
541
|
+
url: "https://agent-workspace.builder.io/feedback-leaderboard/leaderboard",
|
|
542
|
+
status: "ready",
|
|
543
|
+
}}
|
|
544
|
+
/>
|
|
545
|
+
</TooltipProvider>
|
|
546
|
+
</MemoryRouter>,
|
|
547
|
+
);
|
|
548
|
+
});
|
|
549
|
+
|
|
550
|
+
await act(async () =>
|
|
551
|
+
container
|
|
552
|
+
.querySelector<HTMLButtonElement>(".app-open-actions__primary")
|
|
553
|
+
?.click(),
|
|
554
|
+
);
|
|
555
|
+
expect(container.querySelector("[data-location-path]")?.textContent).toBe(
|
|
556
|
+
"/apps/feedback-leaderboard",
|
|
557
|
+
);
|
|
558
|
+
});
|
|
559
|
+
|
|
560
|
+
it("opens in a new tab at the standalone app URL when registry url is Dispatch's host page", async () => {
|
|
561
|
+
const origin = window.location.origin;
|
|
562
|
+
await act(async () => {
|
|
563
|
+
root.render(
|
|
564
|
+
<MemoryRouter>
|
|
565
|
+
<TooltipProvider>
|
|
566
|
+
<WorkspaceAppCard
|
|
567
|
+
app={{
|
|
568
|
+
id: "coach",
|
|
569
|
+
name: "Coach",
|
|
570
|
+
path: "/coach",
|
|
571
|
+
homePath: "/",
|
|
572
|
+
url: `${origin}/dispatch/apps/coach`,
|
|
573
|
+
status: "ready",
|
|
574
|
+
}}
|
|
575
|
+
/>
|
|
576
|
+
</TooltipProvider>
|
|
577
|
+
</MemoryRouter>,
|
|
578
|
+
);
|
|
579
|
+
});
|
|
580
|
+
|
|
581
|
+
await act(async () => {
|
|
582
|
+
container
|
|
583
|
+
.querySelector<HTMLButtonElement>(".app-open-actions__menu")
|
|
584
|
+
?.dispatchEvent(
|
|
585
|
+
new MouseEvent("pointerdown", { bubbles: true, button: 0 }),
|
|
586
|
+
);
|
|
587
|
+
});
|
|
588
|
+
|
|
589
|
+
const newTabItem = Array.from(
|
|
590
|
+
document.querySelectorAll<HTMLElement>('[role="menuitem"]'),
|
|
591
|
+
).find((item) =>
|
|
592
|
+
item.textContent.includes("dispatch.pages.chatFirstOpenInNewTab"),
|
|
593
|
+
);
|
|
594
|
+
expect(newTabItem?.getAttribute("href")).toBe("/coach");
|
|
595
|
+
expect(newTabItem?.getAttribute("target")).toBe("_blank");
|
|
596
|
+
});
|
|
597
|
+
|
|
598
|
+
it("opens mounted workspace apps directly at their standalone root when inside an external iframe", async () => {
|
|
531
599
|
const originalTop = window.top;
|
|
532
|
-
const
|
|
600
|
+
const originalHref = window.location.href;
|
|
601
|
+
const topWindow = { location: { href: "https://chatgpt.com/" } };
|
|
533
602
|
Object.defineProperty(window, "top", {
|
|
534
603
|
configurable: true,
|
|
535
604
|
value: topWindow,
|
|
@@ -543,10 +612,11 @@ describe("WorkspaceAppCard", () => {
|
|
|
543
612
|
<TooltipProvider>
|
|
544
613
|
<WorkspaceAppCard
|
|
545
614
|
app={{
|
|
546
|
-
id: "
|
|
547
|
-
name: "
|
|
548
|
-
path: "/
|
|
549
|
-
|
|
615
|
+
id: "coach",
|
|
616
|
+
name: "Coach",
|
|
617
|
+
path: "/coach",
|
|
618
|
+
homePath: "/",
|
|
619
|
+
url: `${window.location.origin}/dispatch/apps/coach`,
|
|
550
620
|
status: "ready",
|
|
551
621
|
}}
|
|
552
622
|
/>
|
|
@@ -560,15 +630,14 @@ describe("WorkspaceAppCard", () => {
|
|
|
560
630
|
.querySelector<HTMLButtonElement>(".app-open-actions__primary")
|
|
561
631
|
?.click(),
|
|
562
632
|
);
|
|
563
|
-
expect(topWindow.location.href).toBe("");
|
|
564
|
-
expect(
|
|
565
|
-
"/apps/feedback-leaderboard",
|
|
566
|
-
);
|
|
633
|
+
expect(topWindow.location.href).toBe("https://chatgpt.com/");
|
|
634
|
+
expect(window.location.pathname).toBe("/coach");
|
|
567
635
|
} finally {
|
|
568
636
|
Object.defineProperty(window, "top", {
|
|
569
637
|
configurable: true,
|
|
570
638
|
value: originalTop,
|
|
571
639
|
});
|
|
640
|
+
window.history.replaceState({}, "", originalHref);
|
|
572
641
|
}
|
|
573
642
|
});
|
|
574
643
|
|