@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,6 @@
|
|
|
1
1
|
// @vitest-environment happy-dom
|
|
2
2
|
|
|
3
|
+
import { getBrowserTabId } from "@agent-native/core/client/browser-tab-id";
|
|
3
4
|
import React, { act } from "react";
|
|
4
5
|
import { createRoot, type Root } from "react-dom/client";
|
|
5
6
|
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
@@ -26,8 +27,19 @@ vi.mock("@agent-native/core/client/api-path", () => ({
|
|
|
26
27
|
}));
|
|
27
28
|
|
|
28
29
|
vi.mock("@agent-native/toolkit/app/chat/chat-first/app-pane", () => ({
|
|
29
|
-
ChatFirstAppPane: ({
|
|
30
|
-
|
|
30
|
+
ChatFirstAppPane: ({
|
|
31
|
+
app,
|
|
32
|
+
embedUrl,
|
|
33
|
+
renderEmbed,
|
|
34
|
+
}: {
|
|
35
|
+
app: { name: string } | null;
|
|
36
|
+
embedUrl?: string | null;
|
|
37
|
+
renderEmbed: (embed: { url: string }) => React.ReactNode;
|
|
38
|
+
}) => (
|
|
39
|
+
<div data-app-pane>
|
|
40
|
+
{app?.name}
|
|
41
|
+
{embedUrl ? renderEmbed({ url: embedUrl }) : null}
|
|
42
|
+
</div>
|
|
31
43
|
),
|
|
32
44
|
}));
|
|
33
45
|
|
|
@@ -58,7 +70,11 @@ vi.mock("next-themes", () => ({
|
|
|
58
70
|
useTheme: () => ({ resolvedTheme: "light" }),
|
|
59
71
|
}));
|
|
60
72
|
|
|
61
|
-
import {
|
|
73
|
+
import {
|
|
74
|
+
useWorkspaceAppChildBrowserTab,
|
|
75
|
+
WorkspaceAppChatRail,
|
|
76
|
+
WorkspaceAppFrame,
|
|
77
|
+
} from "./workspace-app-host";
|
|
62
78
|
|
|
63
79
|
function jsonResponse(status: number, body: unknown): Response {
|
|
64
80
|
return new Response(JSON.stringify(body), {
|
|
@@ -77,6 +93,8 @@ describe("WorkspaceAppChatRail", () => {
|
|
|
77
93
|
railState.fetchImpl.mockReset();
|
|
78
94
|
vi.stubGlobal("fetch", railState.fetchImpl);
|
|
79
95
|
vi.spyOn(console, "warn").mockImplementation(() => undefined);
|
|
96
|
+
window.happyDOM?.settings &&
|
|
97
|
+
(window.happyDOM.settings.disableIframePageLoading = true);
|
|
80
98
|
container = document.createElement("div");
|
|
81
99
|
document.body.appendChild(container);
|
|
82
100
|
root = createRoot(container);
|
|
@@ -186,6 +204,66 @@ describe("WorkspaceAppChatRail", () => {
|
|
|
186
204
|
expect(container.querySelector("[data-agent-sidebar]")).not.toBeNull();
|
|
187
205
|
});
|
|
188
206
|
|
|
207
|
+
it("sends the embedded frame's claimed tab id from the app chat rail, never Dispatch's", async () => {
|
|
208
|
+
railState.fetchImpl.mockResolvedValue(
|
|
209
|
+
jsonResponse(200, { devMode: false, canToggle: false }),
|
|
210
|
+
);
|
|
211
|
+
const childTabId = "3f9d2c1e-8a47-4b6d-9c3e-5a1b7d0e4f62";
|
|
212
|
+
railState.mutateAsync.mockResolvedValue({
|
|
213
|
+
startUrl: `${window.location.origin}/mail/?agentNativeTab=${childTabId}`,
|
|
214
|
+
childBrowserTabId: childTabId,
|
|
215
|
+
});
|
|
216
|
+
const dispatchTabId = getBrowserTabId();
|
|
217
|
+
|
|
218
|
+
function AppRoute() {
|
|
219
|
+
const childTab = useWorkspaceAppChildBrowserTab();
|
|
220
|
+
return (
|
|
221
|
+
<WorkspaceAppChatRail
|
|
222
|
+
appId="mail"
|
|
223
|
+
appName="Mail"
|
|
224
|
+
browserTabId={childTab.browserTabId}
|
|
225
|
+
>
|
|
226
|
+
<WorkspaceAppFrame
|
|
227
|
+
app={{ id: "mail", name: "Mail", path: "/mail" }}
|
|
228
|
+
claimBrowserTab
|
|
229
|
+
onViewReaderChange={childTab.onViewReaderChange}
|
|
230
|
+
/>
|
|
231
|
+
</WorkspaceAppChatRail>
|
|
232
|
+
);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
await render(<AppRoute />);
|
|
236
|
+
await act(async () => {
|
|
237
|
+
for (let tick = 0; tick < 10; tick += 1) await Promise.resolve();
|
|
238
|
+
});
|
|
239
|
+
const lastTabId = () =>
|
|
240
|
+
railState.sidebarProps[railState.sidebarProps.length - 1]?.browserTabId;
|
|
241
|
+
expect(lastTabId()).toEqual(expect.any(String));
|
|
242
|
+
expect(lastTabId()).not.toBe(dispatchTabId);
|
|
243
|
+
expect(lastTabId()).not.toBe(childTabId);
|
|
244
|
+
|
|
245
|
+
const iframe = container.querySelector<HTMLIFrameElement>("iframe");
|
|
246
|
+
if (!iframe) throw new Error("Workspace app iframe was not rendered");
|
|
247
|
+
Object.defineProperty(iframe, "contentWindow", {
|
|
248
|
+
configurable: true,
|
|
249
|
+
value: {
|
|
250
|
+
postMessage: vi.fn(),
|
|
251
|
+
location: { href: `${window.location.origin}/mail/inbox` },
|
|
252
|
+
document: { title: "Inbox" },
|
|
253
|
+
getSelection: () => ({ toString: () => "" }),
|
|
254
|
+
},
|
|
255
|
+
});
|
|
256
|
+
await act(async () => {
|
|
257
|
+
iframe.dispatchEvent(new Event("load"));
|
|
258
|
+
await Promise.resolve();
|
|
259
|
+
await Promise.resolve();
|
|
260
|
+
await Promise.resolve();
|
|
261
|
+
});
|
|
262
|
+
|
|
263
|
+
expect(lastTabId()).toBe(childTabId);
|
|
264
|
+
expect(lastTabId()).not.toBe(dispatchTabId);
|
|
265
|
+
});
|
|
266
|
+
|
|
189
267
|
it("leaves surfaces with no open app alone — no app rail and no proxy probe", async () => {
|
|
190
268
|
await render(
|
|
191
269
|
<WorkspaceAppFrame app={{ id: "mail", name: "Mail", path: "/mail" }} />,
|
|
@@ -182,6 +182,13 @@ import {
|
|
|
182
182
|
WorkspaceAppKeepAlive,
|
|
183
183
|
} from "./workspace-app-host";
|
|
184
184
|
|
|
185
|
+
function postGuestReply(port: MessagePort, result: unknown): Promise<void> {
|
|
186
|
+
const handled = Promise.withResolvers<void>();
|
|
187
|
+
port.addEventListener("close", () => handled.resolve(), { once: true });
|
|
188
|
+
port.postMessage(result);
|
|
189
|
+
return handled.promise;
|
|
190
|
+
}
|
|
191
|
+
|
|
185
192
|
describe("WorkspaceAppKeepAlive", () => {
|
|
186
193
|
let container: HTMLDivElement;
|
|
187
194
|
let root: Root;
|
|
@@ -258,6 +265,15 @@ describe("WorkspaceAppKeepAlive", () => {
|
|
|
258
265
|
expect(calendarEntry?.classList.contains("hidden")).toBe(false);
|
|
259
266
|
expect(calendarEntry?.querySelector("iframe")).not.toBeNull();
|
|
260
267
|
expect(container.querySelectorAll("iframe")).toHaveLength(2);
|
|
268
|
+
for (const iframe of container.querySelectorAll("iframe")) {
|
|
269
|
+
expect(iframe.getAttribute("allow")?.split(/;\s*/)).toEqual(
|
|
270
|
+
expect.arrayContaining([
|
|
271
|
+
"clipboard-read",
|
|
272
|
+
"clipboard-write",
|
|
273
|
+
"fullscreen",
|
|
274
|
+
]),
|
|
275
|
+
);
|
|
276
|
+
}
|
|
261
277
|
expect(
|
|
262
278
|
clientState.actionQueryParams.find(
|
|
263
279
|
(query) => query.name === "list-workspace-apps",
|
|
@@ -638,6 +654,203 @@ describe("WorkspaceAppKeepAlive", () => {
|
|
|
638
654
|
);
|
|
639
655
|
});
|
|
640
656
|
|
|
657
|
+
it("navigates a qualified app's loaded frame in place after a guest receipt", async () => {
|
|
658
|
+
const origin = "https://mail.example.test";
|
|
659
|
+
const startUrl = `${origin}/mail/inbox`;
|
|
660
|
+
clientState.legacyMutateAsync.mockResolvedValue({ startUrl });
|
|
661
|
+
clientState.suppressFrameLoad = true;
|
|
662
|
+
const app = {
|
|
663
|
+
id: "workspace/mail",
|
|
664
|
+
name: "Mail",
|
|
665
|
+
path: "/mail",
|
|
666
|
+
url: `${origin}/mail`,
|
|
667
|
+
};
|
|
668
|
+
|
|
669
|
+
await act(async () => {
|
|
670
|
+
root.render(<WorkspaceAppFrame app={app} embedPath="/inbox" />);
|
|
671
|
+
});
|
|
672
|
+
const iframe = container.querySelector("iframe");
|
|
673
|
+
if (!iframe || !iframe.contentWindow) throw new Error("Missing app frame");
|
|
674
|
+
const postMessage = vi.spyOn(iframe.contentWindow, "postMessage");
|
|
675
|
+
const target = "/mail/threads/42?mode=all#message";
|
|
676
|
+
const guestPort = Promise.withResolvers<MessagePort>();
|
|
677
|
+
postMessage.mockImplementation((message, _origin, transfer) => {
|
|
678
|
+
if (message?.type !== "agentNative.viewRequest") return;
|
|
679
|
+
const [port] = transfer as MessagePort[];
|
|
680
|
+
guestPort.resolve(port);
|
|
681
|
+
});
|
|
682
|
+
|
|
683
|
+
await act(async () => clientState.frameLoadHandler?.());
|
|
684
|
+
await act(async () => {
|
|
685
|
+
root.render(
|
|
686
|
+
<WorkspaceAppFrame
|
|
687
|
+
app={app}
|
|
688
|
+
embedPath="/threads/42?mode=all#message"
|
|
689
|
+
/>,
|
|
690
|
+
);
|
|
691
|
+
});
|
|
692
|
+
|
|
693
|
+
expect(postMessage).toHaveBeenCalledWith(
|
|
694
|
+
{
|
|
695
|
+
type: "agentNative.viewRequest",
|
|
696
|
+
operation: "navigate",
|
|
697
|
+
path: target,
|
|
698
|
+
deadline: expect.any(Number),
|
|
699
|
+
},
|
|
700
|
+
origin,
|
|
701
|
+
[expect.objectContaining({ postMessage: expect.any(Function) })],
|
|
702
|
+
);
|
|
703
|
+
expect(container.querySelector("iframe")).toBe(iframe);
|
|
704
|
+
expect(clientState.legacyMutateAsync).toHaveBeenCalledTimes(1);
|
|
705
|
+
expect(
|
|
706
|
+
container
|
|
707
|
+
.querySelector("[data-chat-first-app-embed-url]")
|
|
708
|
+
?.getAttribute("data-chat-first-app-embed-url"),
|
|
709
|
+
).toBe(startUrl);
|
|
710
|
+
const port = await guestPort.promise;
|
|
711
|
+
await act(() => postGuestReply(port, { result: { path: target } }));
|
|
712
|
+
expect(container.querySelector("iframe")).toBe(iframe);
|
|
713
|
+
});
|
|
714
|
+
|
|
715
|
+
it.each([
|
|
716
|
+
{ outcome: "accepted", newPath: "/threads/43" },
|
|
717
|
+
{ outcome: "rejected", newPath: "/threads/43" },
|
|
718
|
+
{ outcome: "accepted", newPath: "/inbox" },
|
|
719
|
+
])(
|
|
720
|
+
"opens $newPath in the warm frame when a superseded request is $outcome",
|
|
721
|
+
async ({ outcome, newPath }) => {
|
|
722
|
+
const origin = "https://mail.example.test";
|
|
723
|
+
clientState.legacyMutateAsync.mockResolvedValue({
|
|
724
|
+
startUrl: `${origin}/mail/inbox`,
|
|
725
|
+
});
|
|
726
|
+
clientState.suppressFrameLoad = true;
|
|
727
|
+
const app = {
|
|
728
|
+
id: "workspace/mail",
|
|
729
|
+
name: "Mail",
|
|
730
|
+
path: "/mail",
|
|
731
|
+
url: `${origin}/mail`,
|
|
732
|
+
};
|
|
733
|
+
const onChildRouteChange = vi.fn();
|
|
734
|
+
const renderRoute = (path: string) =>
|
|
735
|
+
act(async () => {
|
|
736
|
+
root.render(
|
|
737
|
+
<WorkspaceAppFrame
|
|
738
|
+
app={app}
|
|
739
|
+
embedPath={path}
|
|
740
|
+
onChildRouteChange={onChildRouteChange}
|
|
741
|
+
/>,
|
|
742
|
+
);
|
|
743
|
+
});
|
|
744
|
+
await renderRoute("/inbox");
|
|
745
|
+
const iframe = container.querySelector("iframe");
|
|
746
|
+
const source = iframe?.contentWindow;
|
|
747
|
+
if (!source) throw new Error("Missing app frame");
|
|
748
|
+
const ports = new Map<string, MessagePort>();
|
|
749
|
+
vi.spyOn(source, "postMessage").mockImplementation(
|
|
750
|
+
(message, _origin, transfer) => {
|
|
751
|
+
if (message?.type !== "agentNative.viewRequest") return;
|
|
752
|
+
const [port] = transfer as MessagePort[];
|
|
753
|
+
ports.set(message.path, port);
|
|
754
|
+
},
|
|
755
|
+
);
|
|
756
|
+
const reportRoute = (path: string) =>
|
|
757
|
+
window.dispatchEvent(
|
|
758
|
+
new MessageEvent("message", {
|
|
759
|
+
data: { type: "agent-native:workspace-app-route", path },
|
|
760
|
+
origin,
|
|
761
|
+
source,
|
|
762
|
+
}),
|
|
763
|
+
);
|
|
764
|
+
const reply = async (path: string, result: object) => {
|
|
765
|
+
const port = ports.get(path);
|
|
766
|
+
if (!port) throw new Error("Missing navigation request");
|
|
767
|
+
await act(() => postGuestReply(port, result));
|
|
768
|
+
};
|
|
769
|
+
|
|
770
|
+
await act(async () => clientState.frameLoadHandler?.());
|
|
771
|
+
if (newPath === "/inbox") {
|
|
772
|
+
reportRoute("/mail/inbox");
|
|
773
|
+
onChildRouteChange.mockClear();
|
|
774
|
+
}
|
|
775
|
+
await renderRoute("/threads/42");
|
|
776
|
+
await renderRoute(newPath);
|
|
777
|
+
const superseded = "/mail/threads/42";
|
|
778
|
+
const latest = `/mail${newPath}`;
|
|
779
|
+
expect([...ports.keys()]).toEqual([superseded]);
|
|
780
|
+
if (outcome === "accepted" && newPath !== "/inbox") {
|
|
781
|
+
reportRoute(superseded);
|
|
782
|
+
}
|
|
783
|
+
await reply(
|
|
784
|
+
superseded,
|
|
785
|
+
outcome === "accepted"
|
|
786
|
+
? { result: { path: superseded } }
|
|
787
|
+
: { error: "View unavailable" },
|
|
788
|
+
);
|
|
789
|
+
|
|
790
|
+
await vi.waitFor(() =>
|
|
791
|
+
expect([...ports.keys()]).toEqual([superseded, latest]),
|
|
792
|
+
);
|
|
793
|
+
reportRoute(latest);
|
|
794
|
+
await reply(latest, { result: { path: latest } });
|
|
795
|
+
expect(onChildRouteChange.mock.calls).toEqual([
|
|
796
|
+
[
|
|
797
|
+
`/apps/workspace%2Fmail?__workspace_app_path=${encodeURIComponent(newPath)}`,
|
|
798
|
+
],
|
|
799
|
+
]);
|
|
800
|
+
expect(container.querySelector("iframe")).toBe(iframe);
|
|
801
|
+
expect(clientState.legacyMutateAsync).toHaveBeenCalledTimes(1);
|
|
802
|
+
},
|
|
803
|
+
);
|
|
804
|
+
|
|
805
|
+
it("opens the requested deep link if the mounted guest rejects in-place navigation", async () => {
|
|
806
|
+
const origin = "https://mail.example.test";
|
|
807
|
+
const startUrl = `${origin}/mail/inbox`;
|
|
808
|
+
const fallbackUrl = `${origin}/mail/threads/42`;
|
|
809
|
+
clientState.legacyMutateAsync
|
|
810
|
+
.mockResolvedValueOnce({ startUrl })
|
|
811
|
+
.mockResolvedValueOnce({ startUrl: fallbackUrl });
|
|
812
|
+
clientState.suppressFrameLoad = true;
|
|
813
|
+
const app = {
|
|
814
|
+
id: "workspace/mail",
|
|
815
|
+
name: "Mail",
|
|
816
|
+
path: "/mail",
|
|
817
|
+
url: `${origin}/mail`,
|
|
818
|
+
};
|
|
819
|
+
|
|
820
|
+
await act(async () => {
|
|
821
|
+
root.render(<WorkspaceAppFrame app={app} embedPath="/inbox" />);
|
|
822
|
+
});
|
|
823
|
+
const iframe = container.querySelector("iframe");
|
|
824
|
+
if (!iframe || !iframe.contentWindow) throw new Error("Missing app frame");
|
|
825
|
+
vi.spyOn(iframe.contentWindow, "postMessage").mockImplementation(
|
|
826
|
+
(message, _origin, transfer) => {
|
|
827
|
+
if (message?.type !== "agentNative.viewRequest") return;
|
|
828
|
+
const [port] = transfer as MessagePort[];
|
|
829
|
+
port.postMessage({ error: "View unavailable" });
|
|
830
|
+
port.close();
|
|
831
|
+
},
|
|
832
|
+
);
|
|
833
|
+
await act(async () => clientState.frameLoadHandler?.());
|
|
834
|
+
await act(async () => {
|
|
835
|
+
root.render(<WorkspaceAppFrame app={app} embedPath="/threads/42" />);
|
|
836
|
+
});
|
|
837
|
+
await act(async () => {
|
|
838
|
+
await vi.waitFor(() =>
|
|
839
|
+
expect(clientState.legacyMutateAsync).toHaveBeenCalledWith({
|
|
840
|
+
app: "workspace/mail",
|
|
841
|
+
path: "/threads/42",
|
|
842
|
+
chrome: "minimal",
|
|
843
|
+
}),
|
|
844
|
+
);
|
|
845
|
+
});
|
|
846
|
+
expect(container.querySelector("iframe")).not.toBe(iframe);
|
|
847
|
+
expect(
|
|
848
|
+
container
|
|
849
|
+
.querySelector("[data-chat-first-app-embed-url]")
|
|
850
|
+
?.getAttribute("data-chat-first-app-embed-url"),
|
|
851
|
+
).toBe(fallbackUrl);
|
|
852
|
+
});
|
|
853
|
+
|
|
641
854
|
it("reports trusted child routes to the standalone Dispatch host", async () => {
|
|
642
855
|
clientState.legacyMutateAsync.mockResolvedValue({
|
|
643
856
|
startUrl: "https://design.example.test/_agent-native/embed",
|
|
@@ -964,8 +1177,11 @@ describe("WorkspaceAppKeepAlive", () => {
|
|
|
964
1177
|
).toBe("Workspace SSO is temporarily unavailable");
|
|
965
1178
|
});
|
|
966
1179
|
|
|
967
|
-
it("
|
|
968
|
-
const
|
|
1180
|
+
it("opens the standalone app in the current frame instead of nesting inside an external iframe", async () => {
|
|
1181
|
+
const originalHref = window.location.href;
|
|
1182
|
+
const topWindow = {
|
|
1183
|
+
location: { href: "https://claude.ai/chat" },
|
|
1184
|
+
} as unknown as Window;
|
|
969
1185
|
Object.defineProperty(window, "parent", {
|
|
970
1186
|
configurable: true,
|
|
971
1187
|
value: {},
|
|
@@ -975,22 +1191,59 @@ describe("WorkspaceAppKeepAlive", () => {
|
|
|
975
1191
|
value: topWindow,
|
|
976
1192
|
});
|
|
977
1193
|
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
1194
|
+
try {
|
|
1195
|
+
await act(async () => {
|
|
1196
|
+
root.render(
|
|
1197
|
+
<WorkspaceAppFrame
|
|
1198
|
+
app={{ id: "mail", name: "Mail", path: "/mail" }}
|
|
1199
|
+
/>,
|
|
1200
|
+
);
|
|
1201
|
+
await Promise.resolve();
|
|
1202
|
+
await Promise.resolve();
|
|
1203
|
+
});
|
|
986
1204
|
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
1205
|
+
expect(topWindow.location.href).toBe("https://claude.ai/chat");
|
|
1206
|
+
expect(window.location.pathname).toBe("/mail/home");
|
|
1207
|
+
expect(clientState.legacyMutateAsync).not.toHaveBeenCalled();
|
|
1208
|
+
expect(container.querySelector("iframe")).toBeNull();
|
|
1209
|
+
} finally {
|
|
1210
|
+
window.history.replaceState({}, "", originalHref);
|
|
1211
|
+
}
|
|
1212
|
+
});
|
|
1213
|
+
|
|
1214
|
+
it("keeps explicit ?embedded=1 host routes inline even when framed", async () => {
|
|
1215
|
+
const originalHref = window.location.href;
|
|
1216
|
+
window.history.replaceState({}, "", "/apps/mail?embedded=1");
|
|
1217
|
+
Object.defineProperty(window, "parent", {
|
|
1218
|
+
configurable: true,
|
|
1219
|
+
value: {},
|
|
992
1220
|
});
|
|
993
|
-
|
|
1221
|
+
Object.defineProperty(window, "top", {
|
|
1222
|
+
configurable: true,
|
|
1223
|
+
value: {},
|
|
1224
|
+
});
|
|
1225
|
+
|
|
1226
|
+
try {
|
|
1227
|
+
await act(async () => {
|
|
1228
|
+
root.render(
|
|
1229
|
+
<WorkspaceAppFrame
|
|
1230
|
+
app={{ id: "mail", name: "Mail", path: "/mail" }}
|
|
1231
|
+
/>,
|
|
1232
|
+
);
|
|
1233
|
+
await Promise.resolve();
|
|
1234
|
+
await Promise.resolve();
|
|
1235
|
+
await Promise.resolve();
|
|
1236
|
+
});
|
|
1237
|
+
|
|
1238
|
+
expect(clientState.legacyMutateAsync).toHaveBeenCalledWith({
|
|
1239
|
+
app: "mail",
|
|
1240
|
+
path: "/mail/home",
|
|
1241
|
+
chrome: "minimal",
|
|
1242
|
+
});
|
|
1243
|
+
expect(container.querySelector("iframe")).not.toBeNull();
|
|
1244
|
+
} finally {
|
|
1245
|
+
window.history.replaceState({}, "", originalHref);
|
|
1246
|
+
}
|
|
994
1247
|
});
|
|
995
1248
|
|
|
996
1249
|
it("opens the app in the top window for a native desktop host", async () => {
|