@inf-monkeys-tech/monkeys-design 1.0.12 → 1.0.13-canary.72.1.22484ee

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,5 +1,6 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import { AgentWorkbenchNavigationViewModel, AgentSessionViewModel, AgentSessionEvent } from '@inf-monkeys-tech/monkeys';
3
+ import { ReactNode } from 'react';
3
4
  type AgentWorkbenchSidebarIntent = {
4
5
  type: 'change-search';
5
6
  query: string;
@@ -50,11 +51,12 @@ interface AgentWorkbenchSidebarClassNames {
50
51
  }
51
52
  interface AgentWorkbenchSidebarProps {
52
53
  viewModel: AgentWorkbenchNavigationViewModel;
54
+ headerActions?: ReactNode;
53
55
  className?: string;
54
56
  classNames?: AgentWorkbenchSidebarClassNames;
55
57
  onIntent?: (intent: AgentWorkbenchSidebarIntent) => void;
56
58
  }
57
- declare function AgentWorkbenchSidebar({ viewModel, className, classNames, onIntent }: AgentWorkbenchSidebarProps): react_jsx_runtime.JSX.Element;
59
+ declare function AgentWorkbenchSidebar({ viewModel, headerActions, className, classNames, onIntent }: AgentWorkbenchSidebarProps): react_jsx_runtime.JSX.Element;
58
60
  interface AgentWorkbenchApprovalIntent {
59
61
  approvalId: string;
60
62
  approved: boolean;
@@ -1,5 +1,6 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import { AgentWorkbenchNavigationViewModel, AgentSessionViewModel, AgentSessionEvent } from '@inf-monkeys-tech/monkeys';
3
+ import { ReactNode } from 'react';
3
4
  type AgentWorkbenchSidebarIntent = {
4
5
  type: 'change-search';
5
6
  query: string;
@@ -50,11 +51,12 @@ interface AgentWorkbenchSidebarClassNames {
50
51
  }
51
52
  interface AgentWorkbenchSidebarProps {
52
53
  viewModel: AgentWorkbenchNavigationViewModel;
54
+ headerActions?: ReactNode;
53
55
  className?: string;
54
56
  classNames?: AgentWorkbenchSidebarClassNames;
55
57
  onIntent?: (intent: AgentWorkbenchSidebarIntent) => void;
56
58
  }
57
- declare function AgentWorkbenchSidebar({ viewModel, className, classNames, onIntent }: AgentWorkbenchSidebarProps): react_jsx_runtime.JSX.Element;
59
+ declare function AgentWorkbenchSidebar({ viewModel, headerActions, className, classNames, onIntent }: AgentWorkbenchSidebarProps): react_jsx_runtime.JSX.Element;
58
60
  interface AgentWorkbenchApprovalIntent {
59
61
  approvalId: string;
60
62
  approved: boolean;
@@ -726,10 +726,13 @@ function SessionActions({
726
726
  ] })
727
727
  ] });
728
728
  }
729
- function AgentWorkbenchSidebar({ viewModel, className, classNames, onIntent }) {
729
+ function AgentWorkbenchSidebar({ viewModel, headerActions, className, classNames, onIntent }) {
730
730
  const { locale } = useMonkeysLocale();
731
731
  const messages = useMonkeysLocaleMessages().agentWorkbench.navigation;
732
732
  const searchRef = React2.useRef(null);
733
+ const renameInputRef = React2.useRef(null);
734
+ const [editingSessionId, setEditingSessionId] = React2.useState();
735
+ const [editingTitle, setEditingTitle] = React2.useState("");
733
736
  const query = viewModel.searchQuery.trim().toLocaleLowerCase();
734
737
  const agents = React2.useMemo(
735
738
  () => viewModel.agents.items.filter((item) => !query || `${item.name} ${item.description ?? ""}`.toLocaleLowerCase().includes(query)),
@@ -749,6 +752,26 @@ function AgentWorkbenchSidebar({ viewModel, className, classNames, onIntent }) {
749
752
  window.addEventListener("keydown", handleShortcut);
750
753
  return () => window.removeEventListener("keydown", handleShortcut);
751
754
  }, []);
755
+ React2.useEffect(() => {
756
+ if (!editingSessionId) return;
757
+ renameInputRef.current?.focus();
758
+ renameInputRef.current?.select();
759
+ }, [editingSessionId]);
760
+ const beginRenameSession = (item) => {
761
+ setEditingSessionId(item.id);
762
+ setEditingTitle(item.title);
763
+ };
764
+ const cancelRenameSession = () => {
765
+ setEditingSessionId(void 0);
766
+ setEditingTitle("");
767
+ };
768
+ const saveRenameSession = (item) => {
769
+ const title = editingTitle.trim();
770
+ if (title && title !== item.title) {
771
+ onIntent?.({ type: "rename-session", sessionId: item.id, title });
772
+ }
773
+ cancelRenameSession();
774
+ };
752
775
  return /* @__PURE__ */ jsxRuntime.jsx("nav", { "aria-label": messages.tabsLabel, className: cn2("h-full min-h-0", classNames?.root, className), children: /* @__PURE__ */ jsxRuntime.jsxs(
753
776
  Tabs,
754
777
  {
@@ -780,9 +803,12 @@ function AgentWorkbenchSidebar({ viewModel, className, classNames, onIntent }) {
780
803
  ),
781
804
  viewModel.searchQuery ? /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "flex size-6 items-center justify-center rounded-md hover:bg-muted", "aria-label": messages.clearSearch, onClick: () => onIntent?.({ type: "change-search", query: "" }), children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, { className: "size-3.5", "aria-hidden": "true" }) }) : /* @__PURE__ */ jsxRuntime.jsx("kbd", { className: "rounded border border-border px-1.5 py-0.5 text-[10px] text-muted-foreground", children: "Ctrl K" })
782
805
  ] }),
783
- /* @__PURE__ */ jsxRuntime.jsxs(TabsList, { className: cn2("grid w-full grid-cols-2 text-foreground", classNames?.tabs), "aria-label": messages.tabsLabel, children: [
784
- /* @__PURE__ */ jsxRuntime.jsx(TabsTrigger, { value: "agents", children: messages.agents }),
785
- /* @__PURE__ */ jsxRuntime.jsx(TabsTrigger, { value: "sessions", children: messages.sessions })
806
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
807
+ /* @__PURE__ */ jsxRuntime.jsxs(TabsList, { className: cn2("grid min-w-0 flex-1 grid-cols-2 text-foreground", classNames?.tabs), "aria-label": messages.tabsLabel, children: [
808
+ /* @__PURE__ */ jsxRuntime.jsx(TabsTrigger, { value: "agents", children: messages.agents }),
809
+ /* @__PURE__ */ jsxRuntime.jsx(TabsTrigger, { value: "sessions", children: messages.sessions })
810
+ ] }),
811
+ headerActions ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex shrink-0 items-center", children: headerActions }) : null
786
812
  ] })
787
813
  ] }),
788
814
  /* @__PURE__ */ jsxRuntime.jsxs(TabsContent, { value: "agents", className: cn2("mt-0 min-h-0 flex-1 overflow-y-auto px-4 pb-4", classNames?.body), children: [
@@ -843,9 +869,36 @@ function AgentWorkbenchSidebar({ viewModel, className, classNames, onIntent }) {
843
869
  /* @__PURE__ */ jsxRuntime.jsx("h3", { className: "mb-2 px-3 text-xs font-medium text-muted-foreground", children: messages.recentSessions }),
844
870
  /* @__PURE__ */ jsxRuntime.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" }) }),
845
871
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "space-y-1", children: sessions.map((item) => {
846
- const percent = item.contextUsage ? Math.min(100, Math.round(item.contextUsage.usedTokens / item.contextUsage.maxTokens * 100)) : void 0;
872
+ const percent = item.contextUsage && item.contextUsage.maxTokens > 0 ? Math.min(100, Math.round(item.contextUsage.usedTokens / item.contextUsage.maxTokens * 100)) : void 0;
847
873
  return /* @__PURE__ */ jsxRuntime.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: [
848
- /* @__PURE__ */ jsxRuntime.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: [
874
+ editingSessionId === item.id ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex min-w-0 flex-1 items-center gap-3", children: [
875
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "flex size-10 shrink-0 items-center justify-center overflow-hidden rounded-lg bg-muted", children: /* @__PURE__ */ jsxRuntime.jsx(SessionAvatar, { item }) }),
876
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "min-w-0 flex-1", children: [
877
+ /* @__PURE__ */ jsxRuntime.jsx(
878
+ "input",
879
+ {
880
+ ref: renameInputRef,
881
+ value: editingTitle,
882
+ "aria-label": messages.rename,
883
+ className: "h-6 w-full rounded border border-primary bg-background px-1.5 text-sm font-medium outline-none",
884
+ onChange: (event) => setEditingTitle(event.target.value),
885
+ onClick: (event) => event.stopPropagation(),
886
+ onBlur: () => saveRenameSession(item),
887
+ onKeyDown: (event) => {
888
+ event.stopPropagation();
889
+ if (event.key === "Enter") {
890
+ event.preventDefault();
891
+ saveRenameSession(item);
892
+ } else if (event.key === "Escape") {
893
+ event.preventDefault();
894
+ cancelRenameSession();
895
+ }
896
+ }
897
+ }
898
+ ),
899
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "block truncate text-xs text-foreground/80", children: new Intl.DateTimeFormat(locale, { dateStyle: "medium", timeStyle: "short" }).format(new Date(item.updatedAt)) })
900
+ ] })
901
+ ] }) : /* @__PURE__ */ jsxRuntime.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: [
849
902
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "flex size-10 shrink-0 items-center justify-center overflow-hidden rounded-lg bg-muted", children: /* @__PURE__ */ jsxRuntime.jsx(SessionAvatar, { item }) }),
850
903
  /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "min-w-0 flex-1", children: [
851
904
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "block truncate text-sm font-medium", children: item.title }),
@@ -861,7 +914,7 @@ function AgentWorkbenchSidebar({ viewModel, className, classNames, onIntent }) {
861
914
  event.stopPropagation();
862
915
  onIntent?.({ type: "toggle-session-pin", sessionId: item.id, pinned: !item.pinned });
863
916
  }, children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Pin, { className: cn2("size-4", item.pinned && "fill-current") }) }) : null,
864
- /* @__PURE__ */ jsxRuntime.jsx("span", { onClick: (event) => event.stopPropagation(), onKeyDown: (event) => event.stopPropagation(), children: /* @__PURE__ */ jsxRuntime.jsx(SessionActions, { item, capabilities: viewModel.capabilities, onIntent }) })
917
+ /* @__PURE__ */ jsxRuntime.jsx("span", { onClick: (event) => event.stopPropagation(), onKeyDown: (event) => event.stopPropagation(), children: /* @__PURE__ */ jsxRuntime.jsx(SessionActions, { item, capabilities: viewModel.capabilities, onIntent: (intent) => intent.type === "rename-session" ? beginRenameSession(item) : onIntent?.(intent) }) })
865
918
  ] })
866
919
  ] }, item.id);
867
920
  }) })