@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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workspace-app-host.d.ts","sourceRoot":"","sources":["../../src/components/workspace-app-host.tsx"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iDAAiD,CAAC;AAOrF,OAAO,
|
|
1
|
+
{"version":3,"file":"workspace-app-host.d.ts","sourceRoot":"","sources":["../../src/components/workspace-app-host.tsx"],"names":[],"mappings":"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"}
|
|
@@ -10,10 +10,12 @@ import { AgentSidebar } from "@agent-native/toolkit/app/chat/AgentSidebar";
|
|
|
10
10
|
import { defaultChatFirstCopy } from "@agent-native/toolkit/app/chat/chat-first-copy";
|
|
11
11
|
import { IconAlertTriangle, IconArrowLeft, IconClockHour4, } from "@tabler/icons-react";
|
|
12
12
|
import { useTheme } from "next-themes";
|
|
13
|
-
import { useCallback, useEffect, useMemo, useRef, useState, } from "react";
|
|
13
|
+
import { useCallback, useEffect, useEffectEvent, useMemo, useRef, useState, } from "react";
|
|
14
14
|
import { Link } from "react-router";
|
|
15
15
|
import { isEmbedSessionExpiredMessage } from "../lib/embed-session-recovery.js";
|
|
16
|
+
import { requestWorkspaceAppFrameView, workspaceAppFramePath, workspaceAppFramePathAtMount, } from "../lib/workspace-app-frame-view.js";
|
|
16
17
|
import { isWorkspaceAppHostPageUrl, isWorkspaceSsoApp, isDispatchWorkspaceAppId, navigateToWorkspaceApp, shouldOpenWorkspaceAppInTopWindow, workspaceAppRouteForChildPath, workspaceAppDirectHref, workspaceAppHref, workspaceAppTargetPath, } from "../lib/workspace-apps.js";
|
|
18
|
+
import { DISPATCH_CHILD_BROWSER_TAB_PARAM, isDispatchChildBrowserTabId, } from "../shared/chat-first-pane.js";
|
|
17
19
|
import { DISPATCH_WORKSPACE_SSO_FLAG } from "../shared/feature-flags.js";
|
|
18
20
|
import { workspaceAppChatProxyPath } from "../shared/workspace-app-chat.js";
|
|
19
21
|
import { ActionQueryError } from "./action-query-error.js";
|
|
@@ -143,7 +145,50 @@ function useWorkspaceAppChatApi(appId) {
|
|
|
143
145
|
retry: useCallback(() => setAttempt((value) => value + 1), []),
|
|
144
146
|
};
|
|
145
147
|
}
|
|
146
|
-
|
|
148
|
+
const CHILD_TAB_POLL_MS = 500;
|
|
149
|
+
const CHILD_TAB_POLL_ATTEMPTS = 40;
|
|
150
|
+
/**
|
|
151
|
+
* The tab id the app's chat requests must carry is the embedded frame's, not
|
|
152
|
+
* Dispatch's: apps share one database, so a `navigate:<tabId>` command written
|
|
153
|
+
* under Dispatch's own id is consumed by Dispatch's navigation state. Until the
|
|
154
|
+
* frame has adopted its claim the rail gets an id nobody consumes.
|
|
155
|
+
*/
|
|
156
|
+
export function useWorkspaceAppChildBrowserTab() {
|
|
157
|
+
const [unclaimedId] = useState(() => crypto.randomUUID());
|
|
158
|
+
const [claimedId, setClaimedId] = useState(null);
|
|
159
|
+
const onViewReaderChange = useCallback((read) => {
|
|
160
|
+
let attempts = 0;
|
|
161
|
+
let stopped = false;
|
|
162
|
+
let timer;
|
|
163
|
+
const retry = () => {
|
|
164
|
+
if (!stopped && attempts < CHILD_TAB_POLL_ATTEMPTS) {
|
|
165
|
+
timer = setTimeout(poll, CHILD_TAB_POLL_MS);
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
const poll = () => {
|
|
169
|
+
attempts += 1;
|
|
170
|
+
read(AbortSignal.timeout(CHILD_TAB_POLL_MS * 4))
|
|
171
|
+
.then((view) => {
|
|
172
|
+
if (stopped)
|
|
173
|
+
return;
|
|
174
|
+
if (view?.childBrowserTabId)
|
|
175
|
+
setClaimedId(view.childBrowserTabId);
|
|
176
|
+
else
|
|
177
|
+
retry();
|
|
178
|
+
})
|
|
179
|
+
// coercion-ok: an unreadable frame stays unclaimed and the rail keeps its inert id.
|
|
180
|
+
.catch(retry);
|
|
181
|
+
};
|
|
182
|
+
poll();
|
|
183
|
+
return () => {
|
|
184
|
+
stopped = true;
|
|
185
|
+
clearTimeout(timer);
|
|
186
|
+
setClaimedId(null);
|
|
187
|
+
};
|
|
188
|
+
}, []);
|
|
189
|
+
return { browserTabId: claimedId ?? unclaimedId, onViewReaderChange };
|
|
190
|
+
}
|
|
191
|
+
export function WorkspaceAppChatRail({ appId, appName, children, copy = defaultChatFirstCopy, agentPageHref, onFullscreenRequest, browserTabId, }) {
|
|
147
192
|
const t = useT();
|
|
148
193
|
const appChat = useWorkspaceAppChatApi(appId);
|
|
149
194
|
const retryRef = useRef(null);
|
|
@@ -170,9 +215,58 @@ export function WorkspaceAppChatRail({ appId, appName, children, copy = defaultC
|
|
|
170
215
|
id: appId,
|
|
171
216
|
label: appName,
|
|
172
217
|
contextKey: `workspace-app:${appId}`,
|
|
173
|
-
}, isolateHistoryByScope: true, apiUrl: appChat.apiUrl, agentChatSurface: "app", showTabBar: true, suppressInlineOpenApp: true, dynamicSuggestions: false, suggestions: [], emptyStateText: `Ask about ${appName}`, ...(agentPageHref ? { agentPageHref } : {}), ...(onFullscreenRequest ? { onFullscreenRequest } : {}), children: children }));
|
|
218
|
+
}, isolateHistoryByScope: true, apiUrl: appChat.apiUrl, agentChatSurface: "app", ...(browserTabId ? { browserTabId } : {}), showTabBar: true, suppressInlineOpenApp: true, dynamicSuggestions: false, suggestions: [], emptyStateText: `Ask about ${appName}`, ...(agentPageHref ? { agentPageHref } : {}), ...(onFullscreenRequest ? { onFullscreenRequest } : {}), children: children }));
|
|
219
|
+
}
|
|
220
|
+
function navigateSameOriginWorkspaceApp(frame, mountPath, url) {
|
|
221
|
+
const base = mountPath?.replace(/\/+$/, "");
|
|
222
|
+
if (!base || url.origin !== window.location.origin)
|
|
223
|
+
return false;
|
|
224
|
+
try {
|
|
225
|
+
const current = new URL(frame.location.href);
|
|
226
|
+
if (current.origin !== url.origin ||
|
|
227
|
+
(current.pathname !== base && !current.pathname.startsWith(`${base}/`))) {
|
|
228
|
+
return false;
|
|
229
|
+
}
|
|
230
|
+
const nextPath = workspaceAppFramePath(url);
|
|
231
|
+
if (workspaceAppFramePath(current) === nextPath)
|
|
232
|
+
return true;
|
|
233
|
+
const index = frame.history.state?.idx;
|
|
234
|
+
const state = {
|
|
235
|
+
usr: null,
|
|
236
|
+
key: crypto.randomUUID(),
|
|
237
|
+
idx: typeof index === "number" ? index + 1 : 0,
|
|
238
|
+
};
|
|
239
|
+
frame.history.pushState(state, "", nextPath);
|
|
240
|
+
const FramePopStateEvent = frame
|
|
241
|
+
.PopStateEvent;
|
|
242
|
+
frame.dispatchEvent(new FramePopStateEvent("popstate", { state }));
|
|
243
|
+
return true;
|
|
244
|
+
}
|
|
245
|
+
catch {
|
|
246
|
+
// coercion-ok: a redirected iframe rejects direct access and falls back to the guest bridge.
|
|
247
|
+
return false;
|
|
248
|
+
}
|
|
174
249
|
}
|
|
175
|
-
|
|
250
|
+
function readSameOriginWorkspaceAppView(frame, mount) {
|
|
251
|
+
try {
|
|
252
|
+
const location = new URL(frame.location.href);
|
|
253
|
+
const path = workspaceAppFramePathAtMount(location, mount);
|
|
254
|
+
if (!path)
|
|
255
|
+
return null;
|
|
256
|
+
const selectedText = frame.getSelection()?.toString().trim();
|
|
257
|
+
return {
|
|
258
|
+
path,
|
|
259
|
+
title: frame.document.title,
|
|
260
|
+
...(selectedText ? { selectedText } : {}),
|
|
261
|
+
pendingTabClaim: location.searchParams.has(DISPATCH_CHILD_BROWSER_TAB_PARAM),
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
catch {
|
|
265
|
+
// coercion-ok: null means the frame view is unavailable after the browser denies access.
|
|
266
|
+
return null;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
export function WorkspaceAppFrame({ app, navigateToTopWindow = navigateToWorkspaceApp, embedPath, initialPath, onChildRouteChange, onViewReaderChange, claimBrowserTab = false, chatSidebar = false, copy = defaultChatFirstCopy, }) {
|
|
176
270
|
const { resolvedTheme } = useTheme();
|
|
177
271
|
const theme = resolvedTheme === "dark" || resolvedTheme === "light"
|
|
178
272
|
? resolvedTheme
|
|
@@ -180,6 +274,22 @@ export function WorkspaceAppFrame({ app, navigateToTopWindow = navigateToWorkspa
|
|
|
180
274
|
document.documentElement.classList.contains("dark")
|
|
181
275
|
? "dark"
|
|
182
276
|
: "light";
|
|
277
|
+
const isExplicitEmbeddedHostRoute = typeof window !== "undefined" &&
|
|
278
|
+
new URLSearchParams(window.location.search).get("embedded") === "1";
|
|
279
|
+
const openInTopWindow = !isExplicitEmbeddedHostRoute && shouldOpenWorkspaceAppInTopWindow();
|
|
280
|
+
const requestedPath = embedPath ?? initialPath;
|
|
281
|
+
const [launchPath, setLaunchPath] = useState(requestedPath);
|
|
282
|
+
const [completedNavigation, setCompletedNavigation] = useState({
|
|
283
|
+
requestedPath,
|
|
284
|
+
accepted: true,
|
|
285
|
+
});
|
|
286
|
+
const requestedPathAccepted = completedNavigation.accepted &&
|
|
287
|
+
completedNavigation.requestedPath === requestedPath;
|
|
288
|
+
const [loadedDocument, setLoadedDocument] = useState(null);
|
|
289
|
+
const pendingNavigation = useRef(null);
|
|
290
|
+
const observedPath = useRef(null);
|
|
291
|
+
const framePath = openInTopWindow ? requestedPath : launchPath;
|
|
292
|
+
const childBrowserTabClaim = useRef(null);
|
|
183
293
|
const [embedUrl, setEmbedUrl] = useState(null);
|
|
184
294
|
const [embedError, setEmbedError] = useState(null);
|
|
185
295
|
const [isDirectFallback, setIsDirectFallback] = useState(false);
|
|
@@ -192,9 +302,13 @@ export function WorkspaceAppFrame({ app, navigateToTopWindow = navigateToWorkspa
|
|
|
192
302
|
const handleFrameLoad = useCallback(() => {
|
|
193
303
|
embedFrameRef.current?.contentWindow?.postMessage({ type: "agentNative.frameOrigin", origin: window.location.origin }, "*");
|
|
194
304
|
postThemeToFrame();
|
|
305
|
+
pendingNavigation.current?.controller.abort();
|
|
306
|
+
pendingNavigation.current = null;
|
|
307
|
+
observedPath.current = null;
|
|
308
|
+
setLoadedDocument(embedUrl ? { url: embedUrl } : null);
|
|
195
309
|
if (isDirectFallback)
|
|
196
310
|
setEmbedError(null);
|
|
197
|
-
}, [isDirectFallback, postThemeToFrame]);
|
|
311
|
+
}, [embedUrl, isDirectFallback, postThemeToFrame]);
|
|
198
312
|
const workspaceSsoEnabled = useFeatureFlag(DISPATCH_WORKSPACE_SSO_FLAG.key);
|
|
199
313
|
const useWorkspaceSso = workspaceSsoEnabled && isWorkspaceSsoApp(app);
|
|
200
314
|
const createEmbedSession = useActionMutation("create_embed_session", {
|
|
@@ -215,17 +329,16 @@ export function WorkspaceAppFrame({ app, navigateToTopWindow = navigateToWorkspa
|
|
|
215
329
|
url: appUrl,
|
|
216
330
|
isDispatch: app.isDispatch ?? isDispatchWorkspaceAppId(app.id),
|
|
217
331
|
});
|
|
218
|
-
const topWindowHref = useMemo(() =>
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
const topWindowSsoAttemptKey = `${app.id}\u0000${app.path ?? ""}\u0000${app.url ?? ""}\u0000${embedPath ?? ""}\u0000${initialPath ?? ""}\u0000${embedAttempt}`;
|
|
332
|
+
const topWindowHref = useMemo(() => requestedPath === undefined
|
|
333
|
+
? appHref
|
|
334
|
+
: workspaceAppDirectHref({ path: app.path ?? null, url: appUrl }, requestedPath), [app.path, appHref, appUrl, requestedPath]);
|
|
335
|
+
const topWindowSsoAttemptKey = JSON.stringify([
|
|
336
|
+
app.id,
|
|
337
|
+
app.path,
|
|
338
|
+
app.url,
|
|
339
|
+
framePath,
|
|
340
|
+
embedAttempt,
|
|
341
|
+
]);
|
|
229
342
|
const topWindowSsoAttemptedRef = useRef(null);
|
|
230
343
|
// A same-origin workspace app already shares the workspace session cookie, so
|
|
231
344
|
// framing it through an embed session makes it worse: an ordinary embed
|
|
@@ -239,7 +352,7 @@ export function WorkspaceAppFrame({ app, navigateToTopWindow = navigateToWorkspa
|
|
|
239
352
|
const hostPageDirectUrl = useMemo(() => {
|
|
240
353
|
if (!isHostPageUrl)
|
|
241
354
|
return null;
|
|
242
|
-
const targetPath =
|
|
355
|
+
const targetPath = framePath;
|
|
243
356
|
const href = targetPath !== undefined
|
|
244
357
|
? workspaceAppDirectHref({ path: app.path ?? null, url: appUrl }, targetPath)
|
|
245
358
|
: appHref;
|
|
@@ -247,13 +360,10 @@ export function WorkspaceAppFrame({ app, navigateToTopWindow = navigateToWorkspa
|
|
|
247
360
|
// batching, and the plain app URL is what the existing direct fallback
|
|
248
361
|
// already loads when a mint fails.
|
|
249
362
|
return href || null;
|
|
250
|
-
}, [app.path, appHref, appUrl,
|
|
363
|
+
}, [app.path, appHref, appUrl, framePath, isHostPageUrl]);
|
|
251
364
|
const embedInput = useMemo(() => {
|
|
252
|
-
if (
|
|
253
|
-
return buildChatFirstEmbedSessionInput(app.id,
|
|
254
|
-
}
|
|
255
|
-
if (initialPath !== undefined) {
|
|
256
|
-
return buildChatFirstEmbedSessionInput(app.id, initialPath);
|
|
365
|
+
if (framePath !== undefined) {
|
|
366
|
+
return buildChatFirstEmbedSessionInput(app.id, framePath);
|
|
257
367
|
}
|
|
258
368
|
if (!appHref)
|
|
259
369
|
return null;
|
|
@@ -265,18 +375,8 @@ export function WorkspaceAppFrame({ app, navigateToTopWindow = navigateToWorkspa
|
|
|
265
375
|
...(appUrl?.trim() ? { url: appHref } : { path: appHref }),
|
|
266
376
|
chrome: "minimal",
|
|
267
377
|
};
|
|
268
|
-
}, [
|
|
269
|
-
app.homePath,
|
|
270
|
-
app.id,
|
|
271
|
-
appHref,
|
|
272
|
-
appUrl,
|
|
273
|
-
embedPath,
|
|
274
|
-
initialPath,
|
|
275
|
-
isHostPageUrl,
|
|
276
|
-
]);
|
|
378
|
+
}, [app.homePath, app.id, appHref, appUrl, framePath, isHostPageUrl]);
|
|
277
379
|
useEffect(() => {
|
|
278
|
-
if (hostPageDirectUrl)
|
|
279
|
-
return;
|
|
280
380
|
if (openInTopWindow && useWorkspaceSso && embedInput) {
|
|
281
381
|
setTopWindowNavigationFailed(false);
|
|
282
382
|
return;
|
|
@@ -305,12 +405,26 @@ export function WorkspaceAppFrame({ app, navigateToTopWindow = navigateToWorkspa
|
|
|
305
405
|
useWorkspaceSso,
|
|
306
406
|
]);
|
|
307
407
|
useEffect(() => {
|
|
308
|
-
|
|
309
|
-
|
|
408
|
+
setLoadedDocument(null);
|
|
409
|
+
observedPath.current = null;
|
|
410
|
+
childBrowserTabClaim.current = null;
|
|
411
|
+
if (hostPageDirectUrl && (!openInTopWindow || topWindowNavigationFailed)) {
|
|
412
|
+
if (claimBrowserTab) {
|
|
413
|
+
const url = new URL(hostPageDirectUrl, window.location.href);
|
|
414
|
+
const id = crypto.randomUUID();
|
|
415
|
+
url.searchParams.set(DISPATCH_CHILD_BROWSER_TAB_PARAM, id);
|
|
416
|
+
childBrowserTabClaim.current = { startUrl: url.href, id };
|
|
417
|
+
setEmbedUrl(url.href);
|
|
418
|
+
}
|
|
419
|
+
else {
|
|
420
|
+
setEmbedUrl(hostPageDirectUrl);
|
|
421
|
+
}
|
|
310
422
|
setEmbedError(null);
|
|
311
423
|
setIsDirectFallback(false);
|
|
312
424
|
return;
|
|
313
425
|
}
|
|
426
|
+
if (hostPageDirectUrl)
|
|
427
|
+
return;
|
|
314
428
|
const useTopWindowSso = openInTopWindow && useWorkspaceSso && !!embedInput;
|
|
315
429
|
if (!embedInput ||
|
|
316
430
|
(openInTopWindow && !useWorkspaceSso && !topWindowNavigationFailed)) {
|
|
@@ -349,6 +463,13 @@ export function WorkspaceAppFrame({ app, navigateToTopWindow = navigateToWorkspa
|
|
|
349
463
|
setEmbedUrl(didNavigate ? null : result.startUrl);
|
|
350
464
|
return;
|
|
351
465
|
}
|
|
466
|
+
if (claimBrowserTab &&
|
|
467
|
+
isDispatchChildBrowserTabId(result.childBrowserTabId)) {
|
|
468
|
+
childBrowserTabClaim.current = {
|
|
469
|
+
startUrl: result.startUrl,
|
|
470
|
+
id: result.childBrowserTabId,
|
|
471
|
+
};
|
|
472
|
+
}
|
|
352
473
|
setEmbedUrl(result.startUrl);
|
|
353
474
|
})
|
|
354
475
|
.catch((cause) => {
|
|
@@ -364,8 +485,8 @@ export function WorkspaceAppFrame({ app, navigateToTopWindow = navigateToWorkspa
|
|
|
364
485
|
return;
|
|
365
486
|
}
|
|
366
487
|
setIsDirectFallback(true);
|
|
367
|
-
const fallbackHref =
|
|
368
|
-
? workspaceAppDirectHref({ path: app.path ?? "", url: appUrl },
|
|
488
|
+
const fallbackHref = framePath !== undefined
|
|
489
|
+
? workspaceAppDirectHref({ path: app.path ?? "", url: appUrl }, framePath)
|
|
369
490
|
: appHref;
|
|
370
491
|
setEmbedUrl(fallbackHref);
|
|
371
492
|
setEmbedError(error);
|
|
@@ -378,12 +499,12 @@ export function WorkspaceAppFrame({ app, navigateToTopWindow = navigateToWorkspa
|
|
|
378
499
|
app.path,
|
|
379
500
|
app.url,
|
|
380
501
|
appHref,
|
|
502
|
+
claimBrowserTab,
|
|
381
503
|
createEmbedSession.mutateAsync,
|
|
382
504
|
createWorkspaceSsoEmbedSession.mutateAsync,
|
|
383
505
|
embedInput,
|
|
384
|
-
|
|
506
|
+
framePath,
|
|
385
507
|
hostPageDirectUrl,
|
|
386
|
-
initialPath,
|
|
387
508
|
embedAttempt,
|
|
388
509
|
openInTopWindow,
|
|
389
510
|
navigateToTopWindow,
|
|
@@ -391,18 +512,106 @@ export function WorkspaceAppFrame({ app, navigateToTopWindow = navigateToWorkspa
|
|
|
391
512
|
topWindowNavigationFailed,
|
|
392
513
|
useWorkspaceSso,
|
|
393
514
|
]);
|
|
515
|
+
const reloadFrame = useCallback(() => {
|
|
516
|
+
pendingNavigation.current?.controller.abort();
|
|
517
|
+
pendingNavigation.current = null;
|
|
518
|
+
setLoadedDocument(null);
|
|
519
|
+
setLaunchPath(requestedPath);
|
|
520
|
+
setCompletedNavigation({ requestedPath, accepted: true });
|
|
521
|
+
setEmbedAttempt((attempt) => attempt + 1);
|
|
522
|
+
}, [requestedPath]);
|
|
523
|
+
useEffect(() => () => {
|
|
524
|
+
pendingNavigation.current?.controller.abort();
|
|
525
|
+
pendingNavigation.current = null;
|
|
526
|
+
}, [embedUrl]);
|
|
527
|
+
const finishNavigation = useEffectEvent((route, accepted) => {
|
|
528
|
+
if (!accepted && route === requestedPath) {
|
|
529
|
+
reloadFrame();
|
|
530
|
+
return;
|
|
531
|
+
}
|
|
532
|
+
setCompletedNavigation({ requestedPath: route, accepted });
|
|
533
|
+
});
|
|
534
|
+
useEffect(() => {
|
|
535
|
+
const frame = embedFrameRef.current;
|
|
536
|
+
const target = frame?.contentWindow;
|
|
537
|
+
if (openInTopWindow ||
|
|
538
|
+
!embedUrl ||
|
|
539
|
+
loadedDocument?.url !== embedUrl ||
|
|
540
|
+
!target ||
|
|
541
|
+
requestedPathAccepted ||
|
|
542
|
+
pendingNavigation.current) {
|
|
543
|
+
return;
|
|
544
|
+
}
|
|
545
|
+
const href = requestedPath === undefined
|
|
546
|
+
? appHref
|
|
547
|
+
: workspaceAppDirectHref({ path: app.path ?? null, url: appUrl }, requestedPath);
|
|
548
|
+
if (!href) {
|
|
549
|
+
finishNavigation(requestedPath, false);
|
|
550
|
+
return;
|
|
551
|
+
}
|
|
552
|
+
const url = new URL(href, window.location.href);
|
|
553
|
+
const origin = new URL(embedUrl, window.location.href).origin;
|
|
554
|
+
if (url.origin !== origin) {
|
|
555
|
+
finishNavigation(requestedPath, false);
|
|
556
|
+
return;
|
|
557
|
+
}
|
|
558
|
+
const path = workspaceAppFramePath(url);
|
|
559
|
+
if (observedPath.current === path) {
|
|
560
|
+
finishNavigation(requestedPath, true);
|
|
561
|
+
return;
|
|
562
|
+
}
|
|
563
|
+
if (hostPageDirectUrl &&
|
|
564
|
+
navigateSameOriginWorkspaceApp(target, app.path, url)) {
|
|
565
|
+
finishNavigation(requestedPath, true);
|
|
566
|
+
return;
|
|
567
|
+
}
|
|
568
|
+
const controller = new AbortController();
|
|
569
|
+
const navigation = { controller, path, requestedPath };
|
|
570
|
+
pendingNavigation.current = navigation;
|
|
571
|
+
void requestWorkspaceAppFrameView(target, origin, { operation: "navigate", path }, controller.signal).then((receipt) => {
|
|
572
|
+
if (pendingNavigation.current !== navigation)
|
|
573
|
+
return;
|
|
574
|
+
pendingNavigation.current = null;
|
|
575
|
+
if (frame !== embedFrameRef.current)
|
|
576
|
+
return;
|
|
577
|
+
const accepted = receipt?.path === navigation.path;
|
|
578
|
+
if (!accepted || observedPath.current !== navigation.path) {
|
|
579
|
+
observedPath.current = null;
|
|
580
|
+
}
|
|
581
|
+
finishNavigation(navigation.requestedPath, accepted);
|
|
582
|
+
});
|
|
583
|
+
}, [
|
|
584
|
+
app.path,
|
|
585
|
+
appHref,
|
|
586
|
+
appUrl,
|
|
587
|
+
completedNavigation,
|
|
588
|
+
embedUrl,
|
|
589
|
+
hostPageDirectUrl,
|
|
590
|
+
loadedDocument,
|
|
591
|
+
requestedPathAccepted,
|
|
592
|
+
openInTopWindow,
|
|
593
|
+
requestedPath,
|
|
594
|
+
]);
|
|
595
|
+
const relayChildRoute = useEffectEvent((childPath, route) => {
|
|
596
|
+
const pending = pendingNavigation.current;
|
|
597
|
+
if (pending
|
|
598
|
+
? pending.requestedPath === requestedPath && pending.path === childPath
|
|
599
|
+
: requestedPathAccepted) {
|
|
600
|
+
onChildRouteChange?.(route);
|
|
601
|
+
}
|
|
602
|
+
});
|
|
394
603
|
useEffect(() => {
|
|
395
604
|
const handleEmbedSessionExpired = (event) => {
|
|
396
605
|
if (!isEmbedSessionExpiredMessage(event, embedFrameRef.current, embedUrl)) {
|
|
397
606
|
return;
|
|
398
607
|
}
|
|
399
|
-
|
|
608
|
+
reloadFrame();
|
|
400
609
|
};
|
|
401
610
|
window.addEventListener("message", handleEmbedSessionExpired);
|
|
402
611
|
return () => window.removeEventListener("message", handleEmbedSessionExpired);
|
|
403
|
-
}, [embedUrl]);
|
|
612
|
+
}, [embedUrl, reloadFrame]);
|
|
404
613
|
useEffect(() => {
|
|
405
|
-
if (!
|
|
614
|
+
if (!embedUrl)
|
|
406
615
|
return;
|
|
407
616
|
const frame = embedFrameRef.current;
|
|
408
617
|
if (!frame)
|
|
@@ -421,16 +630,81 @@ export function WorkspaceAppFrame({ app, navigateToTopWindow = navigateToWorkspa
|
|
|
421
630
|
}
|
|
422
631
|
const message = event.data;
|
|
423
632
|
if (message?.type !== AGENT_NATIVE_WORKSPACE_APP_ROUTE_MESSAGE_TYPE ||
|
|
424
|
-
typeof message.path !== "string"
|
|
633
|
+
typeof message.path !== "string" ||
|
|
634
|
+
!message.path.startsWith("/") ||
|
|
635
|
+
message.path.startsWith("//") ||
|
|
636
|
+
/[\u0000-\u001f\u007f]/.test(message.path)) {
|
|
425
637
|
return;
|
|
426
638
|
}
|
|
427
|
-
const
|
|
428
|
-
if (
|
|
429
|
-
|
|
639
|
+
const childUrl = new URL(message.path, expectedOrigin);
|
|
640
|
+
if (childUrl.origin !== expectedOrigin)
|
|
641
|
+
return;
|
|
642
|
+
const childPath = workspaceAppFramePath(childUrl);
|
|
643
|
+
const route = workspaceAppRouteForChildPath({ id: app.id, path: app.path ?? "", url: appUrl }, childPath);
|
|
644
|
+
if (!route)
|
|
645
|
+
return;
|
|
646
|
+
observedPath.current = childPath;
|
|
647
|
+
relayChildRoute(childPath, route);
|
|
430
648
|
};
|
|
431
649
|
window.addEventListener("message", handleWorkspaceAppRoute);
|
|
432
650
|
return () => window.removeEventListener("message", handleWorkspaceAppRoute);
|
|
433
|
-
}, [app.id, app.path, appUrl, embedUrl
|
|
651
|
+
}, [app.id, app.path, appUrl, embedUrl]);
|
|
652
|
+
useEffect(() => {
|
|
653
|
+
if (!onViewReaderChange || !embedUrl || loadedDocument?.url !== embedUrl) {
|
|
654
|
+
return;
|
|
655
|
+
}
|
|
656
|
+
const frame = embedFrameRef.current;
|
|
657
|
+
const target = frame?.contentWindow;
|
|
658
|
+
const mountHref = workspaceAppDirectHref({ path: app.path ?? null, url: appUrl }, "/");
|
|
659
|
+
if (!target || !mountHref)
|
|
660
|
+
return;
|
|
661
|
+
const origin = new URL(embedUrl, window.location.href).origin;
|
|
662
|
+
const mount = new URL(mountHref, window.location.href);
|
|
663
|
+
if (mount.origin !== origin)
|
|
664
|
+
return;
|
|
665
|
+
let current = true;
|
|
666
|
+
const canRead = (signal) => current &&
|
|
667
|
+
!signal.aborted &&
|
|
668
|
+
frame === embedFrameRef.current &&
|
|
669
|
+
!pendingNavigation.current;
|
|
670
|
+
const unregister = onViewReaderChange(async (signal) => {
|
|
671
|
+
if (!canRead(signal))
|
|
672
|
+
return null;
|
|
673
|
+
const read = origin === window.location.origin
|
|
674
|
+
? readSameOriginWorkspaceAppView(target, mount)
|
|
675
|
+
: await requestWorkspaceAppFrameView(target, origin, { operation: "read" }, signal);
|
|
676
|
+
if (!read || !canRead(signal))
|
|
677
|
+
return null;
|
|
678
|
+
if (/[\u0000-\u001f\u007f]/.test(read.path))
|
|
679
|
+
return null;
|
|
680
|
+
const renderedUrl = new URL(read.path, origin);
|
|
681
|
+
const path = workspaceAppFramePathAtMount(renderedUrl, mount);
|
|
682
|
+
const claim = childBrowserTabClaim.current;
|
|
683
|
+
if (!path ||
|
|
684
|
+
path.length > 2_000 ||
|
|
685
|
+
(observedPath.current && observedPath.current !== path)) {
|
|
686
|
+
return null;
|
|
687
|
+
}
|
|
688
|
+
return {
|
|
689
|
+
path,
|
|
690
|
+
...(read.title === undefined
|
|
691
|
+
? {}
|
|
692
|
+
: { title: read.title.slice(0, 256) }),
|
|
693
|
+
...(read.selectedText === undefined
|
|
694
|
+
? {}
|
|
695
|
+
: { selectedText: read.selectedText.slice(0, 4_000) }),
|
|
696
|
+
...(claim?.startUrl === embedUrl &&
|
|
697
|
+
(!("pendingTabClaim" in read) || read.pendingTabClaim === false) &&
|
|
698
|
+
!renderedUrl.searchParams.has(DISPATCH_CHILD_BROWSER_TAB_PARAM)
|
|
699
|
+
? { childBrowserTabId: claim.id, origin }
|
|
700
|
+
: {}),
|
|
701
|
+
};
|
|
702
|
+
});
|
|
703
|
+
return () => {
|
|
704
|
+
current = false;
|
|
705
|
+
unregister();
|
|
706
|
+
};
|
|
707
|
+
}, [app.path, appUrl, embedUrl, loadedDocument, onViewReaderChange]);
|
|
434
708
|
useEffect(() => {
|
|
435
709
|
if (!embedUrl)
|
|
436
710
|
return;
|
|
@@ -510,12 +784,12 @@ export function WorkspaceAppFrame({ app, navigateToTopWindow = navigateToWorkspa
|
|
|
510
784
|
? "error"
|
|
511
785
|
: embedInput
|
|
512
786
|
? "loading"
|
|
513
|
-
: "unresolved", embedUrl: embedUrl, errorMessage: embedError?.message, onRetry: embedInput ?
|
|
787
|
+
: "unresolved", embedUrl: embedUrl, errorMessage: embedError?.message, onRetry: embedInput ? reloadFrame : undefined, renderEmbed: ({ url, title }) => (_jsx("iframe", { "data-dispatch-workspace-app-frame": true, src: url, title: title ?? app.name, ref: embedFrameRef, onLoad: handleFrameLoad, referrerPolicy: "no-referrer", allow: "clipboard-read; clipboard-write; fullscreen", className: "h-full w-full border-0 bg-background" }, embedAttempt)), copy: copy }));
|
|
514
788
|
if (!chatSidebar)
|
|
515
789
|
return appPane;
|
|
516
790
|
return (_jsx(WorkspaceAppChatRail, { appId: app.id, appName: app.name, copy: copy, children: appPane }));
|
|
517
791
|
}
|
|
518
|
-
export function WorkspaceAppHost({ appId, navigateToTopWindow = navigateToWorkspaceApp, initialPath, onChildRouteChange, }) {
|
|
792
|
+
export function WorkspaceAppHost({ appId, navigateToTopWindow = navigateToWorkspaceApp, initialPath, onChildRouteChange, onViewReaderChange, claimBrowserTab, }) {
|
|
519
793
|
const t = useT();
|
|
520
794
|
const workspaceAppsQuery = useActionQuery("list-workspace-apps", { includeAgentCards: false, includeArchived: true });
|
|
521
795
|
const apps = useMemo(() => (workspaceAppsQuery.data ?? []).filter((item) => !item.archived), [workspaceAppsQuery.data]);
|
|
@@ -541,37 +815,44 @@ export function WorkspaceAppHost({ appId, navigateToTopWindow = navigateToWorksp
|
|
|
541
815
|
defaultValue: "Open in Builder",
|
|
542
816
|
}) }) })) : null] })] }) }));
|
|
543
817
|
}
|
|
544
|
-
return (_jsx("div", { "data-dispatch-workspace-app-host": true, className: "flex h-full min-h-0 flex-col bg-background", children: _jsx("div", { className: "min-h-0 flex-1 bg-muted/20", children: _jsx(WorkspaceAppFrame, { app: app, navigateToTopWindow: navigateToTopWindow, initialPath: initialPath, onChildRouteChange: onChildRouteChange }) }) }));
|
|
818
|
+
return (_jsx("div", { "data-dispatch-workspace-app-host": true, className: "flex h-full min-h-0 flex-col bg-background", children: _jsx("div", { className: "min-h-0 flex-1 bg-muted/20", children: _jsx(WorkspaceAppFrame, { app: app, navigateToTopWindow: navigateToTopWindow, initialPath: initialPath, onChildRouteChange: onChildRouteChange, onViewReaderChange: onViewReaderChange, claimBrowserTab: claimBrowserTab }, app.id) }) }));
|
|
545
819
|
}
|
|
546
820
|
const MAX_KEEP_ALIVE_APPS = 3;
|
|
547
|
-
export function
|
|
548
|
-
const [
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
821
|
+
export function useWarmWorkspaceAppIds(scope, activeQualifiedAppId, availableQualifiedAppIds) {
|
|
822
|
+
const [pool, setPool] = useState(() => ({ scope, ids: [] }));
|
|
823
|
+
const retained = pool.scope === scope ? pool.ids : [];
|
|
824
|
+
const available = availableQualifiedAppIds
|
|
825
|
+
? retained.filter((id) => availableQualifiedAppIds.includes(id))
|
|
826
|
+
: retained;
|
|
827
|
+
const next = activeQualifiedAppId
|
|
828
|
+
? [
|
|
829
|
+
activeQualifiedAppId,
|
|
830
|
+
...available.filter((id) => id !== activeQualifiedAppId),
|
|
831
|
+
].slice(0, MAX_KEEP_ALIVE_APPS)
|
|
832
|
+
: available;
|
|
833
|
+
if (pool.scope === scope &&
|
|
834
|
+
next.length === pool.ids.length &&
|
|
835
|
+
next.every((id, index) => id === pool.ids[index])) {
|
|
836
|
+
return pool.ids;
|
|
837
|
+
}
|
|
838
|
+
setPool({ scope, ids: next });
|
|
839
|
+
return next;
|
|
840
|
+
}
|
|
841
|
+
export function WorkspaceAppKeepAlive({ activeAppId, initialPath, onChildRouteChange, onViewReaderChange, claimBrowserTab, }) {
|
|
842
|
+
const warmAppIds = useWarmWorkspaceAppIds("standalone", activeAppId);
|
|
843
|
+
const renderedAppIds = useMemo(() => [...warmAppIds].sort(), [warmAppIds]);
|
|
844
|
+
const [pathByAppId, setPathByAppId] = useState({});
|
|
555
845
|
useEffect(() => {
|
|
556
846
|
if (!activeAppId)
|
|
557
847
|
return;
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
setPathByAppId((current) => current[activeAppId] === initialPath
|
|
564
|
-
? current
|
|
565
|
-
: { ...current, [activeAppId]: initialPath });
|
|
566
|
-
}, [activeAppId, initialPath]);
|
|
567
|
-
const renderedAppIds = activeAppId && !visitedAppIds.includes(activeAppId)
|
|
568
|
-
? [activeAppId, ...visitedAppIds]
|
|
569
|
-
: visitedAppIds;
|
|
848
|
+
setPathByAppId((current) => Object.fromEntries(warmAppIds.map((id) => [
|
|
849
|
+
id,
|
|
850
|
+
id === activeAppId ? initialPath : current[id],
|
|
851
|
+
])));
|
|
852
|
+
}, [activeAppId, initialPath, warmAppIds]);
|
|
570
853
|
return (_jsx("div", { "data-dispatch-workspace-app-cache": true, className: activeAppId ? "absolute inset-0 overflow-hidden" : "hidden", children: renderedAppIds.map((appId) => {
|
|
571
854
|
const active = appId === activeAppId;
|
|
572
|
-
return (_jsx("div", { "data-dispatch-workspace-app-cache-entry": appId, "aria-hidden": !active, className: active ? "h-full min-h-0" : "hidden", children: _jsx(WorkspaceAppHost, { appId: appId, ...(
|
|
573
|
-
? { initialPath: pathByAppId[appId] }
|
|
574
|
-
: {}), ...(active && onChildRouteChange ? { onChildRouteChange } : {}) }) }, appId));
|
|
855
|
+
return (_jsx("div", { "data-dispatch-workspace-app-cache-entry": appId, "aria-hidden": !active, className: active ? "h-full min-h-0" : "hidden", children: _jsx(WorkspaceAppHost, { appId: appId, initialPath: active ? initialPath : pathByAppId[appId], ...(active && onChildRouteChange ? { onChildRouteChange } : {}), ...(active && onViewReaderChange ? { onViewReaderChange } : {}), ...(active && claimBrowserTab ? { claimBrowserTab } : {}) }) }, appId));
|
|
575
856
|
}) }));
|
|
576
857
|
}
|
|
577
858
|
//# sourceMappingURL=workspace-app-host.js.map
|