@inf-monkeys-tech/monkeys-design 1.0.77 → 1.0.78

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/dist/index.mjs CHANGED
@@ -4,7 +4,7 @@ import * as React4 from 'react';
4
4
  import React4__default, { forwardRef, useMemo, useId, useRef, useState, useEffect, createElement, createContext, useCallback, useContext, Children, isValidElement, Fragment as Fragment$1, useLayoutEffect } from 'react';
5
5
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
6
6
  import * as PopoverPrimitive from '@radix-ui/react-popover';
7
- import { ChevronDown, Search, Circle, Check, ChevronRight, ChevronUp, Plus, Pin, SquarePen, Blocks, MessageSquare, Bot, Settings, X, Ellipsis, Trash2, AlertCircle, RefreshCw, Loader2, TerminalSquare, FileOutput, Download, Clock3, CheckCircle2, XCircle, CircleStop, GitFork, PencilLine, Copy, RotateCcw, FileCode2, Files, TestTube2, Image, Pencil } from 'lucide-react';
7
+ import { ChevronDown, Search, Circle, Check, ChevronRight, ChevronUp, Plus, Pin, Blocks, Settings, TerminalSquare, FileOutput, Download, X, RefreshCw, Bot, SquarePen, MessageSquare, Clock3, Loader2, CheckCircle2, XCircle, CircleStop, AlertCircle, GitFork, PencilLine, Copy, RotateCcw, FileCode2, Files, TestTube2, Ellipsis, Pencil, Trash2, Image } from 'lucide-react';
8
8
  import { twMerge } from 'tailwind-merge';
9
9
  import * as DropdownMenu2 from '@radix-ui/react-dropdown-menu';
10
10
  import * as ContextMenu from '@radix-ui/react-context-menu';
@@ -18364,13 +18364,74 @@ var AgentWorkbenchSidebarContainer = forwardRef(
18364
18364
  }
18365
18365
  );
18366
18366
  AgentWorkbenchSidebarContainer.displayName = "AgentWorkbenchSidebarContainer";
18367
- function ItemAvatar({ item }) {
18368
- const [failed, setFailed] = useState(false);
18369
- if (item.iconUrl && !failed) {
18370
- return /* @__PURE__ */ jsx("img", { src: item.iconUrl, alt: "", className: "size-full object-cover", onError: () => setFailed(true) });
18371
- }
18372
- const initial = item.name.trim().charAt(0).toLocaleUpperCase();
18373
- return initial ? /* @__PURE__ */ jsx("span", { className: "text-sm font-semibold", children: initial }) : /* @__PURE__ */ jsx(Bot, { className: "size-4" });
18367
+ function AgentWorkbenchSidebarSearch({
18368
+ value,
18369
+ label,
18370
+ placeholder = label,
18371
+ className,
18372
+ onChange
18373
+ }) {
18374
+ const messages = useMonkeysLocaleMessages().agentWorkbench.navigation;
18375
+ const searchRef = useRef(null);
18376
+ useEffect(() => {
18377
+ const handleShortcut = (event) => {
18378
+ if (!(event.ctrlKey || event.metaKey) || event.key.toLocaleLowerCase() !== "k")
18379
+ return;
18380
+ event.preventDefault();
18381
+ searchRef.current?.focus();
18382
+ searchRef.current?.select();
18383
+ };
18384
+ window.addEventListener("keydown", handleShortcut);
18385
+ return () => window.removeEventListener("keydown", handleShortcut);
18386
+ }, []);
18387
+ return /* @__PURE__ */ jsxs(InputGroup, { className: cn2("h-10 rounded-lg bg-card", className), children: [
18388
+ /* @__PURE__ */ jsx(InputGroupAddon, { children: /* @__PURE__ */ jsx(Search, { className: "size-4", "aria-hidden": "true" }) }),
18389
+ /* @__PURE__ */ jsx(
18390
+ InputGroupInput,
18391
+ {
18392
+ ref: searchRef,
18393
+ type: "search",
18394
+ value,
18395
+ "aria-label": label,
18396
+ placeholder,
18397
+ className: "min-w-0 [&::-webkit-search-cancel-button]:hidden",
18398
+ onChange: (event) => onChange(event.target.value),
18399
+ onKeyDown: (event) => {
18400
+ if (event.key !== "Escape") return;
18401
+ onChange("");
18402
+ event.currentTarget.blur();
18403
+ }
18404
+ }
18405
+ ),
18406
+ value ? /* @__PURE__ */ jsx(InputGroupAddon, { align: "inline-end", children: /* @__PURE__ */ jsx(
18407
+ InputGroupButton,
18408
+ {
18409
+ size: "icon-xs",
18410
+ "aria-label": messages.clearSearch,
18411
+ onClick: () => onChange(""),
18412
+ children: /* @__PURE__ */ jsx(X, { className: "size-3.5", "aria-hidden": "true" })
18413
+ }
18414
+ ) }) : /* @__PURE__ */ jsx(InputGroupAddon, { align: "inline-end", children: /* @__PURE__ */ jsx("kbd", { className: "border border-border px-1.5 py-0.5 text-[10px]", children: "Ctrl K" }) })
18415
+ ] });
18416
+ }
18417
+ function AgentWorkbenchSidebarNewSessionButton({
18418
+ label,
18419
+ className,
18420
+ onClick
18421
+ }) {
18422
+ return /* @__PURE__ */ jsxs(
18423
+ Button,
18424
+ {
18425
+ type: "button",
18426
+ variant: "ghost",
18427
+ className: cn2("h-9 w-full justify-start gap-2 px-3 text-sm", className),
18428
+ onClick,
18429
+ children: [
18430
+ /* @__PURE__ */ jsx(SquarePen, { className: "size-4", "aria-hidden": "true" }),
18431
+ label
18432
+ ]
18433
+ }
18434
+ );
18374
18435
  }
18375
18436
  function SessionAvatar({ item }) {
18376
18437
  const [failed, setFailed] = useState(false);
@@ -18388,13 +18449,329 @@ function SessionAvatar({ item }) {
18388
18449
  }
18389
18450
  return /* @__PURE__ */ jsx(Image, { className: "size-5", "aria-hidden": "true" });
18390
18451
  }
18391
- function SessionMeta({ item, locale }) {
18452
+ function SessionMeta({ item }) {
18453
+ const { locale } = useMonkeysLocale();
18392
18454
  const messages = useMonkeysLocaleMessages().agentWorkbench.navigation;
18393
18455
  return /* @__PURE__ */ jsxs("span", { className: "flex min-w-0 items-center gap-1.5", children: [
18394
- /* @__PURE__ */ jsx("span", { className: "min-w-0 truncate text-xs text-foreground/80", children: new Intl.DateTimeFormat(locale, { dateStyle: "medium", timeStyle: "short" }).format(new Date(item.updatedAt)) }),
18395
- item.mode ? /* @__PURE__ */ jsx("span", { className: cn2("shrink-0 rounded-full px-1.5 py-0.5 text-[10px] font-medium leading-none", item.mode === "work" ? "bg-primary/10 text-primary" : "bg-muted text-foreground"), children: item.mode === "work" ? messages.work : messages.chat }) : null
18456
+ /* @__PURE__ */ jsx("span", { className: "min-w-0 truncate text-xs text-foreground/80", children: new Intl.DateTimeFormat(locale, {
18457
+ dateStyle: "medium",
18458
+ timeStyle: "short"
18459
+ }).format(new Date(item.updatedAt)) }),
18460
+ item.mode ? /* @__PURE__ */ jsx(
18461
+ "span",
18462
+ {
18463
+ className: cn2(
18464
+ "shrink-0 rounded-full px-1.5 py-0.5 text-[10px] font-medium leading-none",
18465
+ item.mode === "work" ? "bg-primary/10 text-primary" : "bg-muted text-foreground"
18466
+ ),
18467
+ children: item.mode === "work" ? messages.work : messages.chat
18468
+ }
18469
+ ) : null
18470
+ ] });
18471
+ }
18472
+ function StatusIndicator({
18473
+ status
18474
+ }) {
18475
+ const messages = useMonkeysLocaleMessages().agentWorkbench.navigation;
18476
+ if (status === "running") {
18477
+ return /* @__PURE__ */ jsx(
18478
+ Loader2,
18479
+ {
18480
+ className: "size-4 animate-spin text-primary",
18481
+ "aria-label": messages.running
18482
+ }
18483
+ );
18484
+ }
18485
+ if (status === "completed") {
18486
+ return /* @__PURE__ */ jsx(
18487
+ CheckCircle2,
18488
+ {
18489
+ className: "size-4 text-primary",
18490
+ "aria-label": messages.completed
18491
+ }
18492
+ );
18493
+ }
18494
+ if (status === "error") {
18495
+ return /* @__PURE__ */ jsx(
18496
+ AlertCircle,
18497
+ {
18498
+ className: "size-4 text-destructive-text",
18499
+ "aria-label": messages.failed
18500
+ }
18501
+ );
18502
+ }
18503
+ return null;
18504
+ }
18505
+ function AgentWorkbenchSessionList({
18506
+ sessions,
18507
+ selectedSessionId,
18508
+ status = "ready",
18509
+ error,
18510
+ query = "",
18511
+ emptyLabel,
18512
+ noResultsLabel,
18513
+ retryLabel,
18514
+ groupByMode = false,
18515
+ showHeading = false,
18516
+ className,
18517
+ itemClassName,
18518
+ capabilities,
18519
+ onSelect,
18520
+ onTogglePin,
18521
+ onRename,
18522
+ onDelete,
18523
+ onRetry
18524
+ }) {
18525
+ const messages = useMonkeysLocaleMessages().agentWorkbench.navigation;
18526
+ const renameInputRef = useRef(null);
18527
+ const [editingSessionId, setEditingSessionId] = useState();
18528
+ const [editingTitle, setEditingTitle] = useState("");
18529
+ useEffect(() => {
18530
+ if (!editingSessionId) return;
18531
+ renameInputRef.current?.focus();
18532
+ renameInputRef.current?.select();
18533
+ }, [editingSessionId]);
18534
+ const cancelRename = () => {
18535
+ setEditingSessionId(void 0);
18536
+ setEditingTitle("");
18537
+ };
18538
+ const saveRename = (item) => {
18539
+ const title = editingTitle.trim();
18540
+ if (title && title !== item.title) onRename?.(item.id, title);
18541
+ cancelRename();
18542
+ };
18543
+ if (status === "loading" && sessions.length === 0) {
18544
+ return /* @__PURE__ */ jsx("div", { className: "px-3 py-8 text-center text-sm text-muted-foreground", children: messages.loading });
18545
+ }
18546
+ if (status === "error") {
18547
+ return /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center gap-3 px-3 py-8 text-center", children: [
18548
+ /* @__PURE__ */ jsx(
18549
+ "p",
18550
+ {
18551
+ className: "max-w-full break-words text-sm text-muted-foreground",
18552
+ role: "alert",
18553
+ children: error
18554
+ }
18555
+ ),
18556
+ onRetry ? /* @__PURE__ */ jsxs(
18557
+ Button,
18558
+ {
18559
+ type: "button",
18560
+ variant: "ghost",
18561
+ size: "sm",
18562
+ className: "gap-1.5 px-0 text-sm text-primary hover:text-primary",
18563
+ onClick: onRetry,
18564
+ children: [
18565
+ /* @__PURE__ */ jsx(RefreshCw, { className: "size-3.5", "aria-hidden": "true" }),
18566
+ retryLabel ?? messages.retry
18567
+ ]
18568
+ }
18569
+ ) : null
18570
+ ] });
18571
+ }
18572
+ if (sessions.length === 0) {
18573
+ return /* @__PURE__ */ jsx("div", { className: "px-3 py-8 text-center text-sm text-muted-foreground", children: query ? noResultsLabel : emptyLabel });
18574
+ }
18575
+ const renderItems = (items) => /* @__PURE__ */ jsx("div", { className: "space-y-1", children: items.map((item) => {
18576
+ const percent = item.contextUsage && item.contextUsage.maxTokens > 0 ? Math.min(
18577
+ 100,
18578
+ Math.round(
18579
+ item.contextUsage.usedTokens / item.contextUsage.maxTokens * 100
18580
+ )
18581
+ ) : void 0;
18582
+ return /* @__PURE__ */ jsxs(
18583
+ "div",
18584
+ {
18585
+ "aria-current": item.id === selectedSessionId ? "page" : void 0,
18586
+ className: cn2(
18587
+ "group flex w-full min-w-0 items-center gap-3 rounded-lg border border-transparent px-3 py-2 text-left hover:bg-muted aria-[current=page]:border-primary aria-[current=page]:bg-muted",
18588
+ itemClassName
18589
+ ),
18590
+ children: [
18591
+ editingSessionId === item.id ? /* @__PURE__ */ jsxs("div", { className: "flex min-w-0 flex-1 items-center gap-3", children: [
18592
+ /* @__PURE__ */ jsx("span", { className: "flex size-10 shrink-0 items-center justify-center overflow-hidden rounded-lg bg-muted", children: /* @__PURE__ */ jsx(SessionAvatar, { item }) }),
18593
+ /* @__PURE__ */ jsxs("span", { className: "min-w-0 flex-1", children: [
18594
+ /* @__PURE__ */ jsx(
18595
+ Input,
18596
+ {
18597
+ ref: renameInputRef,
18598
+ value: editingTitle,
18599
+ "aria-label": messages.rename,
18600
+ appearance: "compact",
18601
+ className: "h-6 w-full border-primary px-1.5 text-sm font-medium",
18602
+ onChange: (event) => setEditingTitle(event.target.value),
18603
+ onClick: (event) => event.stopPropagation(),
18604
+ onBlur: () => saveRename(item),
18605
+ onKeyDown: (event) => {
18606
+ event.stopPropagation();
18607
+ if (event.key === "Enter") {
18608
+ event.preventDefault();
18609
+ saveRename(item);
18610
+ } else if (event.key === "Escape") {
18611
+ event.preventDefault();
18612
+ cancelRename();
18613
+ }
18614
+ }
18615
+ }
18616
+ ),
18617
+ /* @__PURE__ */ jsx(SessionMeta, { item })
18618
+ ] })
18619
+ ] }) : /* @__PURE__ */ jsxs(
18620
+ "button",
18621
+ {
18622
+ type: "button",
18623
+ title: item.title,
18624
+ className: "flex min-w-0 flex-1 items-center gap-3 text-left",
18625
+ onClick: () => onSelect(item.id),
18626
+ children: [
18627
+ /* @__PURE__ */ jsx("span", { className: "flex size-10 shrink-0 items-center justify-center overflow-hidden rounded-lg bg-muted", children: /* @__PURE__ */ jsx(SessionAvatar, { item }) }),
18628
+ /* @__PURE__ */ jsxs("span", { className: "min-w-0 flex-1", children: [
18629
+ /* @__PURE__ */ jsx("span", { className: "block truncate text-sm font-medium", children: item.title }),
18630
+ /* @__PURE__ */ jsx(SessionMeta, { item })
18631
+ ] })
18632
+ ]
18633
+ }
18634
+ ),
18635
+ /* @__PURE__ */ jsxs(
18636
+ "span",
18637
+ {
18638
+ "data-agent-workbench-item-actions": true,
18639
+ className: "flex shrink-0 items-center gap-1",
18640
+ children: [
18641
+ percent !== void 0 && item.status === "idle" ? /* @__PURE__ */ jsxs(
18642
+ "span",
18643
+ {
18644
+ className: "text-xs text-foreground",
18645
+ "aria-label": messages.contextUsage({ percent }),
18646
+ children: [
18647
+ percent,
18648
+ "%"
18649
+ ]
18650
+ }
18651
+ ) : /* @__PURE__ */ jsx(StatusIndicator, { status: item.status }),
18652
+ capabilities?.pin ? /* @__PURE__ */ jsx(
18653
+ Button,
18654
+ {
18655
+ type: "button",
18656
+ variant: "ghost",
18657
+ size: "icon",
18658
+ "aria-label": item.pinned ? messages.unpin : messages.pin,
18659
+ className: cn2(
18660
+ "size-8 text-muted-foreground opacity-0 group-hover:opacity-100",
18661
+ item.pinned && "text-primary opacity-100"
18662
+ ),
18663
+ onClick: (event) => {
18664
+ event.stopPropagation();
18665
+ onTogglePin?.(item.id, !item.pinned);
18666
+ },
18667
+ children: /* @__PURE__ */ jsx(
18668
+ Pin,
18669
+ {
18670
+ className: cn2("size-4", item.pinned && "fill-current")
18671
+ }
18672
+ )
18673
+ }
18674
+ ) : null,
18675
+ capabilities?.rename || capabilities?.delete ? /* @__PURE__ */ jsx(
18676
+ "span",
18677
+ {
18678
+ onClick: (event) => event.stopPropagation(),
18679
+ onKeyDown: (event) => event.stopPropagation(),
18680
+ children: /* @__PURE__ */ jsxs(DropdownMenu4, { children: [
18681
+ /* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsx(
18682
+ Button,
18683
+ {
18684
+ type: "button",
18685
+ variant: "ghost",
18686
+ size: "icon",
18687
+ className: "size-8",
18688
+ "aria-label": messages.actions,
18689
+ children: /* @__PURE__ */ jsx(Ellipsis, { className: "size-4", "aria-hidden": "true" })
18690
+ }
18691
+ ) }),
18692
+ /* @__PURE__ */ jsxs(DropdownMenuContent, { align: "end", children: [
18693
+ capabilities.rename ? /* @__PURE__ */ jsxs(
18694
+ DropdownMenuItem,
18695
+ {
18696
+ onSelect: () => {
18697
+ setEditingSessionId(item.id);
18698
+ setEditingTitle(item.title);
18699
+ },
18700
+ children: [
18701
+ /* @__PURE__ */ jsx(Pencil, { className: "mr-2 size-4", "aria-hidden": "true" }),
18702
+ messages.rename
18703
+ ]
18704
+ }
18705
+ ) : null,
18706
+ capabilities.delete ? /* @__PURE__ */ jsxs(
18707
+ DropdownMenuItem,
18708
+ {
18709
+ className: "text-destructive-text",
18710
+ onSelect: () => onDelete?.(item.id),
18711
+ children: [
18712
+ /* @__PURE__ */ jsx(Trash2, { className: "mr-2 size-4", "aria-hidden": "true" }),
18713
+ messages.delete
18714
+ ]
18715
+ }
18716
+ ) : null
18717
+ ] })
18718
+ ] })
18719
+ }
18720
+ ) : null
18721
+ ]
18722
+ }
18723
+ )
18724
+ ]
18725
+ },
18726
+ item.id
18727
+ );
18728
+ }) });
18729
+ return /* @__PURE__ */ jsxs("div", { className: cn2("space-y-2", className), children: [
18730
+ showHeading && !groupByMode ? /* @__PURE__ */ jsx("h3", { className: "mb-2 px-3 text-xs font-medium text-muted-foreground", children: messages.recentSessions }) : null,
18731
+ groupByMode ? [
18732
+ {
18733
+ id: "chatbot",
18734
+ label: messages.chats,
18735
+ icon: MessageSquare,
18736
+ items: sessions.filter((item) => item.mode !== "work")
18737
+ },
18738
+ {
18739
+ id: "agent",
18740
+ label: messages.agents,
18741
+ icon: Bot,
18742
+ items: sessions.filter((item) => item.mode === "work")
18743
+ }
18744
+ ].map(({ id, label, icon: Icon2, items }) => /* @__PURE__ */ jsxs("details", { open: true, "aria-label": label, children: [
18745
+ /* @__PURE__ */ jsxs("summary", { className: "flex h-9 cursor-pointer list-none items-center gap-2 rounded-md px-3 text-sm font-semibold hover:bg-muted", children: [
18746
+ /* @__PURE__ */ jsx(
18747
+ Icon2,
18748
+ {
18749
+ className: "size-4 shrink-0 text-muted-foreground",
18750
+ "aria-hidden": "true"
18751
+ }
18752
+ ),
18753
+ /* @__PURE__ */ jsx("span", { className: "min-w-0 truncate", children: label })
18754
+ ] }),
18755
+ renderItems(items)
18756
+ ] }, id)) : renderItems(sessions)
18396
18757
  ] });
18397
18758
  }
18759
+ function ItemAvatar({ item }) {
18760
+ const [failed, setFailed] = useState(false);
18761
+ if (item.iconUrl && !failed) {
18762
+ return /* @__PURE__ */ jsx(
18763
+ "img",
18764
+ {
18765
+ src: item.iconUrl,
18766
+ alt: "",
18767
+ className: "size-full object-cover",
18768
+ onError: () => setFailed(true)
18769
+ }
18770
+ );
18771
+ }
18772
+ const initial = item.name.trim().charAt(0).toLocaleUpperCase();
18773
+ return initial ? /* @__PURE__ */ jsx("span", { className: "text-sm font-semibold", children: initial }) : /* @__PURE__ */ jsx(Bot, { className: "size-4" });
18774
+ }
18398
18775
  function CollectionState({
18399
18776
  status,
18400
18777
  empty,
@@ -18410,11 +18787,28 @@ function CollectionState({
18410
18787
  }
18411
18788
  if (status === "error") {
18412
18789
  return /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center gap-3 px-3 py-8 text-center", children: [
18413
- /* @__PURE__ */ jsx("p", { className: "max-w-full break-words text-sm text-muted-foreground", role: "alert", children: error }),
18414
- /* @__PURE__ */ jsxs(Button, { type: "button", variant: "ghost", size: "sm", className: "gap-1.5 px-0 text-sm text-primary hover:text-primary", onClick: onRetry, children: [
18415
- /* @__PURE__ */ jsx(RefreshCw, { className: "size-3.5", "aria-hidden": "true" }),
18416
- messages.retry
18417
- ] })
18790
+ /* @__PURE__ */ jsx(
18791
+ "p",
18792
+ {
18793
+ className: "max-w-full break-words text-sm text-muted-foreground",
18794
+ role: "alert",
18795
+ children: error
18796
+ }
18797
+ ),
18798
+ /* @__PURE__ */ jsxs(
18799
+ Button,
18800
+ {
18801
+ type: "button",
18802
+ variant: "ghost",
18803
+ size: "sm",
18804
+ className: "gap-1.5 px-0 text-sm text-primary hover:text-primary",
18805
+ onClick: onRetry,
18806
+ children: [
18807
+ /* @__PURE__ */ jsx(RefreshCw, { className: "size-3.5", "aria-hidden": "true" }),
18808
+ messages.retry
18809
+ ]
18810
+ }
18811
+ )
18418
18812
  ] });
18419
18813
  }
18420
18814
  if (!hasItems) {
@@ -18422,40 +18816,6 @@ function CollectionState({
18422
18816
  }
18423
18817
  return null;
18424
18818
  }
18425
- function StatusIndicator({ status }) {
18426
- const messages = useMonkeysLocaleMessages().agentWorkbench.navigation;
18427
- if (status === "running") {
18428
- return /* @__PURE__ */ jsx(Loader2, { className: "size-4 animate-spin text-primary", "aria-label": messages.running });
18429
- }
18430
- if (status === "completed") {
18431
- return /* @__PURE__ */ jsx(CheckCircle2, { className: "size-4 text-primary", "aria-label": messages.completed });
18432
- }
18433
- if (status === "error") {
18434
- return /* @__PURE__ */ jsx(AlertCircle, { className: "size-4 text-destructive-text", "aria-label": messages.failed });
18435
- }
18436
- return null;
18437
- }
18438
- function SessionActions({
18439
- item,
18440
- capabilities,
18441
- onIntent
18442
- }) {
18443
- const messages = useMonkeysLocaleMessages().agentWorkbench.navigation;
18444
- if (!capabilities.renameSessions && !capabilities.deleteSessions) return null;
18445
- return /* @__PURE__ */ jsxs(DropdownMenu4, { children: [
18446
- /* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsx(Button, { type: "button", variant: "ghost", size: "icon", className: "size-8", "aria-label": messages.actions, children: /* @__PURE__ */ jsx(Ellipsis, { className: "size-4", "aria-hidden": "true" }) }) }),
18447
- /* @__PURE__ */ jsxs(DropdownMenuContent, { align: "end", children: [
18448
- capabilities.renameSessions ? /* @__PURE__ */ jsxs(DropdownMenuItem, { onSelect: () => onIntent?.({ type: "rename-session", sessionId: item.id, title: item.title }), children: [
18449
- /* @__PURE__ */ jsx(Pencil, { className: "mr-2 size-4", "aria-hidden": "true" }),
18450
- messages.rename
18451
- ] }) : null,
18452
- capabilities.deleteSessions ? /* @__PURE__ */ jsxs(DropdownMenuItem, { className: "text-destructive-text", onSelect: () => onIntent?.({ type: "delete-session", sessionId: item.id }), children: [
18453
- /* @__PURE__ */ jsx(Trash2, { className: "mr-2 size-4", "aria-hidden": "true" }),
18454
- messages.delete
18455
- ] }) : null
18456
- ] })
18457
- ] });
18458
- }
18459
18819
  function AgentWorkbenchSidebar({
18460
18820
  viewModel,
18461
18821
  navigationMode,
@@ -18467,115 +18827,38 @@ function AgentWorkbenchSidebar({
18467
18827
  classNames,
18468
18828
  onIntent
18469
18829
  }) {
18470
- const { locale } = useMonkeysLocale();
18471
18830
  const messages = useMonkeysLocaleMessages().agentWorkbench.navigation;
18472
- const resolvedConfig = useMemo(() => resolveAgentWorkbenchSidebarConfig(config), [config]);
18473
- const visibleSections = useMemo(() => new Set(resolvedConfig.visibleSections), [resolvedConfig.visibleSections]);
18831
+ const resolvedConfig = useMemo(
18832
+ () => resolveAgentWorkbenchSidebarConfig(config),
18833
+ [config]
18834
+ );
18835
+ const visibleSections = useMemo(
18836
+ () => new Set(resolvedConfig.visibleSections),
18837
+ [resolvedConfig.visibleSections]
18838
+ );
18474
18839
  const sessionsOnly = navigationMode === "sessions-only" || navigationMode === void 0 && resolvedConfig.navigationMode !== "default";
18475
18840
  const showAgents = visibleSections.has("agents") && !sessionsOnly;
18476
18841
  const showSessions = visibleSections.has("sessions");
18477
- const searchRef = useRef(null);
18478
- const renameInputRef = useRef(null);
18479
- const [editingSessionId, setEditingSessionId] = useState();
18480
- const [editingTitle, setEditingTitle] = useState("");
18481
18842
  const query = viewModel.searchQuery.trim().toLocaleLowerCase();
18482
18843
  const agents = useMemo(
18483
- () => viewModel.agents.items.filter((item) => !query || `${item.name} ${item.description ?? ""}`.toLocaleLowerCase().includes(query)),
18844
+ () => viewModel.agents.items.filter(
18845
+ (item) => !query || `${item.name} ${item.description ?? ""}`.toLocaleLowerCase().includes(query)
18846
+ ),
18484
18847
  [query, viewModel.agents.items]
18485
18848
  );
18486
18849
  const sessions = useMemo(
18487
- () => viewModel.sessions.items.filter((item) => !query || item.title.toLocaleLowerCase().includes(query)),
18850
+ () => viewModel.sessions.items.filter(
18851
+ (item) => !query || item.title.toLocaleLowerCase().includes(query)
18852
+ ),
18488
18853
  [query, viewModel.sessions.items]
18489
18854
  );
18490
- const chatbotSessions = useMemo(() => sessions.filter((item) => item.mode !== "work"), [sessions]);
18491
- const agentSessions = useMemo(() => sessions.filter((item) => item.mode === "work"), [sessions]);
18492
- useEffect(() => {
18493
- const handleShortcut = (event) => {
18494
- if (!(event.ctrlKey || event.metaKey) || event.key.toLocaleLowerCase() !== "k") return;
18495
- event.preventDefault();
18496
- searchRef.current?.focus();
18497
- searchRef.current?.select();
18498
- };
18499
- window.addEventListener("keydown", handleShortcut);
18500
- return () => window.removeEventListener("keydown", handleShortcut);
18501
- }, []);
18502
- useEffect(() => {
18503
- if (!editingSessionId) return;
18504
- renameInputRef.current?.focus();
18505
- renameInputRef.current?.select();
18506
- }, [editingSessionId]);
18507
- const beginRenameSession = (item) => {
18508
- setEditingSessionId(item.id);
18509
- setEditingTitle(item.title);
18510
- };
18511
- const cancelRenameSession = () => {
18512
- setEditingSessionId(void 0);
18513
- setEditingTitle("");
18514
- };
18515
- const saveRenameSession = (item) => {
18516
- const title = editingTitle.trim();
18517
- if (title && title !== item.title) {
18518
- onIntent?.({ type: "rename-session", sessionId: item.id, title });
18519
- }
18520
- cancelRenameSession();
18521
- };
18522
- const renderSessionItems = (items) => /* @__PURE__ */ jsx("div", { className: "space-y-1", children: items.map((item) => {
18523
- const percent = item.contextUsage && item.contextUsage.maxTokens > 0 ? Math.min(100, Math.round(item.contextUsage.usedTokens / item.contextUsage.maxTokens * 100)) : void 0;
18524
- return /* @__PURE__ */ jsxs("div", { "aria-current": item.id === viewModel.selectedSessionItem ? "page" : void 0, className: cn2("group flex w-full min-w-0 items-center gap-3 rounded-lg border border-transparent px-3 py-2 text-left hover:bg-muted aria-[current=page]:border-primary aria-[current=page]:bg-muted", classNames?.item), children: [
18525
- editingSessionId === item.id ? /* @__PURE__ */ jsxs("div", { className: "flex min-w-0 flex-1 items-center gap-3", children: [
18526
- /* @__PURE__ */ jsx("span", { className: "flex size-10 shrink-0 items-center justify-center overflow-hidden rounded-lg bg-muted", children: /* @__PURE__ */ jsx(SessionAvatar, { item }) }),
18527
- /* @__PURE__ */ jsxs("span", { className: "min-w-0 flex-1", children: [
18528
- /* @__PURE__ */ jsx(
18529
- Input,
18530
- {
18531
- ref: renameInputRef,
18532
- value: editingTitle,
18533
- "aria-label": messages.rename,
18534
- appearance: "compact",
18535
- className: "h-6 w-full border-primary px-1.5 text-sm font-medium",
18536
- onChange: (event) => setEditingTitle(event.target.value),
18537
- onClick: (event) => event.stopPropagation(),
18538
- onBlur: () => saveRenameSession(item),
18539
- onKeyDown: (event) => {
18540
- event.stopPropagation();
18541
- if (event.key === "Enter") {
18542
- event.preventDefault();
18543
- saveRenameSession(item);
18544
- } else if (event.key === "Escape") {
18545
- event.preventDefault();
18546
- cancelRenameSession();
18547
- }
18548
- }
18549
- }
18550
- ),
18551
- /* @__PURE__ */ jsx(SessionMeta, { item, locale })
18552
- ] })
18553
- ] }) : /* @__PURE__ */ jsxs("button", { type: "button", title: item.title, className: "flex min-w-0 flex-1 items-center gap-3 text-left", onClick: () => onIntent?.({ type: "select-session", sessionId: item.id }), children: [
18554
- /* @__PURE__ */ jsx("span", { className: "flex size-10 shrink-0 items-center justify-center overflow-hidden rounded-lg bg-muted", children: /* @__PURE__ */ jsx(SessionAvatar, { item }) }),
18555
- /* @__PURE__ */ jsxs("span", { className: "min-w-0 flex-1", children: [
18556
- /* @__PURE__ */ jsx("span", { className: "block truncate text-sm font-medium", children: item.title }),
18557
- /* @__PURE__ */ jsx(SessionMeta, { item, locale })
18558
- ] })
18559
- ] }),
18560
- /* @__PURE__ */ jsxs("span", { "data-agent-workbench-item-actions": true, className: "flex shrink-0 items-center gap-1", children: [
18561
- percent !== void 0 && item.status === "idle" ? /* @__PURE__ */ jsxs("span", { className: "text-xs text-foreground", "aria-label": messages.contextUsage({ percent }), children: [
18562
- percent,
18563
- "%"
18564
- ] }) : /* @__PURE__ */ jsx(StatusIndicator, { status: item.status }),
18565
- viewModel.capabilities.pinSessions ? /* @__PURE__ */ jsx(Button, { type: "button", variant: "ghost", size: "icon", "aria-label": item.pinned ? messages.unpin : messages.pin, className: cn2("size-8 text-muted-foreground opacity-0 group-hover:opacity-100", item.pinned && "text-primary opacity-100"), onClick: (event) => {
18566
- event.stopPropagation();
18567
- onIntent?.({ type: "toggle-session-pin", sessionId: item.id, pinned: !item.pinned });
18568
- }, children: /* @__PURE__ */ jsx(Pin, { className: cn2("size-4", item.pinned && "fill-current") }) }) : null,
18569
- /* @__PURE__ */ jsx("span", { onClick: (event) => event.stopPropagation(), onKeyDown: (event) => event.stopPropagation(), children: /* @__PURE__ */ jsx(SessionActions, { item, capabilities: viewModel.capabilities, onIntent: (intent) => intent.type === "rename-session" ? beginRenameSession(item) : onIntent?.(intent) }) })
18570
- ] })
18571
- ] }, item.id);
18572
- }) });
18573
18855
  return /* @__PURE__ */ jsx(
18574
18856
  Tabs,
18575
18857
  {
18576
18858
  value: sessionsOnly || !showAgents ? "sessions" : viewModel.activeTab,
18577
18859
  onValueChange: (value) => {
18578
- if (!sessionsOnly && (value === "agents" || value === "sessions")) onIntent?.({ type: "change-tab", tab: value });
18860
+ if (!sessionsOnly && (value === "agents" || value === "sessions"))
18861
+ onIntent?.({ type: "change-tab", tab: value });
18579
18862
  },
18580
18863
  className: "h-full min-h-0",
18581
18864
  children: /* @__PURE__ */ jsxs(
@@ -18584,115 +18867,230 @@ function AgentWorkbenchSidebar({
18584
18867
  "data-sidebar-width-percent": resolvedConfig.widthPercent,
18585
18868
  "aria-label": messages.tabsLabel,
18586
18869
  header: visibleSections.has("header") ? header : void 0,
18587
- search: visibleSections.has("search") ? /* @__PURE__ */ jsxs(InputGroup, { className: cn2("h-10 rounded-lg bg-card", classNames?.search), children: [
18588
- /* @__PURE__ */ jsx(InputGroupAddon, { children: /* @__PURE__ */ jsx(Search, { className: "size-4", "aria-hidden": "true" }) }),
18589
- /* @__PURE__ */ jsx(
18590
- InputGroupInput,
18870
+ search: visibleSections.has("search") ? /* @__PURE__ */ jsx(
18871
+ AgentWorkbenchSidebarSearch,
18872
+ {
18873
+ value: viewModel.searchQuery,
18874
+ label: sessionsOnly ? messages.searchSessions : messages.search,
18875
+ className: classNames?.search,
18876
+ onChange: (query2) => onIntent?.({ type: "change-search", query: query2 })
18877
+ }
18878
+ ) : void 0,
18879
+ actions: showAgents && showSessions || headerActions ? /* @__PURE__ */ jsxs(Fragment, { children: [
18880
+ showAgents && showSessions ? /* @__PURE__ */ jsxs(
18881
+ TabsList,
18591
18882
  {
18592
- ref: searchRef,
18593
- type: "search",
18594
- value: viewModel.searchQuery,
18595
- "aria-label": sessionsOnly ? messages.searchSessions : messages.search,
18596
- placeholder: sessionsOnly ? messages.searchSessions : messages.search,
18597
- className: "min-w-0 [&::-webkit-search-cancel-button]:hidden",
18598
- onChange: (event) => onIntent?.({ type: "change-search", query: event.target.value }),
18599
- onKeyDown: (event) => {
18600
- if (event.key !== "Escape") return;
18601
- onIntent?.({ type: "change-search", query: "" });
18602
- event.currentTarget.blur();
18603
- }
18883
+ className: cn2(
18884
+ "grid min-w-0 flex-1 grid-cols-2 text-foreground",
18885
+ classNames?.tabs
18886
+ ),
18887
+ "aria-label": messages.tabsLabel,
18888
+ children: [
18889
+ /* @__PURE__ */ jsx(TabsTrigger, { value: "agents", children: messages.agents }),
18890
+ /* @__PURE__ */ jsx(TabsTrigger, { value: "sessions", children: messages.sessions })
18891
+ ]
18604
18892
  }
18605
- ),
18606
- viewModel.searchQuery ? /* @__PURE__ */ jsx(InputGroupAddon, { align: "inline-end", children: /* @__PURE__ */ jsx(InputGroupButton, { size: "icon-xs", "aria-label": messages.clearSearch, onClick: () => onIntent?.({ type: "change-search", query: "" }), children: /* @__PURE__ */ jsx(X, { className: "size-3.5", "aria-hidden": "true" }) }) }) : /* @__PURE__ */ jsx(InputGroupAddon, { align: "inline-end", children: /* @__PURE__ */ jsx("kbd", { className: "border border-border px-1.5 py-0.5 text-[10px]", children: "Ctrl K" }) })
18607
- ] }) : void 0,
18608
- actions: showAgents && showSessions || headerActions ? /* @__PURE__ */ jsxs(Fragment, { children: [
18609
- showAgents && showSessions ? /* @__PURE__ */ jsxs(TabsList, { className: cn2("grid min-w-0 flex-1 grid-cols-2 text-foreground", classNames?.tabs), "aria-label": messages.tabsLabel, children: [
18610
- /* @__PURE__ */ jsx(TabsTrigger, { value: "agents", children: messages.agents }),
18611
- /* @__PURE__ */ jsx(TabsTrigger, { value: "sessions", children: messages.sessions })
18612
- ] }) : null,
18893
+ ) : null,
18613
18894
  headerActions ? /* @__PURE__ */ jsx("div", { className: "flex shrink-0 items-center", children: headerActions }) : null
18614
18895
  ] }) : void 0,
18615
- footer: visibleSections.has("footer") && (!sessionsOnly && viewModel.capabilities.manageAgentSettings || footer) ? /* @__PURE__ */ jsxs("div", { className: cn2("border-t border-border p-4", classNames?.footer), children: [
18616
- !sessionsOnly && viewModel.capabilities.manageAgentSettings ? /* @__PURE__ */ jsxs(Button, { type: "button", variant: "ghost", className: "h-10 w-full justify-start gap-2 px-3 text-sm", onClick: () => onIntent?.({ type: "open-agent-settings" }), children: [
18617
- /* @__PURE__ */ jsx(Settings, { className: "size-4", "aria-hidden": "true" }),
18618
- messages.settings
18619
- ] }) : null,
18620
- footer
18621
- ] }) : void 0,
18896
+ footer: visibleSections.has("footer") && (!sessionsOnly && viewModel.capabilities.manageAgentSettings || footer) ? /* @__PURE__ */ jsxs(
18897
+ "div",
18898
+ {
18899
+ className: cn2("border-t border-border p-4", classNames?.footer),
18900
+ children: [
18901
+ !sessionsOnly && viewModel.capabilities.manageAgentSettings ? /* @__PURE__ */ jsxs(
18902
+ Button,
18903
+ {
18904
+ type: "button",
18905
+ variant: "ghost",
18906
+ className: "h-10 w-full justify-start gap-2 px-3 text-sm",
18907
+ onClick: () => onIntent?.({ type: "open-agent-settings" }),
18908
+ children: [
18909
+ /* @__PURE__ */ jsx(Settings, { className: "size-4", "aria-hidden": "true" }),
18910
+ messages.settings
18911
+ ]
18912
+ }
18913
+ ) : null,
18914
+ footer
18915
+ ]
18916
+ }
18917
+ ) : void 0,
18622
18918
  bodyScrollable: false,
18623
18919
  className,
18624
- classNames: { root: classNames?.root, body: "flex min-h-0 flex-1 flex-col p-0" },
18920
+ classNames: {
18921
+ root: classNames?.root,
18922
+ body: "flex min-h-0 flex-1 flex-col p-0"
18923
+ },
18625
18924
  children: [
18626
- showAgents ? /* @__PURE__ */ jsxs(TabsContent, { value: "agents", "data-agent-workbench-scroll-region": true, className: cn2("mt-0 min-h-0 flex-1 overflow-x-hidden overflow-y-auto overscroll-contain px-4 pb-4", classNames?.body), children: [
18627
- viewModel.capabilities.createAgent ? /* @__PURE__ */ jsxs(Button, { type: "button", variant: "ghost", className: "mb-3 h-9 w-full justify-start gap-2 px-3 text-sm", onClick: () => onIntent?.({ type: "create-agent" }), children: [
18628
- /* @__PURE__ */ jsx(Plus, { className: "size-4", "aria-hidden": "true" }),
18629
- messages.newAgent
18630
- ] }) : null,
18631
- /* @__PURE__ */ jsx("h3", { className: "mb-2 px-3 text-xs font-medium text-muted-foreground", children: messages.allAgents }),
18632
- /* @__PURE__ */ jsx(CollectionState, { status: viewModel.agents.status, empty: messages.emptyAgents, noResults: messages.noResults, hasItems: agents.length > 0, query, error: viewModel.agents.error, onRetry: () => onIntent?.({ type: "retry-agents" }) }),
18633
- /* @__PURE__ */ jsx("div", { className: "space-y-1", children: agents.map((item) => /* @__PURE__ */ jsxs(
18634
- "div",
18635
- {
18636
- "aria-current": item.id === viewModel.selectedAgentItem ? "page" : void 0,
18637
- className: cn2("group flex w-full min-w-0 items-center gap-3 rounded-lg border border-transparent px-3 py-2 text-left hover:bg-muted aria-[current=page]:border-primary aria-[current=page]:bg-muted", classNames?.item),
18638
- children: [
18639
- /* @__PURE__ */ jsxs("button", { type: "button", title: item.name, className: "flex min-w-0 flex-1 items-center gap-3 text-left", onClick: () => onIntent?.({ type: "select-agent", itemId: item.id }), children: [
18640
- /* @__PURE__ */ jsx("span", { className: "flex size-10 shrink-0 items-center justify-center overflow-hidden rounded-lg bg-muted", children: /* @__PURE__ */ jsx(ItemAvatar, { item }) }),
18641
- /* @__PURE__ */ jsxs("span", { className: "min-w-0 flex-1", children: [
18642
- /* @__PURE__ */ jsx("span", { className: "block truncate text-sm font-medium", children: item.name }),
18643
- /* @__PURE__ */ jsx("span", { className: "block truncate text-xs text-foreground/80", children: item.description || messages.noDescription })
18644
- ] })
18645
- ] }),
18646
- item.builtIn ? /* @__PURE__ */ jsx("span", { className: "shrink-0 rounded-full bg-muted px-1.5 py-1 text-[10px] text-foreground", children: messages.builtIn }) : null,
18647
- viewModel.capabilities.pinAgents ? /* @__PURE__ */ jsx(
18648
- Button,
18649
- {
18650
- type: "button",
18651
- variant: "ghost",
18652
- size: "icon",
18653
- "aria-label": item.pinned ? messages.unpin : messages.pin,
18654
- className: cn2("size-8 text-muted-foreground opacity-0 group-hover:opacity-100", item.pinned && "text-primary opacity-100"),
18655
- onClick: (event) => {
18656
- event.stopPropagation();
18657
- onIntent?.({ type: "toggle-agent-pin", itemId: item.id, pinned: !item.pinned });
18658
- },
18659
- onKeyDown: (event) => {
18660
- if (event.key === "Enter" || event.key === " ") {
18661
- event.preventDefault();
18662
- event.stopPropagation();
18663
- onIntent?.({ type: "toggle-agent-pin", itemId: item.id, pinned: !item.pinned });
18925
+ showAgents ? /* @__PURE__ */ jsxs(
18926
+ TabsContent,
18927
+ {
18928
+ value: "agents",
18929
+ "data-agent-workbench-scroll-region": true,
18930
+ className: cn2(
18931
+ "mt-0 min-h-0 flex-1 overflow-x-hidden overflow-y-auto overscroll-contain px-4 pb-4",
18932
+ classNames?.body
18933
+ ),
18934
+ children: [
18935
+ viewModel.capabilities.createAgent ? /* @__PURE__ */ jsxs(
18936
+ Button,
18937
+ {
18938
+ type: "button",
18939
+ variant: "ghost",
18940
+ className: "mb-3 h-9 w-full justify-start gap-2 px-3 text-sm",
18941
+ onClick: () => onIntent?.({ type: "create-agent" }),
18942
+ children: [
18943
+ /* @__PURE__ */ jsx(Plus, { className: "size-4", "aria-hidden": "true" }),
18944
+ messages.newAgent
18945
+ ]
18946
+ }
18947
+ ) : null,
18948
+ /* @__PURE__ */ jsx("h3", { className: "mb-2 px-3 text-xs font-medium text-muted-foreground", children: messages.allAgents }),
18949
+ /* @__PURE__ */ jsx(
18950
+ CollectionState,
18951
+ {
18952
+ status: viewModel.agents.status,
18953
+ empty: messages.emptyAgents,
18954
+ noResults: messages.noResults,
18955
+ hasItems: agents.length > 0,
18956
+ query,
18957
+ error: viewModel.agents.error,
18958
+ onRetry: () => onIntent?.({ type: "retry-agents" })
18959
+ }
18960
+ ),
18961
+ /* @__PURE__ */ jsx("div", { className: "space-y-1", children: agents.map((item) => /* @__PURE__ */ jsxs(
18962
+ "div",
18963
+ {
18964
+ "aria-current": item.id === viewModel.selectedAgentItem ? "page" : void 0,
18965
+ className: cn2(
18966
+ "group flex w-full min-w-0 items-center gap-3 rounded-lg border border-transparent px-3 py-2 text-left hover:bg-muted aria-[current=page]:border-primary aria-[current=page]:bg-muted",
18967
+ classNames?.item
18968
+ ),
18969
+ children: [
18970
+ /* @__PURE__ */ jsxs(
18971
+ "button",
18972
+ {
18973
+ type: "button",
18974
+ title: item.name,
18975
+ className: "flex min-w-0 flex-1 items-center gap-3 text-left",
18976
+ onClick: () => onIntent?.({ type: "select-agent", itemId: item.id }),
18977
+ children: [
18978
+ /* @__PURE__ */ jsx("span", { className: "flex size-10 shrink-0 items-center justify-center overflow-hidden rounded-lg bg-muted", children: /* @__PURE__ */ jsx(ItemAvatar, { item }) }),
18979
+ /* @__PURE__ */ jsxs("span", { className: "min-w-0 flex-1", children: [
18980
+ /* @__PURE__ */ jsx("span", { className: "block truncate text-sm font-medium", children: item.name }),
18981
+ /* @__PURE__ */ jsx("span", { className: "block truncate text-xs text-foreground/80", children: item.description || messages.noDescription })
18982
+ ] })
18983
+ ]
18664
18984
  }
18665
- },
18666
- children: /* @__PURE__ */ jsx(Pin, { className: cn2("size-4", item.pinned && "fill-current", item.pinPending && "animate-pulse") })
18667
- }
18668
- ) : null
18669
- ]
18670
- },
18671
- item.id
18672
- )) })
18673
- ] }) : null,
18674
- showSessions ? /* @__PURE__ */ jsxs(TabsContent, { value: "sessions", "data-agent-workbench-scroll-region": true, className: cn2("mt-0 min-h-0 flex-1 overflow-x-hidden overflow-y-auto overscroll-contain px-4 pb-4", classNames?.body), children: [
18675
- visibleSections.has("new-session") && viewModel.capabilities.createSession ? /* @__PURE__ */ jsxs(Button, { type: "button", variant: "ghost", className: "h-9 w-full justify-start gap-2 px-3 text-sm", onClick: () => onIntent?.({ type: "create-session" }), children: [
18676
- /* @__PURE__ */ jsx(SquarePen, { className: "size-4", "aria-hidden": "true" }),
18677
- messages.newSession
18678
- ] }) : null,
18679
- !sessionsOnly && viewModel.capabilities.manageCapabilities ? /* @__PURE__ */ jsxs(Button, { type: "button", variant: "ghost", className: "mb-3 h-9 w-full justify-start gap-2 px-3 text-sm", onClick: () => onIntent?.({ type: "open-capabilities" }), children: [
18680
- /* @__PURE__ */ jsx(Blocks, { className: "size-4", "aria-hidden": "true" }),
18681
- messages.capabilities
18682
- ] }) : null,
18683
- !sessionsOnly ? /* @__PURE__ */ jsx("h3", { className: "mb-2 px-3 text-xs font-medium text-muted-foreground", children: messages.recentSessions }) : null,
18684
- /* @__PURE__ */ jsx(CollectionState, { status: viewModel.sessions.status, empty: messages.emptySessions, noResults: messages.noResults, hasItems: sessions.length > 0, query, error: viewModel.sessions.error, onRetry: () => onIntent?.({ type: "retry-sessions" }) }),
18685
- sessionsOnly && sessions.length > 0 ? /* @__PURE__ */ jsx("div", { className: "space-y-2", children: [
18686
- { id: "chatbot", label: messages.chats, icon: MessageSquare, items: chatbotSessions },
18687
- { id: "agent", label: messages.agents, icon: Bot, items: agentSessions }
18688
- ].map(({ id, label, icon: Icon2, items }) => /* @__PURE__ */ jsxs("details", { open: true, "aria-label": label, children: [
18689
- /* @__PURE__ */ jsxs("summary", { className: "flex h-9 cursor-pointer list-none items-center gap-2 rounded-md px-3 text-sm font-semibold hover:bg-muted", children: [
18690
- /* @__PURE__ */ jsx(Icon2, { className: "size-4 shrink-0 text-muted-foreground", "aria-hidden": "true" }),
18691
- /* @__PURE__ */ jsx("span", { className: "min-w-0 truncate", children: label })
18692
- ] }),
18693
- renderSessionItems(items)
18694
- ] }, id)) }) : !sessionsOnly ? renderSessionItems(sessions) : null
18695
- ] }) : null
18985
+ ),
18986
+ item.builtIn ? /* @__PURE__ */ jsx("span", { className: "shrink-0 rounded-full bg-muted px-1.5 py-1 text-[10px] text-foreground", children: messages.builtIn }) : null,
18987
+ viewModel.capabilities.pinAgents ? /* @__PURE__ */ jsx(
18988
+ Button,
18989
+ {
18990
+ type: "button",
18991
+ variant: "ghost",
18992
+ size: "icon",
18993
+ "aria-label": item.pinned ? messages.unpin : messages.pin,
18994
+ className: cn2(
18995
+ "size-8 text-muted-foreground opacity-0 group-hover:opacity-100",
18996
+ item.pinned && "text-primary opacity-100"
18997
+ ),
18998
+ onClick: (event) => {
18999
+ event.stopPropagation();
19000
+ onIntent?.({
19001
+ type: "toggle-agent-pin",
19002
+ itemId: item.id,
19003
+ pinned: !item.pinned
19004
+ });
19005
+ },
19006
+ onKeyDown: (event) => {
19007
+ if (event.key === "Enter" || event.key === " ") {
19008
+ event.preventDefault();
19009
+ event.stopPropagation();
19010
+ onIntent?.({
19011
+ type: "toggle-agent-pin",
19012
+ itemId: item.id,
19013
+ pinned: !item.pinned
19014
+ });
19015
+ }
19016
+ },
19017
+ children: /* @__PURE__ */ jsx(
19018
+ Pin,
19019
+ {
19020
+ className: cn2(
19021
+ "size-4",
19022
+ item.pinned && "fill-current",
19023
+ item.pinPending && "animate-pulse"
19024
+ )
19025
+ }
19026
+ )
19027
+ }
19028
+ ) : null
19029
+ ]
19030
+ },
19031
+ item.id
19032
+ )) })
19033
+ ]
19034
+ }
19035
+ ) : null,
19036
+ showSessions ? /* @__PURE__ */ jsxs(
19037
+ TabsContent,
19038
+ {
19039
+ value: "sessions",
19040
+ "data-agent-workbench-scroll-region": true,
19041
+ className: cn2(
19042
+ "mt-0 min-h-0 flex-1 overflow-x-hidden overflow-y-auto overscroll-contain px-4 pb-4",
19043
+ classNames?.body
19044
+ ),
19045
+ children: [
19046
+ visibleSections.has("new-session") && viewModel.capabilities.createSession ? /* @__PURE__ */ jsx(
19047
+ AgentWorkbenchSidebarNewSessionButton,
19048
+ {
19049
+ label: messages.newSession,
19050
+ onClick: () => onIntent?.({ type: "create-session" })
19051
+ }
19052
+ ) : null,
19053
+ !sessionsOnly && viewModel.capabilities.manageCapabilities ? /* @__PURE__ */ jsxs(
19054
+ Button,
19055
+ {
19056
+ type: "button",
19057
+ variant: "ghost",
19058
+ className: "mb-3 h-9 w-full justify-start gap-2 px-3 text-sm",
19059
+ onClick: () => onIntent?.({ type: "open-capabilities" }),
19060
+ children: [
19061
+ /* @__PURE__ */ jsx(Blocks, { className: "size-4", "aria-hidden": "true" }),
19062
+ messages.capabilities
19063
+ ]
19064
+ }
19065
+ ) : null,
19066
+ /* @__PURE__ */ jsx(
19067
+ AgentWorkbenchSessionList,
19068
+ {
19069
+ sessions,
19070
+ selectedSessionId: viewModel.selectedSessionItem,
19071
+ status: viewModel.sessions.status,
19072
+ error: viewModel.sessions.error,
19073
+ query,
19074
+ emptyLabel: messages.emptySessions,
19075
+ noResultsLabel: messages.noResults,
19076
+ groupByMode: sessionsOnly,
19077
+ showHeading: !sessionsOnly,
19078
+ itemClassName: classNames?.item,
19079
+ capabilities: {
19080
+ pin: viewModel.capabilities.pinSessions,
19081
+ rename: viewModel.capabilities.renameSessions,
19082
+ delete: viewModel.capabilities.deleteSessions
19083
+ },
19084
+ onSelect: (sessionId) => onIntent?.({ type: "select-session", sessionId }),
19085
+ onTogglePin: (sessionId, pinned) => onIntent?.({ type: "toggle-session-pin", sessionId, pinned }),
19086
+ onRename: (sessionId, title) => onIntent?.({ type: "rename-session", sessionId, title }),
19087
+ onDelete: (sessionId) => onIntent?.({ type: "delete-session", sessionId }),
19088
+ onRetry: () => onIntent?.({ type: "retry-sessions" })
19089
+ }
19090
+ )
19091
+ ]
19092
+ }
19093
+ ) : null
18696
19094
  ]
18697
19095
  }
18698
19096
  )
@@ -18766,9 +19164,10 @@ function AgentWorkbenchExploreSidebar({
18766
19164
  renderItemMedia,
18767
19165
  onIntent
18768
19166
  }) {
18769
- const navigationMessages = useMonkeysLocaleMessages().agentWorkbench.navigation;
18770
- const searchRef = useRef(null);
18771
- const resolvedConfig = useMemo(() => resolveAgentWorkbenchSidebarConfig(config), [config]);
19167
+ const resolvedConfig = useMemo(
19168
+ () => resolveAgentWorkbenchSidebarConfig(config),
19169
+ [config]
19170
+ );
18772
19171
  const visibleSections = useMemo(
18773
19172
  () => new Set(resolvedConfig.visibleSections),
18774
19173
  [resolvedConfig.visibleSections]
@@ -18791,28 +19190,18 @@ function AgentWorkbenchExploreSidebar({
18791
19190
  if (groups.some((group) => group.id === activeGroupId)) return;
18792
19191
  setActiveGroupId(resolvedDefaultGroupId ?? groups[0]?.id ?? "");
18793
19192
  }, [activeGroupId, groups, resolvedDefaultGroupId]);
18794
- useEffect(() => {
18795
- const handleShortcut = (event) => {
18796
- if (!(event.ctrlKey || event.metaKey) || event.key.toLocaleLowerCase() !== "k")
18797
- return;
18798
- event.preventDefault();
18799
- searchRef.current?.focus();
18800
- searchRef.current?.select();
18801
- };
18802
- window.addEventListener("keydown", handleShortcut);
18803
- return () => window.removeEventListener("keydown", handleShortcut);
18804
- }, []);
18805
19193
  const changeGroup = (groupId) => {
18806
19194
  setActiveGroupId(groupId);
18807
19195
  onIntent?.({ type: "change-group", groupId });
18808
19196
  };
18809
- const state = !visibleSections.has("sessions") ? "ready" : error ? "error" : loading && sessions.length === 0 ? "loading" : filteredSessions.length === 0 && !draftVisible ? "empty" : "ready";
18810
19197
  const groupNavigation = visibleSections.has("groups") && activeGroup ? /* @__PURE__ */ jsx("div", { className: "border-t border-border px-4 pb-4 pt-3", children: /* @__PURE__ */ jsxs(Tabs, { value: activeGroup.id, onValueChange: changeGroup, children: [
18811
19198
  /* @__PURE__ */ jsx(
18812
19199
  TabsList,
18813
19200
  {
18814
19201
  className: "grid h-10 w-full rounded-[var(--radius)] bg-muted p-0.5 text-foreground",
18815
- style: { gridTemplateColumns: `repeat(${groups.length}, minmax(0, 1fr))` },
19202
+ style: {
19203
+ gridTemplateColumns: `repeat(${groups.length}, minmax(0, 1fr))`
19204
+ },
18816
19205
  children: groups.map((group) => /* @__PURE__ */ jsx(
18817
19206
  TabsTrigger,
18818
19207
  {
@@ -18831,7 +19220,11 @@ function AgentWorkbenchExploreSidebar({
18831
19220
  "aria-label": item.title,
18832
19221
  className: "group relative aspect-[1.27] overflow-hidden rounded-[var(--radius)] border border-border bg-card text-left transition hover:border-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
18833
19222
  style: Number.isFinite(group.itemAspectRatio) && Number(group.itemAspectRatio) > 0 ? { aspectRatio: group.itemAspectRatio } : void 0,
18834
- onClick: () => onIntent?.({ type: "select-item", groupId: group.id, item }),
19223
+ onClick: () => onIntent?.({
19224
+ type: "select-item",
19225
+ groupId: group.id,
19226
+ item
19227
+ }),
18835
19228
  children: renderItemMedia?.(item, group) ?? /* @__PURE__ */ jsx(AgentWorkbenchExploreCardMedia, { item })
18836
19229
  },
18837
19230
  item.id
@@ -18844,47 +19237,23 @@ function AgentWorkbenchExploreSidebar({
18844
19237
  "data-sidebar-width-percent": resolvedConfig.widthPercent,
18845
19238
  "aria-label": labels.navigation,
18846
19239
  header: visibleSections.has("header") ? header : void 0,
18847
- search: visibleSections.has("search") ? /* @__PURE__ */ jsxs(InputGroup, { className: "h-12 rounded-[var(--radius)] border-border bg-card text-foreground", children: [
18848
- /* @__PURE__ */ jsx(InputGroupAddon, { children: /* @__PURE__ */ jsx(Search, { className: "size-4 text-muted-foreground", "aria-hidden": "true" }) }),
18849
- /* @__PURE__ */ jsx(
18850
- InputGroupInput,
18851
- {
18852
- ref: searchRef,
18853
- type: "search",
18854
- value: searchQuery,
18855
- "aria-label": labels.search,
18856
- placeholder: labels.search,
18857
- className: "min-w-0 text-foreground placeholder:text-muted-foreground [&::-webkit-search-cancel-button]:hidden",
18858
- onChange: (event) => onIntent?.({ type: "change-search", query: event.target.value })
18859
- }
18860
- ),
18861
- /* @__PURE__ */ jsx(InputGroupAddon, { align: "inline-end", children: /* @__PURE__ */ jsx("kbd", { className: "rounded-sm border border-border px-1.5 py-0.5 text-[10px] text-muted-foreground", children: "Ctrl K" }) })
18862
- ] }) : void 0,
18863
- primaryAction: visibleSections.has("new-session") ? /* @__PURE__ */ jsxs(
18864
- Button,
19240
+ search: visibleSections.has("search") ? /* @__PURE__ */ jsx(
19241
+ AgentWorkbenchSidebarSearch,
18865
19242
  {
18866
- type: "button",
18867
- className: "h-11 w-full justify-start gap-2 rounded-[var(--radius)] border border-primary/60 bg-primary px-3 font-semibold text-primary-foreground hover:bg-primary/90",
18868
- onClick: () => onIntent?.({ type: "create-session" }),
18869
- children: [
18870
- /* @__PURE__ */ jsx(SquarePen, { className: "size-4", "aria-hidden": "true" }),
18871
- labels.newSession
18872
- ]
19243
+ value: searchQuery,
19244
+ label: labels.search,
19245
+ onChange: (query) => onIntent?.({ type: "change-search", query })
19246
+ }
19247
+ ) : void 0,
19248
+ primaryAction: visibleSections.has("new-session") ? /* @__PURE__ */ jsx(
19249
+ AgentWorkbenchSidebarNewSessionButton,
19250
+ {
19251
+ label: labels.newSession,
19252
+ onClick: () => onIntent?.({ type: "create-session" })
18873
19253
  }
18874
19254
  ) : void 0,
18875
19255
  groups: groupNavigation,
18876
19256
  footer: visibleSections.has("footer") ? footer : void 0,
18877
- status: state,
18878
- loadingState: /* @__PURE__ */ jsx("div", { className: "flex h-24 items-center justify-center text-muted-foreground", children: /* @__PURE__ */ jsx(Loader2, { className: "size-5 animate-spin" }) }),
18879
- emptyState: /* @__PURE__ */ jsx("div", { className: "px-3 py-8 text-center text-sm text-muted-foreground", children: normalizedQuery ? labels.noResults : labels.emptySessions }),
18880
- errorState: /* @__PURE__ */ jsxs("div", { className: "flex min-h-24 flex-col items-center justify-center gap-2 px-3 py-6 text-center", role: "alert", children: [
18881
- /* @__PURE__ */ jsx(AlertCircle, { className: "size-5 shrink-0 text-destructive-text", "aria-hidden": "true" }),
18882
- /* @__PURE__ */ jsx("p", { className: "max-w-full break-words text-sm text-muted-foreground", children: error }),
18883
- labels.retry ? /* @__PURE__ */ jsxs(Button, { type: "button", variant: "ghost", size: "sm", className: "gap-1.5 text-primary", onClick: () => onIntent?.({ type: "retry-sessions" }), children: [
18884
- /* @__PURE__ */ jsx(RefreshCw, { className: "size-3.5", "aria-hidden": "true" }),
18885
- labels.retry
18886
- ] }) : null
18887
- ] }),
18888
19257
  bodyProps: { "data-agent-workbench-session-scroll-region": "" },
18889
19258
  className,
18890
19259
  classNames: { body: "min-h-[160px] flex-[0_1_280px] px-4 pb-3" },
@@ -18899,53 +19268,24 @@ function AgentWorkbenchExploreSidebar({
18899
19268
  children: labels.draftSession
18900
19269
  }
18901
19270
  ) : null,
18902
- filteredSessions.map((session) => /* @__PURE__ */ jsxs(
18903
- "div",
19271
+ filteredSessions.length > 0 || !draftVisible || loading || error ? /* @__PURE__ */ jsx(
19272
+ AgentWorkbenchSessionList,
18904
19273
  {
18905
- "aria-current": session.id === selectedSessionId ? "page" : void 0,
18906
- className: "group flex h-10 w-full min-w-0 items-center rounded-[var(--radius)] border border-transparent bg-muted/60 text-foreground transition hover:bg-muted aria-[current=page]:border-primary aria-[current=page]:bg-primary/10",
18907
- children: [
18908
- /* @__PURE__ */ jsx(
18909
- "button",
18910
- {
18911
- type: "button",
18912
- title: session.title,
18913
- className: "h-full min-w-0 flex-1 truncate px-3 text-left text-sm font-semibold",
18914
- onClick: () => onIntent?.({ type: "select-session", sessionId: session.id }),
18915
- children: session.title
18916
- }
18917
- ),
18918
- deleteSessions ? /* @__PURE__ */ jsxs(DropdownMenu4, { children: [
18919
- /* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsx(
18920
- Button,
18921
- {
18922
- type: "button",
18923
- variant: "ghost",
18924
- size: "icon",
18925
- "aria-label": navigationMessages.actions,
18926
- className: "mr-1 size-8 shrink-0 text-muted-foreground opacity-0 transition-opacity group-aria-[current=page]:opacity-100 group-focus-within:opacity-100 group-hover:opacity-100 data-[state=open]:opacity-100",
18927
- children: /* @__PURE__ */ jsx(Ellipsis, { className: "size-4", "aria-hidden": "true" })
18928
- }
18929
- ) }),
18930
- /* @__PURE__ */ jsx(DropdownMenuContent, { align: "end", children: /* @__PURE__ */ jsxs(
18931
- DropdownMenuItem,
18932
- {
18933
- className: "text-destructive-text",
18934
- onSelect: () => onIntent?.({
18935
- type: "delete-session",
18936
- sessionId: session.id
18937
- }),
18938
- children: [
18939
- /* @__PURE__ */ jsx(Trash2, { className: "mr-2 size-4", "aria-hidden": "true" }),
18940
- navigationMessages.delete
18941
- ]
18942
- }
18943
- ) })
18944
- ] }) : null
18945
- ]
18946
- },
18947
- session.id
18948
- ))
19274
+ sessions: filteredSessions,
19275
+ selectedSessionId,
19276
+ status: error ? "error" : loading ? "loading" : "ready",
19277
+ error,
19278
+ query: normalizedQuery,
19279
+ emptyLabel: labels.emptySessions,
19280
+ noResultsLabel: labels.noResults,
19281
+ retryLabel: labels.retry,
19282
+ groupByMode: resolvedConfig.navigationMode !== "default",
19283
+ capabilities: { delete: deleteSessions },
19284
+ onSelect: (sessionId) => onIntent?.({ type: "select-session", sessionId }),
19285
+ onDelete: (sessionId) => onIntent?.({ type: "delete-session", sessionId }),
19286
+ onRetry: labels.retry ? () => onIntent?.({ type: "retry-sessions" }) : void 0
19287
+ }
19288
+ ) : null
18949
19289
  ] }) : null
18950
19290
  }
18951
19291
  );