@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
|
@@ -7,9 +7,9 @@ import {
|
|
|
7
7
|
navigateWithAgentChatViewTransition,
|
|
8
8
|
readChatFirstMode,
|
|
9
9
|
resolveChatFirstBrowserTarget,
|
|
10
|
-
resolveChatFirstAppTarget,
|
|
11
10
|
subscribeChatFirstOpenBrowser,
|
|
12
11
|
subscribeChatFirstOpenApp,
|
|
12
|
+
subscribeChatFirstOpenAppStart,
|
|
13
13
|
useChatFirstSessionWatch,
|
|
14
14
|
useChatFirstSurfacePanel,
|
|
15
15
|
useChatFirstSurfaceResize,
|
|
@@ -33,6 +33,7 @@ import {
|
|
|
33
33
|
readClientAppState,
|
|
34
34
|
writeClientAppState,
|
|
35
35
|
} from "@agent-native/core/client/application-state";
|
|
36
|
+
import { getBrowserTabId } from "@agent-native/core/client/browser-tab-id";
|
|
36
37
|
import {
|
|
37
38
|
useFeatureFlagState,
|
|
38
39
|
type FeatureFlagState,
|
|
@@ -109,11 +110,14 @@ import {
|
|
|
109
110
|
type ChatFirstAppRouteRecord,
|
|
110
111
|
} from "../../lib/chat-first-app-route";
|
|
111
112
|
import {
|
|
113
|
+
createTurnViewportLock,
|
|
112
114
|
delegatedAppFromToolStart,
|
|
115
|
+
resolveDispatchChatFirstAppTarget,
|
|
113
116
|
visibleChatFirstSurfaceTabId,
|
|
114
117
|
} from "../../lib/chat-first-pane";
|
|
115
118
|
import { getDispatchRunThreadContext } from "../../lib/dispatch-run-thread.js";
|
|
116
119
|
import {
|
|
120
|
+
chatFirstExternalApps,
|
|
117
121
|
filterBuiltInApps,
|
|
118
122
|
type ConnectedAppSummary,
|
|
119
123
|
} from "../../lib/other-apps";
|
|
@@ -136,11 +140,17 @@ import {
|
|
|
136
140
|
workspaceAppInitialPathFromPathname,
|
|
137
141
|
workspaceAppDirectHref,
|
|
138
142
|
workspaceAppDirectLaunchHref,
|
|
143
|
+
workspaceAppHref,
|
|
139
144
|
workspaceAppRoute,
|
|
140
145
|
workspaceAppTargetPath,
|
|
141
146
|
type WorkspaceAppSummary,
|
|
142
147
|
} from "../../lib/workspace-apps";
|
|
143
|
-
import {
|
|
148
|
+
import {
|
|
149
|
+
CHAT_FIRST_PANE_BINDING_MAX_AGE_MS,
|
|
150
|
+
CHAT_FIRST_PANE_CONTEXT_STATE_KEY,
|
|
151
|
+
CHAT_FIRST_PANE_STATE_KEY,
|
|
152
|
+
parsePersistedChatFirstPane,
|
|
153
|
+
} from "../../shared/chat-first-pane";
|
|
144
154
|
import { AppIcon } from "../app-icon";
|
|
145
155
|
import { CreateAppPopover } from "../create-app-popover";
|
|
146
156
|
import {
|
|
@@ -167,9 +177,12 @@ import {
|
|
|
167
177
|
} from "../ui/tooltip";
|
|
168
178
|
import {
|
|
169
179
|
usePrefetchChatFirstEmbedSession,
|
|
180
|
+
useWarmWorkspaceAppIds,
|
|
170
181
|
WorkspaceAppChatRail,
|
|
171
182
|
WorkspaceAppFrame,
|
|
183
|
+
type WorkspaceAppViewReader,
|
|
172
184
|
WorkspaceAppKeepAlive,
|
|
185
|
+
useWorkspaceAppChildBrowserTab,
|
|
173
186
|
} from "../workspace-app-host";
|
|
174
187
|
import {
|
|
175
188
|
AppNotice,
|
|
@@ -292,6 +305,7 @@ const CHROMELESS_PATHS = ["/approval", "/browser-chat", "/browser-connect"];
|
|
|
292
305
|
// With nothing pinned, the sidebar suggests this many apps; All apps has the rest.
|
|
293
306
|
const CHAT_FIRST_RAIL_SUGGESTED_APPS = 3;
|
|
294
307
|
const CHAT_FIRST_ROUTE_TIMEOUT_MS = 6_000;
|
|
308
|
+
const CHAT_FIRST_PANE_READ_TIMEOUT_MS = 450;
|
|
295
309
|
const NO_CHAT_FIRST_APPS: ChatFirstAppItem[] = [];
|
|
296
310
|
const SIDEBAR_COLLAPSE_KEY = "dispatch.sidebar.collapsed";
|
|
297
311
|
const CHAT_HISTORY_SOURCE_KEY = "dispatch.chat-history.source";
|
|
@@ -487,6 +501,7 @@ const DISPATCH_CHAT_FIRST_COPY_KEYS: Record<string, string> = {
|
|
|
487
501
|
workspaceApps: "chatFirstWorkspaceApps",
|
|
488
502
|
createWorkspaceApp: "chatFirstCreateWorkspaceApp",
|
|
489
503
|
openApp: "chatFirstOpenApp",
|
|
504
|
+
openInNewTab: "chatFirstOpenInNewTab",
|
|
490
505
|
appsLoadError: "chatFirstAppsLoadError",
|
|
491
506
|
noWorkspaceApps: "chatFirstNoWorkspaceApps",
|
|
492
507
|
createApp: "chatFirstCreateApp",
|
|
@@ -589,20 +604,6 @@ function chatThreadPath(threadId: string | null): string {
|
|
|
589
604
|
return threadId ? `/chat/${encodeURIComponent(threadId)}` : "/chat";
|
|
590
605
|
}
|
|
591
606
|
|
|
592
|
-
function persistedChatFirstPane(value: unknown): DispatchChatFirstPane | null {
|
|
593
|
-
if (!value || typeof value !== "object") return null;
|
|
594
|
-
const record = value as Record<string, unknown>;
|
|
595
|
-
if (typeof record.appId !== "string" || !record.appId.trim()) return null;
|
|
596
|
-
return {
|
|
597
|
-
appId: record.appId,
|
|
598
|
-
...(record.placement === "main" || record.placement === "side"
|
|
599
|
-
? { placement: record.placement }
|
|
600
|
-
: {}),
|
|
601
|
-
...(typeof record.path === "string" ? { path: record.path } : {}),
|
|
602
|
-
...(typeof record.view === "string" ? { view: record.view } : {}),
|
|
603
|
-
};
|
|
604
|
-
}
|
|
605
|
-
|
|
606
607
|
function threadIdFromPath(pathname: string): string | null {
|
|
607
608
|
const match = pathname.match(/^\/chat\/([^/]+)/);
|
|
608
609
|
if (!match) return null;
|
|
@@ -1333,6 +1334,8 @@ export function renderChatFirstAppSurfaceTab({
|
|
|
1333
1334
|
isMobileSurface,
|
|
1334
1335
|
copy,
|
|
1335
1336
|
placement = "main",
|
|
1337
|
+
onViewReaderChange,
|
|
1338
|
+
onChildRouteChange,
|
|
1336
1339
|
}: {
|
|
1337
1340
|
registration: ChatFirstAppRegistration | null;
|
|
1338
1341
|
embedPath: string;
|
|
@@ -1340,6 +1343,8 @@ export function renderChatFirstAppSurfaceTab({
|
|
|
1340
1343
|
isMobileSurface: boolean;
|
|
1341
1344
|
copy: ChatFirstCopy;
|
|
1342
1345
|
placement?: ChatFirstAppSurfacePlacement;
|
|
1346
|
+
onViewReaderChange?: (read: WorkspaceAppViewReader) => () => void;
|
|
1347
|
+
onChildRouteChange?: (path: string) => void;
|
|
1343
1348
|
}): ReactNode {
|
|
1344
1349
|
if (!registration) {
|
|
1345
1350
|
return (
|
|
@@ -1375,6 +1380,9 @@ export function renderChatFirstAppSurfaceTab({
|
|
|
1375
1380
|
url: registration.url,
|
|
1376
1381
|
}}
|
|
1377
1382
|
embedPath={embedPath}
|
|
1383
|
+
claimBrowserTab
|
|
1384
|
+
onViewReaderChange={onViewReaderChange}
|
|
1385
|
+
onChildRouteChange={onChildRouteChange}
|
|
1378
1386
|
chatSidebar={!isMobileSurface && placement === "main"}
|
|
1379
1387
|
copy={copy}
|
|
1380
1388
|
/>
|
|
@@ -1547,18 +1555,16 @@ function DispatchLayout({
|
|
|
1547
1555
|
mergeChatFirstWorkspaceApps(
|
|
1548
1556
|
chatFirstAppsQuery.data,
|
|
1549
1557
|
chatFirstEnabledBuiltinAppIds,
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
source: "builtin" as const,
|
|
1556
|
-
hiddenFromLaunchers: app.hiddenFromLaunchers,
|
|
1557
|
-
})),
|
|
1558
|
+
chatFirstExternalApps(
|
|
1559
|
+
chatFirstConnectedAppsQuery.data ?? [],
|
|
1560
|
+
chatFirstAppsQuery.data ??
|
|
1561
|
+
(chatFirstAppsQuery.isError ? "unreadable" : "loading"),
|
|
1562
|
+
),
|
|
1558
1563
|
).filter((app) => app.status !== "pending" && app.archived !== true),
|
|
1559
1564
|
[
|
|
1560
1565
|
chatFirstAppsQuery.data,
|
|
1561
|
-
|
|
1566
|
+
chatFirstAppsQuery.isError,
|
|
1567
|
+
chatFirstConnectedAppsQuery.data,
|
|
1562
1568
|
chatFirstEnabledBuiltinAppIds,
|
|
1563
1569
|
],
|
|
1564
1570
|
);
|
|
@@ -1588,6 +1594,7 @@ function DispatchLayout({
|
|
|
1588
1594
|
id: app.id,
|
|
1589
1595
|
name: app.name,
|
|
1590
1596
|
source: app.source ?? "workspace",
|
|
1597
|
+
href: workspaceAppHref(app),
|
|
1591
1598
|
})),
|
|
1592
1599
|
[chatFirstWorkspaceApps],
|
|
1593
1600
|
);
|
|
@@ -1678,6 +1685,8 @@ function DispatchLayout({
|
|
|
1678
1685
|
chatFirstSurfaceScope,
|
|
1679
1686
|
);
|
|
1680
1687
|
const chatFirstPaneHydratedRef = useRef(false);
|
|
1688
|
+
const chatFirstSurfaceScopeRef = useRef(chatFirstSurfaceScope);
|
|
1689
|
+
chatFirstSurfaceScopeRef.current = chatFirstSurfaceScope;
|
|
1681
1690
|
const pendingChatFirstOpenAppRef = useRef<ChatFirstOpenAppDetail | null>(
|
|
1682
1691
|
null,
|
|
1683
1692
|
);
|
|
@@ -1686,6 +1695,8 @@ function DispatchLayout({
|
|
|
1686
1695
|
appId: string;
|
|
1687
1696
|
tabId: string;
|
|
1688
1697
|
} | null>(null);
|
|
1698
|
+
const turnViewportLockRef = useRef(createTurnViewportLock());
|
|
1699
|
+
const workspaceAppChildTab = useWorkspaceAppChildBrowserTab();
|
|
1689
1700
|
const previousChatFirstSurfaceScopeRef = useRef(chatFirstSurfaceScope);
|
|
1690
1701
|
const previousChatFirstSurfaceTabCountRef = useRef<number | null>(null);
|
|
1691
1702
|
const activeChatFirstSurfaceTab = useMemo(
|
|
@@ -1706,6 +1717,123 @@ function DispatchLayout({
|
|
|
1706
1717
|
) ?? null,
|
|
1707
1718
|
[chatFirstSurfaceTabs.tabs, visibleChatFirstSurfaceTabIdValue],
|
|
1708
1719
|
);
|
|
1720
|
+
const warmWorkspaceAppIds = useWarmWorkspaceAppIds(
|
|
1721
|
+
chatFirstSurfaceScope,
|
|
1722
|
+
visibleChatFirstSurfaceTab?.kind === "app"
|
|
1723
|
+
? (visibleChatFirstSurfaceTab.appId ?? null)
|
|
1724
|
+
: null,
|
|
1725
|
+
chatFirstSurfaceTabs.tabs.flatMap((tab) =>
|
|
1726
|
+
tab.kind === "app" && tab.appId ? [tab.appId] : [],
|
|
1727
|
+
),
|
|
1728
|
+
);
|
|
1729
|
+
const chatFirstViewReader = useRef<{
|
|
1730
|
+
tabId: string;
|
|
1731
|
+
scope: string;
|
|
1732
|
+
read: WorkspaceAppViewReader;
|
|
1733
|
+
} | null>(null);
|
|
1734
|
+
const visiblePaneTabId = visibleChatFirstSurfaceTabIdValue;
|
|
1735
|
+
const visiblePaneAppId =
|
|
1736
|
+
chatFirstMode &&
|
|
1737
|
+
isChatRoute &&
|
|
1738
|
+
chatFirstSurfacePanel.open &&
|
|
1739
|
+
visibleChatFirstSurfaceTab?.kind === "app"
|
|
1740
|
+
? visibleChatFirstSurfaceTab.appId
|
|
1741
|
+
: undefined;
|
|
1742
|
+
const visiblePanePath = visiblePaneAppId
|
|
1743
|
+
? visibleChatFirstSurfaceTab?.path
|
|
1744
|
+
: undefined;
|
|
1745
|
+
const visiblePaneView = visiblePaneAppId
|
|
1746
|
+
? visibleChatFirstSurfaceTab?.view
|
|
1747
|
+
: undefined;
|
|
1748
|
+
const writeActivePaneContext = useCallback(
|
|
1749
|
+
(
|
|
1750
|
+
view: {
|
|
1751
|
+
path: string;
|
|
1752
|
+
origin?: string;
|
|
1753
|
+
childBrowserTabId?: string;
|
|
1754
|
+
} | null,
|
|
1755
|
+
) =>
|
|
1756
|
+
writeClientAppState(
|
|
1757
|
+
`${CHAT_FIRST_PANE_CONTEXT_STATE_KEY}:${getBrowserTabId()}`,
|
|
1758
|
+
visiblePaneAppId
|
|
1759
|
+
? {
|
|
1760
|
+
appId: visiblePaneAppId,
|
|
1761
|
+
path: view?.path ?? visiblePanePath ?? "/",
|
|
1762
|
+
...(visiblePaneView ? { view: visiblePaneView } : {}),
|
|
1763
|
+
...(view?.origin && view.childBrowserTabId
|
|
1764
|
+
? {
|
|
1765
|
+
origin: view.origin,
|
|
1766
|
+
childBrowserTabId: view.childBrowserTabId,
|
|
1767
|
+
observedAt: Date.now(),
|
|
1768
|
+
}
|
|
1769
|
+
: {}),
|
|
1770
|
+
}
|
|
1771
|
+
: null,
|
|
1772
|
+
{ keepalive: true },
|
|
1773
|
+
).catch(() => {}),
|
|
1774
|
+
[visiblePaneAppId, visiblePanePath, visiblePaneView],
|
|
1775
|
+
);
|
|
1776
|
+
useEffect(() => {
|
|
1777
|
+
void writeActivePaneContext(null);
|
|
1778
|
+
}, [writeActivePaneContext]);
|
|
1779
|
+
const refreshActivePaneContext = useCallback(() => {
|
|
1780
|
+
const reader = chatFirstViewReader.current;
|
|
1781
|
+
if (!reader) return;
|
|
1782
|
+
void reader
|
|
1783
|
+
.read(AbortSignal.timeout(CHAT_FIRST_PANE_READ_TIMEOUT_MS))
|
|
1784
|
+
.then((view) => {
|
|
1785
|
+
if (view && chatFirstViewReader.current === reader) {
|
|
1786
|
+
return writeActivePaneContext(view);
|
|
1787
|
+
}
|
|
1788
|
+
})
|
|
1789
|
+
.catch(() => {});
|
|
1790
|
+
}, [writeActivePaneContext]);
|
|
1791
|
+
useEffect(() => {
|
|
1792
|
+
if (!visiblePaneAppId) return;
|
|
1793
|
+
const clearPagePane = () => {
|
|
1794
|
+
void writeClientAppState(
|
|
1795
|
+
`${CHAT_FIRST_PANE_CONTEXT_STATE_KEY}:${getBrowserTabId()}`,
|
|
1796
|
+
null,
|
|
1797
|
+
{ keepalive: true },
|
|
1798
|
+
).catch(() => {});
|
|
1799
|
+
};
|
|
1800
|
+
const refreshVisiblePane = () => {
|
|
1801
|
+
if (document.visibilityState === "visible") refreshActivePaneContext();
|
|
1802
|
+
};
|
|
1803
|
+
const refreshTimer = window.setInterval(
|
|
1804
|
+
refreshVisiblePane,
|
|
1805
|
+
CHAT_FIRST_PANE_BINDING_MAX_AGE_MS / 2,
|
|
1806
|
+
);
|
|
1807
|
+
document.addEventListener("visibilitychange", refreshVisiblePane);
|
|
1808
|
+
window.addEventListener("focus", refreshActivePaneContext);
|
|
1809
|
+
window.addEventListener("pageshow", refreshActivePaneContext);
|
|
1810
|
+
window.addEventListener("pagehide", clearPagePane);
|
|
1811
|
+
return () => {
|
|
1812
|
+
window.clearInterval(refreshTimer);
|
|
1813
|
+
document.removeEventListener("visibilitychange", refreshVisiblePane);
|
|
1814
|
+
window.removeEventListener("focus", refreshActivePaneContext);
|
|
1815
|
+
window.removeEventListener("pageshow", refreshActivePaneContext);
|
|
1816
|
+
window.removeEventListener("pagehide", clearPagePane);
|
|
1817
|
+
};
|
|
1818
|
+
}, [refreshActivePaneContext, visiblePaneAppId]);
|
|
1819
|
+
const registerChatFirstViewReader = useCallback(
|
|
1820
|
+
(read: WorkspaceAppViewReader) => {
|
|
1821
|
+
if (!visiblePaneTabId) return () => {};
|
|
1822
|
+
const reader = {
|
|
1823
|
+
tabId: visiblePaneTabId,
|
|
1824
|
+
scope: chatFirstSurfaceScope,
|
|
1825
|
+
read,
|
|
1826
|
+
};
|
|
1827
|
+
chatFirstViewReader.current = reader;
|
|
1828
|
+
refreshActivePaneContext();
|
|
1829
|
+
return () => {
|
|
1830
|
+
if (chatFirstViewReader.current === reader) {
|
|
1831
|
+
chatFirstViewReader.current = null;
|
|
1832
|
+
}
|
|
1833
|
+
};
|
|
1834
|
+
},
|
|
1835
|
+
[chatFirstSurfaceScope, refreshActivePaneContext, visiblePaneTabId],
|
|
1836
|
+
);
|
|
1709
1837
|
const chatFirstAppTakesMain =
|
|
1710
1838
|
chatFirstMode &&
|
|
1711
1839
|
isChatRoute &&
|
|
@@ -1784,22 +1912,20 @@ function DispatchLayout({
|
|
|
1784
1912
|
const app = chatFirstAppRegistrations.find(
|
|
1785
1913
|
(candidate) => candidate.id === pane.appId,
|
|
1786
1914
|
);
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1915
|
+
const snapshot = chatFirstSurfaceTabsStore.getSnapshot();
|
|
1916
|
+
const existing = snapshot.tabs.find(
|
|
1917
|
+
(tab) => tab.kind === "app" && tab.appId === pane.appId,
|
|
1790
1918
|
);
|
|
1919
|
+
const tabId = existing?.id ?? chatFirstSurfaceTabId("app", pane.appId);
|
|
1791
1920
|
const earlier = provisionalChatFirstTabRef.current;
|
|
1792
1921
|
provisionalChatFirstTabRef.current = null;
|
|
1793
1922
|
if (
|
|
1794
1923
|
earlier &&
|
|
1795
1924
|
earlier.scope === chatFirstSurfaceScope &&
|
|
1796
1925
|
earlier.tabId !== tabId &&
|
|
1797
|
-
|
|
1798
|
-
.getSnapshot()
|
|
1799
|
-
.tabs.some((tab) => tab.id === earlier.tabId)
|
|
1926
|
+
snapshot.tabs.some((tab) => tab.id === earlier.tabId)
|
|
1800
1927
|
) {
|
|
1801
|
-
|
|
1802
|
-
else chatFirstSurfaceTabsStore.close(earlier.tabId);
|
|
1928
|
+
chatFirstSurfaceTabsStore.close(earlier.tabId);
|
|
1803
1929
|
}
|
|
1804
1930
|
if (provisional) {
|
|
1805
1931
|
provisionalChatFirstTabRef.current = {
|
|
@@ -1893,7 +2019,7 @@ function DispatchLayout({
|
|
|
1893
2019
|
);
|
|
1894
2020
|
const resolveChatFirstOpenApp = useCallback(
|
|
1895
2021
|
(detail: ChatFirstOpenAppDetail) => {
|
|
1896
|
-
const resolution =
|
|
2022
|
+
const resolution = resolveDispatchChatFirstAppTarget(
|
|
1897
2023
|
detail,
|
|
1898
2024
|
chatFirstAppRegistrations,
|
|
1899
2025
|
{
|
|
@@ -1925,6 +2051,7 @@ function DispatchLayout({
|
|
|
1925
2051
|
}
|
|
1926
2052
|
pendingChatFirstOpenAppRef.current = null;
|
|
1927
2053
|
if (isDispatchWorkspaceAppId(resolution.target.appId)) {
|
|
2054
|
+
turnViewportLockRef.current.clear();
|
|
1928
2055
|
closeChatFirstSessionWatch();
|
|
1929
2056
|
chatFirstSurfaceTabsStore.closeAll();
|
|
1930
2057
|
setChatFirstSurfacePanelOpen(false);
|
|
@@ -1937,7 +2064,15 @@ function DispatchLayout({
|
|
|
1937
2064
|
}
|
|
1938
2065
|
return;
|
|
1939
2066
|
}
|
|
1940
|
-
|
|
2067
|
+
const lockDecision = turnViewportLockRef.current.evaluate({
|
|
2068
|
+
appId: resolution.target.appId,
|
|
2069
|
+
focus: detail.focus,
|
|
2070
|
+
turnKey: detail.turnId,
|
|
2071
|
+
});
|
|
2072
|
+
if (!lockDecision.allowed) {
|
|
2073
|
+
return;
|
|
2074
|
+
}
|
|
2075
|
+
openChatFirstPane(resolution.target, "side", detail.optimistic === true);
|
|
1941
2076
|
},
|
|
1942
2077
|
[
|
|
1943
2078
|
chatFirstAppRegistrations,
|
|
@@ -1991,11 +2126,15 @@ function DispatchLayout({
|
|
|
1991
2126
|
return;
|
|
1992
2127
|
}
|
|
1993
2128
|
const unsubscribeApp = subscribeChatFirstOpenApp(resolveChatFirstOpenApp);
|
|
2129
|
+
const unsubscribeAppStart = subscribeChatFirstOpenAppStart(
|
|
2130
|
+
resolveChatFirstOpenApp,
|
|
2131
|
+
);
|
|
1994
2132
|
const unsubscribeBrowser = subscribeChatFirstOpenBrowser(
|
|
1995
2133
|
resolveChatFirstOpenBrowser,
|
|
1996
2134
|
);
|
|
1997
2135
|
return () => {
|
|
1998
2136
|
unsubscribeApp();
|
|
2137
|
+
unsubscribeAppStart();
|
|
1999
2138
|
unsubscribeBrowser();
|
|
2000
2139
|
};
|
|
2001
2140
|
}, [
|
|
@@ -2017,7 +2156,7 @@ function DispatchLayout({
|
|
|
2017
2156
|
.getSnapshot()
|
|
2018
2157
|
.tabs.some((tab) => tab.kind === "app" && tab.appId === appId);
|
|
2019
2158
|
if (alreadyOpen) return;
|
|
2020
|
-
const resolution =
|
|
2159
|
+
const resolution = resolveDispatchChatFirstAppTarget(
|
|
2021
2160
|
{ app: appId },
|
|
2022
2161
|
chatFirstAppRegistrations,
|
|
2023
2162
|
typeof window === "undefined"
|
|
@@ -2030,11 +2169,28 @@ function DispatchLayout({
|
|
|
2030
2169
|
) {
|
|
2031
2170
|
return;
|
|
2032
2171
|
}
|
|
2172
|
+
const lockDecision = turnViewportLockRef.current.evaluate({
|
|
2173
|
+
appId: resolution.target.appId,
|
|
2174
|
+
focus: false,
|
|
2175
|
+
});
|
|
2176
|
+
if (!lockDecision.allowed) {
|
|
2177
|
+
return;
|
|
2178
|
+
}
|
|
2033
2179
|
openChatFirstPane(resolution.target);
|
|
2034
2180
|
};
|
|
2181
|
+
const handleTurnStart = (event: Event) => {
|
|
2182
|
+
const detail = (event as CustomEvent<{ turnId?: unknown } | undefined>)
|
|
2183
|
+
.detail;
|
|
2184
|
+
const turnId =
|
|
2185
|
+
typeof detail?.turnId === "string" ? detail.turnId : undefined;
|
|
2186
|
+
turnViewportLockRef.current.beginTurn(turnId);
|
|
2187
|
+
};
|
|
2035
2188
|
window.addEventListener("agent-native:tool-start", handleToolStart);
|
|
2036
|
-
|
|
2189
|
+
window.addEventListener("agent-native:turn-start", handleTurnStart);
|
|
2190
|
+
return () => {
|
|
2037
2191
|
window.removeEventListener("agent-native:tool-start", handleToolStart);
|
|
2192
|
+
window.removeEventListener("agent-native:turn-start", handleTurnStart);
|
|
2193
|
+
};
|
|
2038
2194
|
}, [
|
|
2039
2195
|
chatFirstAppRegistrations,
|
|
2040
2196
|
chatFirstMode,
|
|
@@ -2054,21 +2210,33 @@ function DispatchLayout({
|
|
|
2054
2210
|
}
|
|
2055
2211
|
chatFirstPaneHydratedRef.current = true;
|
|
2056
2212
|
if (chatFirstPane) return;
|
|
2213
|
+
const unreadable = () =>
|
|
2214
|
+
setChatFirstNotice(
|
|
2215
|
+
"The last app pane could not be restored from workspace state.",
|
|
2216
|
+
);
|
|
2217
|
+
const scope = chatFirstSurfaceScope;
|
|
2057
2218
|
let active = true;
|
|
2219
|
+
let settled = false;
|
|
2058
2220
|
void readClientAppState<unknown>(CHAT_FIRST_PANE_STATE_KEY)
|
|
2059
2221
|
.then((value) => {
|
|
2222
|
+
settled = true;
|
|
2060
2223
|
if (!active) return;
|
|
2061
|
-
|
|
2224
|
+
const state = parsePersistedChatFirstPane(value);
|
|
2225
|
+
if (state.status === "restorable") {
|
|
2226
|
+
setPendingChatFirstPaneRestore(state.pane);
|
|
2227
|
+
} else if (state.status === "unreadable") {
|
|
2228
|
+
unreadable();
|
|
2229
|
+
}
|
|
2062
2230
|
})
|
|
2063
2231
|
.catch(() => {
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
"The last app pane could not be restored from workspace state.",
|
|
2067
|
-
);
|
|
2068
|
-
}
|
|
2232
|
+
settled = true;
|
|
2233
|
+
if (active) unreadable();
|
|
2069
2234
|
});
|
|
2070
2235
|
return () => {
|
|
2071
2236
|
active = false;
|
|
2237
|
+
if (!settled && chatFirstSurfaceScopeRef.current === scope) {
|
|
2238
|
+
chatFirstPaneHydratedRef.current = false;
|
|
2239
|
+
}
|
|
2072
2240
|
};
|
|
2073
2241
|
}, [chatFirstMode, chatFirstPane, chatFirstSurfaceScope, isChatRoute]);
|
|
2074
2242
|
|
|
@@ -2085,7 +2253,7 @@ function DispatchLayout({
|
|
|
2085
2253
|
setPendingChatFirstPaneRestore(null);
|
|
2086
2254
|
return;
|
|
2087
2255
|
}
|
|
2088
|
-
const resolution =
|
|
2256
|
+
const resolution = resolveDispatchChatFirstAppTarget(
|
|
2089
2257
|
{
|
|
2090
2258
|
app: pendingChatFirstPaneRestore.appId,
|
|
2091
2259
|
path: pendingChatFirstPaneRestore.path,
|
|
@@ -2135,6 +2303,7 @@ function DispatchLayout({
|
|
|
2135
2303
|
}
|
|
2136
2304
|
const chatGainedItsId = previousChatFirstSurfaceScopeRef.current === "new";
|
|
2137
2305
|
previousChatFirstSurfaceScopeRef.current = chatFirstSurfaceScope;
|
|
2306
|
+
turnViewportLockRef.current.clear();
|
|
2138
2307
|
persistChatFirstPane(null);
|
|
2139
2308
|
setChatFirstNotice(null);
|
|
2140
2309
|
if (!chatGainedItsId) pendingChatFirstOpenAppRef.current = null;
|
|
@@ -2202,12 +2371,6 @@ function DispatchLayout({
|
|
|
2202
2371
|
]);
|
|
2203
2372
|
|
|
2204
2373
|
const prefetchChatFirstEmbedSession = usePrefetchChatFirstEmbedSession();
|
|
2205
|
-
const chatFirstPaneAppId =
|
|
2206
|
-
visibleChatFirstSurfaceTab?.kind === "app"
|
|
2207
|
-
? visibleChatFirstSurfaceTab.appId
|
|
2208
|
-
: activeChatFirstSurfaceTab?.kind === "app"
|
|
2209
|
-
? activeChatFirstSurfaceTab.appId
|
|
2210
|
-
: undefined;
|
|
2211
2374
|
const chatFirstRouteSendRef = useRef<{ seq: number; id: string | null }>({
|
|
2212
2375
|
seq: 0,
|
|
2213
2376
|
id: null,
|
|
@@ -2218,11 +2381,26 @@ function DispatchLayout({
|
|
|
2218
2381
|
sentPane: string;
|
|
2219
2382
|
pane: DispatchChatFirstPane;
|
|
2220
2383
|
} | null>(null);
|
|
2384
|
+
useEffect(() => {
|
|
2385
|
+
if (!chatFirstMode || !isChatRoute) return;
|
|
2386
|
+
const cancelPendingRoute = (event: Event) => {
|
|
2387
|
+
const detail = (event as CustomEvent<{ tool?: unknown } | null>).detail;
|
|
2388
|
+
if (detail?.tool !== "open_app" && detail?.tool !== "open-app") return;
|
|
2389
|
+
const current = chatFirstRouteSendRef.current;
|
|
2390
|
+
chatFirstRouteSendRef.current = { seq: current.seq + 1, id: null };
|
|
2391
|
+
chatFirstRoutedPaneRef.current = null;
|
|
2392
|
+
};
|
|
2393
|
+
window.addEventListener("agent-native:tool-start", cancelPendingRoute);
|
|
2394
|
+
return () =>
|
|
2395
|
+
window.removeEventListener("agent-native:tool-start", cancelPendingRoute);
|
|
2396
|
+
}, [chatFirstMode, isChatRoute]);
|
|
2221
2397
|
const chatFirstRouteLatest = {
|
|
2222
2398
|
onChatRoute: chatFirstMode && isChatRoute,
|
|
2223
2399
|
scope: chatFirstSurfaceScope,
|
|
2224
2400
|
tabsStore: chatFirstSurfaceTabsStore,
|
|
2225
|
-
shownAppId:
|
|
2401
|
+
shownAppId: visiblePaneAppId ?? null,
|
|
2402
|
+
visiblePaneTabId,
|
|
2403
|
+
openPath: visiblePanePath,
|
|
2226
2404
|
registrations: chatFirstAppRegistrations,
|
|
2227
2405
|
openPane: openChatFirstPane,
|
|
2228
2406
|
prefetch: prefetchChatFirstEmbedSession,
|
|
@@ -2267,18 +2445,48 @@ function DispatchLayout({
|
|
|
2267
2445
|
chatFirstRouteSendRef.current = { seq, id: detail.id };
|
|
2268
2446
|
chatFirstRoutedPaneRef.current = null;
|
|
2269
2447
|
provisionalChatFirstTabRef.current = null;
|
|
2448
|
+
turnViewportLockRef.current.beginTurn(`submit:${seq}`);
|
|
2270
2449
|
if (detail.queued) return;
|
|
2271
2450
|
const sentPane = chatFirstPaneSignature(sent.tabsStore.getSnapshot());
|
|
2272
2451
|
const started = performance.now();
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2452
|
+
const reader = chatFirstViewReader.current;
|
|
2453
|
+
const route = async () => {
|
|
2454
|
+
const liveView =
|
|
2455
|
+
reader &&
|
|
2456
|
+
reader.tabId === sent.visiblePaneTabId &&
|
|
2457
|
+
reader.scope === sent.scope
|
|
2458
|
+
? await reader
|
|
2459
|
+
.read(AbortSignal.timeout(CHAT_FIRST_PANE_READ_TIMEOUT_MS))
|
|
2460
|
+
// coercion-ok: An unavailable live read leaves only the registered route as context.
|
|
2461
|
+
.catch(() => null)
|
|
2462
|
+
: null;
|
|
2463
|
+
const latest = chatFirstRouteLatestRef.current;
|
|
2464
|
+
const validView =
|
|
2465
|
+
liveView &&
|
|
2466
|
+
chatFirstViewReader.current === reader &&
|
|
2467
|
+
latest.scope === sent.scope &&
|
|
2468
|
+
latest.visiblePaneTabId === sent.visiblePaneTabId
|
|
2469
|
+
? liveView
|
|
2470
|
+
: null;
|
|
2471
|
+
const openPath = validView?.path ?? sent.openPath;
|
|
2472
|
+
if (validView) void writeActivePaneContext(validView);
|
|
2473
|
+
return callAction(
|
|
2474
|
+
"route-app-intent",
|
|
2475
|
+
{
|
|
2476
|
+
text: detail.text.slice(0, 4000),
|
|
2477
|
+
...(sent.shownAppId ? { openApp: sent.shownAppId } : {}),
|
|
2478
|
+
...(openPath ? { openPath } : {}),
|
|
2479
|
+
...(validView?.selectedText
|
|
2480
|
+
? { selection: validView.selectedText }
|
|
2481
|
+
: {}),
|
|
2482
|
+
...(detail.previousTurn
|
|
2483
|
+
? { previousTurn: detail.previousTurn }
|
|
2484
|
+
: {}),
|
|
2485
|
+
},
|
|
2486
|
+
{ timeoutMs: CHAT_FIRST_ROUTE_TIMEOUT_MS },
|
|
2487
|
+
);
|
|
2488
|
+
};
|
|
2489
|
+
void route()
|
|
2282
2490
|
.then(
|
|
2283
2491
|
(result) => result as ChatFirstAppRouteAnswer,
|
|
2284
2492
|
(error: unknown): ChatFirstAppRouteAnswer | "timeout" =>
|
|
@@ -2303,7 +2511,7 @@ function DispatchLayout({
|
|
|
2303
2511
|
const objectPath = object?.objectId?.startsWith("/")
|
|
2304
2512
|
? object.objectId
|
|
2305
2513
|
: undefined;
|
|
2306
|
-
const resolution =
|
|
2514
|
+
const resolution = resolveDispatchChatFirstAppTarget(
|
|
2307
2515
|
{
|
|
2308
2516
|
app,
|
|
2309
2517
|
...(object?.url ? { url: object.url } : {}),
|
|
@@ -2324,13 +2532,16 @@ function DispatchLayout({
|
|
|
2324
2532
|
? answer.app
|
|
2325
2533
|
: "unrouted",
|
|
2326
2534
|
outcome: answer === "timeout" ? "timeout" : answer.status,
|
|
2327
|
-
plan
|
|
2535
|
+
plan:
|
|
2536
|
+
plan.kind === "skip"
|
|
2537
|
+
? plan
|
|
2538
|
+
: { kind: plan.kind, target: { appId: plan.target.appId } },
|
|
2328
2539
|
latencyMs: Math.round(performance.now() - started),
|
|
2329
2540
|
...(answer !== "timeout" && answer.latencyMs !== undefined
|
|
2330
2541
|
? { hostedLatencyMs: answer.latencyMs }
|
|
2331
2542
|
: {}),
|
|
2332
2543
|
} satisfies ChatFirstAppRouteRecord);
|
|
2333
|
-
if (plan.kind
|
|
2544
|
+
if (plan.kind === "skip") return;
|
|
2334
2545
|
const pane: DispatchChatFirstPane = plan.target;
|
|
2335
2546
|
const registration = now.registrations.find(
|
|
2336
2547
|
(candidate) => candidate.id === pane.appId,
|
|
@@ -2347,11 +2558,17 @@ function DispatchLayout({
|
|
|
2347
2558
|
pane.path ?? registration.path ?? "/",
|
|
2348
2559
|
);
|
|
2349
2560
|
}
|
|
2561
|
+
if (plan.kind !== "open") return;
|
|
2350
2562
|
chatFirstRoutedPaneRef.current = { seq, chat, sentPane, pane };
|
|
2351
2563
|
applyChatFirstRoutedPane();
|
|
2352
2564
|
});
|
|
2353
2565
|
});
|
|
2354
|
-
}, [
|
|
2566
|
+
}, [
|
|
2567
|
+
applyChatFirstRoutedPane,
|
|
2568
|
+
chatFirstMode,
|
|
2569
|
+
isChatRoute,
|
|
2570
|
+
writeActivePaneContext,
|
|
2571
|
+
]);
|
|
2355
2572
|
|
|
2356
2573
|
useEffect(() => {
|
|
2357
2574
|
const target = chatFirstSessionWatch.target;
|
|
@@ -2386,6 +2603,9 @@ function DispatchLayout({
|
|
|
2386
2603
|
),
|
|
2387
2604
|
].find(
|
|
2388
2605
|
(candidate) =>
|
|
2606
|
+
candidate
|
|
2607
|
+
.closest("[data-dispatch-workspace-app-cache-entry]")
|
|
2608
|
+
?.getAttribute("aria-hidden") !== "true" &&
|
|
2389
2609
|
candidate
|
|
2390
2610
|
.closest("[data-chat-first-surface-content]")
|
|
2391
2611
|
?.getAttribute("aria-hidden") !== "true",
|
|
@@ -2525,6 +2745,12 @@ function DispatchLayout({
|
|
|
2525
2745
|
: null;
|
|
2526
2746
|
return renderChatFirstAppSurfaceTab({
|
|
2527
2747
|
registration,
|
|
2748
|
+
...(tab.id === visiblePaneTabId && visiblePaneAppId
|
|
2749
|
+
? {
|
|
2750
|
+
onViewReaderChange: registerChatFirstViewReader,
|
|
2751
|
+
onChildRouteChange: refreshActivePaneContext,
|
|
2752
|
+
}
|
|
2753
|
+
: {}),
|
|
2528
2754
|
embedPath: tab.path ?? registration?.path ?? "/",
|
|
2529
2755
|
placement: tab.placement ?? "main",
|
|
2530
2756
|
loading:
|
|
@@ -2546,7 +2772,7 @@ function DispatchLayout({
|
|
|
2546
2772
|
src={url}
|
|
2547
2773
|
title={title ?? chatFirstCopy("browserPage")}
|
|
2548
2774
|
referrerPolicy="no-referrer"
|
|
2549
|
-
allow="clipboard-read; clipboard-write"
|
|
2775
|
+
allow="clipboard-read; clipboard-write; fullscreen"
|
|
2550
2776
|
className="h-full w-full border-0 bg-background"
|
|
2551
2777
|
/>
|
|
2552
2778
|
)}
|
|
@@ -2608,6 +2834,10 @@ function DispatchLayout({
|
|
|
2608
2834
|
closeChatFirstSurfaceTab,
|
|
2609
2835
|
isMobileSurface,
|
|
2610
2836
|
renderChatFirstWatchChat,
|
|
2837
|
+
registerChatFirstViewReader,
|
|
2838
|
+
refreshActivePaneContext,
|
|
2839
|
+
visiblePaneAppId,
|
|
2840
|
+
visiblePaneTabId,
|
|
2611
2841
|
],
|
|
2612
2842
|
);
|
|
2613
2843
|
|
|
@@ -2650,7 +2880,12 @@ function DispatchLayout({
|
|
|
2650
2880
|
const chatFirstSurfaceContent =
|
|
2651
2881
|
chatFirstSurfaceTabs.tabs.length > 0 ? (
|
|
2652
2882
|
<ChatFirstSurfaceContent
|
|
2653
|
-
tabs={chatFirstSurfaceTabs.tabs
|
|
2883
|
+
tabs={chatFirstSurfaceTabs.tabs.filter(
|
|
2884
|
+
(tab) =>
|
|
2885
|
+
tab.kind !== "app" ||
|
|
2886
|
+
(tab.appId !== undefined &&
|
|
2887
|
+
warmWorkspaceAppIds.includes(tab.appId)),
|
|
2888
|
+
)}
|
|
2654
2889
|
activeTabId={visibleChatFirstSurfaceTabIdValue}
|
|
2655
2890
|
renderTab={renderChatFirstSurfaceTab}
|
|
2656
2891
|
/>
|
|
@@ -2831,9 +3066,12 @@ function DispatchLayout({
|
|
|
2831
3066
|
appName={workspaceAppChatRegistration.name ?? workspaceAppId}
|
|
2832
3067
|
agentPageHref={agentPageHref}
|
|
2833
3068
|
onFullscreenRequest={openAskAgentFullscreen}
|
|
3069
|
+
browserTabId={workspaceAppChildTab.browserTabId}
|
|
2834
3070
|
>
|
|
2835
3071
|
<WorkspaceAppKeepAlive
|
|
2836
3072
|
activeAppId={workspaceAppId}
|
|
3073
|
+
claimBrowserTab
|
|
3074
|
+
onViewReaderChange={workspaceAppChildTab.onViewReaderChange}
|
|
2837
3075
|
{...(workspaceAppDeepPath
|
|
2838
3076
|
? { initialPath: workspaceAppDeepPath }
|
|
2839
3077
|
: {})}
|