@agent-native/dispatch 0.23.2 → 0.23.5

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.
Files changed (86) hide show
  1. package/dist/actions/provider-api-register.d.ts +11 -11
  2. package/dist/components/app-list-row.d.ts +1 -1
  3. package/dist/components/app-list-row.d.ts.map +1 -1
  4. package/dist/components/app-list-row.js +2 -2
  5. package/dist/components/app-list-row.js.map +1 -1
  6. package/dist/components/app-open-actions.d.ts.map +1 -1
  7. package/dist/components/app-open-actions.js +3 -2
  8. package/dist/components/app-open-actions.js.map +1 -1
  9. package/dist/components/create-app-popover.d.ts.map +1 -1
  10. package/dist/components/create-app-popover.js +11 -0
  11. package/dist/components/create-app-popover.js.map +1 -1
  12. package/dist/components/dispatch-control-plane.d.ts.map +1 -1
  13. package/dist/components/dispatch-control-plane.js +3 -2
  14. package/dist/components/dispatch-control-plane.js.map +1 -1
  15. package/dist/components/layout/Layout.d.ts +5 -2
  16. package/dist/components/layout/Layout.d.ts.map +1 -1
  17. package/dist/components/layout/Layout.js +122 -13
  18. package/dist/components/layout/Layout.js.map +1 -1
  19. package/dist/components/layout/workspace-apps-rail.d.ts.map +1 -1
  20. package/dist/components/layout/workspace-apps-rail.js +3 -23
  21. package/dist/components/layout/workspace-apps-rail.js.map +1 -1
  22. package/dist/components/other-apps-section.d.ts.map +1 -1
  23. package/dist/components/other-apps-section.js +5 -1
  24. package/dist/components/other-apps-section.js.map +1 -1
  25. package/dist/components/workspace-app-card.d.ts.map +1 -1
  26. package/dist/components/workspace-app-card.js +3 -4
  27. package/dist/components/workspace-app-card.js.map +1 -1
  28. package/dist/components/workspace-template-card.d.ts.map +1 -1
  29. package/dist/components/workspace-template-card.js +1 -1
  30. package/dist/components/workspace-template-card.js.map +1 -1
  31. package/dist/config.d.ts +2 -0
  32. package/dist/config.d.ts.map +1 -1
  33. package/dist/config.js.map +1 -1
  34. package/dist/lib/other-apps.d.ts.map +1 -1
  35. package/dist/lib/other-apps.js +2 -0
  36. package/dist/lib/other-apps.js.map +1 -1
  37. package/dist/lib/workspace-apps.d.ts +4 -0
  38. package/dist/lib/workspace-apps.d.ts.map +1 -1
  39. package/dist/lib/workspace-apps.js +23 -0
  40. package/dist/lib/workspace-apps.js.map +1 -1
  41. package/dist/routes/index.js +1 -1
  42. package/dist/routes/index.js.map +1 -1
  43. package/dist/routes/pages/agent-integrations.d.ts +5 -0
  44. package/dist/routes/pages/agent-integrations.d.ts.map +1 -0
  45. package/dist/routes/pages/agent-integrations.js +15 -0
  46. package/dist/routes/pages/agent-integrations.js.map +1 -0
  47. package/dist/routes/pages/apps.$appId.d.ts.map +1 -1
  48. package/dist/routes/pages/apps.$appId.js +14 -2
  49. package/dist/routes/pages/apps.$appId.js.map +1 -1
  50. package/dist/routes/pages/apps.d.ts.map +1 -1
  51. package/dist/routes/pages/apps.js +2 -1
  52. package/dist/routes/pages/apps.js.map +1 -1
  53. package/dist/routes/pages/overview.d.ts +2 -2
  54. package/dist/routes/pages/settings.d.ts.map +1 -1
  55. package/dist/routes/pages/settings.js +1 -1
  56. package/dist/routes/pages/settings.js.map +1 -1
  57. package/dist/server/plugins/auth.d.ts.map +1 -1
  58. package/dist/server/plugins/auth.js +1 -0
  59. package/dist/server/plugins/auth.js.map +1 -1
  60. package/package.json +3 -3
  61. package/src/components/app-list-row.tsx +3 -2
  62. package/src/components/app-open-actions.tsx +3 -2
  63. package/src/components/create-app-popover.spec.tsx +26 -2
  64. package/src/components/create-app-popover.tsx +10 -0
  65. package/src/components/dispatch-control-plane.spec.tsx +1 -0
  66. package/src/components/dispatch-control-plane.tsx +8 -2
  67. package/src/components/layout/Layout.spec.tsx +9 -0
  68. package/src/components/layout/Layout.tsx +181 -19
  69. package/src/components/layout/workspace-apps-rail.tsx +4 -26
  70. package/src/components/other-apps-section.tsx +8 -1
  71. package/src/components/workspace-app-card.spec.tsx +6 -6
  72. package/src/components/workspace-app-card.tsx +4 -7
  73. package/src/components/workspace-template-card.spec.tsx +4 -16
  74. package/src/components/workspace-template-card.tsx +0 -1
  75. package/src/config.ts +2 -0
  76. package/src/lib/other-apps.spec.ts +26 -0
  77. package/src/lib/other-apps.ts +3 -0
  78. package/src/lib/workspace-apps.spec.ts +44 -0
  79. package/src/lib/workspace-apps.ts +27 -0
  80. package/src/routes/index.ts +1 -1
  81. package/src/routes/pages/agent-integrations.tsx +24 -0
  82. package/src/routes/pages/apps.$appId.tsx +19 -1
  83. package/src/routes/pages/apps.tsx +5 -2
  84. package/src/routes/pages/settings.tsx +1 -19
  85. package/src/server/plugins/auth.spec.ts +45 -0
  86. package/src/server/plugins/auth.ts +1 -0
@@ -16,7 +16,7 @@ import { createContext, useEffect, useMemo, useRef, useState, useContext, useCal
16
16
  import { Link, useLocation, useNavigate } from "react-router";
17
17
  import { toast } from "sonner";
18
18
  import { cn } from "../../lib/utils.js";
19
- import { mergeChatFirstWorkspaceApps, } from "../../lib/workspace-apps.js";
19
+ import { isDispatchWorkspaceAppId, isWorkspaceAppVisibleInDefaultLaunchers, mergeChatFirstWorkspaceApps, workspaceAppIdFromRoute, workspaceAppRoute, } from "../../lib/workspace-apps.js";
20
20
  import { AppIcon } from "../app-icon.js";
21
21
  import { CreateAppPopover } from "../create-app-popover.js";
22
22
  import { Sheet, SheetContent, SheetDescription, SheetTitle } from "../ui/sheet.js";
@@ -115,6 +115,27 @@ function localDispatchPath(pathname) {
115
115
  }
116
116
  return pathname;
117
117
  }
118
+ export function isElectronEmbeddedSearch(search) {
119
+ return new URLSearchParams(search).get("electron") === "1";
120
+ }
121
+ function chatFirstPrimaryTabForPath(pathname) {
122
+ if (pathname === "/chat" || pathname.startsWith("/chat/")) {
123
+ return "new-chat";
124
+ }
125
+ if (pathname === "/integrations" ||
126
+ pathname.startsWith("/integrations/") ||
127
+ pathname === "/admin/integrations" ||
128
+ pathname.startsWith("/admin/integrations/")) {
129
+ return "integrations";
130
+ }
131
+ if (pathname === "/automations" ||
132
+ pathname.startsWith("/automations/") ||
133
+ pathname === "/admin/automations" ||
134
+ pathname.startsWith("/admin/automations/")) {
135
+ return "scheduled";
136
+ }
137
+ return undefined;
138
+ }
118
139
  function dispatchNavLinkTarget(path) {
119
140
  if (typeof window === "undefined")
120
141
  return path;
@@ -420,7 +441,10 @@ function DispatchChatsSection({ onNavigate, showNewChat = false, prelude, chatFi
420
441
  if (threadId)
421
442
  openThread(threadId, { isNew: true });
422
443
  }
423
- return (_jsxs("div", { className: cn("min-w-0 space-y-0.5", showNewChat && "dispatch-chat-first-chats"), children: [showNewChat && chatFirstNavigation ? (_jsx("nav", { className: "space-y-0.5 px-0 py-2", children: _jsx(ChatFirstPrimaryNavigation, { copy: chatFirstCopy, onNewChat: () => void handleNewChat(), onOpenIntegrations: chatFirstNavigation.onOpenIntegrations, onOpenScheduled: chatFirstNavigation.onOpenScheduled, onSearch: openCommandMenu }) })) : null, prelude, !chatFirstMode ? (_jsx("div", { className: "flex justify-end px-2 pt-0.5", children: _jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { asChild: true, children: _jsx("button", { type: "button", "data-dispatch-chat-source-toggle": true, "aria-pressed": includeExternal, "aria-label": includeExternal
444
+ return (_jsxs("div", { className: cn("min-w-0 space-y-0.5", showNewChat && "dispatch-chat-first-chats"), children: [showNewChat && chatFirstNavigation ? (_jsx("nav", { className: "space-y-0.5 px-2 py-2", children: _jsx(ChatFirstPrimaryNavigation, { copy: chatFirstCopy, onNewChat: () => {
445
+ chatFirstNavigation.onNewChat?.();
446
+ void handleNewChat();
447
+ }, onOpenIntegrations: chatFirstNavigation.onOpenIntegrations, onOpenScheduled: chatFirstNavigation.onOpenScheduled, onSearch: openCommandMenu, activeTab: chatFirstNavigation.activeTab }) })) : null, prelude, !chatFirstMode ? (_jsx("div", { className: "flex justify-end px-2 pt-0.5", children: _jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { asChild: true, children: _jsx("button", { type: "button", "data-dispatch-chat-source-toggle": true, "aria-pressed": includeExternal, "aria-label": includeExternal
424
448
  ? t("dispatch.sidebar.showLocalChats", {
425
449
  defaultValue: "Show local chats",
426
450
  })
@@ -458,7 +482,7 @@ function DispatchChatsSection({ onNavigate, showNewChat = false, prelude, chatFi
458
482
  kind: "agent-chat",
459
483
  sourceSessionId: displayedActiveThreadId ?? undefined,
460
484
  });
461
- }, children: [_jsx(IconEye, { size: 13, strokeWidth: 1.8 }), _jsx("span", { children: "Watch and message session" })] })) : null] })), className: "min-w-0" })) : (_jsx(ChatHistoryRail, { items: chatItems, activeId: displayedActiveThreadId, onSelect: (threadId) => openThread(threadId), onNewChat: () => void handleNewChat(), railLabels: {
485
+ }, children: [_jsx(IconEye, { size: 13, strokeWidth: 1.8 }), _jsx("span", { children: "Watch and message session" })] })) : null] })), className: "min-w-0 px-2" })) : (_jsx(ChatHistoryRail, { items: chatItems, activeId: displayedActiveThreadId, onSelect: (threadId) => openThread(threadId), onNewChat: () => void handleNewChat(), railLabels: {
462
486
  newChat: t("dispatch.sidebar.newChat"),
463
487
  showMore: t("dispatch.sidebar.chats"),
464
488
  showLess: t("dispatch.sidebar.chats"),
@@ -485,9 +509,9 @@ function DispatchChatsSection({ onNavigate, showNewChat = false, prelude, chatFi
485
509
  kind: "agent-chat",
486
510
  sourceSessionId: displayedActiveThreadId ?? undefined,
487
511
  });
488
- }, children: [_jsx(IconEye, { size: 13, strokeWidth: 1.8 }), _jsx("span", { children: "Watch and message session" })] })) : null] })), className: "min-w-0" }))] }));
512
+ }, children: [_jsx(IconEye, { size: 13, strokeWidth: 1.8 }), _jsx("span", { children: "Watch and message session" })] })) : null] })), className: cn("min-w-0", chatFirstMode && "px-2") }))] }));
489
513
  }
490
- export function NavContent({ onNavigate, extensions, chatFirstMode = false, chatFirstEmbedded = false, collapsed = false, collapsible = false, onCollapsedChange, chatFirstAppLayout, onChatFirstAppLayoutChange, chatFirstApps = [], chatFirstAppsLoading = false, chatFirstAppsError, chatFirstActiveAppId, onChatFirstAppOpen, onChatFirstAppsRetry, }) {
514
+ export function NavContent({ onNavigate, extensions, chatFirstMode = false, chatFirstEmbedded = false, collapsed = false, collapsible = false, onCollapsedChange, chatFirstAppLayout, onChatFirstAppLayoutChange, chatFirstApps = [], chatFirstAppsLoading = false, chatFirstAppsError, chatFirstActiveAppId, chatFirstActivePrimaryTab, onChatFirstNewChat, onChatFirstAppOpen, onChatFirstAppsRetry, }) {
491
515
  const t = useT();
492
516
  const chatFirstCopy = useMemo(() => createDispatchChatFirstCopy(t), [t]);
493
517
  const location = useLocation();
@@ -559,6 +583,8 @@ export function NavContent({ onNavigate, extensions, chatFirstMode = false, chat
559
583
  const organizationPicker = (_jsx("div", { className: cn("py-2", collapsed ? "flex justify-center px-1" : "px-3"), children: _jsx(OrgSwitcher, { compact: collapsed, reserveSpace: true }) }));
560
584
  const sidebarFooterActions = (_jsx(SidebarFooterActions, { collapsed: collapsed, feedback: feedbackButton, search: searchButton, collapse: collapseButton }));
561
585
  return (_jsxs(_Fragment, { children: [_jsx("div", { className: cn("flex h-12 shrink-0 items-center border-b border-sidebar-border", collapsed ? "justify-center px-0" : "px-4"), children: _jsxs("div", { className: cn("flex items-center", collapsed ? "justify-center" : "gap-2"), children: [_jsx("img", { src: appPath("/agent-native-icon-light.svg"), alt: "", "aria-hidden": "true", width: 35, height: 20, className: cn("block shrink-0 object-contain object-center dark:hidden", collapsed ? "h-4 w-7" : "h-5 w-[35px]") }), _jsx("img", { src: appPath("/agent-native-icon-dark.svg"), alt: "", "aria-hidden": "true", width: 35, height: 20, className: cn("hidden shrink-0 object-contain object-center dark:block", collapsed ? "h-4 w-7" : "h-5 w-[35px]") }), !collapsed && (_jsx("div", { className: "min-w-0 flex-1", children: _jsx("div", { "data-dispatch-sidebar-label": true, className: "truncate text-lg font-bold tracking-tight text-foreground", children: DISPATCH_SIDEBAR_LABEL }) }))] }) }), chatFirstMode ? (_jsx("div", { className: "flex min-h-0 flex-1 flex-col overflow-y-auto", children: !collapsed ? (_jsx(DispatchChatsSection, { onNavigate: onNavigate, showNewChat: true, chatFirstMode: true, chatFirstEmbedded: chatFirstEmbedded, chatFirstNavigation: {
586
+ activeTab: chatFirstActivePrimaryTab,
587
+ onNewChat: onChatFirstNewChat,
562
588
  onOpenIntegrations: () => {
563
589
  navigate(dispatchNavLinkTarget("/admin/integrations"));
564
590
  onNavigate?.();
@@ -585,6 +611,9 @@ export function Layout({ children, extensions, agentPageHref, }) {
585
611
  }
586
612
  });
587
613
  const localPathname = localDispatchPath(location.pathname);
614
+ const [electronEmbedded] = useState(() => typeof window !== "undefined"
615
+ ? isElectronEmbeddedSearch(window.location.search)
616
+ : false);
588
617
  const isChatRoute = localPathname === "/chat" || localPathname.startsWith("/chat/");
589
618
  const chatFirstSurfaceScope = threadIdFromPath(localPathname) ?? "new";
590
619
  const isWorkspaceAppRoute = localPathname.startsWith("/apps/");
@@ -596,6 +625,21 @@ export function Layout({ children, extensions, agentPageHref, }) {
596
625
  new URLSearchParams(window.location.search).get("chatFirst") === "1";
597
626
  const chatFirstMode = extensions?.chatFirst === true || chatFirstPreference || chatFirstEmbedded;
598
627
  const chatFirstHasActiveChat = chatFirstSurfaceScope !== "new";
628
+ useEffect(() => {
629
+ if (!electronEmbedded || typeof window === "undefined")
630
+ return;
631
+ const url = new URL(window.location.href);
632
+ if (isElectronEmbeddedSearch(url.search))
633
+ return;
634
+ url.searchParams.set("electron", "1");
635
+ window.history.replaceState(window.history.state, "", `${url.pathname}${url.search}${url.hash}`);
636
+ }, [electronEmbedded, location.pathname, location.search]);
637
+ useEffect(() => {
638
+ if (!chatFirstMode || chatFirstEmbedded || localPathname !== "/overview") {
639
+ return;
640
+ }
641
+ navigate(dispatchNavLinkTarget("/chat"), { replace: true });
642
+ }, [chatFirstEmbedded, chatFirstMode, localPathname, navigate]);
599
643
  const [chatFirstAppLayout, setChatFirstAppLayout] = useState(() => readChatFirstAppLayout());
600
644
  const chatFirstAppLayoutHydratedRef = useRef(false);
601
645
  const chatFirstAppsQuery = useActionQuery("list-workspace-apps", { includeAgentCards: false }, { enabled: chatFirstMode });
@@ -626,7 +670,7 @@ export function Layout({ children, extensions, agentPageHref, }) {
626
670
  return [...registrations.values()];
627
671
  }, [chatFirstGrantedAppsQuery.data?.apps, chatFirstWorkspaceApps]);
628
672
  const chatFirstAppItems = useMemo(() => chatFirstAppRegistrations
629
- .filter((app) => app.enabled)
673
+ .filter((app) => app.enabled && isWorkspaceAppVisibleInDefaultLaunchers(app))
630
674
  .map((app) => ({
631
675
  id: app.id,
632
676
  name: app.name ?? app.id,
@@ -637,6 +681,7 @@ export function Layout({ children, extensions, agentPageHref, }) {
637
681
  const [chatFirstEmbedUrl, setChatFirstEmbedUrl] = useState(null);
638
682
  const [chatFirstEmbedError, setChatFirstEmbedError] = useState(null);
639
683
  const [chatFirstEmbedAttempt, setChatFirstEmbedAttempt] = useState(0);
684
+ const chatFirstAppFrameRef = useRef(null);
640
685
  const [chatFirstNotice, setChatFirstNotice] = useState(null);
641
686
  const chatFirstSessionWatch = useChatFirstSessionWatch();
642
687
  const chatFirstSurfaceTabs = useChatFirstSurfaceTabs(chatFirstSurfaceScope);
@@ -658,6 +703,18 @@ export function Layout({ children, extensions, agentPageHref, }) {
658
703
  isChatRoute &&
659
704
  activeChatFirstSurfaceTab?.kind === "app" &&
660
705
  activeChatFirstSurfaceTab.placement === "main";
706
+ const chatFirstAppSelected = chatFirstMode && activeChatFirstSurfaceTab?.kind === "app";
707
+ const chatFirstActivePrimaryTab = chatFirstAppSelected
708
+ ? activeChatFirstSurfaceTab?.kind === "app" &&
709
+ activeChatFirstSurfaceTab.appId === "dispatch"
710
+ ? chatFirstPrimaryTabForPath(activeChatFirstSurfaceTab.path ?? "")
711
+ : undefined
712
+ : chatFirstPrimaryTabForPath(localPathname);
713
+ const chatFirstActiveAppId = isWorkspaceAppRoute
714
+ ? (workspaceAppIdFromRoute(localPathname) ?? undefined)
715
+ : chatFirstAppSelected && activeChatFirstSurfaceTab?.kind === "app"
716
+ ? activeChatFirstSurfaceTab.appId
717
+ : undefined;
661
718
  const activeChatFirstAppRegistration = useMemo(() => activeChatFirstSurfaceTab?.kind === "app" &&
662
719
  activeChatFirstSurfaceTab.appId
663
720
  ? (chatFirstAppRegistrations.find((app) => app.id === activeChatFirstSurfaceTab.appId) ?? null)
@@ -721,12 +778,37 @@ export function Layout({ children, extensions, agentPageHref, }) {
721
778
  createChatFirstEmbedSession.mutateAsync,
722
779
  isChatRoute,
723
780
  ]);
781
+ useEffect(() => {
782
+ if (!chatFirstMode || !isChatRoute || !activeChatFirstApp)
783
+ return;
784
+ const handleEmbedSessionExpired = (event) => {
785
+ if (event.data?.type !== "agentNative.embedSessionExpired" ||
786
+ event.source !== chatFirstAppFrameRef.current?.contentWindow) {
787
+ return;
788
+ }
789
+ setChatFirstEmbedAttempt((attempt) => attempt + 1);
790
+ };
791
+ window.addEventListener("message", handleEmbedSessionExpired);
792
+ return () => window.removeEventListener("message", handleEmbedSessionExpired);
793
+ }, [activeChatFirstApp, chatFirstMode, isChatRoute]);
724
794
  const persistChatFirstPane = useCallback((pane) => {
725
795
  setChatFirstPane(pane);
726
796
  void writeClientAppState(CHAT_FIRST_PANE_STATE_KEY, pane).catch(() => {
727
797
  setChatFirstNotice("The app pane opened locally, but its focus could not be synced.");
728
798
  });
729
799
  }, []);
800
+ useEffect(() => {
801
+ if (!chatFirstMode || isChatRoute)
802
+ return;
803
+ persistChatFirstPane(null);
804
+ closeChatFirstSessionWatch();
805
+ chatFirstSurfaceTabsStore.closeAll();
806
+ }, [
807
+ chatFirstMode,
808
+ chatFirstSurfaceTabsStore,
809
+ isChatRoute,
810
+ persistChatFirstPane,
811
+ ]);
730
812
  const openChatFirstPane = useCallback((pane, placement = "side") => {
731
813
  if (placement === "side" && !chatFirstHasActiveChat)
732
814
  return;
@@ -826,13 +908,28 @@ export function Layout({ children, extensions, agentPageHref, }) {
826
908
  setChatFirstNotice(chatFirstResolutionMessage(resolution.reason));
827
909
  return;
828
910
  }
911
+ if (isDispatchWorkspaceAppId(resolution.target.appId)) {
912
+ closeChatFirstSessionWatch();
913
+ chatFirstSurfaceTabsStore.closeAll();
914
+ setChatFirstSurfacePanelOpen(false);
915
+ persistChatFirstPane(null);
916
+ if (resolution.target.path) {
917
+ navigateWithAgentChatViewTransition(navigate, dispatchNavLinkTarget(resolution.target.path));
918
+ }
919
+ return;
920
+ }
829
921
  openChatFirstPane(resolution.target);
830
922
  }, [
831
923
  chatFirstAppRegistrations,
832
924
  chatFirstAppsQuery.isError,
833
925
  chatFirstAppsQuery.isLoading,
834
926
  chatFirstGrantedAppsQuery.isLoading,
927
+ chatFirstSurfaceTabsStore,
928
+ closeChatFirstSessionWatch,
835
929
  openChatFirstPane,
930
+ navigate,
931
+ persistChatFirstPane,
932
+ setChatFirstSurfacePanelOpen,
836
933
  ]);
837
934
  const chatHomeHandoffActive = useAgentChatHomeHandoff({
838
935
  storageKey: "dispatch",
@@ -1120,7 +1217,7 @@ export function Layout({ children, extensions, agentPageHref, }) {
1120
1217
  ? "loading"
1121
1218
  : app
1122
1219
  ? "loading"
1123
- : "unresolved", embedUrl: chatFirstEmbedUrl, errorMessage: chatFirstEmbedError, onRetry: () => setChatFirstEmbedAttempt((value) => value + 1), renderEmbed: ({ url, title }) => (_jsx("iframe", { "data-dispatch-chat-first-app-frame": true, src: url, title: title ?? chatFirstCopy("appUnavailable"), referrerPolicy: "no-referrer", allow: "clipboard-read; clipboard-write", className: "h-full w-full border-0 bg-background" })), copy: chatFirstCopy }));
1220
+ : "unresolved", embedUrl: chatFirstEmbedUrl, errorMessage: chatFirstEmbedError, onRetry: () => setChatFirstEmbedAttempt((value) => value + 1), renderEmbed: ({ url, title }) => (_jsx("iframe", { "data-dispatch-chat-first-app-frame": true, src: url, title: title ?? chatFirstCopy("appUnavailable"), ref: chatFirstAppFrameRef, referrerPolicy: "no-referrer", allow: "clipboard-read; clipboard-write", className: "h-full w-full border-0 bg-background" })), copy: chatFirstCopy }));
1124
1221
  }
1125
1222
  if (tab.kind === "browser" && tab.url) {
1126
1223
  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 }));
@@ -1161,6 +1258,9 @@ export function Layout({ children, extensions, agentPageHref, }) {
1161
1258
  if (CHROMELESS_PATHS.some((path) => localPathname === path)) {
1162
1259
  return _jsx(_Fragment, { children: children });
1163
1260
  }
1261
+ if (electronEmbedded) {
1262
+ return (_jsx(DispatchExtensionsContext.Provider, { value: extensions, children: _jsx(HeaderActionsProvider, { children: _jsx("div", { "data-dispatch-electron-control-plane": true, className: "flex h-screen w-full overflow-hidden bg-background", children: _jsxs("div", { className: "relative flex min-w-0 flex-1 flex-col overflow-hidden", children: [_jsx(Header, { showAgentToggle: false }), _jsx(InvitationBanner, {}), _jsx("main", { className: "flex-1 overflow-y-auto", children: _jsx("div", { className: "mx-auto max-w-7xl space-y-10 px-4 py-6 sm:px-6", children: children }) })] }) }) }) }));
1263
+ }
1164
1264
  if (isWorkspaceAppHostRoute) {
1165
1265
  return (_jsx(DispatchExtensionsContext.Provider, { value: extensions, children: _jsx(HeaderActionsProvider, { children: _jsx("div", { "data-dispatch-workspace-app-chrome-less": true, className: "h-screen w-full overflow-hidden bg-background", children: children }) }) }));
1166
1266
  }
@@ -1193,12 +1293,21 @@ export function Layout({ children, extensions, agentPageHref, }) {
1193
1293
  chatFirstSurfacePanel.open ? (_jsxs(ChatFirstSurfacePanel, { width: chatFirstSurfaceResize.width, onResizePointerDown: chatFirstSurfaceResize.onPointerDown, copy: chatFirstCopy, children: [chatFirstSurfaceTabsBar, chatFirstSurfaceContent] })) : null] })) })) : isWorkspaceAppRoute ? (appContent) : (_jsx(AgentSidebar, { position: "right", defaultOpen: false, agentPageHref: agentPageHref, chatViewTransition: true, storageKey: "dispatch", openOnChatRunning: chatHomeHandoffActive, onFullscreenRequest: openAskAgentFullscreen, emptyStateText: t("dispatch.sidebar.emptyAgentText"), suggestions: sidebarSuggestions, children: appContent }));
1194
1294
  return (_jsx(DispatchExtensionsContext.Provider, { value: extensions, children: _jsx(HeaderActionsProvider, { children: _jsxs("div", { className: "agent-layout-shell flex h-screen w-full overflow-hidden bg-background", children: [_jsx("aside", { "data-collapsed": sidebarCollapsed ? "true" : "false", className: cn("agent-layout-left-drawer hidden shrink-0 flex-col border-e !border-e-sidebar-border bg-sidebar text-sidebar-foreground transition-[width] duration-200 ease-out lg:flex", sidebarCollapsed ? "w-14" : "w-56"), children: _jsx(NavContent, { extensions: extensions, chatFirstMode: chatFirstMode, chatFirstEmbedded: chatFirstEmbedded, collapsed: sidebarCollapsed, chatFirstAppLayout: chatFirstAppLayout, onChatFirstAppLayoutChange: persistChatFirstAppLayout, chatFirstApps: chatFirstAppItems, chatFirstAppsLoading: chatFirstAppsQuery.isLoading, chatFirstAppsError: chatFirstAppsQuery.isError
1195
1295
  ? chatFirstCopy("appsLoadError")
1196
- : null, chatFirstActiveAppId: activeChatFirstSurfaceTab?.kind === "app"
1197
- ? activeChatFirstSurfaceTab.appId
1198
- : undefined, onChatFirstAppOpen: (app) => openChatFirstPane({ appId: app.id }, "main"), onChatFirstAppsRetry: () => void chatFirstAppsQuery.refetch(), collapsible: true, onCollapsedChange: setSidebarCollapsed }) }), _jsx(Sheet, { open: mobileOpen, onOpenChange: setMobileOpen, children: _jsxs(SheetContent, { side: "left", className: "w-72 bg-sidebar p-0 text-sidebar-foreground [&>button]:hidden", children: [_jsx(SheetTitle, { className: "sr-only", children: t("dispatch.nav.navigation") }), _jsx(SheetDescription, { className: "sr-only", children: t("dispatch.nav.navigationDescription") }), _jsx("div", { className: "flex h-full w-full flex-col", children: _jsx(NavContent, { extensions: extensions, chatFirstMode: chatFirstMode, chatFirstEmbedded: chatFirstEmbedded, collapsed: false, chatFirstAppLayout: chatFirstAppLayout, onChatFirstAppLayoutChange: persistChatFirstAppLayout, chatFirstApps: chatFirstAppItems, chatFirstAppsLoading: chatFirstAppsQuery.isLoading, chatFirstAppsError: chatFirstAppsQuery.isError
1296
+ : null, chatFirstActiveAppId: chatFirstActiveAppId, chatFirstActivePrimaryTab: chatFirstActivePrimaryTab, onChatFirstNewChat: () => {
1297
+ closeChatFirstSessionWatch();
1298
+ chatFirstSurfaceTabsStore.closeAll();
1299
+ setChatFirstSurfacePanelOpen(false);
1300
+ }, onChatFirstAppOpen: (app) => {
1301
+ if (isDispatchWorkspaceAppId(app.id))
1302
+ return;
1303
+ setSidebarCollapsed(true);
1304
+ navigate(dispatchNavLinkTarget(workspaceAppRoute(app.id)));
1305
+ }, onChatFirstAppsRetry: () => void chatFirstAppsQuery.refetch(), collapsible: true, onCollapsedChange: setSidebarCollapsed }) }), _jsx(Sheet, { open: mobileOpen, onOpenChange: setMobileOpen, children: _jsxs(SheetContent, { side: "left", className: "w-72 bg-sidebar p-0 text-sidebar-foreground [&>button]:hidden", children: [_jsx(SheetTitle, { className: "sr-only", children: t("dispatch.nav.navigation") }), _jsx(SheetDescription, { className: "sr-only", children: t("dispatch.nav.navigationDescription") }), _jsx("div", { className: "flex h-full w-full flex-col", children: _jsx(NavContent, { extensions: extensions, chatFirstMode: chatFirstMode, chatFirstEmbedded: chatFirstEmbedded, collapsed: false, chatFirstAppLayout: chatFirstAppLayout, onChatFirstAppLayoutChange: persistChatFirstAppLayout, chatFirstApps: chatFirstAppItems, chatFirstAppsLoading: chatFirstAppsQuery.isLoading, chatFirstAppsError: chatFirstAppsQuery.isError
1199
1306
  ? chatFirstCopy("appsLoadError")
1200
- : null, chatFirstActiveAppId: activeChatFirstSurfaceTab?.kind === "app"
1201
- ? activeChatFirstSurfaceTab.appId
1202
- : undefined, onChatFirstAppOpen: (app) => openChatFirstPane({ appId: app.id }, "main"), onChatFirstAppsRetry: () => void chatFirstAppsQuery.refetch(), onNavigate: () => setMobileOpen(false) }) })] }) }), content] }) }) }));
1307
+ : null, chatFirstActiveAppId: chatFirstActiveAppId, chatFirstActivePrimaryTab: chatFirstActivePrimaryTab, onChatFirstNewChat: () => {
1308
+ closeChatFirstSessionWatch();
1309
+ chatFirstSurfaceTabsStore.closeAll();
1310
+ setChatFirstSurfacePanelOpen(false);
1311
+ }, onChatFirstAppOpen: (app) => navigate(dispatchNavLinkTarget(workspaceAppRoute(app.id))), onChatFirstAppsRetry: () => void chatFirstAppsQuery.refetch(), onNavigate: () => setMobileOpen(false) }) })] }) }), content] }) }) }));
1203
1312
  }
1204
1313
  //# sourceMappingURL=Layout.js.map