@agent-native/dispatch 0.40.37 → 0.40.39

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,29 @@
1
1
  # @agent-native/dispatch
2
2
 
3
+ ## 0.40.39
4
+
5
+ ### Patch Changes
6
+
7
+ - Release all public npm packages with a patch version bump.
8
+ - Updated dependencies [838e1ae]
9
+ - Updated dependencies
10
+ - Updated dependencies [86429da]
11
+ - Updated dependencies [7b293b2]
12
+ - @agent-native/toolkit@0.219.0
13
+
14
+ ## 0.40.38
15
+
16
+ ### Patch Changes
17
+
18
+ - de3f844: Sign Dispatch's own workspace apps gateway read as the signed-in member with the deployment secret, so the receiver keeps the member's identity. Signing it with the organization secret made the registry refuse it, and a Dispatch with no deployment manifest to fall back on showed "Couldn't load data" (`workspace_gateway_rejected`).
19
+ - Release all public npm packages with a patch version bump.
20
+ - 84e4b2e: Show owned and shared chats in separate Dispatch history sections with independent paging and owner and access details.
21
+ - Updated dependencies [84e4b2e]
22
+ - Updated dependencies
23
+ - Updated dependencies [84e4b2e]
24
+ - Updated dependencies [fc038a0]
25
+ - @agent-native/toolkit@0.218.0
26
+
3
27
  ## 0.40.37
4
28
 
5
29
  ### Patch Changes
@@ -1321,18 +1345,4 @@
1321
1345
 
1322
1346
  - c58cd6e: Preserve verified mutation receipts and exact member identity across Dispatch and A2A delegation.
1323
1347
 
1324
- ## 0.30.2
1325
-
1326
- ### Patch Changes
1327
-
1328
- - 330cf77: Keep impersonal HTML redirects eligible for the shared SSR edge cache.
1329
-
1330
- ## 0.30.1
1331
-
1332
- ### Patch Changes
1333
-
1334
- - a2f21dc: Keep workspace apps inline outside Builder.io embeds.
1335
- - Updated dependencies [a2f21dc]
1336
- - @agent-native/toolkit@0.16.6
1337
-
1338
1348
  For the full list of releases, see the [changelog archive](./changelog/archive/CHANGELOG.md).
@@ -73,7 +73,6 @@ export declare function shouldQueryChatFirstApps(isChatRoute: boolean, chatFirst
73
73
  */
74
74
  export declare function isRedesignedSettingsPath(pathname: string, settingsRedesign: FeatureFlagState): boolean;
75
75
  export declare function dispatchNavLinkTarget(path: string): string;
76
- export declare function formatThreadAge(updatedAt: number, now?: number): string;
77
76
  export declare function NavContent({ onNavigate, extensions, brandName, brandIcon, chatFirstMode, chatFirstEmbedded, collapsed, collapsible, onCollapsedChange, chatFirstAppLayout, onChatFirstAppLayoutChange, chatFirstApps, chatFirstAppsLoading, chatFirstAppsError, chatFirstActiveAppId, chatFirstActivePrimaryTab, onChatFirstNewChat, onChatFirstAppOpen, onChatFirstAppsRetry, }: DispatchNavContentProps): import("node_modules/@types/react").JSX.Element;
78
77
  export declare function renderChatFirstAppSurfaceTab({ registration, embedPath, loading, isMobileSurface, copy, }: {
79
78
  registration: ChatFirstAppRegistration | null;
@@ -1 +1 @@
1
- {"version":3,"file":"Layout.d.ts","sourceRoot":"","sources":["../../../src/components/layout/Layout.tsx"],"names":[],"mappings":"AAAA,OAAO,EAiBL,KAAK,wBAAwB,EAC7B,KAAK,4BAA4B,EAYlC,MAAM,sCAAsC,CAAC;AAM9C,OAAO,EAEL,KAAK,gBAAgB,EACtB,MAAM,yCAAyC,CAAC;AAWjD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uDAAuD,CAAC;AACjG,OAAO,KAAK,EAEV,gBAAgB,EAChB,aAAa,EAEd,MAAM,iDAAiD,CAAC;AAiCzD,OAAO,EAQL,KAAK,aAAa,EAClB,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAYf,OAAO,EAaL,KAAK,mBAAmB,EACzB,MAAM,0BAA0B,CAAC;AAuClC,OAAO,EAAE,+BAA+B,EAAE,MAAM,uBAAuB,CAAC;AAExE,MAAM,MAAM,kBAAkB,GAAG,SAAS,GAAG,YAAY,CAAC;AAE1D,MAAM,MAAM,eAAe,GAAG,aAAa,CAAC;IAC1C,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACvB,S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M,EAChB,gBAAgB,EAAE,gBAAgB,GACjC,OAAO,CAKT;AAyBD,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAQ1D;AAshBD,wBAAgB,UAAU,CAAC,EACzB,UAAU,EACV,UAAU,EACV,SAAkC,EAClC,SAAS,EACT,aAAqB,EACrB,iBAAyB,EACzB,SAAiB,EACjB,WAAmB,EACnB,iBAAiB,EACjB,kBAAkB,EAClB,0BAA0B,EAC1B,aAAkB,EAClB,oBAA4B,EAC5B,kBAAkB,EAClB,oBAAoB,EACpB,yBAAyB,EACzB,kBAAkB,EAClB,kBAAkB,EAClB,oBAAoB,GACrB,EAAE,uBAAuB,mDAsRzB;AAED,wBAAgB,4BAA4B,CAAC,EAC3C,YAAY,EACZ,SAAS,EACT,OAAO,EACP,eAAe,EACf,IAAI,GACL,EAAE;IACD,YAAY,EAAE,wBAAwB,GAAG,IAAI,CAAC;IAC9C,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,OAAO,CAAC;IACjB,eAAe,EAAE,OAAO,CAAC;IACzB,IAAI,EAAE,aAAa,CAAC;CACrB,GAAG,SAAS,CAuCZ;AAED,wBAAgB,MAAM,CAAC,KAAK,EAAE,mBAAmB,mDAMhD"}
@@ -8,12 +8,12 @@ import { useT } from "@agent-native/core/client/i18n";
8
8
  import { SETTINGS_REDESIGN_FLAG } from "@agent-native/core/feature-flags/registry";
9
9
  import { AgentToggleButton, AgentSidebar, focusAgentChat, } from "@agent-native/toolkit/app/chat/AgentSidebar";
10
10
  import { defaultChatFirstCopy } from "@agent-native/toolkit/app/chat/chat-first-copy";
11
+ import { OwnershipChatHistoryRail, ownDraftRows, useOwnershipChatHistory, } from "@agent-native/toolkit/app/chat/ownership-history";
11
12
  import { FeedbackButton } from "@agent-native/toolkit/app/feedback";
12
13
  import { InvitationBanner, OrgSwitcher } from "@agent-native/toolkit/app/org";
13
14
  import { RunsTray } from "@agent-native/toolkit/app/progress";
14
15
  import { isSettingsPathname } from "@agent-native/toolkit/app/settings";
15
16
  import { AppSidebarFooter, AppSidebarHeader, openCommandMenu, } from "@agent-native/toolkit/app/shared";
16
- import { ChatHistoryRail, } from "@agent-native/toolkit/chat-history";
17
17
  import { writeClipboardText } from "@agent-native/toolkit/clipboard";
18
18
  import { IconApps, IconBrandSlack, IconBrandTelegram, IconCopy, IconEye, IconHierarchy2, IconMessageQuestion, IconBroadcast, IconLayoutSidebar, IconLayoutSidebarLeftCollapse, IconLayoutSidebarLeftExpand, IconSettings, IconShield, IconWorld, IconDeviceDesktop, IconPlus, } from "@tabler/icons-react";
19
19
  import { createContext, useEffect, useMemo, useRef, useState, useContext, useCallback, } from "react";
@@ -31,7 +31,6 @@ import { CreateAppPopover } from "../create-app-popover.js";
31
31
  import { AgentChatSurface, ChatFirstAgentsPane, ChatFirstAppPane, ChatFirstAppsRail, ChatFirstBrowserPane, ChatFirstChatHistory, ChatFirstPrimaryNavigation, ChatFirstSessionWatchPane, ChatFirstSurfaceContent, ChatFirstSurfacePanel, ChatFirstSurfacePanelToggle, ChatFirstSurfaceTabs, } from "../deferred-chat-components.js";
32
32
  import { Button } from "../ui/button.js";
33
33
  import { Sheet, SheetContent, SheetDescription, SheetTitle } from "../ui/sheet.js";
34
- import { Skeleton } from "../ui/skeleton.js";
35
34
  import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, } from "../ui/tooltip.js";
36
35
  import { WorkspaceAppChatRail, WorkspaceAppFrame, WorkspaceAppKeepAlive, } from "../workspace-app-host.js";
37
36
  import { Header } from "./Header.js";
@@ -334,26 +333,6 @@ function threadIdFromPath(pathname) {
334
333
  return null;
335
334
  }
336
335
  }
337
- export function formatThreadAge(updatedAt, now = Date.now()) {
338
- const diffMs = Math.max(0, now - updatedAt);
339
- const minutes = Math.floor(diffMs / 60_000);
340
- if (minutes < 1)
341
- return "now";
342
- if (minutes < 60)
343
- return `${minutes}m`;
344
- const hours = Math.floor(minutes / 60);
345
- if (hours < 24)
346
- return `${hours}h`;
347
- const days = Math.floor(hours / 24);
348
- if (days < 14)
349
- return `${days}d`;
350
- if (days < 365)
351
- return `${Math.floor(days / 7)}w`;
352
- return `${Math.floor(days / 365)}y`;
353
- }
354
- function threadTitle(thread, fallback) {
355
- return thread.title || thread.preview || fallback;
356
- }
357
336
  function threadSourceIcon(platform) {
358
337
  const normalized = platform?.trim().toLowerCase();
359
338
  if (!normalized)
@@ -377,13 +356,6 @@ function readChatHistoryIncludesExternal() {
377
356
  return false;
378
357
  }
379
358
  }
380
- function threadUpdatedAt(thread) {
381
- return Number.isFinite(thread.updatedAt)
382
- ? thread.updatedAt
383
- : Number.isFinite(thread.createdAt)
384
- ? thread.createdAt
385
- : 0;
386
- }
387
359
  function DispatchChatsSection({ onNavigate, showNewChat = false, prelude, chatFirstMode = false, chatFirstEmbedded = false, collapsed = false, chatFirstNavigation, }) {
388
360
  const t = useT();
389
361
  const chatFirstCopy = useMemo(() => createDispatchChatFirstCopy(t), [t]);
@@ -391,35 +363,45 @@ function DispatchChatsSection({ onNavigate, showNewChat = false, prelude, chatFi
391
363
  const location = useLocation();
392
364
  const [includeExternal, setIncludeExternal] = useState(false);
393
365
  const [historyPreferenceReady, setHistoryPreferenceReady] = useState(false);
394
- const historyModeRef = useRef(includeExternal);
395
- const { threads, activeThreadId, isLoading: chatsLoading, threadsLoadError, createThread, switchThread, renameThread, refreshThreads, } = useChatThreads(undefined, "dispatch", undefined, {
366
+ const { threads, activeThreadId, createThread, switchThread, renameThread, pinThread, archiveThread, isNewThread, } = useChatThreads(undefined, "dispatch", undefined, {
396
367
  autoCreate: false,
397
368
  includeExternal,
398
369
  });
399
- const visibleThreads = useMemo(() => threads
400
- .filter((thread) => thread.messageCount > 0 || thread.id === activeThreadId)
401
- .sort((a, b) => threadUpdatedAt(b) - threadUpdatedAt(a))
402
- .slice(0, 8), [activeThreadId, threads]);
403
370
  const localPathname = localDispatchPath(location.pathname);
404
371
  const displayedActiveThreadId = threadIdFromPath(localPathname) ??
405
372
  (localPathname === "/chat" ? null : activeThreadId);
406
- const chatItems = visibleThreads.map((thread) => {
407
- const title = threadTitle(thread, t("dispatch.sidebar.newChat"));
408
- const sourceIcon = threadSourceIcon(thread.source?.platform);
409
- const sourceLabel = thread.source?.platform
410
- ? thread.source.platform[0].toUpperCase() +
411
- thread.source.platform.slice(1)
412
- : null;
413
- return {
414
- id: thread.id,
415
- title: (_jsxs("span", { className: "flex min-w-0 items-center gap-1", title: sourceLabel ? `${sourceLabel}: ${title}` : title, children: [sourceIcon ? (_jsx("span", { className: "shrink-0 text-sidebar-foreground/55", "aria-label": sourceLabel ?? "Connected source", children: sourceIcon })) : null, _jsx("span", { className: "truncate", children: title })] })),
416
- titleText: title,
417
- timestamp: thread.id === displayedActiveThreadId
418
- ? ""
419
- : formatThreadAge(threadUpdatedAt(thread)),
420
- };
373
+ const history = useOwnershipChatHistory({
374
+ getThreadUrl: (threadId) => appPath(chatThreadPath(threadId)),
375
+ includeExternal,
376
+ activeId: displayedActiveThreadId,
377
+ localMineRows: ownDraftRows({
378
+ threads,
379
+ isNewThread,
380
+ activeId: activeThreadId,
381
+ }),
382
+ mutations: { pin: pinThread, rename: renameThread, archive: archiveThread },
383
+ onMutationFailed: () => toast.error(t("dispatch.integrations.failedToSave")),
384
+ decorateItem: (item, row) => {
385
+ const source = "source" in row ? row.source : undefined;
386
+ const sourceLabel = source?.platform
387
+ ? source.platform[0].toUpperCase() + source.platform.slice(1)
388
+ : undefined;
389
+ const sourceIcon = threadSourceIcon(source?.platform);
390
+ return {
391
+ ...item,
392
+ title: (_jsxs("span", { className: "flex min-w-0 items-center gap-1", title: sourceLabel ? `${sourceLabel}: ${item.titleText}` : item.titleText, children: [sourceIcon ? (_jsx("span", { className: "shrink-0 text-sidebar-foreground/55", "aria-label": sourceLabel, children: sourceIcon })) : null, _jsx("span", { className: "truncate", children: item.title })] })),
393
+ };
394
+ },
421
395
  });
422
- const chatHistoryError = threadsLoadError ? (_jsxs("button", { type: "button", onClick: () => refreshThreads(), className: "flex w-full items-center justify-between gap-2 rounded-md px-2 py-1.5 text-xs text-sidebar-foreground/65 transition-colors hover:bg-sidebar-accent hover:text-sidebar-accent-foreground", children: [_jsx("span", { children: "Could not load chats" }), _jsx("span", { className: "font-medium", children: "Retry" })] })) : undefined;
396
+ const listProps = {
397
+ ...history.listProps,
398
+ onDelete: async (threadId) => {
399
+ const archived = await history.listProps.onDelete?.(threadId);
400
+ if (archived && threadId === displayedActiveThreadId)
401
+ await handleNewChat();
402
+ return archived === true;
403
+ },
404
+ };
423
405
  useEffect(() => {
424
406
  setIncludeExternal(readChatHistoryIncludesExternal());
425
407
  setHistoryPreferenceReady(true);
@@ -431,27 +413,7 @@ function DispatchChatsSection({ onNavigate, showNewChat = false, prelude, chatFi
431
413
  localStorage.setItem(CHAT_HISTORY_SOURCE_KEY, includeExternal ? "all" : "local");
432
414
  }
433
415
  catch { } // coercion-ok: localStorage is optional browser persistence.
434
- if (historyModeRef.current !== includeExternal) {
435
- historyModeRef.current = includeExternal;
436
- refreshThreads();
437
- }
438
- }, [historyPreferenceReady, includeExternal, refreshThreads]);
439
- useEffect(() => {
440
- const refresh = () => refreshThreads();
441
- const handleRunning = (event) => {
442
- const detail = event.detail;
443
- if (detail?.isRunning === false)
444
- refreshThreads();
445
- };
446
- window.addEventListener("agent-chat:threads-updated", refresh);
447
- window.addEventListener("agentNative.chatRunning", handleRunning);
448
- window.addEventListener("focus", refresh);
449
- return () => {
450
- window.removeEventListener("agent-chat:threads-updated", refresh);
451
- window.removeEventListener("agentNative.chatRunning", handleRunning);
452
- window.removeEventListener("focus", refresh);
453
- };
454
- }, [refreshThreads]);
416
+ }, [historyPreferenceReady, includeExternal]);
455
417
  function openThread(threadId, options) {
456
418
  switchThread(threadId);
457
419
  navigateWithAgentChatViewTransition(navigate, dispatchNavLinkTarget(options?.isNew ? "/chat" : chatThreadPath(threadId)));
@@ -467,29 +429,19 @@ function DispatchChatsSection({ onNavigate, showNewChat = false, prelude, chatFi
467
429
  if (threadId)
468
430
  openThread(threadId, { isNew: true });
469
431
  }
432
+ const sourceToggle = (_jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { asChild: true, children: _jsx("button", { type: "button", "data-dispatch-chat-source-toggle": true, "aria-pressed": includeExternal, "aria-label": includeExternal
433
+ ? t("dispatch.sidebar.showLocalChats")
434
+ : t("dispatch.sidebar.showAllChats"), onClick: () => setIncludeExternal((current) => !current), className: "flex size-6 items-center justify-center rounded-md text-sidebar-foreground/55 transition-colors hover:bg-sidebar-accent hover:text-sidebar-accent-foreground", children: includeExternal ? (_jsx(IconWorld, { size: 14, "aria-hidden": "true" })) : (_jsx(IconDeviceDesktop, { size: 14, "aria-hidden": "true" })) }) }), _jsx(TooltipContent, { side: "right", children: includeExternal
435
+ ? t("dispatch.sidebar.showLocalChats")
436
+ : t("dispatch.sidebar.showAllChats") })] }));
470
437
  const collapsedChatFirst = collapsed && chatFirstMode;
471
438
  return (_jsxs("div", { className: cn("min-w-0 space-y-0.5", showNewChat && "dispatch-chat-first-chats"), children: [showNewChat && chatFirstNavigation ? (_jsx("nav", { className: cn("space-y-0.5 py-2", collapsed ? "px-1.5" : "px-2"), children: _jsx(ChatFirstPrimaryNavigation, { copy: chatFirstCopy, onNewChat: () => {
472
439
  chatFirstNavigation.onNewChat?.();
473
440
  void handleNewChat();
474
- }, onOpenIntegrations: chatFirstNavigation.onOpenIntegrations, onOpenScheduled: chatFirstNavigation.onOpenScheduled, onSearch: openCommandMenu, activeTab: chatFirstNavigation.activeTab, collapsed: collapsed }) })) : null, prelude, !collapsedChatFirst && !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
475
- ? t("dispatch.sidebar.showLocalChats", {
476
- defaultValue: "Show local chats",
477
- })
478
- : t("dispatch.sidebar.showAllChats", {
479
- defaultValue: "Show all chats",
480
- }), onClick: () => setIncludeExternal((current) => !current), className: "flex size-6 items-center justify-center rounded-md text-sidebar-foreground/55 transition-colors hover:bg-sidebar-accent hover:text-sidebar-accent-foreground", children: includeExternal ? (_jsx(IconWorld, { size: 14, "aria-hidden": "true" })) : (_jsx(IconDeviceDesktop, { size: 14, "aria-hidden": "true" })) }) }), _jsx(TooltipContent, { side: "right", children: includeExternal
481
- ? t("dispatch.sidebar.showLocalChats", {
482
- defaultValue: "Show local chats",
483
- })
484
- : t("dispatch.sidebar.showAllChats", {
485
- defaultValue: "Show all chats",
486
- }) })] }) })) : null, !collapsedChatFirst &&
487
- !chatFirstMode &&
488
- chatsLoading &&
489
- visibleThreads.length === 0 &&
490
- Array.from({ length: 3 }).map((_, index) => (_jsxs("div", { className: "flex items-center gap-2 px-3 py-1", children: [_jsx(Skeleton, { className: "size-3.5 shrink-0 rounded-sm" }), _jsx(Skeleton, { className: "h-3 w-3/4 rounded" })] }, `chat-skeleton-${index}`))), !collapsedChatFirst &&
441
+ }, onOpenIntegrations: chatFirstNavigation.onOpenIntegrations, onOpenScheduled: chatFirstNavigation.onOpenScheduled, onSearch: openCommandMenu, activeTab: chatFirstNavigation.activeTab, collapsed: collapsed }) })) : null, prelude, !collapsedChatFirst ? (_jsx("div", { className: "flex justify-end px-2 pt-0.5", children: sourceToggle })) : null, !collapsedChatFirst &&
491
442
  chatFirstMode &&
492
- (chatsLoading || visibleThreads.length > 0) ? (_jsx(ChatFirstChatHistory, { items: chatItems, activeId: displayedActiveThreadId, loading: chatsLoading && visibleThreads.length === 0, loadingLabel: _jsx("div", { className: "space-y-1 px-2 py-1", children: [0, 1, 2].map((index) => (_jsxs("div", { className: "flex items-center gap-2 px-1 py-1", children: [_jsx(Skeleton, { className: "size-3.5 shrink-0 rounded-sm" }), _jsx(Skeleton, { className: "h-3 w-3/4 rounded" })] }, index))) }), label: t("dispatch.sidebar.chats", { defaultValue: "Chats" }), error: chatHistoryError, onSelect: (threadId) => openThread(threadId), renameMaxLength: 160, onRename: (threadId, title) => void renameThread(threadId, title), labels: {
443
+ (history.loading ||
444
+ history.sections.some((section) => section.items.length > 0 || section.error)) ? (_jsx(ChatFirstChatHistory, { sections: history.sections, ...history.listProps, onDelete: listProps.onDelete, onNewChat: () => void handleNewChat(), showNewChat: false, railLabels: history.railLabels, activeId: displayedActiveThreadId, label: t("dispatch.sidebar.chats"), onSelect: (threadId) => openThread(threadId), renameMaxLength: 160, labels: {
493
445
  options: (item) => t("dispatch.sidebar.chatOptions", {
494
446
  title: item.titleText ?? "",
495
447
  }),
@@ -497,14 +449,17 @@ function DispatchChatsSection({ onNavigate, showNewChat = false, prelude, chatFi
497
449
  title: item.titleText ?? "",
498
450
  }),
499
451
  rename: t("dispatch.sidebar.renameChat"),
452
+ pin: t("agentChat.contextXray.pin"),
453
+ unpin: t("agentChat.contextXray.unpin"),
454
+ delete: t("extensions.delete"),
500
455
  }, renderAdditionalRowActions: (item, closeMenu) => (_jsxs(_Fragment, { children: [_jsxs("button", { type: "button", role: "menuitem", className: "an-chat-history-row__menu-item", onClick: () => {
501
456
  closeMenu();
502
457
  void writeClipboardText(item.id).then((copied) => {
503
458
  toast[copied ? "success" : "error"](copied
504
- ? "Session ID copied"
505
- : "Could not copy the session ID");
459
+ ? chatFirstCopy("sessionIdCopied")
460
+ : t("agentChat.recovery.copyFailed"));
506
461
  });
507
- }, children: [_jsx(IconCopy, { size: 13, strokeWidth: 1.8 }), _jsx("span", { children: "Copy session ID" })] }), !chatFirstEmbedded ? (_jsxs("button", { type: "button", role: "menuitem", className: "an-chat-history-row__menu-item", onClick: () => {
462
+ }, children: [_jsx(IconCopy, { size: 13, strokeWidth: 1.8 }), _jsx("span", { children: chatFirstCopy("copySessionId") })] }), !chatFirstEmbedded ? (_jsxs("button", { type: "button", role: "menuitem", className: "an-chat-history-row__menu-item", onClick: () => {
508
463
  closeMenu();
509
464
  emitChatFirstSessionWatch({
510
465
  sessionId: item.id,
@@ -512,11 +467,9 @@ function DispatchChatsSection({ onNavigate, showNewChat = false, prelude, chatFi
512
467
  kind: "agent-chat",
513
468
  sourceSessionId: displayedActiveThreadId ?? undefined,
514
469
  });
515
- }, children: [_jsx(IconEye, { size: 13, strokeWidth: 1.8 }), _jsx("span", { children: "Watch and message session" })] })) : null] })), className: "min-w-0 px-2" })) : !collapsedChatFirst ? (_jsx(ChatHistoryRail, { items: chatItems, activeId: displayedActiveThreadId, onSelect: (threadId) => openThread(threadId), onNewChat: () => void handleNewChat(), railLabels: {
470
+ }, children: [_jsx(IconEye, { size: 13, strokeWidth: 1.8 }), _jsx("span", { children: chatFirstCopy("watchSession") })] })) : null] })), className: "min-w-0 px-2" })) : !collapsedChatFirst && !chatFirstMode ? (_jsx(OwnershipChatHistoryRail, { sections: history.sections, listProps: listProps, activeId: displayedActiveThreadId, onSelect: (threadId) => openThread(threadId), onNewChat: () => void handleNewChat(), railLabels: {
516
471
  newChat: t("dispatch.sidebar.newChat"),
517
- showMore: t("dispatch.sidebar.chats"),
518
- showLess: t("dispatch.sidebar.chats"),
519
- }, error: chatHistoryError, renameMaxLength: 160, onRename: (threadId, title) => void renameThread(threadId, title), labels: {
472
+ }, renameMaxLength: 160, labels: {
520
473
  options: (item) => t("dispatch.sidebar.chatOptions", {
521
474
  title: item.titleText ?? "",
522
475
  }),
@@ -524,14 +477,17 @@ function DispatchChatsSection({ onNavigate, showNewChat = false, prelude, chatFi
524
477
  title: item.titleText ?? "",
525
478
  }),
526
479
  rename: t("dispatch.sidebar.renameChat"),
480
+ pin: t("agentChat.contextXray.pin"),
481
+ unpin: t("agentChat.contextXray.unpin"),
482
+ delete: t("extensions.delete"),
527
483
  }, renderAdditionalRowActions: (item, closeMenu) => (_jsxs(_Fragment, { children: [_jsxs("button", { type: "button", role: "menuitem", className: "an-chat-history-row__menu-item", onClick: () => {
528
484
  closeMenu();
529
485
  void writeClipboardText(item.id).then((copied) => {
530
486
  toast[copied ? "success" : "error"](copied
531
- ? "Session ID copied"
532
- : "Could not copy the session ID");
487
+ ? chatFirstCopy("sessionIdCopied")
488
+ : t("agentChat.recovery.copyFailed"));
533
489
  });
534
- }, children: [_jsx(IconCopy, { size: 13, strokeWidth: 1.8 }), _jsx("span", { children: "Copy session ID" })] }), chatFirstMode && !chatFirstEmbedded ? (_jsxs("button", { type: "button", role: "menuitem", className: "an-chat-history-row__menu-item", onClick: () => {
490
+ }, children: [_jsx(IconCopy, { size: 13, strokeWidth: 1.8 }), _jsx("span", { children: chatFirstCopy("copySessionId") })] }), chatFirstMode && !chatFirstEmbedded ? (_jsxs("button", { type: "button", role: "menuitem", className: "an-chat-history-row__menu-item", onClick: () => {
535
491
  closeMenu();
536
492
  emitChatFirstSessionWatch({
537
493
  sessionId: item.id,
@@ -539,7 +495,7 @@ function DispatchChatsSection({ onNavigate, showNewChat = false, prelude, chatFi
539
495
  kind: "agent-chat",
540
496
  sourceSessionId: displayedActiveThreadId ?? undefined,
541
497
  });
542
- }, children: [_jsx(IconEye, { size: 13, strokeWidth: 1.8 }), _jsx("span", { children: "Watch and message session" })] })) : null] })), className: "min-w-0 px-2" })) : null] }));
498
+ }, children: [_jsx(IconEye, { size: 13, strokeWidth: 1.8 }), _jsx("span", { children: chatFirstCopy("watchSession") })] })) : null] })), className: "min-w-0 px-2" })) : null] }));
543
499
  }
544
500
  export function NavContent({ onNavigate, extensions, brandName = DISPATCH_SIDEBAR_LABEL, brandIcon, chatFirstMode = false, chatFirstEmbedded = false, collapsed = false, collapsible = false, onCollapsedChange, chatFirstAppLayout, onChatFirstAppLayoutChange, chatFirstApps = [], chatFirstAppsLoading = false, chatFirstAppsError, chatFirstActiveAppId, chatFirstActivePrimaryTab, onChatFirstNewChat, onChatFirstAppOpen, onChatFirstAppsRetry, }) {
545
501
  const t = useT();