@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,7 +1,8 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { CHAT_FIRST_MODE_CHANGED_EVENT, chatFirstSurfaceTabId, closeChatFirstSessionWatch, emitChatFirstSessionWatch, getChatFirstSurfaceTabsStore, navigateWithAgentChatViewTransition, readChatFirstMode, resolveChatFirstBrowserTarget,
|
|
2
|
+
import { CHAT_FIRST_MODE_CHANGED_EVENT, chatFirstSurfaceTabId, closeChatFirstSessionWatch, emitChatFirstSessionWatch, getChatFirstSurfaceTabsStore, navigateWithAgentChatViewTransition, readChatFirstMode, resolveChatFirstBrowserTarget, subscribeChatFirstOpenBrowser, subscribeChatFirstOpenApp, subscribeChatFirstOpenAppStart, useChatFirstSessionWatch, useChatFirstSurfacePanel, useChatFirstSurfaceResize, useChatFirstSurfaceTabs, useAgentChatHomeHandoff, useAgentChatHomeHandoffLinks, useChatThreads, subscribeAgentChatComposerSubmit, } from "@agent-native/core/client/agent-chat";
|
|
3
3
|
import { appBasePath, appPath } from "@agent-native/core/client/api-path";
|
|
4
4
|
import { readClientAppState, writeClientAppState, } from "@agent-native/core/client/application-state";
|
|
5
|
+
import { getBrowserTabId } from "@agent-native/core/client/browser-tab-id";
|
|
5
6
|
import { useFeatureFlagState, } from "@agent-native/core/client/feature-flags";
|
|
6
7
|
import { callAction, useActionQuery } from "@agent-native/core/client/hooks";
|
|
7
8
|
import { useT } from "@agent-native/core/client/i18n";
|
|
@@ -22,20 +23,20 @@ import { Link, useLocation, useNavigate } from "react-router";
|
|
|
22
23
|
import { toast } from "sonner";
|
|
23
24
|
import { useIsMobile } from "../../hooks/use-mobile.js";
|
|
24
25
|
import { chatFirstPaneSignature, planChatFirstAppRoute, } from "../../lib/chat-first-app-route.js";
|
|
25
|
-
import { delegatedAppFromToolStart, visibleChatFirstSurfaceTabId, } from "../../lib/chat-first-pane.js";
|
|
26
|
+
import { createTurnViewportLock, delegatedAppFromToolStart, resolveDispatchChatFirstAppTarget, visibleChatFirstSurfaceTabId, } from "../../lib/chat-first-pane.js";
|
|
26
27
|
import { getDispatchRunThreadContext } from "../../lib/dispatch-run-thread.js";
|
|
27
|
-
import { filterBuiltInApps, } from "../../lib/other-apps.js";
|
|
28
|
+
import { chatFirstExternalApps, filterBuiltInApps, } from "../../lib/other-apps.js";
|
|
28
29
|
import { cn } from "../../lib/utils.js";
|
|
29
30
|
import { tierWorkspaceApps, useWorkspaceAppLayout, appListsStatus, } from "../../lib/workspace-app-layout.js";
|
|
30
|
-
import { isDispatchWorkspaceAppId, isPathMountedWorkspaceApp, isWorkspaceAppVisibleInDefaultLaunchers, isWorkspaceSsoApp, mergeChatFirstWorkspaceApps, navigateToWorkspaceApp, shouldOpenWorkspaceAppInTopWindow, workspaceAppIdFromRoute, workspaceAppInitialPathFromPathname, workspaceAppDirectHref, workspaceAppDirectLaunchHref, workspaceAppRoute, workspaceAppTargetPath, } from "../../lib/workspace-apps.js";
|
|
31
|
-
import { CHAT_FIRST_PANE_STATE_KEY } from "../../shared/chat-first-pane.js";
|
|
31
|
+
import { isDispatchWorkspaceAppId, isPathMountedWorkspaceApp, isWorkspaceAppVisibleInDefaultLaunchers, isWorkspaceSsoApp, mergeChatFirstWorkspaceApps, navigateToWorkspaceApp, shouldOpenWorkspaceAppInTopWindow, workspaceAppIdFromRoute, workspaceAppInitialPathFromPathname, workspaceAppDirectHref, workspaceAppDirectLaunchHref, workspaceAppHref, workspaceAppRoute, workspaceAppTargetPath, } from "../../lib/workspace-apps.js";
|
|
32
|
+
import { CHAT_FIRST_PANE_BINDING_MAX_AGE_MS, CHAT_FIRST_PANE_CONTEXT_STATE_KEY, CHAT_FIRST_PANE_STATE_KEY, parsePersistedChatFirstPane, } from "../../shared/chat-first-pane.js";
|
|
32
33
|
import { AppIcon } from "../app-icon.js";
|
|
33
34
|
import { CreateAppPopover } from "../create-app-popover.js";
|
|
34
35
|
import { AgentChatSurface, ChatFirstAgentsPane, ChatFirstAppPane, ChatFirstAppsRail, ChatFirstBrowserPane, ChatFirstChatHistory, ChatFirstPrimaryNavigation, ChatFirstSessionWatchPane, ChatFirstSurfaceContent, ChatFirstSurfacePanel, ChatFirstSurfacePanelToggle, ChatFirstSurfaceTabs, } from "../deferred-chat-components.js";
|
|
35
36
|
import { Button } from "../ui/button.js";
|
|
36
37
|
import { Sheet, SheetContent, SheetDescription, SheetTitle } from "../ui/sheet.js";
|
|
37
38
|
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, } from "../ui/tooltip.js";
|
|
38
|
-
import { usePrefetchChatFirstEmbedSession, WorkspaceAppChatRail, WorkspaceAppFrame, WorkspaceAppKeepAlive, } from "../workspace-app-host.js";
|
|
39
|
+
import { usePrefetchChatFirstEmbedSession, useWarmWorkspaceAppIds, WorkspaceAppChatRail, WorkspaceAppFrame, WorkspaceAppKeepAlive, useWorkspaceAppChildBrowserTab, } from "../workspace-app-host.js";
|
|
39
40
|
import { AppNotice, WorkspaceAppLayoutNotice, } from "../workspace-app-layout-notice.js";
|
|
40
41
|
import { Header } from "./Header.js";
|
|
41
42
|
import { HeaderActionsProvider, useHeaderActions, useHeaderTitle, } from "./HeaderActions.js";
|
|
@@ -90,6 +91,7 @@ const CHROMELESS_PATHS = ["/approval", "/browser-chat", "/browser-connect"];
|
|
|
90
91
|
// With nothing pinned, the sidebar suggests this many apps; All apps has the rest.
|
|
91
92
|
const CHAT_FIRST_RAIL_SUGGESTED_APPS = 3;
|
|
92
93
|
const CHAT_FIRST_ROUTE_TIMEOUT_MS = 6_000;
|
|
94
|
+
const CHAT_FIRST_PANE_READ_TIMEOUT_MS = 450;
|
|
93
95
|
const NO_CHAT_FIRST_APPS = [];
|
|
94
96
|
const SIDEBAR_COLLAPSE_KEY = "dispatch.sidebar.collapsed";
|
|
95
97
|
const CHAT_HISTORY_SOURCE_KEY = "dispatch.chat-history.source";
|
|
@@ -210,6 +212,7 @@ const DISPATCH_CHAT_FIRST_COPY_KEYS = {
|
|
|
210
212
|
workspaceApps: "chatFirstWorkspaceApps",
|
|
211
213
|
createWorkspaceApp: "chatFirstCreateWorkspaceApp",
|
|
212
214
|
openApp: "chatFirstOpenApp",
|
|
215
|
+
openInNewTab: "chatFirstOpenInNewTab",
|
|
213
216
|
appsLoadError: "chatFirstAppsLoadError",
|
|
214
217
|
noWorkspaceApps: "chatFirstNoWorkspaceApps",
|
|
215
218
|
createApp: "chatFirstCreateApp",
|
|
@@ -302,21 +305,6 @@ function createDispatchChatFirstCopy(t) {
|
|
|
302
305
|
function chatThreadPath(threadId) {
|
|
303
306
|
return threadId ? `/chat/${encodeURIComponent(threadId)}` : "/chat";
|
|
304
307
|
}
|
|
305
|
-
function persistedChatFirstPane(value) {
|
|
306
|
-
if (!value || typeof value !== "object")
|
|
307
|
-
return null;
|
|
308
|
-
const record = value;
|
|
309
|
-
if (typeof record.appId !== "string" || !record.appId.trim())
|
|
310
|
-
return null;
|
|
311
|
-
return {
|
|
312
|
-
appId: record.appId,
|
|
313
|
-
...(record.placement === "main" || record.placement === "side"
|
|
314
|
-
? { placement: record.placement }
|
|
315
|
-
: {}),
|
|
316
|
-
...(typeof record.path === "string" ? { path: record.path } : {}),
|
|
317
|
-
...(typeof record.view === "string" ? { view: record.view } : {}),
|
|
318
|
-
};
|
|
319
|
-
}
|
|
320
308
|
function threadIdFromPath(pathname) {
|
|
321
309
|
const match = pathname.match(/^\/chat\/([^/]+)/);
|
|
322
310
|
if (!match)
|
|
@@ -615,7 +603,7 @@ export function NavContent({ onNavigate, extensions, brandName = DISPATCH_SIDEBA
|
|
|
615
603
|
},
|
|
616
604
|
}, appsRail: chatFirstAppsRail }) })) : null, !chatFirstMode ? (_jsx("div", { className: "min-h-0 flex-1 overflow-y-auto", children: _jsx("nav", { className: cn("py-2", collapsed ? "px-1.5" : "px-2"), children: _jsx("ul", { className: cn(collapsed ? "flex flex-col items-center gap-1" : "space-y-0.5"), children: primaryNavItems.map(renderNavItem) }) }) })) : null, _jsxs("div", { className: "mt-auto shrink-0", "data-dispatch-sidebar-footer": chatFirstMode ? "chat-first" : "standard", children: [bottomNavigation, _jsx(AppSidebarFooter, { collapsed: collapsed, collapsible: false, feedback: feedbackButton, orgSwitcher: _jsx(OrgSwitcher, { compact: collapsed, reserveSpace: true, currentAppId: "dispatch", className: cn("!bg-transparent !text-primary hover:!bg-accent/60 hover:!text-primary", collapsed ? "!size-9 !p-0 [&>svg]:!size-4" : "min-w-0 flex-1") }), footerExtras: collapseButton })] })] }));
|
|
617
605
|
}
|
|
618
|
-
export function renderChatFirstAppSurfaceTab({ registration, embedPath, loading, isMobileSurface, copy, placement = "main", }) {
|
|
606
|
+
export function renderChatFirstAppSurfaceTab({ registration, embedPath, loading, isMobileSurface, copy, placement = "main", onViewReaderChange, onChildRouteChange, }) {
|
|
619
607
|
if (!registration) {
|
|
620
608
|
return (_jsx(ChatFirstAppPane, { app: null, status: loading ? "loading" : "unresolved", renderEmbed: () => null, copy: copy }));
|
|
621
609
|
}
|
|
@@ -631,7 +619,7 @@ export function renderChatFirstAppSurfaceTab({ registration, embedPath, loading,
|
|
|
631
619
|
path: registration.path,
|
|
632
620
|
homePath: registration.homePath,
|
|
633
621
|
url: registration.url,
|
|
634
|
-
}, embedPath: embedPath, chatSidebar: !isMobileSurface && placement === "main", copy: copy }));
|
|
622
|
+
}, embedPath: embedPath, claimBrowserTab: true, onViewReaderChange: onViewReaderChange, onChildRouteChange: onChildRouteChange, chatSidebar: !isMobileSurface && placement === "main", copy: copy }));
|
|
635
623
|
}
|
|
636
624
|
export function Layout(props) {
|
|
637
625
|
return (_jsx(TooltipProvider, { children: _jsx(DispatchLayout, { ...props }) }));
|
|
@@ -736,16 +724,11 @@ function DispatchLayout({ children, extensions, agentPageHref, notice, brandName
|
|
|
736
724
|
? "list-connected-agents"
|
|
737
725
|
: undefined;
|
|
738
726
|
const chatFirstWorkspaceAppsStatus = appListsStatus(chatFirstAppsQuery, chatFirstConnectedAppsQuery);
|
|
739
|
-
const chatFirstResolvableApps = useMemo(() => mergeChatFirstWorkspaceApps(chatFirstAppsQuery.data, chatFirstEnabledBuiltinAppIds,
|
|
740
|
-
|
|
741
|
-
name: app.name,
|
|
742
|
-
description: app.description,
|
|
743
|
-
url: app.homeUrl?.trim() || app.url,
|
|
744
|
-
source: "builtin",
|
|
745
|
-
hiddenFromLaunchers: app.hiddenFromLaunchers,
|
|
746
|
-
}))).filter((app) => app.status !== "pending" && app.archived !== true), [
|
|
727
|
+
const chatFirstResolvableApps = useMemo(() => mergeChatFirstWorkspaceApps(chatFirstAppsQuery.data, chatFirstEnabledBuiltinAppIds, chatFirstExternalApps(chatFirstConnectedAppsQuery.data ?? [], chatFirstAppsQuery.data ??
|
|
728
|
+
(chatFirstAppsQuery.isError ? "unreadable" : "loading"))).filter((app) => app.status !== "pending" && app.archived !== true), [
|
|
747
729
|
chatFirstAppsQuery.data,
|
|
748
|
-
|
|
730
|
+
chatFirstAppsQuery.isError,
|
|
731
|
+
chatFirstConnectedAppsQuery.data,
|
|
749
732
|
chatFirstEnabledBuiltinAppIds,
|
|
750
733
|
]);
|
|
751
734
|
const chatFirstWorkspaceApps = useMemo(() => chatFirstWorkspaceAppsStatus === "ready"
|
|
@@ -766,6 +749,7 @@ function DispatchLayout({ children, extensions, agentPageHref, notice, brandName
|
|
|
766
749
|
id: app.id,
|
|
767
750
|
name: app.name,
|
|
768
751
|
source: app.source ?? "workspace",
|
|
752
|
+
href: workspaceAppHref(app),
|
|
769
753
|
})), [chatFirstWorkspaceApps]);
|
|
770
754
|
const openChatFirstApp = useCallback((app) => {
|
|
771
755
|
if (isDispatchWorkspaceAppId(app.id))
|
|
@@ -832,13 +816,103 @@ function DispatchLayout({ children, extensions, agentPageHref, notice, brandName
|
|
|
832
816
|
const { setOpen: setChatFirstSurfacePanelOpen } = chatFirstSurfacePanel;
|
|
833
817
|
const chatFirstSurfaceResize = useChatFirstSurfaceResize(chatFirstSurfaceScope);
|
|
834
818
|
const chatFirstPaneHydratedRef = useRef(false);
|
|
819
|
+
const chatFirstSurfaceScopeRef = useRef(chatFirstSurfaceScope);
|
|
820
|
+
chatFirstSurfaceScopeRef.current = chatFirstSurfaceScope;
|
|
835
821
|
const pendingChatFirstOpenAppRef = useRef(null);
|
|
836
822
|
const provisionalChatFirstTabRef = useRef(null);
|
|
823
|
+
const turnViewportLockRef = useRef(createTurnViewportLock());
|
|
824
|
+
const workspaceAppChildTab = useWorkspaceAppChildBrowserTab();
|
|
837
825
|
const previousChatFirstSurfaceScopeRef = useRef(chatFirstSurfaceScope);
|
|
838
826
|
const previousChatFirstSurfaceTabCountRef = useRef(null);
|
|
839
827
|
const activeChatFirstSurfaceTab = useMemo(() => chatFirstSurfaceTabs.tabs.find((tab) => tab.id === chatFirstSurfaceTabs.activeTabId) ?? null, [chatFirstSurfaceTabs]);
|
|
840
828
|
const visibleChatFirstSurfaceTabIdValue = visibleChatFirstSurfaceTabId(chatFirstSurfaceTabs.tabs, chatFirstSurfaceTabs.activeTabId);
|
|
841
829
|
const visibleChatFirstSurfaceTab = useMemo(() => chatFirstSurfaceTabs.tabs.find((tab) => tab.id === visibleChatFirstSurfaceTabIdValue) ?? null, [chatFirstSurfaceTabs.tabs, visibleChatFirstSurfaceTabIdValue]);
|
|
830
|
+
const warmWorkspaceAppIds = useWarmWorkspaceAppIds(chatFirstSurfaceScope, visibleChatFirstSurfaceTab?.kind === "app"
|
|
831
|
+
? (visibleChatFirstSurfaceTab.appId ?? null)
|
|
832
|
+
: null, chatFirstSurfaceTabs.tabs.flatMap((tab) => tab.kind === "app" && tab.appId ? [tab.appId] : []));
|
|
833
|
+
const chatFirstViewReader = useRef(null);
|
|
834
|
+
const visiblePaneTabId = visibleChatFirstSurfaceTabIdValue;
|
|
835
|
+
const visiblePaneAppId = chatFirstMode &&
|
|
836
|
+
isChatRoute &&
|
|
837
|
+
chatFirstSurfacePanel.open &&
|
|
838
|
+
visibleChatFirstSurfaceTab?.kind === "app"
|
|
839
|
+
? visibleChatFirstSurfaceTab.appId
|
|
840
|
+
: undefined;
|
|
841
|
+
const visiblePanePath = visiblePaneAppId
|
|
842
|
+
? visibleChatFirstSurfaceTab?.path
|
|
843
|
+
: undefined;
|
|
844
|
+
const visiblePaneView = visiblePaneAppId
|
|
845
|
+
? visibleChatFirstSurfaceTab?.view
|
|
846
|
+
: undefined;
|
|
847
|
+
const writeActivePaneContext = useCallback((view) => writeClientAppState(`${CHAT_FIRST_PANE_CONTEXT_STATE_KEY}:${getBrowserTabId()}`, visiblePaneAppId
|
|
848
|
+
? {
|
|
849
|
+
appId: visiblePaneAppId,
|
|
850
|
+
path: view?.path ?? visiblePanePath ?? "/",
|
|
851
|
+
...(visiblePaneView ? { view: visiblePaneView } : {}),
|
|
852
|
+
...(view?.origin && view.childBrowserTabId
|
|
853
|
+
? {
|
|
854
|
+
origin: view.origin,
|
|
855
|
+
childBrowserTabId: view.childBrowserTabId,
|
|
856
|
+
observedAt: Date.now(),
|
|
857
|
+
}
|
|
858
|
+
: {}),
|
|
859
|
+
}
|
|
860
|
+
: null, { keepalive: true }).catch(() => { }), [visiblePaneAppId, visiblePanePath, visiblePaneView]);
|
|
861
|
+
useEffect(() => {
|
|
862
|
+
void writeActivePaneContext(null);
|
|
863
|
+
}, [writeActivePaneContext]);
|
|
864
|
+
const refreshActivePaneContext = useCallback(() => {
|
|
865
|
+
const reader = chatFirstViewReader.current;
|
|
866
|
+
if (!reader)
|
|
867
|
+
return;
|
|
868
|
+
void reader
|
|
869
|
+
.read(AbortSignal.timeout(CHAT_FIRST_PANE_READ_TIMEOUT_MS))
|
|
870
|
+
.then((view) => {
|
|
871
|
+
if (view && chatFirstViewReader.current === reader) {
|
|
872
|
+
return writeActivePaneContext(view);
|
|
873
|
+
}
|
|
874
|
+
})
|
|
875
|
+
.catch(() => { });
|
|
876
|
+
}, [writeActivePaneContext]);
|
|
877
|
+
useEffect(() => {
|
|
878
|
+
if (!visiblePaneAppId)
|
|
879
|
+
return;
|
|
880
|
+
const clearPagePane = () => {
|
|
881
|
+
void writeClientAppState(`${CHAT_FIRST_PANE_CONTEXT_STATE_KEY}:${getBrowserTabId()}`, null, { keepalive: true }).catch(() => { });
|
|
882
|
+
};
|
|
883
|
+
const refreshVisiblePane = () => {
|
|
884
|
+
if (document.visibilityState === "visible")
|
|
885
|
+
refreshActivePaneContext();
|
|
886
|
+
};
|
|
887
|
+
const refreshTimer = window.setInterval(refreshVisiblePane, CHAT_FIRST_PANE_BINDING_MAX_AGE_MS / 2);
|
|
888
|
+
document.addEventListener("visibilitychange", refreshVisiblePane);
|
|
889
|
+
window.addEventListener("focus", refreshActivePaneContext);
|
|
890
|
+
window.addEventListener("pageshow", refreshActivePaneContext);
|
|
891
|
+
window.addEventListener("pagehide", clearPagePane);
|
|
892
|
+
return () => {
|
|
893
|
+
window.clearInterval(refreshTimer);
|
|
894
|
+
document.removeEventListener("visibilitychange", refreshVisiblePane);
|
|
895
|
+
window.removeEventListener("focus", refreshActivePaneContext);
|
|
896
|
+
window.removeEventListener("pageshow", refreshActivePaneContext);
|
|
897
|
+
window.removeEventListener("pagehide", clearPagePane);
|
|
898
|
+
};
|
|
899
|
+
}, [refreshActivePaneContext, visiblePaneAppId]);
|
|
900
|
+
const registerChatFirstViewReader = useCallback((read) => {
|
|
901
|
+
if (!visiblePaneTabId)
|
|
902
|
+
return () => { };
|
|
903
|
+
const reader = {
|
|
904
|
+
tabId: visiblePaneTabId,
|
|
905
|
+
scope: chatFirstSurfaceScope,
|
|
906
|
+
read,
|
|
907
|
+
};
|
|
908
|
+
chatFirstViewReader.current = reader;
|
|
909
|
+
refreshActivePaneContext();
|
|
910
|
+
return () => {
|
|
911
|
+
if (chatFirstViewReader.current === reader) {
|
|
912
|
+
chatFirstViewReader.current = null;
|
|
913
|
+
}
|
|
914
|
+
};
|
|
915
|
+
}, [chatFirstSurfaceScope, refreshActivePaneContext, visiblePaneTabId]);
|
|
842
916
|
const chatFirstAppTakesMain = chatFirstMode &&
|
|
843
917
|
isChatRoute &&
|
|
844
918
|
activeChatFirstSurfaceTab?.kind === "app" &&
|
|
@@ -896,19 +970,16 @@ function DispatchLayout({ children, extensions, agentPageHref, notice, brandName
|
|
|
896
970
|
navigateWithAgentChatViewTransition(navigate, dispatchNavLinkTarget("/chat"));
|
|
897
971
|
}
|
|
898
972
|
const app = chatFirstAppRegistrations.find((candidate) => candidate.id === pane.appId);
|
|
899
|
-
|
|
973
|
+
const snapshot = chatFirstSurfaceTabsStore.getSnapshot();
|
|
974
|
+
const existing = snapshot.tabs.find((tab) => tab.kind === "app" && tab.appId === pane.appId);
|
|
975
|
+
const tabId = existing?.id ?? chatFirstSurfaceTabId("app", pane.appId);
|
|
900
976
|
const earlier = provisionalChatFirstTabRef.current;
|
|
901
977
|
provisionalChatFirstTabRef.current = null;
|
|
902
978
|
if (earlier &&
|
|
903
979
|
earlier.scope === chatFirstSurfaceScope &&
|
|
904
980
|
earlier.tabId !== tabId &&
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
.tabs.some((tab) => tab.id === earlier.tabId)) {
|
|
908
|
-
if (!provisional && earlier.appId === pane.appId)
|
|
909
|
-
tabId = earlier.tabId;
|
|
910
|
-
else
|
|
911
|
-
chatFirstSurfaceTabsStore.close(earlier.tabId);
|
|
981
|
+
snapshot.tabs.some((tab) => tab.id === earlier.tabId)) {
|
|
982
|
+
chatFirstSurfaceTabsStore.close(earlier.tabId);
|
|
912
983
|
}
|
|
913
984
|
if (provisional) {
|
|
914
985
|
provisionalChatFirstTabRef.current = {
|
|
@@ -988,7 +1059,7 @@ function DispatchLayout({ children, extensions, agentPageHref, notice, brandName
|
|
|
988
1059
|
});
|
|
989
1060
|
}, [chatFirstSurfaceTabsStore, persistChatFirstPane]);
|
|
990
1061
|
const resolveChatFirstOpenApp = useCallback((detail) => {
|
|
991
|
-
const resolution =
|
|
1062
|
+
const resolution = resolveDispatchChatFirstAppTarget(detail, chatFirstAppRegistrations, {
|
|
992
1063
|
currentOrigin: typeof window === "undefined" ? undefined : window.location.origin,
|
|
993
1064
|
});
|
|
994
1065
|
if (resolution.status === "unresolved") {
|
|
@@ -1011,6 +1082,7 @@ function DispatchLayout({ children, extensions, agentPageHref, notice, brandName
|
|
|
1011
1082
|
}
|
|
1012
1083
|
pendingChatFirstOpenAppRef.current = null;
|
|
1013
1084
|
if (isDispatchWorkspaceAppId(resolution.target.appId)) {
|
|
1085
|
+
turnViewportLockRef.current.clear();
|
|
1014
1086
|
closeChatFirstSessionWatch();
|
|
1015
1087
|
chatFirstSurfaceTabsStore.closeAll();
|
|
1016
1088
|
setChatFirstSurfacePanelOpen(false);
|
|
@@ -1020,7 +1092,15 @@ function DispatchLayout({ children, extensions, agentPageHref, notice, brandName
|
|
|
1020
1092
|
}
|
|
1021
1093
|
return;
|
|
1022
1094
|
}
|
|
1023
|
-
|
|
1095
|
+
const lockDecision = turnViewportLockRef.current.evaluate({
|
|
1096
|
+
appId: resolution.target.appId,
|
|
1097
|
+
focus: detail.focus,
|
|
1098
|
+
turnKey: detail.turnId,
|
|
1099
|
+
});
|
|
1100
|
+
if (!lockDecision.allowed) {
|
|
1101
|
+
return;
|
|
1102
|
+
}
|
|
1103
|
+
openChatFirstPane(resolution.target, "side", detail.optimistic === true);
|
|
1024
1104
|
}, [
|
|
1025
1105
|
chatFirstAppRegistrations,
|
|
1026
1106
|
chatFirstAppsFailed,
|
|
@@ -1065,9 +1145,11 @@ function DispatchLayout({ children, extensions, agentPageHref, notice, brandName
|
|
|
1065
1145
|
return;
|
|
1066
1146
|
}
|
|
1067
1147
|
const unsubscribeApp = subscribeChatFirstOpenApp(resolveChatFirstOpenApp);
|
|
1148
|
+
const unsubscribeAppStart = subscribeChatFirstOpenAppStart(resolveChatFirstOpenApp);
|
|
1068
1149
|
const unsubscribeBrowser = subscribeChatFirstOpenBrowser(resolveChatFirstOpenBrowser);
|
|
1069
1150
|
return () => {
|
|
1070
1151
|
unsubscribeApp();
|
|
1152
|
+
unsubscribeAppStart();
|
|
1071
1153
|
unsubscribeBrowser();
|
|
1072
1154
|
};
|
|
1073
1155
|
}, [
|
|
@@ -1089,17 +1171,34 @@ function DispatchLayout({ children, extensions, agentPageHref, notice, brandName
|
|
|
1089
1171
|
.tabs.some((tab) => tab.kind === "app" && tab.appId === appId);
|
|
1090
1172
|
if (alreadyOpen)
|
|
1091
1173
|
return;
|
|
1092
|
-
const resolution =
|
|
1174
|
+
const resolution = resolveDispatchChatFirstAppTarget({ app: appId }, chatFirstAppRegistrations, typeof window === "undefined"
|
|
1093
1175
|
? {}
|
|
1094
1176
|
: { currentOrigin: window.location.origin });
|
|
1095
1177
|
if (resolution.status !== "ready" ||
|
|
1096
1178
|
isDispatchWorkspaceAppId(resolution.target.appId)) {
|
|
1097
1179
|
return;
|
|
1098
1180
|
}
|
|
1181
|
+
const lockDecision = turnViewportLockRef.current.evaluate({
|
|
1182
|
+
appId: resolution.target.appId,
|
|
1183
|
+
focus: false,
|
|
1184
|
+
});
|
|
1185
|
+
if (!lockDecision.allowed) {
|
|
1186
|
+
return;
|
|
1187
|
+
}
|
|
1099
1188
|
openChatFirstPane(resolution.target);
|
|
1100
1189
|
};
|
|
1190
|
+
const handleTurnStart = (event) => {
|
|
1191
|
+
const detail = event
|
|
1192
|
+
.detail;
|
|
1193
|
+
const turnId = typeof detail?.turnId === "string" ? detail.turnId : undefined;
|
|
1194
|
+
turnViewportLockRef.current.beginTurn(turnId);
|
|
1195
|
+
};
|
|
1101
1196
|
window.addEventListener("agent-native:tool-start", handleToolStart);
|
|
1102
|
-
|
|
1197
|
+
window.addEventListener("agent-native:turn-start", handleTurnStart);
|
|
1198
|
+
return () => {
|
|
1199
|
+
window.removeEventListener("agent-native:tool-start", handleToolStart);
|
|
1200
|
+
window.removeEventListener("agent-native:turn-start", handleTurnStart);
|
|
1201
|
+
};
|
|
1103
1202
|
}, [
|
|
1104
1203
|
chatFirstAppRegistrations,
|
|
1105
1204
|
chatFirstMode,
|
|
@@ -1117,20 +1216,33 @@ function DispatchLayout({ children, extensions, agentPageHref, notice, brandName
|
|
|
1117
1216
|
chatFirstPaneHydratedRef.current = true;
|
|
1118
1217
|
if (chatFirstPane)
|
|
1119
1218
|
return;
|
|
1219
|
+
const unreadable = () => setChatFirstNotice("The last app pane could not be restored from workspace state.");
|
|
1220
|
+
const scope = chatFirstSurfaceScope;
|
|
1120
1221
|
let active = true;
|
|
1222
|
+
let settled = false;
|
|
1121
1223
|
void readClientAppState(CHAT_FIRST_PANE_STATE_KEY)
|
|
1122
1224
|
.then((value) => {
|
|
1225
|
+
settled = true;
|
|
1123
1226
|
if (!active)
|
|
1124
1227
|
return;
|
|
1125
|
-
|
|
1228
|
+
const state = parsePersistedChatFirstPane(value);
|
|
1229
|
+
if (state.status === "restorable") {
|
|
1230
|
+
setPendingChatFirstPaneRestore(state.pane);
|
|
1231
|
+
}
|
|
1232
|
+
else if (state.status === "unreadable") {
|
|
1233
|
+
unreadable();
|
|
1234
|
+
}
|
|
1126
1235
|
})
|
|
1127
1236
|
.catch(() => {
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1237
|
+
settled = true;
|
|
1238
|
+
if (active)
|
|
1239
|
+
unreadable();
|
|
1131
1240
|
});
|
|
1132
1241
|
return () => {
|
|
1133
1242
|
active = false;
|
|
1243
|
+
if (!settled && chatFirstSurfaceScopeRef.current === scope) {
|
|
1244
|
+
chatFirstPaneHydratedRef.current = false;
|
|
1245
|
+
}
|
|
1134
1246
|
};
|
|
1135
1247
|
}, [chatFirstMode, chatFirstPane, chatFirstSurfaceScope, isChatRoute]);
|
|
1136
1248
|
useEffect(() => {
|
|
@@ -1144,7 +1256,7 @@ function DispatchLayout({ children, extensions, agentPageHref, notice, brandName
|
|
|
1144
1256
|
setPendingChatFirstPaneRestore(null);
|
|
1145
1257
|
return;
|
|
1146
1258
|
}
|
|
1147
|
-
const resolution =
|
|
1259
|
+
const resolution = resolveDispatchChatFirstAppTarget({
|
|
1148
1260
|
app: pendingChatFirstPaneRestore.appId,
|
|
1149
1261
|
path: pendingChatFirstPaneRestore.path,
|
|
1150
1262
|
view: pendingChatFirstPaneRestore.view,
|
|
@@ -1183,6 +1295,7 @@ function DispatchLayout({ children, extensions, agentPageHref, notice, brandName
|
|
|
1183
1295
|
}
|
|
1184
1296
|
const chatGainedItsId = previousChatFirstSurfaceScopeRef.current === "new";
|
|
1185
1297
|
previousChatFirstSurfaceScopeRef.current = chatFirstSurfaceScope;
|
|
1298
|
+
turnViewportLockRef.current.clear();
|
|
1186
1299
|
persistChatFirstPane(null);
|
|
1187
1300
|
setChatFirstNotice(null);
|
|
1188
1301
|
if (!chatGainedItsId)
|
|
@@ -1244,21 +1357,32 @@ function DispatchLayout({ children, extensions, agentPageHref, notice, brandName
|
|
|
1244
1357
|
resolveChatFirstOpenApp,
|
|
1245
1358
|
]);
|
|
1246
1359
|
const prefetchChatFirstEmbedSession = usePrefetchChatFirstEmbedSession();
|
|
1247
|
-
const chatFirstPaneAppId = visibleChatFirstSurfaceTab?.kind === "app"
|
|
1248
|
-
? visibleChatFirstSurfaceTab.appId
|
|
1249
|
-
: activeChatFirstSurfaceTab?.kind === "app"
|
|
1250
|
-
? activeChatFirstSurfaceTab.appId
|
|
1251
|
-
: undefined;
|
|
1252
1360
|
const chatFirstRouteSendRef = useRef({
|
|
1253
1361
|
seq: 0,
|
|
1254
1362
|
id: null,
|
|
1255
1363
|
});
|
|
1256
1364
|
const chatFirstRoutedPaneRef = useRef(null);
|
|
1365
|
+
useEffect(() => {
|
|
1366
|
+
if (!chatFirstMode || !isChatRoute)
|
|
1367
|
+
return;
|
|
1368
|
+
const cancelPendingRoute = (event) => {
|
|
1369
|
+
const detail = event.detail;
|
|
1370
|
+
if (detail?.tool !== "open_app" && detail?.tool !== "open-app")
|
|
1371
|
+
return;
|
|
1372
|
+
const current = chatFirstRouteSendRef.current;
|
|
1373
|
+
chatFirstRouteSendRef.current = { seq: current.seq + 1, id: null };
|
|
1374
|
+
chatFirstRoutedPaneRef.current = null;
|
|
1375
|
+
};
|
|
1376
|
+
window.addEventListener("agent-native:tool-start", cancelPendingRoute);
|
|
1377
|
+
return () => window.removeEventListener("agent-native:tool-start", cancelPendingRoute);
|
|
1378
|
+
}, [chatFirstMode, isChatRoute]);
|
|
1257
1379
|
const chatFirstRouteLatest = {
|
|
1258
1380
|
onChatRoute: chatFirstMode && isChatRoute,
|
|
1259
1381
|
scope: chatFirstSurfaceScope,
|
|
1260
1382
|
tabsStore: chatFirstSurfaceTabsStore,
|
|
1261
|
-
shownAppId:
|
|
1383
|
+
shownAppId: visiblePaneAppId ?? null,
|
|
1384
|
+
visiblePaneTabId,
|
|
1385
|
+
openPath: visiblePanePath,
|
|
1262
1386
|
registrations: chatFirstAppRegistrations,
|
|
1263
1387
|
openPane: openChatFirstPane,
|
|
1264
1388
|
prefetch: prefetchChatFirstEmbedSession,
|
|
@@ -1304,15 +1428,44 @@ function DispatchLayout({ children, extensions, agentPageHref, notice, brandName
|
|
|
1304
1428
|
chatFirstRouteSendRef.current = { seq, id: detail.id };
|
|
1305
1429
|
chatFirstRoutedPaneRef.current = null;
|
|
1306
1430
|
provisionalChatFirstTabRef.current = null;
|
|
1431
|
+
turnViewportLockRef.current.beginTurn(`submit:${seq}`);
|
|
1307
1432
|
if (detail.queued)
|
|
1308
1433
|
return;
|
|
1309
1434
|
const sentPane = chatFirstPaneSignature(sent.tabsStore.getSnapshot());
|
|
1310
1435
|
const started = performance.now();
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1436
|
+
const reader = chatFirstViewReader.current;
|
|
1437
|
+
const route = async () => {
|
|
1438
|
+
const liveView = reader &&
|
|
1439
|
+
reader.tabId === sent.visiblePaneTabId &&
|
|
1440
|
+
reader.scope === sent.scope
|
|
1441
|
+
? await reader
|
|
1442
|
+
.read(AbortSignal.timeout(CHAT_FIRST_PANE_READ_TIMEOUT_MS))
|
|
1443
|
+
// coercion-ok: An unavailable live read leaves only the registered route as context.
|
|
1444
|
+
.catch(() => null)
|
|
1445
|
+
: null;
|
|
1446
|
+
const latest = chatFirstRouteLatestRef.current;
|
|
1447
|
+
const validView = liveView &&
|
|
1448
|
+
chatFirstViewReader.current === reader &&
|
|
1449
|
+
latest.scope === sent.scope &&
|
|
1450
|
+
latest.visiblePaneTabId === sent.visiblePaneTabId
|
|
1451
|
+
? liveView
|
|
1452
|
+
: null;
|
|
1453
|
+
const openPath = validView?.path ?? sent.openPath;
|
|
1454
|
+
if (validView)
|
|
1455
|
+
void writeActivePaneContext(validView);
|
|
1456
|
+
return callAction("route-app-intent", {
|
|
1457
|
+
text: detail.text.slice(0, 4000),
|
|
1458
|
+
...(sent.shownAppId ? { openApp: sent.shownAppId } : {}),
|
|
1459
|
+
...(openPath ? { openPath } : {}),
|
|
1460
|
+
...(validView?.selectedText
|
|
1461
|
+
? { selection: validView.selectedText }
|
|
1462
|
+
: {}),
|
|
1463
|
+
...(detail.previousTurn
|
|
1464
|
+
? { previousTurn: detail.previousTurn }
|
|
1465
|
+
: {}),
|
|
1466
|
+
}, { timeoutMs: CHAT_FIRST_ROUTE_TIMEOUT_MS });
|
|
1467
|
+
};
|
|
1468
|
+
void route()
|
|
1316
1469
|
.then((result) => result, (error) => error?.timedOut === true
|
|
1317
1470
|
? "timeout"
|
|
1318
1471
|
: { status: "failed", reason: "route_call_rejected" })
|
|
@@ -1331,7 +1484,7 @@ function DispatchLayout({ children, extensions, agentPageHref, notice, brandName
|
|
|
1331
1484
|
const objectPath = object?.objectId?.startsWith("/")
|
|
1332
1485
|
? object.objectId
|
|
1333
1486
|
: undefined;
|
|
1334
|
-
const resolution =
|
|
1487
|
+
const resolution = resolveDispatchChatFirstAppTarget({
|
|
1335
1488
|
app,
|
|
1336
1489
|
...(object?.url ? { url: object.url } : {}),
|
|
1337
1490
|
...(!object?.url && objectPath ? { path: objectPath } : {}),
|
|
@@ -1347,13 +1500,15 @@ function DispatchLayout({ children, extensions, agentPageHref, notice, brandName
|
|
|
1347
1500
|
? answer.app
|
|
1348
1501
|
: "unrouted",
|
|
1349
1502
|
outcome: answer === "timeout" ? "timeout" : answer.status,
|
|
1350
|
-
plan
|
|
1503
|
+
plan: plan.kind === "skip"
|
|
1504
|
+
? plan
|
|
1505
|
+
: { kind: plan.kind, target: { appId: plan.target.appId } },
|
|
1351
1506
|
latencyMs: Math.round(performance.now() - started),
|
|
1352
1507
|
...(answer !== "timeout" && answer.latencyMs !== undefined
|
|
1353
1508
|
? { hostedLatencyMs: answer.latencyMs }
|
|
1354
1509
|
: {}),
|
|
1355
1510
|
});
|
|
1356
|
-
if (plan.kind
|
|
1511
|
+
if (plan.kind === "skip")
|
|
1357
1512
|
return;
|
|
1358
1513
|
const pane = plan.target;
|
|
1359
1514
|
const registration = now.registrations.find((candidate) => candidate.id === pane.appId);
|
|
@@ -1366,11 +1521,18 @@ function DispatchLayout({ children, extensions, agentPageHref, notice, brandName
|
|
|
1366
1521
|
url: registration.url ?? null,
|
|
1367
1522
|
}, pane.path ?? registration.path ?? "/");
|
|
1368
1523
|
}
|
|
1524
|
+
if (plan.kind !== "open")
|
|
1525
|
+
return;
|
|
1369
1526
|
chatFirstRoutedPaneRef.current = { seq, chat, sentPane, pane };
|
|
1370
1527
|
applyChatFirstRoutedPane();
|
|
1371
1528
|
});
|
|
1372
1529
|
});
|
|
1373
|
-
}, [
|
|
1530
|
+
}, [
|
|
1531
|
+
applyChatFirstRoutedPane,
|
|
1532
|
+
chatFirstMode,
|
|
1533
|
+
isChatRoute,
|
|
1534
|
+
writeActivePaneContext,
|
|
1535
|
+
]);
|
|
1374
1536
|
useEffect(() => {
|
|
1375
1537
|
const target = chatFirstSessionWatch.target;
|
|
1376
1538
|
if (!target || !chatFirstMode || !isChatRoute)
|
|
@@ -1402,8 +1564,11 @@ function DispatchLayout({ children, extensions, agentPageHref, notice, brandName
|
|
|
1402
1564
|
const frame = [
|
|
1403
1565
|
...document.querySelectorAll("[data-dispatch-workspace-app-frame]"),
|
|
1404
1566
|
].find((candidate) => candidate
|
|
1405
|
-
.closest("[data-
|
|
1406
|
-
?.getAttribute("aria-hidden") !== "true"
|
|
1567
|
+
.closest("[data-dispatch-workspace-app-cache-entry]")
|
|
1568
|
+
?.getAttribute("aria-hidden") !== "true" &&
|
|
1569
|
+
candidate
|
|
1570
|
+
.closest("[data-chat-first-surface-content]")
|
|
1571
|
+
?.getAttribute("aria-hidden") !== "true");
|
|
1407
1572
|
if (!(frame instanceof HTMLIFrameElement))
|
|
1408
1573
|
return;
|
|
1409
1574
|
if (event.source !== frame.contentWindow)
|
|
@@ -1498,6 +1663,12 @@ function DispatchLayout({ children, extensions, agentPageHref, notice, brandName
|
|
|
1498
1663
|
: null;
|
|
1499
1664
|
return renderChatFirstAppSurfaceTab({
|
|
1500
1665
|
registration,
|
|
1666
|
+
...(tab.id === visiblePaneTabId && visiblePaneAppId
|
|
1667
|
+
? {
|
|
1668
|
+
onViewReaderChange: registerChatFirstViewReader,
|
|
1669
|
+
onChildRouteChange: refreshActivePaneContext,
|
|
1670
|
+
}
|
|
1671
|
+
: {}),
|
|
1501
1672
|
embedPath: tab.path ?? registration?.path ?? "/",
|
|
1502
1673
|
placement: tab.placement ?? "main",
|
|
1503
1674
|
loading: !registration &&
|
|
@@ -1507,7 +1678,7 @@ function DispatchLayout({ children, extensions, agentPageHref, notice, brandName
|
|
|
1507
1678
|
});
|
|
1508
1679
|
}
|
|
1509
1680
|
if (tab.kind === "browser" && tab.url) {
|
|
1510
|
-
return (_jsx(ChatFirstBrowserPane, { url: tab.url, title: tab.title, onClose: () => closeChatFirstSurfaceTab(tab), renderEmbed: ({ url, title, key }) => (_jsx("iframe", { src: url, title: title ?? chatFirstCopy("browserPage"), referrerPolicy: "no-referrer", allow: "clipboard-read; clipboard-write", className: "h-full w-full border-0 bg-background" }, key)), copy: chatFirstCopy }));
|
|
1681
|
+
return (_jsx(ChatFirstBrowserPane, { url: tab.url, title: tab.title, onClose: () => closeChatFirstSurfaceTab(tab), renderEmbed: ({ url, title, key }) => (_jsx("iframe", { src: url, title: title ?? chatFirstCopy("browserPage"), referrerPolicy: "no-referrer", allow: "clipboard-read; clipboard-write; fullscreen", className: "h-full w-full border-0 bg-background" }, key)), copy: chatFirstCopy }));
|
|
1511
1682
|
}
|
|
1512
1683
|
if (tab.kind === "side-chat") {
|
|
1513
1684
|
const target = tab.session ??
|
|
@@ -1541,6 +1712,10 @@ function DispatchLayout({ children, extensions, agentPageHref, notice, brandName
|
|
|
1541
1712
|
closeChatFirstSurfaceTab,
|
|
1542
1713
|
isMobileSurface,
|
|
1543
1714
|
renderChatFirstWatchChat,
|
|
1715
|
+
registerChatFirstViewReader,
|
|
1716
|
+
refreshActivePaneContext,
|
|
1717
|
+
visiblePaneAppId,
|
|
1718
|
+
visiblePaneTabId,
|
|
1544
1719
|
]);
|
|
1545
1720
|
const chatFirstSurfaceTabsBar = visibleChatFirstSurfaceTab?.kind === "app" ? null : (_jsx(ChatFirstSurfaceTabs, { tabs: chatFirstSurfaceTabs.tabs, activeTabId: visibleChatFirstSurfaceTabIdValue, onActivate: activateChatFirstSurfaceTab, onClose: closeChatFirstSurfaceTab, onCloseOthers: (tab) => {
|
|
1546
1721
|
activateChatFirstSurfaceTab(tab);
|
|
@@ -1552,7 +1727,9 @@ function DispatchLayout({ children, extensions, agentPageHref, notice, brandName
|
|
|
1552
1727
|
activateChatFirstSurfaceTab(tab);
|
|
1553
1728
|
chatFirstSurfaceTabsStore.closeToRight(tab.id);
|
|
1554
1729
|
}, onCloseAll: closeAllChatFirstSurfaceTabs, onOpenSurface: openChatFirstSurface, apps: chatFirstAppItems, onOpenApp: (app) => openChatFirstPane({ appId: app.id }, "side"), renderAppIcon: (app) => (_jsx(AppIcon, { id: app.id, name: app.name, size: "sm", className: "size-7 rounded-lg" })), copy: chatFirstCopy }));
|
|
1555
|
-
const chatFirstSurfaceContent = chatFirstSurfaceTabs.tabs.length > 0 ? (_jsx(ChatFirstSurfaceContent, { tabs: chatFirstSurfaceTabs.tabs
|
|
1730
|
+
const chatFirstSurfaceContent = chatFirstSurfaceTabs.tabs.length > 0 ? (_jsx(ChatFirstSurfaceContent, { tabs: chatFirstSurfaceTabs.tabs.filter((tab) => tab.kind !== "app" ||
|
|
1731
|
+
(tab.appId !== undefined &&
|
|
1732
|
+
warmWorkspaceAppIds.includes(tab.appId))), activeTabId: visibleChatFirstSurfaceTabIdValue, renderTab: renderChatFirstSurfaceTab })) : null;
|
|
1556
1733
|
if (CHROMELESS_PATHS.some((path) => localPathname === path)) {
|
|
1557
1734
|
return _jsx(_Fragment, { children: children });
|
|
1558
1735
|
}
|
|
@@ -1600,7 +1777,7 @@ function DispatchLayout({ children, extensions, agentPageHref, notice, brandName
|
|
|
1600
1777
|
const workspaceAppDeepPath = workspaceAppRouteActive
|
|
1601
1778
|
? workspaceAppInitialPathFromPathname(localPathname, location.search, location.hash)
|
|
1602
1779
|
: undefined;
|
|
1603
|
-
const workspaceAppContent = workspaceAppRouteActive && workspaceAppId ? (workspaceAppChatRegistration ? (_jsx(WorkspaceAppChatRail, { appId: workspaceAppId, appName: workspaceAppChatRegistration.name ?? workspaceAppId, agentPageHref: agentPageHref, onFullscreenRequest: openAskAgentFullscreen, children: _jsx(WorkspaceAppKeepAlive, { activeAppId: workspaceAppId, ...(workspaceAppDeepPath
|
|
1780
|
+
const workspaceAppContent = workspaceAppRouteActive && workspaceAppId ? (workspaceAppChatRegistration ? (_jsx(WorkspaceAppChatRail, { appId: workspaceAppId, appName: workspaceAppChatRegistration.name ?? workspaceAppId, agentPageHref: agentPageHref, onFullscreenRequest: openAskAgentFullscreen, browserTabId: workspaceAppChildTab.browserTabId, children: _jsx(WorkspaceAppKeepAlive, { activeAppId: workspaceAppId, claimBrowserTab: true, onViewReaderChange: workspaceAppChildTab.onViewReaderChange, ...(workspaceAppDeepPath
|
|
1604
1781
|
? { initialPath: workspaceAppDeepPath }
|
|
1605
1782
|
: {}) }) })) : (_jsx(WorkspaceAppKeepAlive, { activeAppId: workspaceAppId, ...(workspaceAppDeepPath
|
|
1606
1783
|
? { initialPath: workspaceAppDeepPath }
|