@agent-native/dispatch 0.8.18 → 0.8.20
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/README.md +22 -2
- package/dist/actions/navigate.js +1 -1
- package/dist/actions/navigate.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/view-screen.d.ts.map +1 -1
- package/dist/actions/view-screen.js +6 -0
- package/dist/actions/view-screen.js.map +1 -1
- package/dist/components/create-app-popover.js +3 -3
- package/dist/components/create-app-popover.js.map +1 -1
- package/dist/components/layout/Layout.d.ts.map +1 -1
- package/dist/components/layout/Layout.js +149 -14
- package/dist/components/layout/Layout.js.map +1 -1
- package/dist/hooks/use-navigation-state.js +5 -0
- package/dist/hooks/use-navigation-state.js.map +1 -1
- package/dist/lib/overview-chat.d.ts +3 -1
- package/dist/lib/overview-chat.d.ts.map +1 -1
- package/dist/lib/overview-chat.js +2 -1
- package/dist/lib/overview-chat.js.map +1 -1
- package/dist/routes/index.d.ts.map +1 -1
- package/dist/routes/index.js +1 -0
- package/dist/routes/index.js.map +1 -1
- package/dist/routes/pages/_index.js +1 -1
- package/dist/routes/pages/_index.js.map +1 -1
- package/dist/routes/pages/apps.d.ts.map +1 -1
- package/dist/routes/pages/apps.js +3 -1
- package/dist/routes/pages/apps.js.map +1 -1
- package/dist/routes/pages/chat.d.ts +5 -0
- package/dist/routes/pages/chat.d.ts.map +1 -0
- package/dist/routes/pages/chat.js +55 -0
- package/dist/routes/pages/chat.js.map +1 -0
- package/dist/routes/pages/overview.d.ts.map +1 -1
- package/dist/routes/pages/overview.js +20 -7
- package/dist/routes/pages/overview.js.map +1 -1
- package/dist/server/lib/app-creation-store.d.ts.map +1 -1
- package/dist/server/lib/app-creation-store.js +18 -0
- package/dist/server/lib/app-creation-store.js.map +1 -1
- package/dist/server/plugins/agent-chat.js +1 -1
- package/dist/server/plugins/agent-chat.js.map +1 -1
- package/dist/server/plugins/integrations.js +2 -2
- package/dist/server/plugins/integrations.js.map +1 -1
- package/package.json +1 -1
- package/src/actions/navigate.ts +1 -1
- package/src/actions/start-workspace-app-creation.ts +1 -1
- package/src/actions/view-screen.ts +7 -0
- package/src/components/create-app-popover.tsx +3 -3
- package/src/components/layout/Layout.tsx +307 -19
- package/src/hooks/use-navigation-state.spec.ts +7 -0
- package/src/hooks/use-navigation-state.ts +4 -0
- package/src/lib/overview-chat.spec.ts +15 -0
- package/src/lib/overview-chat.ts +2 -0
- package/src/routes/index.ts +1 -0
- package/src/routes/pages/_index.tsx +1 -1
- package/src/routes/pages/apps.tsx +4 -0
- package/src/routes/pages/chat.tsx +99 -0
- package/src/routes/pages/overview.tsx +21 -5
- package/src/server/lib/app-creation-store.spec.ts +15 -0
- package/src/server/lib/app-creation-store.ts +18 -0
- package/src/server/plugins/agent-chat.ts +1 -1
- package/src/server/plugins/integrations.ts +2 -2
- package/src/styles/dispatch-css.spec.ts +9 -0
- package/src/styles/dispatch.css +103 -0
|
@@ -1,15 +1,25 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { useState } from "react";
|
|
3
|
-
import { NavLink, useLocation } from "react-router";
|
|
4
|
-
import { AgentSidebar, FeedbackButton, appBasePath, appPath, useActionQuery, } from "@agent-native/core/client";
|
|
2
|
+
import { useEffect, useMemo, useRef, useState, } from "react";
|
|
3
|
+
import { NavLink, useLocation, useNavigate } from "react-router";
|
|
4
|
+
import { AgentSidebar, FeedbackButton, appBasePath, appPath, useActionQuery, useChatThreads, } from "@agent-native/core/client";
|
|
5
5
|
import { ExtensionsSidebarSection } from "@agent-native/core/client/extensions";
|
|
6
6
|
import { InvitationBanner, OrgSwitcher } from "@agent-native/core/client/org";
|
|
7
|
-
import { IconArrowUpRight, IconApps, IconBrain, IconChartBar, IconBrandTelegram, IconKey, IconChevronDown, IconLayersSubtract, IconMessages, IconPlugConnected, IconBroadcast, IconFingerprint, IconHistory, IconPuzzle, IconShieldCheck, IconUsersGroup, } from "@tabler/icons-react";
|
|
7
|
+
import { IconArrowUpRight, IconApps, IconBrain, IconChartBar, IconBrandTelegram, IconKey, IconChevronDown, IconDots, IconEdit, IconLayersSubtract, IconMessageQuestion, IconMessages, IconPlus, IconPlugConnected, IconBroadcast, IconFingerprint, IconHistory, IconPuzzle, IconShieldCheck, IconUsersGroup, } from "@tabler/icons-react";
|
|
8
8
|
import { cn } from "../../lib/utils.js";
|
|
9
|
+
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, } from "../../components/ui/dropdown-menu.js";
|
|
10
|
+
import { Input } from "../../components/ui/input.js";
|
|
9
11
|
import { Sheet, SheetContent, SheetDescription, SheetTitle, } from "../../components/ui/sheet.js";
|
|
12
|
+
import { Tooltip, TooltipContent, TooltipTrigger, } from "../../components/ui/tooltip.js";
|
|
10
13
|
import { Header } from "./Header.js";
|
|
11
14
|
import { HeaderActionsProvider } from "./HeaderActions.js";
|
|
12
15
|
const PRIMARY_NAV_ITEMS = [
|
|
16
|
+
{
|
|
17
|
+
id: "chat",
|
|
18
|
+
to: "/chat",
|
|
19
|
+
label: "Chat",
|
|
20
|
+
icon: IconMessageQuestion,
|
|
21
|
+
section: "primary",
|
|
22
|
+
},
|
|
13
23
|
{
|
|
14
24
|
id: "overview",
|
|
15
25
|
to: "/overview",
|
|
@@ -180,6 +190,127 @@ function dispatchNavLinkTarget(path) {
|
|
|
180
190
|
const routerHasBasename = pathname === basePath || pathname.startsWith(`${basePath}/`);
|
|
181
191
|
return routerHasBasename ? path : appPath(path);
|
|
182
192
|
}
|
|
193
|
+
function formatThreadAge(updatedAt) {
|
|
194
|
+
const diffMs = Math.max(0, Date.now() - updatedAt);
|
|
195
|
+
const minutes = Math.floor(diffMs / 60_000);
|
|
196
|
+
if (minutes < 1)
|
|
197
|
+
return "now";
|
|
198
|
+
if (minutes < 60)
|
|
199
|
+
return `${minutes}m`;
|
|
200
|
+
const hours = Math.floor(minutes / 60);
|
|
201
|
+
if (hours < 24)
|
|
202
|
+
return `${hours}h`;
|
|
203
|
+
const days = Math.floor(hours / 24);
|
|
204
|
+
if (days < 7)
|
|
205
|
+
return `${days}d`;
|
|
206
|
+
return new Date(updatedAt).toLocaleDateString([], {
|
|
207
|
+
month: "short",
|
|
208
|
+
day: "numeric",
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
function threadTitle(thread) {
|
|
212
|
+
return thread.title || thread.preview || "New chat";
|
|
213
|
+
}
|
|
214
|
+
function threadUpdatedAt(thread) {
|
|
215
|
+
return Number.isFinite(thread.updatedAt)
|
|
216
|
+
? thread.updatedAt
|
|
217
|
+
: Number.isFinite(thread.createdAt)
|
|
218
|
+
? thread.createdAt
|
|
219
|
+
: 0;
|
|
220
|
+
}
|
|
221
|
+
function DispatchChatsSection({ onNavigate }) {
|
|
222
|
+
const navigate = useNavigate();
|
|
223
|
+
const { threads, activeThreadId, createThread, switchThread, renameThread, refreshThreads, } = useChatThreads(undefined, undefined, undefined, { autoCreate: false });
|
|
224
|
+
const [renamingThreadId, setRenamingThreadId] = useState(null);
|
|
225
|
+
const [renameDraft, setRenameDraft] = useState("");
|
|
226
|
+
const renameInputRef = useRef(null);
|
|
227
|
+
const committingRenameRef = useRef(false);
|
|
228
|
+
const visibleThreads = useMemo(() => threads
|
|
229
|
+
.filter((thread) => thread.messageCount > 0 || thread.id === activeThreadId)
|
|
230
|
+
.sort((a, b) => threadUpdatedAt(b) - threadUpdatedAt(a))
|
|
231
|
+
.slice(0, 8), [activeThreadId, threads]);
|
|
232
|
+
useEffect(() => {
|
|
233
|
+
const refresh = () => refreshThreads();
|
|
234
|
+
const handleRunning = (event) => {
|
|
235
|
+
const detail = event.detail;
|
|
236
|
+
if (detail?.isRunning === false)
|
|
237
|
+
refreshThreads();
|
|
238
|
+
};
|
|
239
|
+
window.addEventListener("agent-chat:threads-updated", refresh);
|
|
240
|
+
window.addEventListener("agentNative.chatRunning", handleRunning);
|
|
241
|
+
window.addEventListener("focus", refresh);
|
|
242
|
+
return () => {
|
|
243
|
+
window.removeEventListener("agent-chat:threads-updated", refresh);
|
|
244
|
+
window.removeEventListener("agentNative.chatRunning", handleRunning);
|
|
245
|
+
window.removeEventListener("focus", refresh);
|
|
246
|
+
};
|
|
247
|
+
}, [refreshThreads]);
|
|
248
|
+
useEffect(() => {
|
|
249
|
+
if (!renamingThreadId)
|
|
250
|
+
return;
|
|
251
|
+
requestAnimationFrame(() => {
|
|
252
|
+
renameInputRef.current?.focus();
|
|
253
|
+
renameInputRef.current?.select();
|
|
254
|
+
});
|
|
255
|
+
}, [renamingThreadId]);
|
|
256
|
+
function openThread(threadId, options) {
|
|
257
|
+
switchThread(threadId);
|
|
258
|
+
navigate(dispatchNavLinkTarget("/chat"));
|
|
259
|
+
onNavigate?.();
|
|
260
|
+
window.requestAnimationFrame(() => {
|
|
261
|
+
window.dispatchEvent(new CustomEvent("agent-chat:open-thread", {
|
|
262
|
+
detail: { threadId, newThread: options?.isNew === true },
|
|
263
|
+
}));
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
async function handleNewChat() {
|
|
267
|
+
const threadId = await createThread();
|
|
268
|
+
if (threadId)
|
|
269
|
+
openThread(threadId, { isNew: true });
|
|
270
|
+
}
|
|
271
|
+
function startRenameThread(thread) {
|
|
272
|
+
committingRenameRef.current = false;
|
|
273
|
+
setRenameDraft(threadTitle(thread));
|
|
274
|
+
setRenamingThreadId(thread.id);
|
|
275
|
+
}
|
|
276
|
+
function cancelRenameThread() {
|
|
277
|
+
committingRenameRef.current = true;
|
|
278
|
+
setRenamingThreadId(null);
|
|
279
|
+
setRenameDraft("");
|
|
280
|
+
}
|
|
281
|
+
async function commitRenameThread() {
|
|
282
|
+
if (committingRenameRef.current)
|
|
283
|
+
return;
|
|
284
|
+
const threadId = renamingThreadId;
|
|
285
|
+
const title = renameDraft.trim();
|
|
286
|
+
if (!threadId)
|
|
287
|
+
return;
|
|
288
|
+
committingRenameRef.current = true;
|
|
289
|
+
setRenamingThreadId(null);
|
|
290
|
+
setRenameDraft("");
|
|
291
|
+
if (title)
|
|
292
|
+
await renameThread(threadId, title);
|
|
293
|
+
committingRenameRef.current = false;
|
|
294
|
+
}
|
|
295
|
+
function handleRenameSubmit(event) {
|
|
296
|
+
event.preventDefault();
|
|
297
|
+
void commitRenameThread();
|
|
298
|
+
}
|
|
299
|
+
return (_jsxs("div", { className: "mt-2 border-l border-sidebar-border/70 pl-3", children: [_jsxs("div", { className: "mb-1 flex h-7 items-center gap-2 pr-1", children: [_jsx("div", { className: "min-w-0 flex-1 text-xs font-medium text-sidebar-foreground/70", children: "Chats" }), _jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { asChild: true, children: _jsx("button", { type: "button", onClick: handleNewChat, className: "flex size-6 shrink-0 cursor-pointer items-center justify-center rounded-md text-sidebar-foreground/65 transition-colors hover:bg-sidebar-accent hover:text-sidebar-accent-foreground", "aria-label": "New Dispatch chat", children: _jsx(IconPlus, { className: "size-3.5" }) }) }), _jsx(TooltipContent, { children: "New chat" })] })] }), _jsx("div", { className: "grid gap-0.5", children: visibleThreads.length > 0 ? (visibleThreads.map((thread) => {
|
|
300
|
+
const isActive = thread.id === activeThreadId;
|
|
301
|
+
const isRenaming = thread.id === renamingThreadId;
|
|
302
|
+
return (_jsx("div", { className: cn("group flex h-8 min-w-0 items-center rounded-md text-sm transition-colors", isActive
|
|
303
|
+
? "bg-sidebar-accent text-sidebar-accent-foreground"
|
|
304
|
+
: "text-sidebar-foreground/80 hover:bg-sidebar-accent/65 hover:text-sidebar-accent-foreground"), children: isRenaming ? (_jsx("form", { onSubmit: handleRenameSubmit, className: "flex h-full min-w-0 flex-1 items-center px-1.5", children: _jsx(Input, { ref: renameInputRef, value: renameDraft, onChange: (event) => setRenameDraft(event.target.value), onBlur: () => void commitRenameThread(), onKeyDown: (event) => {
|
|
305
|
+
if (event.key === "Escape") {
|
|
306
|
+
event.preventDefault();
|
|
307
|
+
cancelRenameThread();
|
|
308
|
+
}
|
|
309
|
+
}, maxLength: 160, "aria-label": `Rename ${threadTitle(thread)}`, className: "h-6 min-w-0 rounded-sm border-sidebar-border bg-background px-1.5 text-xs" }) })) : (_jsxs(_Fragment, { children: [_jsx("button", { type: "button", onClick: () => openThread(thread.id), className: "flex h-full min-w-0 flex-1 cursor-pointer items-center px-2 text-left outline-none focus-visible:ring-2 focus-visible:ring-ring", children: _jsx("span", { className: "min-w-0 flex-1 truncate", children: threadTitle(thread) }) }), _jsxs("div", { className: "relative flex size-7 shrink-0 items-center justify-end pr-1", children: [_jsx("span", { className: "text-[11px] text-sidebar-foreground/50 transition-opacity group-hover:opacity-0 group-focus-within:opacity-0", children: isActive
|
|
310
|
+
? ""
|
|
311
|
+
: formatThreadAge(threadUpdatedAt(thread)) }), _jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsx("button", { type: "button", "aria-label": `Chat options for ${threadTitle(thread)}`, className: "absolute right-1 flex size-6 cursor-pointer items-center justify-center rounded-md text-sidebar-foreground/65 opacity-0 transition-opacity hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring group-hover:opacity-100 group-focus-within:opacity-100 data-[state=open]:opacity-100", children: _jsx(IconDots, { className: "size-4" }) }) }), _jsx(DropdownMenuContent, { align: "end", side: "right", sideOffset: 6, children: _jsxs(DropdownMenuItem, { onSelect: () => startRenameThread(thread), children: [_jsx(IconEdit, { className: "size-4" }), "Rename chat"] }) })] })] })] })) }, thread.id));
|
|
312
|
+
})) : (_jsx("button", { type: "button", onClick: handleNewChat, className: "flex h-8 cursor-pointer items-center rounded-md px-2 text-left text-sm text-sidebar-foreground/70 transition-colors hover:bg-sidebar-accent/65 hover:text-sidebar-accent-foreground", children: _jsx("span", { className: "truncate", children: "New chat" }) })) })] }));
|
|
313
|
+
}
|
|
183
314
|
export function NavContent({ onNavigate, extensions, }) {
|
|
184
315
|
const location = useLocation();
|
|
185
316
|
const { data: workspace } = useActionQuery("get-workspace-info", {}, { staleTime: 60_000 });
|
|
@@ -198,12 +329,13 @@ export function NavContent({ onNavigate, extensions, }) {
|
|
|
198
329
|
const operationsOpen = operationsNavItems.some((item) => navItemMatchesPath(item, localPathname));
|
|
199
330
|
const renderNavItem = (item) => {
|
|
200
331
|
const Icon = item.icon;
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
332
|
+
const itemMatchesLocalPath = navItemMatchesPath(item, localPathname);
|
|
333
|
+
return (_jsxs("li", { children: [_jsxs(NavLink, { to: dispatchNavLinkTarget(item.to), onClick: onNavigate, className: ({ isActive }) => {
|
|
334
|
+
const active = isActive || itemMatchesLocalPath;
|
|
335
|
+
return cn("flex h-8 w-full items-center gap-2 rounded-md px-2 text-sm", active
|
|
336
|
+
? "bg-sidebar-accent font-medium text-sidebar-accent-foreground"
|
|
337
|
+
: "text-sidebar-foreground/70 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground");
|
|
338
|
+
}, children: [Icon ? (_jsx(Icon, { size: 16, className: "shrink-0" })) : (_jsx("span", { className: "h-4 w-4 shrink-0", "aria-hidden": "true" })), _jsx("span", { className: "truncate", children: item.label })] }), item.id === "chat" && itemMatchesLocalPath ? (_jsx(DispatchChatsSection, { onNavigate: onNavigate })) : null] }, item.id));
|
|
207
339
|
};
|
|
208
340
|
return (_jsxs(_Fragment, { children: [_jsx("div", { className: "border-b px-4 py-3", children: _jsxs("div", { className: "flex items-center gap-3", children: [_jsxs("div", { className: "flex h-9 w-9 items-center justify-center rounded-xl border bg-card text-foreground", children: [_jsx("img", { src: appPath("/agent-native-icon-light.svg"), alt: "", "aria-hidden": "true", className: "block h-4 w-auto shrink-0 dark:hidden" }), _jsx("img", { src: appPath("/agent-native-icon-dark.svg"), alt: "", "aria-hidden": "true", className: "hidden h-4 w-auto shrink-0 dark:block" })] }), _jsxs("div", { className: "min-w-0", children: [_jsx("div", { className: "truncate text-sm font-semibold text-foreground", children: workspaceLabel ?? "Dispatch" }), _jsx("div", { className: "truncate text-xs text-muted-foreground", children: workspaceLabel
|
|
209
341
|
? `Workspace · ${ws?.appCount ?? 0} app${ws?.appCount === 1 ? "" : "s"}`
|
|
@@ -212,11 +344,14 @@ export function NavContent({ onNavigate, extensions, }) {
|
|
|
212
344
|
export function Layout({ children, extensions, }) {
|
|
213
345
|
const location = useLocation();
|
|
214
346
|
const [mobileOpen, setMobileOpen] = useState(false);
|
|
215
|
-
|
|
347
|
+
const localPathname = localDispatchPath(location.pathname);
|
|
348
|
+
if (CHROMELESS_PATHS.some((path) => localPathname === path)) {
|
|
216
349
|
return _jsx(_Fragment, { children: children });
|
|
217
350
|
}
|
|
218
|
-
const
|
|
219
|
-
const
|
|
220
|
-
|
|
351
|
+
const isChatRoute = localPathname === "/chat";
|
|
352
|
+
const showHeader = !isChatRoute && !pageOwnsToolbar(localPathname);
|
|
353
|
+
const appContent = (_jsxs("div", { className: "flex h-full min-w-0 flex-1 flex-col overflow-hidden", children: [showHeader ? _jsx(Header, { onOpenMobile: () => setMobileOpen(true) }) : null, _jsx(InvitationBanner, {}), _jsx("main", { className: cn("flex-1", isChatRoute ? "min-h-0 overflow-hidden" : "overflow-y-auto"), children: showHeader ? (_jsx("div", { className: "mx-auto max-w-7xl space-y-10 px-4 py-6 sm:px-6", children: children })) : (children) })] }));
|
|
354
|
+
const content = isChatRoute ? (appContent) : (_jsx(AgentSidebar, { position: "right", defaultOpen: false, emptyStateText: "Create apps, manage vault keys, and route work across the workspace.", suggestions: SIDEBAR_SUGGESTIONS, children: appContent }));
|
|
355
|
+
return (_jsx(HeaderActionsProvider, { children: _jsxs("div", { className: "flex h-screen w-full overflow-hidden bg-background", children: [_jsx("aside", { className: "hidden lg:flex w-64 shrink-0 flex-col border-r bg-sidebar text-sidebar-foreground", children: _jsx(NavContent, { extensions: extensions }) }), _jsx(Sheet, { open: mobileOpen, onOpenChange: setMobileOpen, children: _jsxs(SheetContent, { side: "left", className: "w-72 p-0 bg-sidebar text-sidebar-foreground [&>button]:hidden", children: [_jsx(SheetTitle, { className: "sr-only", children: "Navigation" }), _jsx(SheetDescription, { className: "sr-only", children: "Workspace navigation links" }), _jsx("div", { className: "flex h-full w-full flex-col", children: _jsx(NavContent, { extensions: extensions, onNavigate: () => setMobileOpen(false) }) })] }) }), content] }) }));
|
|
221
356
|
}
|
|
222
357
|
//# sourceMappingURL=Layout.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Layout.js","sourceRoot":"","sources":["../../../src/components/layout/Layout.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAsC,MAAM,OAAO,CAAC;AACrE,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EACL,YAAY,EACZ,cAAc,EACd,WAAW,EACX,OAAO,EACP,cAAc,GACf,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAChF,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAC9E,OAAO,EACL,gBAAgB,EAChB,QAAQ,EACR,SAAS,EACT,YAAY,EACZ,iBAAiB,EACjB,OAAO,EACP,eAAe,EACf,kBAAkB,EAClB,YAAY,EACZ,iBAAiB,EACjB,aAAa,EACb,eAAe,EACf,WAAW,EACX,UAAU,EACV,eAAe,EACf,cAAc,GACf,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AACjC,OAAO,EACL,KAAK,EACL,YAAY,EACZ,gBAAgB,EAChB,UAAU,GACX,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC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,IACX,GACgB,CACzB,CAAC;AACJ,CAAC","sourcesContent":["import { useState, type ComponentType, type ReactNode } from \"react\";\nimport { NavLink, useLocation } from \"react-router\";\nimport {\n AgentSidebar,\n FeedbackButton,\n appBasePath,\n appPath,\n useActionQuery,\n} from \"@agent-native/core/client\";\nimport { ExtensionsSidebarSection } from \"@agent-native/core/client/extensions\";\nimport { InvitationBanner, OrgSwitcher } from \"@agent-native/core/client/org\";\nimport {\n IconArrowUpRight,\n IconApps,\n IconBrain,\n IconChartBar,\n IconBrandTelegram,\n IconKey,\n IconChevronDown,\n IconLayersSubtract,\n IconMessages,\n IconPlugConnected,\n IconBroadcast,\n IconFingerprint,\n IconHistory,\n IconPuzzle,\n IconShieldCheck,\n IconUsersGroup,\n} from \"@tabler/icons-react\";\nimport { cn } from \"@/lib/utils\";\nimport {\n Sheet,\n SheetContent,\n SheetDescription,\n SheetTitle,\n} from \"@/components/ui/sheet\";\nimport { Header } from \"./Header\";\nimport { HeaderActionsProvider } from \"./HeaderActions\";\n\nexport type DispatchNavSection = \"primary\" | \"operations\";\n\nexport type DispatchNavIcon = ComponentType<{\n size?: number | string;\n className?: string;\n}>;\n\nexport interface DispatchNavItem {\n /** Stable id used for keys and navigation.view. Avoid built-in ids. */\n id: string;\n /** React Router path for the tab, usually backed by an app/routes/*.tsx file. */\n to: string;\n label: string;\n icon?: DispatchNavIcon;\n /** Defaults to \"operations\", which is where local management tools usually fit. */\n section?: DispatchNavSection;\n /** Override active matching for nested or multi-route tools. */\n match?: (pathname: string) => boolean;\n}\n\nexport interface DispatchExtensionConfig {\n /** Extra sidebar tabs supplied by the generated workspace. */\n navItems?: readonly DispatchNavItem[];\n /** Extra React Query keys to invalidate when Dispatch receives DB sync events. */\n queryKeys?: readonly string[];\n}\n\nconst PRIMARY_NAV_ITEMS = [\n {\n id: \"overview\",\n to: \"/overview\",\n label: \"Overview\",\n icon: IconBroadcast,\n section: \"primary\",\n },\n {\n id: \"apps\",\n to: \"/apps\",\n label: \"Apps\",\n icon: IconApps,\n section: \"primary\",\n },\n {\n id: \"metrics\",\n to: \"/metrics\",\n label: \"Metrics\",\n icon: IconChartBar,\n section: \"primary\",\n },\n {\n id: \"vault\",\n to: \"/vault\",\n label: \"Vault\",\n icon: IconKey,\n section: \"primary\",\n },\n {\n id: \"integrations\",\n to: \"/integrations\",\n label: \"Integrations\",\n icon: IconPuzzle,\n section: \"primary\",\n },\n {\n id: \"agents\",\n to: \"/agents\",\n label: \"Agents\",\n icon: IconPlugConnected,\n section: \"primary\",\n },\n] as const satisfies readonly DispatchNavItem[];\n\nconst OPERATIONS_NAV_ITEMS = [\n {\n id: \"workspace\",\n to: \"/workspace\",\n label: \"Resources\",\n icon: IconLayersSubtract,\n section: \"operations\",\n },\n {\n id: \"messaging\",\n to: \"/messaging\",\n label: \"Messaging\",\n icon: IconBrandTelegram,\n section: \"operations\",\n },\n {\n id: \"destinations\",\n to: \"/destinations\",\n label: \"Destinations\",\n icon: IconArrowUpRight,\n section: \"operations\",\n },\n {\n id: \"identities\",\n to: \"/identities\",\n label: \"Identities\",\n icon: IconFingerprint,\n section: \"operations\",\n },\n {\n id: \"approvals\",\n to: \"/approvals\",\n label: \"Approvals\",\n icon: IconShieldCheck,\n section: \"operations\",\n },\n {\n id: \"audit\",\n to: \"/audit\",\n label: \"Audit\",\n icon: IconHistory,\n section: \"operations\",\n },\n {\n id: \"dreams\",\n to: \"/dreams\",\n label: \"Dreams\",\n icon: IconBrain,\n section: \"operations\",\n },\n {\n id: \"thread-debug\",\n to: \"/thread-debug\",\n label: \"Thread Debug\",\n icon: IconMessages,\n section: \"operations\",\n },\n {\n id: \"team\",\n to: \"/team\",\n label: \"Team\",\n icon: IconUsersGroup,\n section: \"operations\",\n },\n] as const satisfies readonly DispatchNavItem[];\n\nconst EMPTY_NAV_ITEMS: readonly DispatchNavItem[] = [];\n\nconst SIDEBAR_SUGGESTIONS = [\n \"Build a workspace app for X\",\n \"Route Slack mentions to my analytics app\",\n \"Grant my OpenAI key to this app\",\n];\n\nconst CHROMELESS_PATHS = [\"/approval\"];\n\n// Routes whose page renders its own toolbar (with NotificationsBell + AgentToggleButton).\n// Layout still mounts the sidebar + AgentSidebar, but skips its own Header so\n// there's no double-header.\nfunction pageOwnsToolbar(pathname: string): boolean {\n if (pathname === \"/tools\" || pathname.startsWith(\"/tools/\")) return true;\n if (pathname === \"/extensions\" || pathname.startsWith(\"/extensions/\"))\n return true;\n return false;\n}\n\ninterface WorkspaceInfo {\n name: string | null;\n displayName: string | null;\n appCount: number;\n}\n\nfunction sectionFor(item: DispatchNavItem): DispatchNavSection {\n return item.section ?? \"operations\";\n}\n\nfunction navItemMatchesPath(item: DispatchNavItem, pathname: string): boolean {\n if (item.match) {\n try {\n if (item.match(pathname)) return true;\n } catch {\n return false;\n }\n }\n return pathname === item.to || pathname.startsWith(`${item.to}/`);\n}\n\nfunction navItemsForSection(\n items: readonly DispatchNavItem[],\n section: DispatchNavSection,\n): DispatchNavItem[] {\n return items.filter((item) => sectionFor(item) === section);\n}\n\nfunction localDispatchPath(pathname: string): string {\n const basePath = appBasePath();\n if (!basePath) return pathname;\n if (pathname === basePath) return \"/\";\n if (pathname.startsWith(`${basePath}/`)) {\n return pathname.slice(basePath.length) || \"/\";\n }\n return pathname;\n}\n\nfunction dispatchNavLinkTarget(path: string): string {\n if (typeof window === \"undefined\") return path;\n const basePath = appBasePath();\n if (!basePath) return path;\n // Mirror the basename calculation entry.client.tsx uses to configure the\n // router (basePath iff the current URL is under that mount, \"\" otherwise).\n // Reading the live URL directly avoids races with the previous check on\n // `__reactRouterContext.basename`, which could read undefined before the\n // entry script set it — that race produced /dispatch/dispatch/<route>\n // history entries that 404'd on back-button navigation.\n const pathname = window.location.pathname;\n const routerHasBasename =\n pathname === basePath || pathname.startsWith(`${basePath}/`);\n return routerHasBasename ? path : appPath(path);\n}\n\nexport function NavContent({\n onNavigate,\n extensions,\n}: {\n onNavigate?: () => void;\n extensions?: DispatchExtensionConfig;\n}) {\n const location = useLocation();\n const { data: workspace } = useActionQuery(\n \"get-workspace-info\",\n {},\n { staleTime: 60_000 },\n );\n const ws = workspace as WorkspaceInfo | undefined;\n const workspaceLabel = ws?.displayName ?? ws?.name ?? null;\n const extensionNavItems = extensions?.navItems ?? EMPTY_NAV_ITEMS;\n const primaryNavItems = [\n ...PRIMARY_NAV_ITEMS,\n ...navItemsForSection(extensionNavItems, \"primary\"),\n ];\n const operationsNavItems = [\n ...OPERATIONS_NAV_ITEMS,\n ...navItemsForSection(extensionNavItems, \"operations\"),\n ];\n const localPathname = localDispatchPath(location.pathname);\n const operationsOpen = operationsNavItems.some((item) =>\n navItemMatchesPath(item, localPathname),\n );\n\n const renderNavItem = (item: DispatchNavItem) => {\n const Icon = item.icon;\n return (\n <li key={item.id}>\n <NavLink\n to={dispatchNavLinkTarget(item.to)}\n onClick={onNavigate}\n className={({ isActive }) => {\n const active = isActive || navItemMatchesPath(item, localPathname);\n return cn(\n \"flex h-8 w-full items-center gap-2 rounded-md px-2 text-sm\",\n active\n ? \"bg-sidebar-accent font-medium text-sidebar-accent-foreground\"\n : \"text-sidebar-foreground/70 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground\",\n );\n }}\n >\n {Icon ? (\n <Icon size={16} className=\"shrink-0\" />\n ) : (\n <span className=\"h-4 w-4 shrink-0\" aria-hidden=\"true\" />\n )}\n <span className=\"truncate\">{item.label}</span>\n </NavLink>\n </li>\n );\n };\n\n return (\n <>\n <div className=\"border-b px-4 py-3\">\n <div className=\"flex items-center gap-3\">\n <div className=\"flex h-9 w-9 items-center justify-center rounded-xl border bg-card text-foreground\">\n <img\n src={appPath(\"/agent-native-icon-light.svg\")}\n alt=\"\"\n aria-hidden=\"true\"\n className=\"block h-4 w-auto shrink-0 dark:hidden\"\n />\n <img\n src={appPath(\"/agent-native-icon-dark.svg\")}\n alt=\"\"\n aria-hidden=\"true\"\n className=\"hidden h-4 w-auto shrink-0 dark:block\"\n />\n </div>\n <div className=\"min-w-0\">\n <div className=\"truncate text-sm font-semibold text-foreground\">\n {workspaceLabel ?? \"Dispatch\"}\n </div>\n <div className=\"truncate text-xs text-muted-foreground\">\n {workspaceLabel\n ? `Workspace · ${ws?.appCount ?? 0} app${ws?.appCount === 1 ? \"\" : \"s\"}`\n : \"Workspace control plane\"}\n </div>\n </div>\n </div>\n </div>\n\n <div className=\"flex min-h-0 flex-1 flex-col overflow-y-auto\">\n <nav className=\"px-2 py-3\">\n <ul className=\"space-y-0.5\">{primaryNavItems.map(renderNavItem)}</ul>\n </nav>\n\n <div className=\"mt-auto shrink-0\">\n <div className=\"border-t px-2 py-2\">\n <details className=\"group\" open={operationsOpen}>\n <summary className=\"flex h-8 cursor-pointer list-none items-center justify-between rounded-md px-2 text-xs font-medium uppercase text-sidebar-foreground/50 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground [&::-webkit-details-marker]:hidden\">\n <span>Operations</span>\n <IconChevronDown\n size={14}\n className=\"transition-transform group-open:rotate-180\"\n />\n </summary>\n <ul className=\"mt-1 space-y-0.5\">\n {operationsNavItems.map(renderNavItem)}\n </ul>\n </details>\n </div>\n\n <div className=\"border-t px-2 py-1\">\n <ExtensionsSidebarSection />\n </div>\n\n <div className=\"border-t px-3 py-2\">\n <OrgSwitcher />\n </div>\n\n <div className=\"border-t px-3 py-2\">\n <FeedbackButton />\n </div>\n </div>\n </div>\n </>\n );\n}\n\nexport function Layout({\n children,\n extensions,\n}: {\n children: ReactNode;\n extensions?: DispatchExtensionConfig;\n}) {\n const location = useLocation();\n const [mobileOpen, setMobileOpen] = useState(false);\n\n if (CHROMELESS_PATHS.some((path) => location.pathname === path)) {\n return <>{children}</>;\n }\n\n const showHeader = !pageOwnsToolbar(location.pathname);\n const appContent = (\n <div className=\"flex h-full flex-1 flex-col overflow-hidden\">\n {showHeader ? <Header onOpenMobile={() => setMobileOpen(true)} /> : null}\n <InvitationBanner />\n <main className=\"flex-1 overflow-y-auto\">\n {showHeader ? (\n <div className=\"mx-auto max-w-7xl space-y-10 px-4 py-6 sm:px-6\">\n {children}\n </div>\n ) : (\n children\n )}\n </main>\n </div>\n );\n\n return (\n <HeaderActionsProvider>\n <div className=\"flex h-screen w-full overflow-hidden bg-background\">\n <aside className=\"hidden lg:flex w-64 shrink-0 flex-col border-r bg-sidebar text-sidebar-foreground\">\n <NavContent extensions={extensions} />\n </aside>\n\n <Sheet open={mobileOpen} onOpenChange={setMobileOpen}>\n <SheetContent\n side=\"left\"\n className=\"w-72 p-0 bg-sidebar text-sidebar-foreground [&>button]:hidden\"\n >\n <SheetTitle className=\"sr-only\">Navigation</SheetTitle>\n <SheetDescription className=\"sr-only\">\n Workspace navigation links\n </SheetDescription>\n <div className=\"flex h-full w-full flex-col\">\n <NavContent\n extensions={extensions}\n onNavigate={() => setMobileOpen(false)}\n />\n </div>\n </SheetContent>\n </Sheet>\n\n {/*\n * Always mount AgentSidebar so home composer's sendToAgentChat\n * fallback can pop it via agent-panel:open.\n */}\n <AgentSidebar\n position=\"right\"\n defaultOpen={false}\n emptyStateText=\"Create apps, manage vault keys, and route work across the workspace.\"\n suggestions={SIDEBAR_SUGGESTIONS}\n >\n {appContent}\n </AgentSidebar>\n </div>\n </HeaderActionsProvider>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"Layout.js","sourceRoot":"","sources":["../../../src/components/layout/Layout.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,SAAS,EACT,OAAO,EACP,MAAM,EACN,QAAQ,GAIT,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AACjE,OAAO,EACL,YAAY,EACZ,cAAc,EACd,WAAW,EACX,OAAO,EACP,cAAc,EACd,cAAc,GAEf,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAChF,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAC9E,OAAO,EACL,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EACxE,KAAC,gBAAgB,KAAG,EACpB,eACE,SAAS,EAAE,EAAE,CACX,QAAQ,EACR,WAAW,CAAC,CAAC,CAAC,yBAAyB,CAAC,CAAC,CAAC,iBAAiB,CAC5D,YAEA,UAAU,CAAC,CAAC,CAAC,CACZ,cAAK,SAAS,EAAC,gDAAgD,YAC5D,QAAQ,GACL,CACP,CAAC,CAAC,CAAC,CACF,QAAQ,CACT,GACI,IACH,CACP,CAAC;IACF,MAAM,OAAO,GAAG,WAAW,CAAC,CAAC,CAAC,CAC5B,UAAU,CACX,CAAC,CAAC,CAAC,CACF,KAAC,YAAY,IACX,QAAQ,EAAC,OAAO,EAChB,WAAW,EAAE,KAAK,EAClB,cAAc,EAAC,sEAAsE,EACrF,WAAW,EAAE,mBAAmB,YAE/B,UAAU,GACE,CAChB,CAAC;IAEF,OAAO,CACL,KAAC,qBAAqB,cACpB,eAAK,SAAS,EAAC,oDAAoD,aACjE,gBAAO,SAAS,EAAC,mFAAmF,YAClG,KAAC,UAAU,IAAC,UAAU,EAAE,UAAU,GAAI,GAChC,EAER,KAAC,KAAK,IAAC,IAAI,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,YAClD,MAAC,YAAY,IACX,IAAI,EAAC,MAAM,EACX,SAAS,EAAC,+DAA+D,aAEzE,KAAC,UAAU,IAAC,SAAS,EAAC,SAAS,2BAAwB,EACvD,KAAC,gBAAgB,IAAC,SAAS,EAAC,SAAS,2CAElB,EACnB,cAAK,SAAS,EAAC,6BAA6B,YAC1C,KAAC,UAAU,IACT,UAAU,EAAE,UAAU,EACtB,UAAU,EAAE,GAAG,EAAE,CAAC,aAAa,CAAC,KAAK,CAAC,GACtC,GACE,IACO,GACT,EAEP,OAAO,IACJ,GACgB,CACzB,CAAC;AACJ,CAAC","sourcesContent":["import {\n useEffect,\n useMemo,\n useRef,\n useState,\n type ComponentType,\n type FormEvent,\n type ReactNode,\n} from \"react\";\nimport { NavLink, useLocation, useNavigate } from \"react-router\";\nimport {\n AgentSidebar,\n FeedbackButton,\n appBasePath,\n appPath,\n useActionQuery,\n useChatThreads,\n type ChatThreadSummary,\n} from \"@agent-native/core/client\";\nimport { ExtensionsSidebarSection } from \"@agent-native/core/client/extensions\";\nimport { InvitationBanner, OrgSwitcher } from \"@agent-native/core/client/org\";\nimport {\n IconArrowUpRight,\n IconApps,\n IconBrain,\n IconChartBar,\n IconBrandTelegram,\n IconKey,\n IconChevronDown,\n IconDots,\n IconEdit,\n IconLayersSubtract,\n IconMessageQuestion,\n IconMessages,\n IconPlus,\n IconPlugConnected,\n IconBroadcast,\n IconFingerprint,\n IconHistory,\n IconPuzzle,\n IconShieldCheck,\n IconUsersGroup,\n} from \"@tabler/icons-react\";\nimport { cn } from \"@/lib/utils\";\nimport {\n DropdownMenu,\n DropdownMenuContent,\n DropdownMenuItem,\n DropdownMenuTrigger,\n} from \"@/components/ui/dropdown-menu\";\nimport { Input } from \"@/components/ui/input\";\nimport {\n Sheet,\n SheetContent,\n SheetDescription,\n SheetTitle,\n} from \"@/components/ui/sheet\";\nimport {\n Tooltip,\n TooltipContent,\n TooltipTrigger,\n} from \"@/components/ui/tooltip\";\nimport { Header } from \"./Header\";\nimport { HeaderActionsProvider } from \"./HeaderActions\";\n\nexport type DispatchNavSection = \"primary\" | \"operations\";\n\nexport type DispatchNavIcon = ComponentType<{\n size?: number | string;\n className?: string;\n}>;\n\nexport interface DispatchNavItem {\n /** Stable id used for keys and navigation.view. Avoid built-in ids. */\n id: string;\n /** React Router path for the tab, usually backed by an app/routes/*.tsx file. */\n to: string;\n label: string;\n icon?: DispatchNavIcon;\n /** Defaults to \"operations\", which is where local management tools usually fit. */\n section?: DispatchNavSection;\n /** Override active matching for nested or multi-route tools. */\n match?: (pathname: string) => boolean;\n}\n\nexport interface DispatchExtensionConfig {\n /** Extra sidebar tabs supplied by the generated workspace. */\n navItems?: readonly DispatchNavItem[];\n /** Extra React Query keys to invalidate when Dispatch receives DB sync events. */\n queryKeys?: readonly string[];\n}\n\nconst PRIMARY_NAV_ITEMS = [\n {\n id: \"chat\",\n to: \"/chat\",\n label: \"Chat\",\n icon: IconMessageQuestion,\n section: \"primary\",\n },\n {\n id: \"overview\",\n to: \"/overview\",\n label: \"Overview\",\n icon: IconBroadcast,\n section: \"primary\",\n },\n {\n id: \"apps\",\n to: \"/apps\",\n label: \"Apps\",\n icon: IconApps,\n section: \"primary\",\n },\n {\n id: \"metrics\",\n to: \"/metrics\",\n label: \"Metrics\",\n icon: IconChartBar,\n section: \"primary\",\n },\n {\n id: \"vault\",\n to: \"/vault\",\n label: \"Vault\",\n icon: IconKey,\n section: \"primary\",\n },\n {\n id: \"integrations\",\n to: \"/integrations\",\n label: \"Integrations\",\n icon: IconPuzzle,\n section: \"primary\",\n },\n {\n id: \"agents\",\n to: \"/agents\",\n label: \"Agents\",\n icon: IconPlugConnected,\n section: \"primary\",\n },\n] as const satisfies readonly DispatchNavItem[];\n\nconst OPERATIONS_NAV_ITEMS = [\n {\n id: \"workspace\",\n to: \"/workspace\",\n label: \"Resources\",\n icon: IconLayersSubtract,\n section: \"operations\",\n },\n {\n id: \"messaging\",\n to: \"/messaging\",\n label: \"Messaging\",\n icon: IconBrandTelegram,\n section: \"operations\",\n },\n {\n id: \"destinations\",\n to: \"/destinations\",\n label: \"Destinations\",\n icon: IconArrowUpRight,\n section: \"operations\",\n },\n {\n id: \"identities\",\n to: \"/identities\",\n label: \"Identities\",\n icon: IconFingerprint,\n section: \"operations\",\n },\n {\n id: \"approvals\",\n to: \"/approvals\",\n label: \"Approvals\",\n icon: IconShieldCheck,\n section: \"operations\",\n },\n {\n id: \"audit\",\n to: \"/audit\",\n label: \"Audit\",\n icon: IconHistory,\n section: \"operations\",\n },\n {\n id: \"dreams\",\n to: \"/dreams\",\n label: \"Dreams\",\n icon: IconBrain,\n section: \"operations\",\n },\n {\n id: \"thread-debug\",\n to: \"/thread-debug\",\n label: \"Thread Debug\",\n icon: IconMessages,\n section: \"operations\",\n },\n {\n id: \"team\",\n to: \"/team\",\n label: \"Team\",\n icon: IconUsersGroup,\n section: \"operations\",\n },\n] as const satisfies readonly DispatchNavItem[];\n\nconst EMPTY_NAV_ITEMS: readonly DispatchNavItem[] = [];\n\nconst SIDEBAR_SUGGESTIONS = [\n \"Build a workspace app for X\",\n \"Route Slack mentions to my analytics app\",\n \"Grant my OpenAI key to this app\",\n];\n\nconst CHROMELESS_PATHS = [\"/approval\"];\n\n// Routes whose page renders its own toolbar (with NotificationsBell + AgentToggleButton).\n// Layout still mounts the sidebar + AgentSidebar, but skips its own Header so\n// there's no double-header.\nfunction pageOwnsToolbar(pathname: string): boolean {\n if (pathname === \"/tools\" || pathname.startsWith(\"/tools/\")) return true;\n if (pathname === \"/extensions\" || pathname.startsWith(\"/extensions/\"))\n return true;\n return false;\n}\n\ninterface WorkspaceInfo {\n name: string | null;\n displayName: string | null;\n appCount: number;\n}\n\nfunction sectionFor(item: DispatchNavItem): DispatchNavSection {\n return item.section ?? \"operations\";\n}\n\nfunction navItemMatchesPath(item: DispatchNavItem, pathname: string): boolean {\n if (item.match) {\n try {\n if (item.match(pathname)) return true;\n } catch {\n return false;\n }\n }\n return pathname === item.to || pathname.startsWith(`${item.to}/`);\n}\n\nfunction navItemsForSection(\n items: readonly DispatchNavItem[],\n section: DispatchNavSection,\n): DispatchNavItem[] {\n return items.filter((item) => sectionFor(item) === section);\n}\n\nfunction localDispatchPath(pathname: string): string {\n const basePath = appBasePath();\n if (!basePath) return pathname;\n if (pathname === basePath) return \"/\";\n if (pathname.startsWith(`${basePath}/`)) {\n return pathname.slice(basePath.length) || \"/\";\n }\n return pathname;\n}\n\nfunction dispatchNavLinkTarget(path: string): string {\n if (typeof window === \"undefined\") return path;\n const basePath = appBasePath();\n if (!basePath) return path;\n // Mirror the basename calculation entry.client.tsx uses to configure the\n // router (basePath iff the current URL is under that mount, \"\" otherwise).\n // Reading the live URL directly avoids races with the previous check on\n // `__reactRouterContext.basename`, which could read undefined before the\n // entry script set it — that race produced /dispatch/dispatch/<route>\n // history entries that 404'd on back-button navigation.\n const pathname = window.location.pathname;\n const routerHasBasename =\n pathname === basePath || pathname.startsWith(`${basePath}/`);\n return routerHasBasename ? path : appPath(path);\n}\n\nfunction formatThreadAge(updatedAt: number) {\n const diffMs = Math.max(0, Date.now() - updatedAt);\n const minutes = Math.floor(diffMs / 60_000);\n if (minutes < 1) return \"now\";\n if (minutes < 60) return `${minutes}m`;\n const hours = Math.floor(minutes / 60);\n if (hours < 24) return `${hours}h`;\n const days = Math.floor(hours / 24);\n if (days < 7) return `${days}d`;\n return new Date(updatedAt).toLocaleDateString([], {\n month: \"short\",\n day: \"numeric\",\n });\n}\n\nfunction threadTitle(thread: ChatThreadSummary) {\n return thread.title || thread.preview || \"New chat\";\n}\n\nfunction threadUpdatedAt(thread: ChatThreadSummary) {\n return Number.isFinite(thread.updatedAt)\n ? thread.updatedAt\n : Number.isFinite(thread.createdAt)\n ? thread.createdAt\n : 0;\n}\n\nfunction DispatchChatsSection({ onNavigate }: { onNavigate?: () => void }) {\n const navigate = useNavigate();\n const {\n threads,\n activeThreadId,\n createThread,\n switchThread,\n renameThread,\n refreshThreads,\n } = useChatThreads(undefined, undefined, undefined, { autoCreate: false });\n const [renamingThreadId, setRenamingThreadId] = useState<string | null>(null);\n const [renameDraft, setRenameDraft] = useState(\"\");\n const renameInputRef = useRef<HTMLInputElement | null>(null);\n const committingRenameRef = useRef(false);\n\n const visibleThreads = useMemo(\n () =>\n threads\n .filter(\n (thread) => thread.messageCount > 0 || thread.id === activeThreadId,\n )\n .sort((a, b) => threadUpdatedAt(b) - threadUpdatedAt(a))\n .slice(0, 8),\n [activeThreadId, threads],\n );\n\n useEffect(() => {\n const refresh = () => refreshThreads();\n const handleRunning = (event: Event) => {\n const detail = (event as CustomEvent).detail as\n | { isRunning?: unknown }\n | undefined;\n if (detail?.isRunning === false) refreshThreads();\n };\n\n window.addEventListener(\"agent-chat:threads-updated\", refresh);\n window.addEventListener(\"agentNative.chatRunning\", handleRunning);\n window.addEventListener(\"focus\", refresh);\n return () => {\n window.removeEventListener(\"agent-chat:threads-updated\", refresh);\n window.removeEventListener(\"agentNative.chatRunning\", handleRunning);\n window.removeEventListener(\"focus\", refresh);\n };\n }, [refreshThreads]);\n\n useEffect(() => {\n if (!renamingThreadId) return;\n requestAnimationFrame(() => {\n renameInputRef.current?.focus();\n renameInputRef.current?.select();\n });\n }, [renamingThreadId]);\n\n function openThread(threadId: string, options?: { isNew?: boolean }) {\n switchThread(threadId);\n navigate(dispatchNavLinkTarget(\"/chat\"));\n onNavigate?.();\n window.requestAnimationFrame(() => {\n window.dispatchEvent(\n new CustomEvent(\"agent-chat:open-thread\", {\n detail: { threadId, newThread: options?.isNew === true },\n }),\n );\n });\n }\n\n async function handleNewChat() {\n const threadId = await createThread();\n if (threadId) openThread(threadId, { isNew: true });\n }\n\n function startRenameThread(thread: ChatThreadSummary) {\n committingRenameRef.current = false;\n setRenameDraft(threadTitle(thread));\n setRenamingThreadId(thread.id);\n }\n\n function cancelRenameThread() {\n committingRenameRef.current = true;\n setRenamingThreadId(null);\n setRenameDraft(\"\");\n }\n\n async function commitRenameThread() {\n if (committingRenameRef.current) return;\n const threadId = renamingThreadId;\n const title = renameDraft.trim();\n if (!threadId) return;\n committingRenameRef.current = true;\n setRenamingThreadId(null);\n setRenameDraft(\"\");\n if (title) await renameThread(threadId, title);\n committingRenameRef.current = false;\n }\n\n function handleRenameSubmit(event: FormEvent<HTMLFormElement>) {\n event.preventDefault();\n void commitRenameThread();\n }\n\n return (\n <div className=\"mt-2 border-l border-sidebar-border/70 pl-3\">\n <div className=\"mb-1 flex h-7 items-center gap-2 pr-1\">\n <div className=\"min-w-0 flex-1 text-xs font-medium text-sidebar-foreground/70\">\n Chats\n </div>\n <Tooltip>\n <TooltipTrigger asChild>\n <button\n type=\"button\"\n onClick={handleNewChat}\n className=\"flex size-6 shrink-0 cursor-pointer items-center justify-center rounded-md text-sidebar-foreground/65 transition-colors hover:bg-sidebar-accent hover:text-sidebar-accent-foreground\"\n aria-label=\"New Dispatch chat\"\n >\n <IconPlus className=\"size-3.5\" />\n </button>\n </TooltipTrigger>\n <TooltipContent>New chat</TooltipContent>\n </Tooltip>\n </div>\n <div className=\"grid gap-0.5\">\n {visibleThreads.length > 0 ? (\n visibleThreads.map((thread) => {\n const isActive = thread.id === activeThreadId;\n const isRenaming = thread.id === renamingThreadId;\n return (\n <div\n key={thread.id}\n className={cn(\n \"group flex h-8 min-w-0 items-center rounded-md text-sm transition-colors\",\n isActive\n ? \"bg-sidebar-accent text-sidebar-accent-foreground\"\n : \"text-sidebar-foreground/80 hover:bg-sidebar-accent/65 hover:text-sidebar-accent-foreground\",\n )}\n >\n {isRenaming ? (\n <form\n onSubmit={handleRenameSubmit}\n className=\"flex h-full min-w-0 flex-1 items-center px-1.5\"\n >\n <Input\n ref={renameInputRef}\n value={renameDraft}\n onChange={(event) => setRenameDraft(event.target.value)}\n onBlur={() => void commitRenameThread()}\n onKeyDown={(event) => {\n if (event.key === \"Escape\") {\n event.preventDefault();\n cancelRenameThread();\n }\n }}\n maxLength={160}\n aria-label={`Rename ${threadTitle(thread)}`}\n className=\"h-6 min-w-0 rounded-sm border-sidebar-border bg-background px-1.5 text-xs\"\n />\n </form>\n ) : (\n <>\n <button\n type=\"button\"\n onClick={() => openThread(thread.id)}\n className=\"flex h-full min-w-0 flex-1 cursor-pointer items-center px-2 text-left outline-none focus-visible:ring-2 focus-visible:ring-ring\"\n >\n <span className=\"min-w-0 flex-1 truncate\">\n {threadTitle(thread)}\n </span>\n </button>\n <div className=\"relative flex size-7 shrink-0 items-center justify-end pr-1\">\n <span className=\"text-[11px] text-sidebar-foreground/50 transition-opacity group-hover:opacity-0 group-focus-within:opacity-0\">\n {isActive\n ? \"\"\n : formatThreadAge(threadUpdatedAt(thread))}\n </span>\n <DropdownMenu>\n <DropdownMenuTrigger asChild>\n <button\n type=\"button\"\n aria-label={`Chat options for ${threadTitle(thread)}`}\n className=\"absolute right-1 flex size-6 cursor-pointer items-center justify-center rounded-md text-sidebar-foreground/65 opacity-0 transition-opacity hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring group-hover:opacity-100 group-focus-within:opacity-100 data-[state=open]:opacity-100\"\n >\n <IconDots className=\"size-4\" />\n </button>\n </DropdownMenuTrigger>\n <DropdownMenuContent\n align=\"end\"\n side=\"right\"\n sideOffset={6}\n >\n <DropdownMenuItem\n onSelect={() => startRenameThread(thread)}\n >\n <IconEdit className=\"size-4\" />\n Rename chat\n </DropdownMenuItem>\n </DropdownMenuContent>\n </DropdownMenu>\n </div>\n </>\n )}\n </div>\n );\n })\n ) : (\n <button\n type=\"button\"\n onClick={handleNewChat}\n className=\"flex h-8 cursor-pointer items-center rounded-md px-2 text-left text-sm text-sidebar-foreground/70 transition-colors hover:bg-sidebar-accent/65 hover:text-sidebar-accent-foreground\"\n >\n <span className=\"truncate\">New chat</span>\n </button>\n )}\n </div>\n </div>\n );\n}\n\nexport function NavContent({\n onNavigate,\n extensions,\n}: {\n onNavigate?: () => void;\n extensions?: DispatchExtensionConfig;\n}) {\n const location = useLocation();\n const { data: workspace } = useActionQuery(\n \"get-workspace-info\",\n {},\n { staleTime: 60_000 },\n );\n const ws = workspace as WorkspaceInfo | undefined;\n const workspaceLabel = ws?.displayName ?? ws?.name ?? null;\n const extensionNavItems = extensions?.navItems ?? EMPTY_NAV_ITEMS;\n const primaryNavItems = [\n ...PRIMARY_NAV_ITEMS,\n ...navItemsForSection(extensionNavItems, \"primary\"),\n ];\n const operationsNavItems = [\n ...OPERATIONS_NAV_ITEMS,\n ...navItemsForSection(extensionNavItems, \"operations\"),\n ];\n const localPathname = localDispatchPath(location.pathname);\n const operationsOpen = operationsNavItems.some((item) =>\n navItemMatchesPath(item, localPathname),\n );\n\n const renderNavItem = (item: DispatchNavItem) => {\n const Icon = item.icon;\n const itemMatchesLocalPath = navItemMatchesPath(item, localPathname);\n return (\n <li key={item.id}>\n <NavLink\n to={dispatchNavLinkTarget(item.to)}\n onClick={onNavigate}\n className={({ isActive }) => {\n const active = isActive || itemMatchesLocalPath;\n return cn(\n \"flex h-8 w-full items-center gap-2 rounded-md px-2 text-sm\",\n active\n ? \"bg-sidebar-accent font-medium text-sidebar-accent-foreground\"\n : \"text-sidebar-foreground/70 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground\",\n );\n }}\n >\n {Icon ? (\n <Icon size={16} className=\"shrink-0\" />\n ) : (\n <span className=\"h-4 w-4 shrink-0\" aria-hidden=\"true\" />\n )}\n <span className=\"truncate\">{item.label}</span>\n </NavLink>\n {item.id === \"chat\" && itemMatchesLocalPath ? (\n <DispatchChatsSection onNavigate={onNavigate} />\n ) : null}\n </li>\n );\n };\n\n return (\n <>\n <div className=\"border-b px-4 py-3\">\n <div className=\"flex items-center gap-3\">\n <div className=\"flex h-9 w-9 items-center justify-center rounded-xl border bg-card text-foreground\">\n <img\n src={appPath(\"/agent-native-icon-light.svg\")}\n alt=\"\"\n aria-hidden=\"true\"\n className=\"block h-4 w-auto shrink-0 dark:hidden\"\n />\n <img\n src={appPath(\"/agent-native-icon-dark.svg\")}\n alt=\"\"\n aria-hidden=\"true\"\n className=\"hidden h-4 w-auto shrink-0 dark:block\"\n />\n </div>\n <div className=\"min-w-0\">\n <div className=\"truncate text-sm font-semibold text-foreground\">\n {workspaceLabel ?? \"Dispatch\"}\n </div>\n <div className=\"truncate text-xs text-muted-foreground\">\n {workspaceLabel\n ? `Workspace · ${ws?.appCount ?? 0} app${ws?.appCount === 1 ? \"\" : \"s\"}`\n : \"Workspace control plane\"}\n </div>\n </div>\n </div>\n </div>\n\n <div className=\"flex min-h-0 flex-1 flex-col overflow-y-auto\">\n <nav className=\"px-2 py-3\">\n <ul className=\"space-y-0.5\">{primaryNavItems.map(renderNavItem)}</ul>\n </nav>\n\n <div className=\"mt-auto shrink-0\">\n <div className=\"border-t px-2 py-2\">\n <details className=\"group\" open={operationsOpen}>\n <summary className=\"flex h-8 cursor-pointer list-none items-center justify-between rounded-md px-2 text-xs font-medium uppercase text-sidebar-foreground/50 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground [&::-webkit-details-marker]:hidden\">\n <span>Operations</span>\n <IconChevronDown\n size={14}\n className=\"transition-transform group-open:rotate-180\"\n />\n </summary>\n <ul className=\"mt-1 space-y-0.5\">\n {operationsNavItems.map(renderNavItem)}\n </ul>\n </details>\n </div>\n\n <div className=\"border-t px-2 py-1\">\n <ExtensionsSidebarSection />\n </div>\n\n <div className=\"border-t px-3 py-2\">\n <OrgSwitcher />\n </div>\n\n <div className=\"border-t px-3 py-2\">\n <FeedbackButton />\n </div>\n </div>\n </div>\n </>\n );\n}\n\nexport function Layout({\n children,\n extensions,\n}: {\n children: ReactNode;\n extensions?: DispatchExtensionConfig;\n}) {\n const location = useLocation();\n const [mobileOpen, setMobileOpen] = useState(false);\n const localPathname = localDispatchPath(location.pathname);\n\n if (CHROMELESS_PATHS.some((path) => localPathname === path)) {\n return <>{children}</>;\n }\n\n const isChatRoute = localPathname === \"/chat\";\n const showHeader = !isChatRoute && !pageOwnsToolbar(localPathname);\n const appContent = (\n <div className=\"flex h-full min-w-0 flex-1 flex-col overflow-hidden\">\n {showHeader ? <Header onOpenMobile={() => setMobileOpen(true)} /> : null}\n <InvitationBanner />\n <main\n className={cn(\n \"flex-1\",\n isChatRoute ? \"min-h-0 overflow-hidden\" : \"overflow-y-auto\",\n )}\n >\n {showHeader ? (\n <div className=\"mx-auto max-w-7xl space-y-10 px-4 py-6 sm:px-6\">\n {children}\n </div>\n ) : (\n children\n )}\n </main>\n </div>\n );\n const content = isChatRoute ? (\n appContent\n ) : (\n <AgentSidebar\n position=\"right\"\n defaultOpen={false}\n emptyStateText=\"Create apps, manage vault keys, and route work across the workspace.\"\n suggestions={SIDEBAR_SUGGESTIONS}\n >\n {appContent}\n </AgentSidebar>\n );\n\n return (\n <HeaderActionsProvider>\n <div className=\"flex h-screen w-full overflow-hidden bg-background\">\n <aside className=\"hidden lg:flex w-64 shrink-0 flex-col border-r bg-sidebar text-sidebar-foreground\">\n <NavContent extensions={extensions} />\n </aside>\n\n <Sheet open={mobileOpen} onOpenChange={setMobileOpen}>\n <SheetContent\n side=\"left\"\n className=\"w-72 p-0 bg-sidebar text-sidebar-foreground [&>button]:hidden\"\n >\n <SheetTitle className=\"sr-only\">Navigation</SheetTitle>\n <SheetDescription className=\"sr-only\">\n Workspace navigation links\n </SheetDescription>\n <div className=\"flex h-full w-full flex-col\">\n <NavContent\n extensions={extensions}\n onNavigate={() => setMobileOpen(false)}\n />\n </div>\n </SheetContent>\n </Sheet>\n\n {content}\n </div>\n </HeaderActionsProvider>\n );\n}\n"]}
|
|
@@ -127,6 +127,8 @@ function resolveView(pathname, extensions) {
|
|
|
127
127
|
if (pathname === "/extensions" || pathname.startsWith("/extensions/")) {
|
|
128
128
|
return "extensions";
|
|
129
129
|
}
|
|
130
|
+
if (pathname.startsWith("/chat"))
|
|
131
|
+
return "chat";
|
|
130
132
|
if (pathname.startsWith("/apps"))
|
|
131
133
|
return "apps";
|
|
132
134
|
if (pathname.startsWith("/metrics"))
|
|
@@ -161,6 +163,9 @@ function resolveView(pathname, extensions) {
|
|
|
161
163
|
}
|
|
162
164
|
function resolvePath(view, extensions, command) {
|
|
163
165
|
switch (view) {
|
|
166
|
+
case "chat":
|
|
167
|
+
case "ask":
|
|
168
|
+
return "/chat";
|
|
164
169
|
case "overview":
|
|
165
170
|
return "/overview";
|
|
166
171
|
case "apps":
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-navigation-state.js","sourceRoot":"","sources":["../../src/hooks/use-navigation-state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACjE,O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B;YACE,OAAO,oBAAoB,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;IAClD,CAAC;AACH,CAAC;AAED,SAAS,yBAAyB,CAAC,QAAgB;IACjD,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,iCAAiC,CAAC,CAAC;IAChE,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;QAAE,OAAO,SAAS,CAAC;IAClC,IAAI,CAAC;QACH,OAAO,kBAAkB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IACtC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC","sourcesContent":["import { useEffect } from \"react\";\nimport { useLocation, useNavigate } from \"react-router\";\nimport { useQuery, useQueryClient } from \"@tanstack/react-query\";\nimport {\n agentNativePath,\n appBasePath,\n appPath,\n} from \"@agent-native/core/client\";\nimport { extensionIdFromPathname } from \"@agent-native/core/client/extensions\";\nimport type {\n DispatchExtensionConfig,\n DispatchNavItem,\n} from \"../components/index.js\";\n\nexport interface NavigationState {\n view: string;\n path?: string;\n extensionId?: string;\n extensionSlug?: string;\n dreamId?: string;\n sourceId?: string;\n query?: string;\n}\n\nexport function useNavigationState(extensions?: DispatchExtensionConfig) {\n const location = useLocation();\n const navigate = useNavigate();\n const qc = useQueryClient();\n\n // Sync current route to application state\n useEffect(() => {\n const localPathname = routerPath(location.pathname);\n const state = buildDispatchNavigationState(\n localPathname,\n location.search,\n extensions,\n );\n\n fetch(agentNativePath(\"/_agent-native/application-state/navigation\"), {\n method: \"PUT\",\n keepalive: true,\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify(state),\n }).catch(() => {});\n }, [extensions, location.pathname, location.search]);\n\n // Listen for navigate commands from agent\n const { data: navCommand } = useQuery({\n queryKey: [\"navigate-command\"],\n queryFn: async () => {\n const res = await fetch(\n agentNativePath(\"/_agent-native/application-state/navigate\"),\n );\n if (!res.ok) return null;\n const data = await res.json();\n if (data) {\n // Return with a timestamp to ensure uniqueness\n return { ...data, _ts: Date.now() };\n }\n return null;\n },\n refetchInterval: 2_000,\n structuralSharing: false,\n });\n\n useEffect(() => {\n if (!navCommand) return;\n // Delete the one-shot command AFTER reading it\n fetch(agentNativePath(\"/_agent-native/application-state/navigate\"), {\n method: \"DELETE\",\n headers: { \"X-Agent-Native-CSRF\": \"1\" },\n }).catch(() => {});\n const cmd = navCommand as NavigationState;\n\n // Navigate to a specific path or resolve view name to path\n const resolvedPath =\n cmd.path || resolvePath(cmd.view, extensions, cmd) || \"/overview\";\n const path =\n cmd.view === \"dreams\" && cmd.dreamId && !resolvedPath.includes(\"?\")\n ? `${resolvedPath}?dreamId=${encodeURIComponent(cmd.dreamId)}`\n : resolvedPath;\n const nextPath = routerPath(path);\n navigate(nextPath);\n qc.setQueryData([\"navigate-command\"], null);\n }, [extensions, navCommand, navigate, qc]);\n}\n\nexport function buildDispatchNavigationState(\n pathname: string,\n search = \"\",\n extensions?: DispatchExtensionConfig,\n): NavigationState {\n const state: NavigationState = {\n view: resolveView(pathname, extensions),\n path: appPath(pathname),\n };\n\n const extensionId = extensionIdFromPathname(pathname);\n if (extensionId) {\n state.view = \"extensions\";\n state.extensionId = extensionId;\n const slug = extensionSlugFromPathname(pathname);\n if (slug) state.extensionSlug = slug;\n return state;\n }\n\n if (state.view === \"dreams\") {\n const params = new URLSearchParams(search);\n const dreamId = params.get(\"dreamId\");\n const sourceId = params.get(\"sourceId\");\n const query = params.get(\"query\");\n if (dreamId) state.dreamId = dreamId;\n if (sourceId) state.sourceId = sourceId;\n if (query) state.query = query;\n }\n\n return state;\n}\n\nfunction routerPath(path: string): string {\n const basePath = appBasePath();\n if (!basePath) return path;\n let result = path;\n // Iteratively strip basename. A path that arrives doubly-prefixed\n // (e.g. \"/dispatch/dispatch/overview\", possibly from a stale link or a\n // prior bug) would otherwise get partially stripped here and then\n // re-prefixed by react-router's basename, restoring the bad URL.\n for (let i = 0; i < 4; i += 1) {\n if (result === basePath) return \"/\";\n if (!result.startsWith(`${basePath}/`)) break;\n result = result.slice(basePath.length) || \"/\";\n }\n return result;\n}\n\nfunction extensionItemMatchesPath(\n item: DispatchNavItem,\n pathname: string,\n): boolean {\n if (item.match) {\n try {\n if (item.match(pathname)) return true;\n } catch {\n return false;\n }\n }\n return pathname === item.to || pathname.startsWith(`${item.to}/`);\n}\n\nfunction resolveExtensionView(\n pathname: string,\n extensions?: DispatchExtensionConfig,\n): string | undefined {\n return extensions?.navItems?.find((item) =>\n extensionItemMatchesPath(item, pathname),\n )?.id;\n}\n\nfunction resolveExtensionPath(\n view: string | undefined,\n extensions?: DispatchExtensionConfig,\n): string | undefined {\n if (!view) return undefined;\n return extensions?.navItems?.find((item) => item.id === view)?.to;\n}\n\nfunction resolveView(\n pathname: string,\n extensions?: DispatchExtensionConfig,\n): string {\n const extensionView = resolveExtensionView(pathname, extensions);\n if (extensionView) return extensionView;\n if (pathname === \"/extensions\" || pathname.startsWith(\"/extensions/\")) {\n return \"extensions\";\n }\n if (pathname.startsWith(\"/apps\")) return \"apps\";\n if (pathname.startsWith(\"/metrics\")) return \"metrics\";\n if (pathname.startsWith(\"/new-app\")) return \"new-app\";\n if (pathname.startsWith(\"/vault\")) return \"vault\";\n if (pathname.startsWith(\"/integrations\")) return \"integrations\";\n if (pathname.startsWith(\"/workspace\")) return \"workspace\";\n if (pathname.startsWith(\"/agents\")) return \"agents\";\n if (pathname.startsWith(\"/messaging\")) return \"messaging\";\n if (pathname.startsWith(\"/destinations\")) return \"destinations\";\n if (pathname.startsWith(\"/identities\")) return \"identities\";\n if (pathname.startsWith(\"/approvals\")) return \"approvals\";\n if (pathname.startsWith(\"/audit\")) return \"audit\";\n if (pathname.startsWith(\"/dreams\")) return \"dreams\";\n if (pathname.startsWith(\"/thread-debug\")) return \"thread-debug\";\n if (pathname.startsWith(\"/team\")) return \"team\";\n return \"overview\";\n}\n\nfunction resolvePath(\n view?: string,\n extensions?: DispatchExtensionConfig,\n command?: Pick<NavigationState, \"extensionId\">,\n): string | undefined {\n switch (view) {\n case \"overview\":\n return \"/overview\";\n case \"apps\":\n return \"/apps\";\n case \"metrics\":\n case \"usage\":\n return \"/metrics\";\n case \"new-app\":\n case \"create-app\":\n return \"/new-app\";\n case \"vault\":\n case \"secrets\":\n return \"/vault\";\n case \"integrations\":\n return \"/integrations\";\n case \"workspace\":\n case \"resources\":\n return \"/workspace\";\n case \"agents\":\n return \"/agents\";\n case \"messaging\":\n return \"/messaging\";\n case \"destinations\":\n case \"routes\":\n return \"/destinations\";\n case \"identities\":\n return \"/identities\";\n case \"approvals\":\n return \"/approvals\";\n case \"audit\":\n return \"/audit\";\n case \"dreams\":\n return \"/dreams\";\n case \"thread-debug\":\n case \"threads\":\n return \"/thread-debug\";\n case \"team\":\n return \"/team\";\n case \"extensions\":\n return command?.extensionId\n ? `/extensions/${encodeURIComponent(command.extensionId)}`\n : \"/extensions\";\n default:\n return resolveExtensionPath(view, extensions);\n }\n}\n\nfunction extensionSlugFromPathname(pathname: string): string | undefined {\n const match = pathname.match(/^\\/extensions\\/[^/]+\\/([^/?#]+)/);\n if (!match?.[1]) return undefined;\n try {\n return decodeURIComponent(match[1]);\n } catch {\n return match[1];\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"use-navigation-state.js","sourceRoot":"","sources":["../../src/hooks/use-navigation-state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,EACL,eAAe,EACf,WAAW,EACX,OAAO,GACR,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,uBAAuB,EAAE,MAAM,sCAAsC,CAAC;AAgB/E,MAAM,UAAU,kBAAkB,CAAC,UAAoC;IACrE,MAAM,QAAQ,GAAG,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,CAAC,CAAC;IAClD,CAAC;AACH,CAAC;AAED,SAAS,yBAAyB,CAAC,QAAgB;IACjD,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,iCAAiC,CAAC,CAAC;IAChE,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;QAAE,OAAO,SAAS,CAAC;IAClC,IAAI,CAAC;QACH,OAAO,kBAAkB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IACtC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC","sourcesContent":["import { useEffect } from \"react\";\nimport { useLocation, useNavigate } from \"react-router\";\nimport { useQuery, useQueryClient } from \"@tanstack/react-query\";\nimport {\n agentNativePath,\n appBasePath,\n appPath,\n} from \"@agent-native/core/client\";\nimport { extensionIdFromPathname } from \"@agent-native/core/client/extensions\";\nimport type {\n DispatchExtensionConfig,\n DispatchNavItem,\n} from \"../components/index.js\";\n\nexport interface NavigationState {\n view: string;\n path?: string;\n extensionId?: string;\n extensionSlug?: string;\n dreamId?: string;\n sourceId?: string;\n query?: string;\n}\n\nexport function useNavigationState(extensions?: DispatchExtensionConfig) {\n const location = useLocation();\n const navigate = useNavigate();\n const qc = useQueryClient();\n\n // Sync current route to application state\n useEffect(() => {\n const localPathname = routerPath(location.pathname);\n const state = buildDispatchNavigationState(\n localPathname,\n location.search,\n extensions,\n );\n\n fetch(agentNativePath(\"/_agent-native/application-state/navigation\"), {\n method: \"PUT\",\n keepalive: true,\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify(state),\n }).catch(() => {});\n }, [extensions, location.pathname, location.search]);\n\n // Listen for navigate commands from agent\n const { data: navCommand } = useQuery({\n queryKey: [\"navigate-command\"],\n queryFn: async () => {\n const res = await fetch(\n agentNativePath(\"/_agent-native/application-state/navigate\"),\n );\n if (!res.ok) return null;\n const data = await res.json();\n if (data) {\n // Return with a timestamp to ensure uniqueness\n return { ...data, _ts: Date.now() };\n }\n return null;\n },\n refetchInterval: 2_000,\n structuralSharing: false,\n });\n\n useEffect(() => {\n if (!navCommand) return;\n // Delete the one-shot command AFTER reading it\n fetch(agentNativePath(\"/_agent-native/application-state/navigate\"), {\n method: \"DELETE\",\n headers: { \"X-Agent-Native-CSRF\": \"1\" },\n }).catch(() => {});\n const cmd = navCommand as NavigationState;\n\n // Navigate to a specific path or resolve view name to path\n const resolvedPath =\n cmd.path || resolvePath(cmd.view, extensions, cmd) || \"/overview\";\n const path =\n cmd.view === \"dreams\" && cmd.dreamId && !resolvedPath.includes(\"?\")\n ? `${resolvedPath}?dreamId=${encodeURIComponent(cmd.dreamId)}`\n : resolvedPath;\n const nextPath = routerPath(path);\n navigate(nextPath);\n qc.setQueryData([\"navigate-command\"], null);\n }, [extensions, navCommand, navigate, qc]);\n}\n\nexport function buildDispatchNavigationState(\n pathname: string,\n search = \"\",\n extensions?: DispatchExtensionConfig,\n): NavigationState {\n const state: NavigationState = {\n view: resolveView(pathname, extensions),\n path: appPath(pathname),\n };\n\n const extensionId = extensionIdFromPathname(pathname);\n if (extensionId) {\n state.view = \"extensions\";\n state.extensionId = extensionId;\n const slug = extensionSlugFromPathname(pathname);\n if (slug) state.extensionSlug = slug;\n return state;\n }\n\n if (state.view === \"dreams\") {\n const params = new URLSearchParams(search);\n const dreamId = params.get(\"dreamId\");\n const sourceId = params.get(\"sourceId\");\n const query = params.get(\"query\");\n if (dreamId) state.dreamId = dreamId;\n if (sourceId) state.sourceId = sourceId;\n if (query) state.query = query;\n }\n\n return state;\n}\n\nfunction routerPath(path: string): string {\n const basePath = appBasePath();\n if (!basePath) return path;\n let result = path;\n // Iteratively strip basename. A path that arrives doubly-prefixed\n // (e.g. \"/dispatch/dispatch/overview\", possibly from a stale link or a\n // prior bug) would otherwise get partially stripped here and then\n // re-prefixed by react-router's basename, restoring the bad URL.\n for (let i = 0; i < 4; i += 1) {\n if (result === basePath) return \"/\";\n if (!result.startsWith(`${basePath}/`)) break;\n result = result.slice(basePath.length) || \"/\";\n }\n return result;\n}\n\nfunction extensionItemMatchesPath(\n item: DispatchNavItem,\n pathname: string,\n): boolean {\n if (item.match) {\n try {\n if (item.match(pathname)) return true;\n } catch {\n return false;\n }\n }\n return pathname === item.to || pathname.startsWith(`${item.to}/`);\n}\n\nfunction resolveExtensionView(\n pathname: string,\n extensions?: DispatchExtensionConfig,\n): string | undefined {\n return extensions?.navItems?.find((item) =>\n extensionItemMatchesPath(item, pathname),\n )?.id;\n}\n\nfunction resolveExtensionPath(\n view: string | undefined,\n extensions?: DispatchExtensionConfig,\n): string | undefined {\n if (!view) return undefined;\n return extensions?.navItems?.find((item) => item.id === view)?.to;\n}\n\nfunction resolveView(\n pathname: string,\n extensions?: DispatchExtensionConfig,\n): string {\n const extensionView = resolveExtensionView(pathname, extensions);\n if (extensionView) return extensionView;\n if (pathname === \"/extensions\" || pathname.startsWith(\"/extensions/\")) {\n return \"extensions\";\n }\n if (pathname.startsWith(\"/chat\")) return \"chat\";\n if (pathname.startsWith(\"/apps\")) return \"apps\";\n if (pathname.startsWith(\"/metrics\")) return \"metrics\";\n if (pathname.startsWith(\"/new-app\")) return \"new-app\";\n if (pathname.startsWith(\"/vault\")) return \"vault\";\n if (pathname.startsWith(\"/integrations\")) return \"integrations\";\n if (pathname.startsWith(\"/workspace\")) return \"workspace\";\n if (pathname.startsWith(\"/agents\")) return \"agents\";\n if (pathname.startsWith(\"/messaging\")) return \"messaging\";\n if (pathname.startsWith(\"/destinations\")) return \"destinations\";\n if (pathname.startsWith(\"/identities\")) return \"identities\";\n if (pathname.startsWith(\"/approvals\")) return \"approvals\";\n if (pathname.startsWith(\"/audit\")) return \"audit\";\n if (pathname.startsWith(\"/dreams\")) return \"dreams\";\n if (pathname.startsWith(\"/thread-debug\")) return \"thread-debug\";\n if (pathname.startsWith(\"/team\")) return \"team\";\n return \"overview\";\n}\n\nfunction resolvePath(\n view?: string,\n extensions?: DispatchExtensionConfig,\n command?: Pick<NavigationState, \"extensionId\">,\n): string | undefined {\n switch (view) {\n case \"chat\":\n case \"ask\":\n return \"/chat\";\n case \"overview\":\n return \"/overview\";\n case \"apps\":\n return \"/apps\";\n case \"metrics\":\n case \"usage\":\n return \"/metrics\";\n case \"new-app\":\n case \"create-app\":\n return \"/new-app\";\n case \"vault\":\n case \"secrets\":\n return \"/vault\";\n case \"integrations\":\n return \"/integrations\";\n case \"workspace\":\n case \"resources\":\n return \"/workspace\";\n case \"agents\":\n return \"/agents\";\n case \"messaging\":\n return \"/messaging\";\n case \"destinations\":\n case \"routes\":\n return \"/destinations\";\n case \"identities\":\n return \"/identities\";\n case \"approvals\":\n return \"/approvals\";\n case \"audit\":\n return \"/audit\";\n case \"dreams\":\n return \"/dreams\";\n case \"thread-debug\":\n case \"threads\":\n return \"/thread-debug\";\n case \"team\":\n return \"/team\";\n case \"extensions\":\n return command?.extensionId\n ? `/extensions/${encodeURIComponent(command.extensionId)}`\n : \"/extensions\";\n default:\n return resolveExtensionPath(view, extensions);\n }\n}\n\nfunction extensionSlugFromPathname(pathname: string): string | undefined {\n const match = pathname.match(/^\\/extensions\\/[^/]+\\/([^/?#]+)/);\n if (!match?.[1]) return undefined;\n try {\n return decodeURIComponent(match[1]);\n } catch {\n return match[1];\n }\n}\n"]}
|
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
export declare function submitOverviewPrompt(message: string, selectedModel?: string | null
|
|
1
|
+
export declare function submitOverviewPrompt(message: string, selectedModel?: string | null, options?: {
|
|
2
|
+
openSidebar?: boolean;
|
|
3
|
+
}): string | null;
|
|
2
4
|
//# sourceMappingURL=overview-chat.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"overview-chat.d.ts","sourceRoot":"","sources":["../../src/lib/overview-chat.ts"],"names":[],"mappings":"AAEA,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,MAAM,EACf,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"overview-chat.d.ts","sourceRoot":"","sources":["../../src/lib/overview-chat.ts"],"names":[],"mappings":"AAEA,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,MAAM,EACf,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,EAC7B,OAAO,CAAC,EAAE;IAAE,WAAW,CAAC,EAAE,OAAO,CAAA;CAAE,GAClC,MAAM,GAAG,IAAI,CAmBf"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isInBuilderFrame, sendToAgentChat } from "@agent-native/core/client";
|
|
2
|
-
export function submitOverviewPrompt(message, selectedModel) {
|
|
2
|
+
export function submitOverviewPrompt(message, selectedModel, options) {
|
|
3
3
|
const trimmed = message.trim();
|
|
4
4
|
if (!trimmed)
|
|
5
5
|
return null;
|
|
@@ -15,6 +15,7 @@ export function submitOverviewPrompt(message, selectedModel) {
|
|
|
15
15
|
submit: true,
|
|
16
16
|
newTab: true,
|
|
17
17
|
model: selectedModel || undefined,
|
|
18
|
+
...(options?.openSidebar === false ? { openSidebar: false } : {}),
|
|
18
19
|
});
|
|
19
20
|
}
|
|
20
21
|
//# sourceMappingURL=overview-chat.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"overview-chat.js","sourceRoot":"","sources":["../../src/lib/overview-chat.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAE9E,MAAM,UAAU,oBAAoB,CAClC,OAAe,EACf,aAA6B;
|
|
1
|
+
{"version":3,"file":"overview-chat.js","sourceRoot":"","sources":["../../src/lib/overview-chat.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAE9E,MAAM,UAAU,oBAAoB,CAClC,OAAe,EACf,aAA6B,EAC7B,OAAmC;IAEnC,MAAM,OAAO,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;IAC/B,IAAI,CAAC,OAAO;QAAE,OAAO,IAAI,CAAC;IAE1B,IAAI,gBAAgB,EAAE,EAAE,CAAC;QACvB,OAAO,eAAe,CAAC;YACrB,OAAO,EAAE,OAAO;YAChB,MAAM,EAAE,IAAI;YACZ,IAAI,EAAE,MAAM;SACb,CAAC,CAAC;IACL,CAAC;IAED,OAAO,eAAe,CAAC;QACrB,OAAO,EAAE,OAAO;QAChB,MAAM,EAAE,IAAI;QACZ,MAAM,EAAE,IAAI;QACZ,KAAK,EAAE,aAAa,IAAI,SAAS;QACjC,GAAG,CAAC,OAAO,EAAE,WAAW,KAAK,KAAK,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAClE,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { isInBuilderFrame, sendToAgentChat } from \"@agent-native/core/client\";\n\nexport function submitOverviewPrompt(\n message: string,\n selectedModel?: string | null,\n options?: { openSidebar?: boolean },\n): string | null {\n const trimmed = message.trim();\n if (!trimmed) return null;\n\n if (isInBuilderFrame()) {\n return sendToAgentChat({\n message: trimmed,\n submit: true,\n type: \"code\",\n });\n }\n\n return sendToAgentChat({\n message: trimmed,\n submit: true,\n newTab: true,\n model: selectedModel || undefined,\n ...(options?.openSidebar === false ? { openSidebar: false } : {}),\n });\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/routes/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAgB,MAAM,0BAA0B,CAAC;AAE1E;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,eAAO,MAAM,cAAc,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/routes/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAgB,MAAM,0BAA0B,CAAC;AAE1E;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,eAAO,MAAM,cAAc,EAAE,WA6B5B,CAAC"}
|
package/dist/routes/index.js
CHANGED
|
@@ -30,6 +30,7 @@ import { route, index } from "@react-router/dev/routes";
|
|
|
30
30
|
*/
|
|
31
31
|
export const dispatchRoutes = [
|
|
32
32
|
index("./pages/_index.js"),
|
|
33
|
+
route("chat", "./pages/chat.js"),
|
|
33
34
|
route("overview", "./pages/overview.js"),
|
|
34
35
|
route("metrics", "./pages/metrics.js"),
|
|
35
36
|
route("apps", "./pages/apps.js"),
|
package/dist/routes/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/routes/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,KAAK,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AAE1E;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,CAAC,MAAM,cAAc,GAAgB;IACzC,KAAK,CAAC,mBAAmB,CAAC;IAC1B,KAAK,CAAC,UAAU,EAAE,qBAAqB,CAAC;IACxC,KAAK,CAAC,SAAS,EAAE,oBAAoB,CAAC;IACtC,KAAK,CAAC,MAAM,EAAE,iBAAiB,CAAC;IAChC,KAAK,CAAC,aAAa,EAAE,wBAAwB,CAAC;IAC9C,KAAK,CAAC,SAAS,EAAE,oBAAoB,CAAC;IACtC,KAAK,CAAC,OAAO,EAAE,kBAAkB,CAAC;IAClC,KAAK,CAAC,cAAc,EAAE,yBAAyB,CAAC;IAChD,KAAK,CAAC,QAAQ,EAAE,mBAAmB,CAAC;IACpC,KAAK,CAAC,WAAW,EAAE,sBAAsB,CAAC;IAC1C,KAAK,CAAC,WAAW,EAAE,sBAAsB,CAAC;IAC1C,KAAK,CAAC,cAAc,EAAE,yBAAyB,CAAC;IAChD,KAAK,CAAC,YAAY,EAAE,uBAAuB,CAAC;IAC5C,KAAK,CAAC,UAAU,EAAE,qBAAqB,CAAC;IACxC,KAAK,CAAC,WAAW,EAAE,sBAAsB,CAAC;IAC1C,KAAK,CAAC,OAAO,EAAE,kBAAkB,CAAC;IAClC,KAAK,CAAC,QAAQ,EAAE,mBAAmB,CAAC;IACpC,KAAK,CAAC,cAAc,EAAE,yBAAyB,CAAC;IAChD,KAAK,CAAC,MAAM,EAAE,iBAAiB,CAAC;IAChC,KAAK,CAAC,YAAY,EAAE,8BAA8B,CAAC;IACnD,KAAK,CAAC,gBAAgB,EAAE,2BAA2B,CAAC;IACpD,KAAK,CAAC,sBAAsB,EAAE,2BAA2B,CAAC;IAC1D,yEAAyE;IACzE,0EAA0E;IAC1E,2EAA2E;IAC3E,wEAAwE;IACxE,KAAK,CAAC,QAAQ,EAAE,mBAAmB,CAAC;CACrC,CAAC","sourcesContent":["import { type RouteConfig, route, index } from \"@react-router/dev/routes\";\n\n/**\n * Dispatch's routes as a programmatic `RouteConfig[]`. Splat into the\n * consumer's `app/routes.ts`:\n *\n * ```ts\n * import { type RouteConfig } from \"@react-router/dev/routes\";\n * import { dispatchRoutes } from \"@agent-native/dispatch/routes\";\n *\n * export default [\n * ...localRoutes, // consumer's own routes win on collision\n * ...dispatchRoutes, // dispatch fills in everything else\n * ] satisfies RouteConfig;\n * ```\n *\n * Route precedence: React Router 7 matches in declaration order, so\n * placing `dispatchRoutes` LAST means consumer-defined routes with the\n * same path take precedence. To override a single dispatch route, define\n * it in your local routes; to keep it, omit it.\n *\n * The `file` paths below resolve relative to this file at runtime — they\n * point into `packages/dispatch/dist/routes/pages/*.js` after build.\n *\n * Naming maps the original flatRoutes file conventions:\n * `_index.tsx` → `index(...)`\n * `<name>.tsx` → `route(\"<name>\", ...)`\n * `<a>.$<param>.tsx` → `route(\"<a>/:<param>\", ...)`\n * `<a>._index.tsx` → flattened as `route(\"<a>\", ...)` (workspace\n * versions are bare and don't wrap a parent layout)\n */\nexport const dispatchRoutes: RouteConfig = [\n index(\"./pages/_index.js\"),\n route(\"overview\", \"./pages/overview.js\"),\n route(\"metrics\", \"./pages/metrics.js\"),\n route(\"apps\", \"./pages/apps.js\"),\n route(\"apps/:appId\", \"./pages/apps.$appId.js\"),\n route(\"new-app\", \"./pages/new-app.js\"),\n route(\"vault\", \"./pages/vault.js\"),\n route(\"integrations\", \"./pages/integrations.js\"),\n route(\"agents\", \"./pages/agents.js\"),\n route(\"workspace\", \"./pages/workspace.js\"),\n route(\"messaging\", \"./pages/messaging.js\"),\n route(\"destinations\", \"./pages/destinations.js\"),\n route(\"identities\", \"./pages/identities.js\"),\n route(\"approval\", \"./pages/approval.js\"),\n route(\"approvals\", \"./pages/approvals.js\"),\n route(\"audit\", \"./pages/audit.js\"),\n route(\"dreams\", \"./pages/dreams.js\"),\n route(\"thread-debug\", \"./pages/thread-debug.js\"),\n route(\"team\", \"./pages/team.js\"),\n route(\"extensions\", \"./pages/extensions._index.js\"),\n route(\"extensions/:id\", \"./pages/extensions.$id.js\"),\n route(\"extensions/:id/:slug\", \"./pages/extensions.$id.js\"),\n // Catch-all for /:appId — bounces /dispatch/<appId> to /<appId> when the\n // segment names a workspace app sibling (e.g. Builder.io routing a \"go to\n // /todo\" call through Dispatch's mount). Declared last so React Router 7's\n // specificity ranking still matches explicit static routes above first.\n route(\":appId\", \"./pages/$appId.js\"),\n];\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/routes/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,KAAK,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AAE1E;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,CAAC,MAAM,cAAc,GAAgB;IACzC,KAAK,CAAC,mBAAmB,CAAC;IAC1B,KAAK,CAAC,MAAM,EAAE,iBAAiB,CAAC;IAChC,KAAK,CAAC,UAAU,EAAE,qBAAqB,CAAC;IACxC,KAAK,CAAC,SAAS,EAAE,oBAAoB,CAAC;IACtC,KAAK,CAAC,MAAM,EAAE,iBAAiB,CAAC;IAChC,KAAK,CAAC,aAAa,EAAE,wBAAwB,CAAC;IAC9C,KAAK,CAAC,SAAS,EAAE,oBAAoB,CAAC;IACtC,KAAK,CAAC,OAAO,EAAE,kBAAkB,CAAC;IAClC,KAAK,CAAC,cAAc,EAAE,yBAAyB,CAAC;IAChD,KAAK,CAAC,QAAQ,EAAE,mBAAmB,CAAC;IACpC,KAAK,CAAC,WAAW,EAAE,sBAAsB,CAAC;IAC1C,KAAK,CAAC,WAAW,EAAE,sBAAsB,CAAC;IAC1C,KAAK,CAAC,cAAc,EAAE,yBAAyB,CAAC;IAChD,KAAK,CAAC,YAAY,EAAE,uBAAuB,CAAC;IAC5C,KAAK,CAAC,UAAU,EAAE,qBAAqB,CAAC;IACxC,KAAK,CAAC,WAAW,EAAE,sBAAsB,CAAC;IAC1C,KAAK,CAAC,OAAO,EAAE,kBAAkB,CAAC;IAClC,KAAK,CAAC,QAAQ,EAAE,mBAAmB,CAAC;IACpC,KAAK,CAAC,cAAc,EAAE,yBAAyB,CAAC;IAChD,KAAK,CAAC,MAAM,EAAE,iBAAiB,CAAC;IAChC,KAAK,CAAC,YAAY,EAAE,8BAA8B,CAAC;IACnD,KAAK,CAAC,gBAAgB,EAAE,2BAA2B,CAAC;IACpD,KAAK,CAAC,sBAAsB,EAAE,2BAA2B,CAAC;IAC1D,yEAAyE;IACzE,0EAA0E;IAC1E,2EAA2E;IAC3E,wEAAwE;IACxE,KAAK,CAAC,QAAQ,EAAE,mBAAmB,CAAC;CACrC,CAAC","sourcesContent":["import { type RouteConfig, route, index } from \"@react-router/dev/routes\";\n\n/**\n * Dispatch's routes as a programmatic `RouteConfig[]`. Splat into the\n * consumer's `app/routes.ts`:\n *\n * ```ts\n * import { type RouteConfig } from \"@react-router/dev/routes\";\n * import { dispatchRoutes } from \"@agent-native/dispatch/routes\";\n *\n * export default [\n * ...localRoutes, // consumer's own routes win on collision\n * ...dispatchRoutes, // dispatch fills in everything else\n * ] satisfies RouteConfig;\n * ```\n *\n * Route precedence: React Router 7 matches in declaration order, so\n * placing `dispatchRoutes` LAST means consumer-defined routes with the\n * same path take precedence. To override a single dispatch route, define\n * it in your local routes; to keep it, omit it.\n *\n * The `file` paths below resolve relative to this file at runtime — they\n * point into `packages/dispatch/dist/routes/pages/*.js` after build.\n *\n * Naming maps the original flatRoutes file conventions:\n * `_index.tsx` → `index(...)`\n * `<name>.tsx` → `route(\"<name>\", ...)`\n * `<a>.$<param>.tsx` → `route(\"<a>/:<param>\", ...)`\n * `<a>._index.tsx` → flattened as `route(\"<a>\", ...)` (workspace\n * versions are bare and don't wrap a parent layout)\n */\nexport const dispatchRoutes: RouteConfig = [\n index(\"./pages/_index.js\"),\n route(\"chat\", \"./pages/chat.js\"),\n route(\"overview\", \"./pages/overview.js\"),\n route(\"metrics\", \"./pages/metrics.js\"),\n route(\"apps\", \"./pages/apps.js\"),\n route(\"apps/:appId\", \"./pages/apps.$appId.js\"),\n route(\"new-app\", \"./pages/new-app.js\"),\n route(\"vault\", \"./pages/vault.js\"),\n route(\"integrations\", \"./pages/integrations.js\"),\n route(\"agents\", \"./pages/agents.js\"),\n route(\"workspace\", \"./pages/workspace.js\"),\n route(\"messaging\", \"./pages/messaging.js\"),\n route(\"destinations\", \"./pages/destinations.js\"),\n route(\"identities\", \"./pages/identities.js\"),\n route(\"approval\", \"./pages/approval.js\"),\n route(\"approvals\", \"./pages/approvals.js\"),\n route(\"audit\", \"./pages/audit.js\"),\n route(\"dreams\", \"./pages/dreams.js\"),\n route(\"thread-debug\", \"./pages/thread-debug.js\"),\n route(\"team\", \"./pages/team.js\"),\n route(\"extensions\", \"./pages/extensions._index.js\"),\n route(\"extensions/:id\", \"./pages/extensions.$id.js\"),\n route(\"extensions/:id/:slug\", \"./pages/extensions.$id.js\"),\n // Catch-all for /:appId — bounces /dispatch/<appId> to /<appId> when the\n // segment names a workspace app sibling (e.g. Builder.io routing a \"go to\n // /todo\" call through Dispatch's mount). Declared last so React Router 7's\n // specificity ranking still matches explicit static routes above first.\n route(\":appId\", \"./pages/$appId.js\"),\n];\n"]}
|
|
@@ -21,7 +21,7 @@ export function meta() {
|
|
|
21
21
|
*
|
|
22
22
|
* We preserve `?` and `#` so deep-links like `?thread=<id>` from a Slack
|
|
23
23
|
* "Open thread" button survive the bounce — `useThreadDeepLink` in
|
|
24
|
-
* `root.tsx` reads them after the redirect lands
|
|
24
|
+
* `root.tsx` reads them after the redirect lands and opens `/chat`.
|
|
25
25
|
*/
|
|
26
26
|
function buildTarget(request) {
|
|
27
27
|
const url = new URL(request.url);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_index.js","sourceRoot":"","sources":["../../../src/routes/pages/_index.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAA2B,MAAM,cAAc,CAAC;AACjE,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAElD,MAAM,UAAU,IAAI;IAClB,OAAO;QACL,EAAE,KAAK,EAAE,uBAAuB,EAAE;QAClC;YACE,IAAI,EAAE,aAAa;YACnB,OAAO,EACL,sGAAsG;SACzG;KACF,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;GAWG;AACH,SAAS,WAAW,CAAC,OAAgB;IACnC,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACjC,OAAO,OAAO,CAAC,YAAY,GAAG,CAAC,MAAM,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC;AACtD,CAAC;AAED,MAAM,UAAU,MAAM,CAAC,EAAE,OAAO,EAAsB;IACpD,MAAM,QAAQ,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC;AACvC,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,EAAE,OAAO,EAAsB;IAC1D,MAAM,QAAQ,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC;AACvC,CAAC;AAED,MAAM,UAAU,eAAe;IAC7B,OAAO,CACL,cAAK,SAAS,EAAC,kDAAkD,YAC/D,KAAC,OAAO,IAAC,SAAS,EAAC,QAAQ,GAAG,GAC1B,CACP,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,OAAO,UAAU,SAAS;IAC/B,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import { redirect, type LoaderFunctionArgs } from \"react-router\";\nimport { appPath } from \"@agent-native/core/client\";\nimport { Spinner } from \"@/components/ui/spinner\";\n\nexport function meta() {\n return [\n { title: \"Agent-Native Dispatch\" },\n {\n name: \"description\",\n content:\n \"Your AI agent manages secrets, orchestrates other agents, and routes messages across your workspace.\",\n },\n ];\n}\n\n/**\n * Run the redirect on both the server and the client. A client-only\n * `<Navigate>` can drop during hydration (before the route tree is fully\n * attached), leaving the user stranded on `/` with a blank main area while\n * the layout chrome around it still renders. A `loader` redirect runs as\n * part of the server response and the navigation completes before the app\n * hydrates; `clientLoader` covers SPA-style navigations to `/`.\n *\n * We preserve `?` and `#` so deep-links like `?thread=<id>` from a Slack\n * \"Open thread\" button survive the bounce — `useThreadDeepLink` in\n * `root.tsx` reads them after the redirect lands
|
|
1
|
+
{"version":3,"file":"_index.js","sourceRoot":"","sources":["../../../src/routes/pages/_index.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAA2B,MAAM,cAAc,CAAC;AACjE,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAElD,MAAM,UAAU,IAAI;IAClB,OAAO;QACL,EAAE,KAAK,EAAE,uBAAuB,EAAE;QAClC;YACE,IAAI,EAAE,aAAa;YACnB,OAAO,EACL,sGAAsG;SACzG;KACF,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;GAWG;AACH,SAAS,WAAW,CAAC,OAAgB;IACnC,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACjC,OAAO,OAAO,CAAC,YAAY,GAAG,CAAC,MAAM,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC;AACtD,CAAC;AAED,MAAM,UAAU,MAAM,CAAC,EAAE,OAAO,EAAsB;IACpD,MAAM,QAAQ,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC;AACvC,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,EAAE,OAAO,EAAsB;IAC1D,MAAM,QAAQ,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC;AACvC,CAAC;AAED,MAAM,UAAU,eAAe;IAC7B,OAAO,CACL,cAAK,SAAS,EAAC,kDAAkD,YAC/D,KAAC,OAAO,IAAC,SAAS,EAAC,QAAQ,GAAG,GAC1B,CACP,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,OAAO,UAAU,SAAS;IAC/B,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import { redirect, type LoaderFunctionArgs } from \"react-router\";\nimport { appPath } from \"@agent-native/core/client\";\nimport { Spinner } from \"@/components/ui/spinner\";\n\nexport function meta() {\n return [\n { title: \"Agent-Native Dispatch\" },\n {\n name: \"description\",\n content:\n \"Your AI agent manages secrets, orchestrates other agents, and routes messages across your workspace.\",\n },\n ];\n}\n\n/**\n * Run the redirect on both the server and the client. A client-only\n * `<Navigate>` can drop during hydration (before the route tree is fully\n * attached), leaving the user stranded on `/` with a blank main area while\n * the layout chrome around it still renders. A `loader` redirect runs as\n * part of the server response and the navigation completes before the app\n * hydrates; `clientLoader` covers SPA-style navigations to `/`.\n *\n * We preserve `?` and `#` so deep-links like `?thread=<id>` from a Slack\n * \"Open thread\" button survive the bounce — `useThreadDeepLink` in\n * `root.tsx` reads them after the redirect lands and opens `/chat`.\n */\nfunction buildTarget(request: Request): string {\n const url = new URL(request.url);\n return appPath(`/overview${url.search}${url.hash}`);\n}\n\nexport function loader({ request }: LoaderFunctionArgs) {\n throw redirect(buildTarget(request));\n}\n\nexport function clientLoader({ request }: LoaderFunctionArgs) {\n throw redirect(buildTarget(request));\n}\n\nexport function HydrateFallback() {\n return (\n <div className=\"flex items-center justify-center h-screen w-full\">\n <Spinner className=\"size-8\" />\n </div>\n );\n}\n\nexport default function IndexPage() {\n return null;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apps.d.ts","sourceRoot":"","sources":["../../../src/routes/pages/apps.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"apps.d.ts","sourceRoot":"","sources":["../../../src/routes/pages/apps.tsx"],"names":[],"mappings":"AAoCA,wBAAgB,IAAI;;IAEnB;AAgCD,MAAM,CAAC,OAAO,UAAU,SAAS,4CAsMhC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { useState } from "react";
|
|
3
3
|
import { useActionMutation, useActionQuery } from "@agent-native/core/client";
|
|
4
|
-
import { IconApps, IconBrush, IconCalendarMonth, IconChartBar, IconChevronDown, IconClipboardList, IconEyeOff, IconFileText, IconLoader2, IconMail, IconPlus, IconPresentation, IconScreenShare, IconSparkles, IconStack3, IconVideo, } from "@tabler/icons-react";
|
|
4
|
+
import { IconApps, IconBrain, IconBrush, IconCalendarMonth, IconChartBar, IconChevronDown, IconClipboardList, IconEyeOff, IconFileText, IconLoader2, IconMail, IconPhoto, IconPlus, IconPresentation, IconScreenShare, IconSparkles, IconStack3, IconVideo, } from "@tabler/icons-react";
|
|
5
5
|
import { toast } from "sonner";
|
|
6
6
|
import { CreateAppPopover } from "../../components/create-app-popover.js";
|
|
7
7
|
import { DispatchShell } from "../../components/dispatch-shell.js";
|
|
@@ -19,6 +19,8 @@ const TEMPLATE_ICONS = {
|
|
|
19
19
|
FileText: IconFileText,
|
|
20
20
|
Presentation: IconPresentation,
|
|
21
21
|
ScreenShare: IconScreenShare,
|
|
22
|
+
Brain: IconBrain,
|
|
23
|
+
Photo: IconPhoto,
|
|
22
24
|
ChartBar: IconChartBar,
|
|
23
25
|
ClipboardList: IconClipboardList,
|
|
24
26
|
Brush: IconBrush,
|