@inf-monkeys-tech/monkeys-design 1.0.12 → 1.0.13

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.
@@ -1,6 +1,6 @@
1
1
  import { ChevronDown, Check, ChevronRight, Circle, ChevronUp, Search, X, Plus, Pin, SquarePen, Blocks, Settings, TerminalSquare, Clock3, FileOutput, Download, RefreshCw, Bot, Image, Loader2, CheckCircle2, AlertCircle, Ellipsis, Pencil, Trash2, XCircle, CircleStop, Copy, RotateCcw, FileCode2, Files, TestTube2 } from 'lucide-react';
2
2
  import * as React2 from 'react';
3
- import { createContext, useRef, useMemo, useEffect, useState, useContext } from 'react';
3
+ import { createContext, useRef, useState, useMemo, useEffect, useContext } from 'react';
4
4
  import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';
5
5
  import { twMerge } from 'tailwind-merge';
6
6
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
@@ -700,6 +700,9 @@ function AgentWorkbenchSidebar({ viewModel, className, classNames, onIntent }) {
700
700
  const { locale } = useMonkeysLocale();
701
701
  const messages = useMonkeysLocaleMessages().agentWorkbench.navigation;
702
702
  const searchRef = useRef(null);
703
+ const renameInputRef = useRef(null);
704
+ const [editingSessionId, setEditingSessionId] = useState();
705
+ const [editingTitle, setEditingTitle] = useState("");
703
706
  const query = viewModel.searchQuery.trim().toLocaleLowerCase();
704
707
  const agents = useMemo(
705
708
  () => viewModel.agents.items.filter((item) => !query || `${item.name} ${item.description ?? ""}`.toLocaleLowerCase().includes(query)),
@@ -719,6 +722,26 @@ function AgentWorkbenchSidebar({ viewModel, className, classNames, onIntent }) {
719
722
  window.addEventListener("keydown", handleShortcut);
720
723
  return () => window.removeEventListener("keydown", handleShortcut);
721
724
  }, []);
725
+ useEffect(() => {
726
+ if (!editingSessionId) return;
727
+ renameInputRef.current?.focus();
728
+ renameInputRef.current?.select();
729
+ }, [editingSessionId]);
730
+ const beginRenameSession = (item) => {
731
+ setEditingSessionId(item.id);
732
+ setEditingTitle(item.title);
733
+ };
734
+ const cancelRenameSession = () => {
735
+ setEditingSessionId(void 0);
736
+ setEditingTitle("");
737
+ };
738
+ const saveRenameSession = (item) => {
739
+ const title = editingTitle.trim();
740
+ if (title && title !== item.title) {
741
+ onIntent?.({ type: "rename-session", sessionId: item.id, title });
742
+ }
743
+ cancelRenameSession();
744
+ };
722
745
  return /* @__PURE__ */ jsx("nav", { "aria-label": messages.tabsLabel, className: cn2("h-full min-h-0", classNames?.root, className), children: /* @__PURE__ */ jsxs(
723
746
  Tabs,
724
747
  {
@@ -813,9 +836,36 @@ function AgentWorkbenchSidebar({ viewModel, className, classNames, onIntent }) {
813
836
  /* @__PURE__ */ jsx("h3", { className: "mb-2 px-3 text-xs font-medium text-muted-foreground", children: messages.recentSessions }),
814
837
  /* @__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" }) }),
815
838
  /* @__PURE__ */ jsx("div", { className: "space-y-1", children: sessions.map((item) => {
816
- const percent = item.contextUsage ? Math.min(100, Math.round(item.contextUsage.usedTokens / item.contextUsage.maxTokens * 100)) : void 0;
839
+ const percent = item.contextUsage && item.contextUsage.maxTokens > 0 ? Math.min(100, Math.round(item.contextUsage.usedTokens / item.contextUsage.maxTokens * 100)) : void 0;
817
840
  return /* @__PURE__ */ jsxs("div", { "aria-current": item.id === viewModel.selectedSessionItem ? "page" : void 0, className: cn2("group flex w-full 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: [
818
- /* @__PURE__ */ jsxs("button", { type: "button", className: "flex min-w-0 flex-1 items-center gap-3 text-left", onClick: () => onIntent?.({ type: "select-session", sessionId: item.id }), children: [
841
+ editingSessionId === item.id ? /* @__PURE__ */ jsxs("div", { className: "flex min-w-0 flex-1 items-center gap-3", children: [
842
+ /* @__PURE__ */ jsx("span", { className: "flex size-10 shrink-0 items-center justify-center overflow-hidden rounded-lg bg-muted", children: /* @__PURE__ */ jsx(SessionAvatar, { item }) }),
843
+ /* @__PURE__ */ jsxs("span", { className: "min-w-0 flex-1", children: [
844
+ /* @__PURE__ */ jsx(
845
+ "input",
846
+ {
847
+ ref: renameInputRef,
848
+ value: editingTitle,
849
+ "aria-label": messages.rename,
850
+ className: "h-6 w-full rounded border border-primary bg-background px-1.5 text-sm font-medium outline-none",
851
+ onChange: (event) => setEditingTitle(event.target.value),
852
+ onClick: (event) => event.stopPropagation(),
853
+ onBlur: () => saveRenameSession(item),
854
+ onKeyDown: (event) => {
855
+ event.stopPropagation();
856
+ if (event.key === "Enter") {
857
+ event.preventDefault();
858
+ saveRenameSession(item);
859
+ } else if (event.key === "Escape") {
860
+ event.preventDefault();
861
+ cancelRenameSession();
862
+ }
863
+ }
864
+ }
865
+ ),
866
+ /* @__PURE__ */ jsx("span", { className: "block truncate text-xs text-foreground/80", children: new Intl.DateTimeFormat(locale, { dateStyle: "medium", timeStyle: "short" }).format(new Date(item.updatedAt)) })
867
+ ] })
868
+ ] }) : /* @__PURE__ */ jsxs("button", { type: "button", className: "flex min-w-0 flex-1 items-center gap-3 text-left", onClick: () => onIntent?.({ type: "select-session", sessionId: item.id }), children: [
819
869
  /* @__PURE__ */ jsx("span", { className: "flex size-10 shrink-0 items-center justify-center overflow-hidden rounded-lg bg-muted", children: /* @__PURE__ */ jsx(SessionAvatar, { item }) }),
820
870
  /* @__PURE__ */ jsxs("span", { className: "min-w-0 flex-1", children: [
821
871
  /* @__PURE__ */ jsx("span", { className: "block truncate text-sm font-medium", children: item.title }),
@@ -831,7 +881,7 @@ function AgentWorkbenchSidebar({ viewModel, className, classNames, onIntent }) {
831
881
  event.stopPropagation();
832
882
  onIntent?.({ type: "toggle-session-pin", sessionId: item.id, pinned: !item.pinned });
833
883
  }, children: /* @__PURE__ */ jsx(Pin, { className: cn2("size-4", item.pinned && "fill-current") }) }) : null,
834
- /* @__PURE__ */ jsx("span", { onClick: (event) => event.stopPropagation(), onKeyDown: (event) => event.stopPropagation(), children: /* @__PURE__ */ jsx(SessionActions, { item, capabilities: viewModel.capabilities, onIntent }) })
884
+ /* @__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) }) })
835
885
  ] })
836
886
  ] }, item.id);
837
887
  }) })