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

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.
@@ -14,6 +14,7 @@ import * as TabsPrimitive from '@radix-ui/react-tabs';
14
14
  import * as TooltipPrimitive from '@radix-ui/react-tooltip';
15
15
  import { cva } from 'class-variance-authority';
16
16
  import * as SelectPrimitive from '@radix-ui/react-select';
17
+ import { resolveAgentWorkbenchSidebarConfig } from '@inf-monkeys-tech/monkeys';
17
18
  import * as CollapsiblePrimitive from '@radix-ui/react-collapsible';
18
19
  import { useSensors, useSensor, PointerSensor, KeyboardSensor, DndContext, closestCenter } from '@dnd-kit/core';
19
20
  import { sortableKeyboardCoordinates, SortableContext, horizontalListSortingStrategy, useSortable } from '@dnd-kit/sortable';
@@ -1579,7 +1580,8 @@ function SessionActions({
1579
1580
  }
1580
1581
  function AgentWorkbenchSidebar({
1581
1582
  viewModel,
1582
- navigationMode = "agents-and-sessions",
1583
+ navigationMode,
1584
+ config,
1583
1585
  header,
1584
1586
  headerActions,
1585
1587
  footer,
@@ -1589,7 +1591,11 @@ function AgentWorkbenchSidebar({
1589
1591
  }) {
1590
1592
  const { locale } = useMonkeysLocale();
1591
1593
  const messages = useMonkeysLocaleMessages().agentWorkbench.navigation;
1592
- const sessionsOnly = navigationMode === "sessions-only";
1594
+ const resolvedConfig = useMemo(() => resolveAgentWorkbenchSidebarConfig(config), [config]);
1595
+ const visibleSections = useMemo(() => new Set(resolvedConfig.visibleSections), [resolvedConfig.visibleSections]);
1596
+ const sessionsOnly = navigationMode === "sessions-only" || navigationMode === void 0 && resolvedConfig.navigationMode !== "default";
1597
+ const showAgents = visibleSections.has("agents") && !sessionsOnly;
1598
+ const showSessions = visibleSections.has("sessions");
1593
1599
  const searchRef = useRef(null);
1594
1600
  const renameInputRef = useRef(null);
1595
1601
  const [editingSessionId, setEditingSessionId] = useState();
@@ -1689,7 +1695,7 @@ function AgentWorkbenchSidebar({
1689
1695
  return /* @__PURE__ */ jsx(
1690
1696
  Tabs,
1691
1697
  {
1692
- value: sessionsOnly ? "sessions" : viewModel.activeTab,
1698
+ value: sessionsOnly || !showAgents ? "sessions" : viewModel.activeTab,
1693
1699
  onValueChange: (value) => {
1694
1700
  if (!sessionsOnly && (value === "agents" || value === "sessions")) onIntent?.({ type: "change-tab", tab: value });
1695
1701
  },
@@ -1697,9 +1703,10 @@ function AgentWorkbenchSidebar({
1697
1703
  children: /* @__PURE__ */ jsxs(
1698
1704
  AgentWorkbenchSidebarContainer,
1699
1705
  {
1706
+ "data-sidebar-width-percent": resolvedConfig.widthPercent,
1700
1707
  "aria-label": messages.tabsLabel,
1701
- header,
1702
- search: /* @__PURE__ */ jsxs(InputGroup, { className: cn2("h-10 rounded-lg bg-card", classNames?.search), children: [
1708
+ header: visibleSections.has("header") ? header : void 0,
1709
+ search: visibleSections.has("search") ? /* @__PURE__ */ jsxs(InputGroup, { className: cn2("h-10 rounded-lg bg-card", classNames?.search), children: [
1703
1710
  /* @__PURE__ */ jsx(InputGroupAddon, { children: /* @__PURE__ */ jsx(Search, { className: "size-4", "aria-hidden": "true" }) }),
1704
1711
  /* @__PURE__ */ jsx(
1705
1712
  InputGroupInput,
@@ -1719,15 +1726,15 @@ function AgentWorkbenchSidebar({
1719
1726
  }
1720
1727
  ),
1721
1728
  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" }) })
1722
- ] }),
1723
- actions: !sessionsOnly || headerActions ? /* @__PURE__ */ jsxs(Fragment, { children: [
1724
- !sessionsOnly ? /* @__PURE__ */ jsxs(TabsList, { className: cn2("grid min-w-0 flex-1 grid-cols-2 text-foreground", classNames?.tabs), "aria-label": messages.tabsLabel, children: [
1729
+ ] }) : void 0,
1730
+ actions: showAgents && showSessions || headerActions ? /* @__PURE__ */ jsxs(Fragment, { children: [
1731
+ 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: [
1725
1732
  /* @__PURE__ */ jsx(TabsTrigger, { value: "agents", children: messages.agents }),
1726
1733
  /* @__PURE__ */ jsx(TabsTrigger, { value: "sessions", children: messages.sessions })
1727
1734
  ] }) : null,
1728
1735
  headerActions ? /* @__PURE__ */ jsx("div", { className: "flex shrink-0 items-center", children: headerActions }) : null
1729
1736
  ] }) : void 0,
1730
- footer: !sessionsOnly && viewModel.capabilities.manageAgentSettings || footer ? /* @__PURE__ */ jsxs("div", { className: cn2("border-t border-border p-4", classNames?.footer), children: [
1737
+ footer: visibleSections.has("footer") && (!sessionsOnly && viewModel.capabilities.manageAgentSettings || footer) ? /* @__PURE__ */ jsxs("div", { className: cn2("border-t border-border p-4", classNames?.footer), children: [
1731
1738
  !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: [
1732
1739
  /* @__PURE__ */ jsx(Settings, { className: "size-4", "aria-hidden": "true" }),
1733
1740
  messages.settings
@@ -1738,7 +1745,7 @@ function AgentWorkbenchSidebar({
1738
1745
  className,
1739
1746
  classNames: { root: classNames?.root, body: "flex min-h-0 flex-1 flex-col p-0" },
1740
1747
  children: [
1741
- !sessionsOnly ? /* @__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: [
1748
+ 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: [
1742
1749
  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: [
1743
1750
  /* @__PURE__ */ jsx(Plus, { className: "size-4", "aria-hidden": "true" }),
1744
1751
  messages.newAgent
@@ -1786,8 +1793,8 @@ function AgentWorkbenchSidebar({
1786
1793
  item.id
1787
1794
  )) })
1788
1795
  ] }) : null,
1789
- /* @__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: [
1790
- 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: [
1796
+ 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: [
1797
+ 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: [
1791
1798
  /* @__PURE__ */ jsx(SquarePen, { className: "size-4", "aria-hidden": "true" }),
1792
1799
  messages.newSession
1793
1800
  ] }) : null,
@@ -1807,7 +1814,7 @@ function AgentWorkbenchSidebar({
1807
1814
  ] }),
1808
1815
  renderSessionItems(items)
1809
1816
  ] }, id)) }) : !sessionsOnly ? renderSessionItems(sessions) : null
1810
- ] })
1817
+ ] }) : null
1811
1818
  ]
1812
1819
  }
1813
1820
  )
@@ -1865,7 +1872,8 @@ function AgentWorkbenchExploreCardMedia({
1865
1872
  }
1866
1873
  function AgentWorkbenchExploreSidebar({
1867
1874
  sessions,
1868
- groups,
1875
+ groups: configuredGroups,
1876
+ config,
1869
1877
  labels,
1870
1878
  selectedSessionId,
1871
1879
  searchQuery = "",
@@ -1882,8 +1890,15 @@ function AgentWorkbenchExploreSidebar({
1882
1890
  }) {
1883
1891
  const navigationMessages = useMonkeysLocaleMessages().agentWorkbench.navigation;
1884
1892
  const searchRef = useRef(null);
1893
+ const resolvedConfig = useMemo(() => resolveAgentWorkbenchSidebarConfig(config), [config]);
1894
+ const visibleSections = useMemo(
1895
+ () => new Set(resolvedConfig.visibleSections),
1896
+ [resolvedConfig.visibleSections]
1897
+ );
1898
+ const groups = configuredGroups?.length ? configuredGroups : resolvedConfig.groups;
1899
+ const resolvedDefaultGroupId = defaultGroupId ?? resolvedConfig.defaultGroupId;
1885
1900
  const [activeGroupId, setActiveGroupId] = useState(
1886
- defaultGroupId ?? groups[0]?.id ?? ""
1901
+ resolvedDefaultGroupId ?? groups[0]?.id ?? ""
1887
1902
  );
1888
1903
  const activeGroup = groups.find((group) => group.id === activeGroupId) ?? groups[0];
1889
1904
  const normalizedQuery = searchQuery.trim().toLocaleLowerCase();
@@ -1896,8 +1911,8 @@ function AgentWorkbenchExploreSidebar({
1896
1911
  );
1897
1912
  useEffect(() => {
1898
1913
  if (groups.some((group) => group.id === activeGroupId)) return;
1899
- setActiveGroupId(defaultGroupId ?? groups[0]?.id ?? "");
1900
- }, [activeGroupId, defaultGroupId, groups]);
1914
+ setActiveGroupId(resolvedDefaultGroupId ?? groups[0]?.id ?? "");
1915
+ }, [activeGroupId, groups, resolvedDefaultGroupId]);
1901
1916
  useEffect(() => {
1902
1917
  const handleShortcut = (event) => {
1903
1918
  if (!(event.ctrlKey || event.metaKey) || event.key.toLocaleLowerCase() !== "k")
@@ -1913,8 +1928,8 @@ function AgentWorkbenchExploreSidebar({
1913
1928
  setActiveGroupId(groupId);
1914
1929
  onIntent?.({ type: "change-group", groupId });
1915
1930
  };
1916
- const state = error ? "error" : loading && sessions.length === 0 ? "loading" : filteredSessions.length === 0 && !draftVisible ? "empty" : "ready";
1917
- const groupNavigation = 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: [
1931
+ const state = !visibleSections.has("sessions") ? "ready" : error ? "error" : loading && sessions.length === 0 ? "loading" : filteredSessions.length === 0 && !draftVisible ? "empty" : "ready";
1932
+ 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: [
1918
1933
  /* @__PURE__ */ jsx(
1919
1934
  TabsList,
1920
1935
  {
@@ -1948,9 +1963,10 @@ function AgentWorkbenchExploreSidebar({
1948
1963
  AgentWorkbenchSidebarContainer,
1949
1964
  {
1950
1965
  "data-sidebar-style": "explore",
1966
+ "data-sidebar-width-percent": resolvedConfig.widthPercent,
1951
1967
  "aria-label": labels.navigation,
1952
- header,
1953
- search: /* @__PURE__ */ jsxs(InputGroup, { className: "h-12 rounded-[var(--radius)] border-border bg-card text-foreground", children: [
1968
+ header: visibleSections.has("header") ? header : void 0,
1969
+ search: visibleSections.has("search") ? /* @__PURE__ */ jsxs(InputGroup, { className: "h-12 rounded-[var(--radius)] border-border bg-card text-foreground", children: [
1954
1970
  /* @__PURE__ */ jsx(InputGroupAddon, { children: /* @__PURE__ */ jsx(Search, { className: "size-4 text-muted-foreground", "aria-hidden": "true" }) }),
1955
1971
  /* @__PURE__ */ jsx(
1956
1972
  InputGroupInput,
@@ -1965,8 +1981,8 @@ function AgentWorkbenchExploreSidebar({
1965
1981
  }
1966
1982
  ),
1967
1983
  /* @__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" }) })
1968
- ] }),
1969
- primaryAction: /* @__PURE__ */ jsxs(
1984
+ ] }) : void 0,
1985
+ primaryAction: visibleSections.has("new-session") ? /* @__PURE__ */ jsxs(
1970
1986
  Button,
1971
1987
  {
1972
1988
  type: "button",
@@ -1977,9 +1993,9 @@ function AgentWorkbenchExploreSidebar({
1977
1993
  labels.newSession
1978
1994
  ]
1979
1995
  }
1980
- ),
1996
+ ) : void 0,
1981
1997
  groups: groupNavigation,
1982
- footer,
1998
+ footer: visibleSections.has("footer") ? footer : void 0,
1983
1999
  status: state,
1984
2000
  loadingState: /* @__PURE__ */ jsx("div", { className: "flex h-24 items-center justify-center text-muted-foreground", children: /* @__PURE__ */ jsx(Loader2, { className: "size-5 animate-spin" }) }),
1985
2001
  emptyState: /* @__PURE__ */ jsx("div", { className: "px-3 py-8 text-center text-sm text-muted-foreground", children: normalizedQuery ? labels.noResults : labels.emptySessions }),
@@ -1994,7 +2010,7 @@ function AgentWorkbenchExploreSidebar({
1994
2010
  bodyProps: { "data-agent-workbench-session-scroll-region": "" },
1995
2011
  className,
1996
2012
  classNames: { body: "min-h-[160px] flex-[0_1_280px] px-4 pb-3" },
1997
- children: /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
2013
+ children: visibleSections.has("sessions") ? /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
1998
2014
  draftVisible ? /* @__PURE__ */ jsx(
1999
2015
  "button",
2000
2016
  {
@@ -2052,7 +2068,7 @@ function AgentWorkbenchExploreSidebar({
2052
2068
  },
2053
2069
  session.id
2054
2070
  ))
2055
- ] })
2071
+ ] }) : null
2056
2072
  }
2057
2073
  );
2058
2074
  }