@tangle-network/agent-app 0.53.4 → 0.53.6
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/{DesignCanvasEditor-3R6KODJG.js → DesignCanvasEditor-ZQDWOGRV.js} +3 -3
- package/dist/assistant/index.js +7 -6
- package/dist/assistant/index.js.map +1 -1
- package/dist/chat-react/index.js +3 -3
- package/dist/chat-routes/index.js +4 -4
- package/dist/chunk-2WELYICW.js +78 -0
- package/dist/chunk-2WELYICW.js.map +1 -0
- package/dist/{chunk-K3A4GGV6.js → chunk-5GYKS6WT.js} +2 -2
- package/dist/{chunk-3YVSRH26.js → chunk-6JM5EWOP.js} +2 -2
- package/dist/{chunk-6FYFGQ6I.js → chunk-AUA75YFF.js} +2 -2
- package/dist/{chunk-7HMDNSIA.js → chunk-JZ64GXYP.js} +4 -4
- package/dist/{chunk-WRT5E74D.js → chunk-LFMP73W3.js} +2 -2
- package/dist/{chunk-IYK5BRL4.js → chunk-LVSKKDX2.js} +7 -4
- package/dist/chunk-LVSKKDX2.js.map +1 -0
- package/dist/{chunk-IN4DXT5F.js → chunk-P2GXQRFR.js} +4 -4
- package/dist/{chunk-ODP3X4BN.js → chunk-QHLQPK2H.js} +11 -5
- package/dist/chunk-QHLQPK2H.js.map +1 -0
- package/dist/{chunk-RYGNTGEL.js → chunk-T52MKPHE.js} +117 -215
- package/dist/chunk-T52MKPHE.js.map +1 -0
- package/dist/{chunk-C4V2LIUC.js → chunk-TUGR3FCS.js} +1 -1
- package/dist/{chunk-C4V2LIUC.js.map → chunk-TUGR3FCS.js.map} +1 -1
- package/dist/{chunk-NH32EPWU.js → chunk-WZ2FER6A.js} +15 -72
- package/dist/chunk-WZ2FER6A.js.map +1 -0
- package/dist/{chunk-2YSXWBBL.js → chunk-YFGV5ZBY.js} +2 -2
- package/dist/{chunk-BINC6OWR.js → chunk-ZFFBT5BF.js} +2 -2
- package/dist/design-canvas-react/index.js +3 -3
- package/dist/design-canvas-react/lazy.js +1 -1
- package/dist/{mention-editor-E6J2RUG4.js → mention-editor-4EWHJ5G5.js} +2 -2
- package/dist/preset-cloudflare/index.js +2 -2
- package/dist/sandbox/index.js +4 -4
- package/dist/studio-react/index.js +3 -2
- package/dist/studio-react/index.js.map +1 -1
- package/dist/theme/brand.generated.d.ts +1 -1
- package/dist/theme/index.js +1 -1
- package/dist/theme/tokens.css +3 -3
- package/dist/tools/index.js +4 -4
- package/dist/web-react/action-dialog.d.ts +15 -0
- package/dist/web-react/controls.d.ts +6 -1
- package/dist/web-react/index.js +9 -6
- package/dist/web-react/workspace-switcher.d.ts +9 -0
- package/dist/work-product/index.js +2 -2
- package/dist/workspace-react/index.d.ts +13 -1
- package/dist/workspace-react/index.js +598 -20
- package/dist/workspace-react/index.js.map +1 -1
- package/dist/workspace-react/rail-identity.d.ts +55 -0
- package/dist/workspace-react/workspace-list.d.ts +82 -0
- package/package.json +3 -3
- package/dist/chunk-IYK5BRL4.js.map +0 -1
- package/dist/chunk-NH32EPWU.js.map +0 -1
- package/dist/chunk-ODP3X4BN.js.map +0 -1
- package/dist/chunk-RYGNTGEL.js.map +0 -1
- /package/dist/{DesignCanvasEditor-3R6KODJG.js.map → DesignCanvasEditor-ZQDWOGRV.js.map} +0 -0
- /package/dist/{chunk-K3A4GGV6.js.map → chunk-5GYKS6WT.js.map} +0 -0
- /package/dist/{chunk-3YVSRH26.js.map → chunk-6JM5EWOP.js.map} +0 -0
- /package/dist/{chunk-6FYFGQ6I.js.map → chunk-AUA75YFF.js.map} +0 -0
- /package/dist/{chunk-7HMDNSIA.js.map → chunk-JZ64GXYP.js.map} +0 -0
- /package/dist/{chunk-WRT5E74D.js.map → chunk-LFMP73W3.js.map} +0 -0
- /package/dist/{chunk-IN4DXT5F.js.map → chunk-P2GXQRFR.js.map} +0 -0
- /package/dist/{chunk-2YSXWBBL.js.map → chunk-YFGV5ZBY.js.map} +0 -0
- /package/dist/{chunk-BINC6OWR.js.map → chunk-ZFFBT5BF.js.map} +0 -0
- /package/dist/{mention-editor-E6J2RUG4.js.map → mention-editor-4EWHJ5G5.js.map} +0 -0
|
@@ -1,8 +1,20 @@
|
|
|
1
1
|
import {
|
|
2
|
+
WorkspaceInitial,
|
|
2
3
|
WorkspaceSwitcher
|
|
3
|
-
} from "../chunk-
|
|
4
|
-
import
|
|
5
|
-
|
|
4
|
+
} from "../chunk-QHLQPK2H.js";
|
|
5
|
+
import {
|
|
6
|
+
ActionDialog,
|
|
7
|
+
ActionDialogButton
|
|
8
|
+
} from "../chunk-2WELYICW.js";
|
|
9
|
+
import {
|
|
10
|
+
usePopoverDialog
|
|
11
|
+
} from "../chunk-AUA75YFF.js";
|
|
12
|
+
import {
|
|
13
|
+
CheckGlyph,
|
|
14
|
+
OVERLAY_SHADOW,
|
|
15
|
+
PopoverSurface,
|
|
16
|
+
usePopover
|
|
17
|
+
} from "../chunk-LVSKKDX2.js";
|
|
6
18
|
import {
|
|
7
19
|
buildSessionNavItem,
|
|
8
20
|
composeSidebarSessions,
|
|
@@ -14,12 +26,170 @@ import "../chunk-7YA4QNTU.js";
|
|
|
14
26
|
// src/workspace-react/index.tsx
|
|
15
27
|
import { SidebarLayout } from "@tangle-network/sandbox-ui/dashboard";
|
|
16
28
|
|
|
29
|
+
// src/workspace-react/rail-identity.tsx
|
|
30
|
+
import { useCallback, useState } from "react";
|
|
31
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
32
|
+
var DEFAULT_WORKSPACE_NOUN = { singular: "workspace", plural: "workspaces" };
|
|
33
|
+
var SEARCH_THRESHOLD = 7;
|
|
34
|
+
var HIDE_ON_RAIL = { md: "md:hidden", lg: "lg:hidden" };
|
|
35
|
+
function capitalize(text) {
|
|
36
|
+
return text.charAt(0).toLocaleUpperCase() + text.slice(1);
|
|
37
|
+
}
|
|
38
|
+
function DefaultLink({ href, to, ...props }) {
|
|
39
|
+
return /* @__PURE__ */ jsx("a", { href: href ?? to, ...props });
|
|
40
|
+
}
|
|
41
|
+
function AgentRailIdentity({ product, workspace, hideBelow = "lg", LinkComponent }) {
|
|
42
|
+
const Link = LinkComponent ?? DefaultLink;
|
|
43
|
+
const mobileMark = /* @__PURE__ */ jsx("span", { "aria-hidden": true, className: `flex h-7 w-7 shrink-0 items-center justify-center ${HIDE_ON_RAIL[hideBelow]}`, children: product.mark });
|
|
44
|
+
if (!workspace) {
|
|
45
|
+
return /* @__PURE__ */ jsxs(
|
|
46
|
+
Link,
|
|
47
|
+
{
|
|
48
|
+
href: product.href,
|
|
49
|
+
to: product.href,
|
|
50
|
+
title: product.name,
|
|
51
|
+
className: "flex w-full min-w-0 items-center gap-2 rounded-md px-1.5 py-1 transition-colors hover:bg-accent",
|
|
52
|
+
children: [
|
|
53
|
+
mobileMark,
|
|
54
|
+
/* @__PURE__ */ jsx("span", { className: "min-w-0 flex-1 truncate text-sm font-semibold text-foreground", children: product.name })
|
|
55
|
+
]
|
|
56
|
+
}
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
const stack = /* @__PURE__ */ jsxs("span", { className: "min-w-0 flex-1 text-left", children: [
|
|
60
|
+
/* @__PURE__ */ jsx("span", { className: "block truncate text-sm font-semibold leading-5 text-foreground", children: workspace.name }),
|
|
61
|
+
/* @__PURE__ */ jsx("span", { className: "block truncate text-xs leading-4 text-muted-foreground", children: product.name })
|
|
62
|
+
] });
|
|
63
|
+
const others = (workspace.options ?? []).filter((option) => option.id !== workspace.id);
|
|
64
|
+
const switchable = others.length > 0 && workspace.hrefForWorkspace !== void 0 || Boolean(workspace.listHref) || Boolean(workspace.createHref);
|
|
65
|
+
if (!switchable) {
|
|
66
|
+
return /* @__PURE__ */ jsxs("div", { title: `${workspace.name} \xB7 ${product.name}`, className: "flex w-full min-w-0 items-center gap-2 px-1.5 py-1", children: [
|
|
67
|
+
mobileMark,
|
|
68
|
+
stack
|
|
69
|
+
] });
|
|
70
|
+
}
|
|
71
|
+
return /* @__PURE__ */ jsx(WorkspaceMenu, { product, workspace, mobileMark, stack, Link });
|
|
72
|
+
}
|
|
73
|
+
function WorkspaceMenu({
|
|
74
|
+
product,
|
|
75
|
+
workspace,
|
|
76
|
+
mobileMark,
|
|
77
|
+
stack,
|
|
78
|
+
Link
|
|
79
|
+
}) {
|
|
80
|
+
const [open, setOpen] = useState(false);
|
|
81
|
+
const [query, setQuery] = useState("");
|
|
82
|
+
const changeOpen = useCallback((next) => {
|
|
83
|
+
setOpen(next);
|
|
84
|
+
if (!next) setQuery("");
|
|
85
|
+
}, []);
|
|
86
|
+
const { containerRef, triggerRef, panelRef, triggerProps, id: panelId } = usePopoverDialog(open, changeOpen);
|
|
87
|
+
const noun = workspace.noun ?? DEFAULT_WORKSPACE_NOUN;
|
|
88
|
+
const options = workspace.hrefForWorkspace ? workspace.options ?? [] : [];
|
|
89
|
+
const search = query.trim().toLocaleLowerCase();
|
|
90
|
+
const visible = search ? options.filter((option) => option.name.toLocaleLowerCase().includes(search)) : options;
|
|
91
|
+
const close = () => changeOpen(false);
|
|
92
|
+
const rowClass = "flex min-h-9 w-full min-w-0 items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm text-foreground transition-colors hover:bg-accent";
|
|
93
|
+
return /* @__PURE__ */ jsxs("div", { ref: containerRef, className: "w-full min-w-0", children: [
|
|
94
|
+
/* @__PURE__ */ jsxs(
|
|
95
|
+
"button",
|
|
96
|
+
{
|
|
97
|
+
type: "button",
|
|
98
|
+
...triggerProps,
|
|
99
|
+
"aria-label": `${capitalize(noun.singular)}: ${workspace.name}. Switch ${noun.singular}`,
|
|
100
|
+
title: `${workspace.name} \xB7 ${product.name}`,
|
|
101
|
+
onClick: () => changeOpen(!open),
|
|
102
|
+
className: "flex w-full min-w-0 items-center gap-2 rounded-md px-1.5 py-1 transition-colors hover:bg-accent aria-expanded:bg-accent",
|
|
103
|
+
children: [
|
|
104
|
+
mobileMark,
|
|
105
|
+
stack,
|
|
106
|
+
/* @__PURE__ */ jsx("svg", { "aria-hidden": true, className: "h-4 w-4 shrink-0 text-muted-foreground", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.75", children: /* @__PURE__ */ jsx("path", { d: "m8 9 4-4 4 4m-8 6 4 4 4-4" }) })
|
|
107
|
+
]
|
|
108
|
+
}
|
|
109
|
+
),
|
|
110
|
+
/* @__PURE__ */ jsxs(
|
|
111
|
+
PopoverSurface,
|
|
112
|
+
{
|
|
113
|
+
open,
|
|
114
|
+
id: panelId,
|
|
115
|
+
role: "dialog",
|
|
116
|
+
"aria-label": `Switch ${noun.singular}`,
|
|
117
|
+
side: "below",
|
|
118
|
+
triggerRef,
|
|
119
|
+
panelRef,
|
|
120
|
+
contentKey: `${query}:${options.length}`,
|
|
121
|
+
className: `w-72 max-w-[calc(100vw-2rem)] overflow-y-auto rounded-lg border border-card-edge bg-popover p-1.5 text-foreground ${OVERLAY_SHADOW}`,
|
|
122
|
+
children: [
|
|
123
|
+
options.length > SEARCH_THRESHOLD && /* @__PURE__ */ jsx(
|
|
124
|
+
"input",
|
|
125
|
+
{
|
|
126
|
+
"data-autofocus": true,
|
|
127
|
+
"aria-label": `Search ${noun.plural}`,
|
|
128
|
+
placeholder: `Search ${noun.plural}`,
|
|
129
|
+
value: query,
|
|
130
|
+
onChange: (event) => setQuery(event.target.value),
|
|
131
|
+
className: "mb-1.5 h-9 w-full rounded-md border border-border bg-background px-2.5 text-sm text-foreground"
|
|
132
|
+
}
|
|
133
|
+
),
|
|
134
|
+
options.length > 0 && /* @__PURE__ */ jsxs("div", { className: "max-h-72 overflow-y-auto", children: [
|
|
135
|
+
visible.map((option) => /* @__PURE__ */ jsxs(
|
|
136
|
+
Link,
|
|
137
|
+
{
|
|
138
|
+
href: workspace.hrefForWorkspace(option.id),
|
|
139
|
+
to: workspace.hrefForWorkspace(option.id),
|
|
140
|
+
"aria-current": option.id === workspace.id ? "page" : void 0,
|
|
141
|
+
title: option.name,
|
|
142
|
+
onClick: close,
|
|
143
|
+
className: rowClass,
|
|
144
|
+
children: [
|
|
145
|
+
/* @__PURE__ */ jsx(WorkspaceInitial, { name: option.name }),
|
|
146
|
+
/* @__PURE__ */ jsx("span", { className: "min-w-0 flex-1 truncate", children: option.name }),
|
|
147
|
+
option.id === workspace.id && /* @__PURE__ */ jsx(CheckGlyph, { className: "h-4 w-4 shrink-0 text-primary" })
|
|
148
|
+
]
|
|
149
|
+
},
|
|
150
|
+
option.id
|
|
151
|
+
)),
|
|
152
|
+
visible.length === 0 && /* @__PURE__ */ jsxs("p", { role: "status", className: "px-2 py-2 text-sm text-muted-foreground", children: [
|
|
153
|
+
"No ",
|
|
154
|
+
noun.plural,
|
|
155
|
+
" match \u201C",
|
|
156
|
+
query.trim(),
|
|
157
|
+
"\u201D."
|
|
158
|
+
] })
|
|
159
|
+
] }),
|
|
160
|
+
(workspace.listHref || workspace.createHref) && /* @__PURE__ */ jsxs("div", { className: options.length > 0 ? "mt-1.5 border-t border-border pt-1.5" : void 0, children: [
|
|
161
|
+
workspace.listHref && /* @__PURE__ */ jsxs(Link, { href: workspace.listHref, to: workspace.listHref, onClick: close, className: rowClass, children: [
|
|
162
|
+
/* @__PURE__ */ jsxs("svg", { "aria-hidden": true, className: "h-4 w-4 shrink-0 text-muted-foreground", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.75", children: [
|
|
163
|
+
/* @__PURE__ */ jsx("rect", { x: "4", y: "4", width: "6.5", height: "6.5", rx: "1.5" }),
|
|
164
|
+
/* @__PURE__ */ jsx("rect", { x: "13.5", y: "4", width: "6.5", height: "6.5", rx: "1.5" }),
|
|
165
|
+
/* @__PURE__ */ jsx("rect", { x: "4", y: "13.5", width: "6.5", height: "6.5", rx: "1.5" }),
|
|
166
|
+
/* @__PURE__ */ jsx("rect", { x: "13.5", y: "13.5", width: "6.5", height: "6.5", rx: "1.5" })
|
|
167
|
+
] }),
|
|
168
|
+
/* @__PURE__ */ jsxs("span", { className: "min-w-0 flex-1 truncate", children: [
|
|
169
|
+
"All ",
|
|
170
|
+
noun.plural
|
|
171
|
+
] })
|
|
172
|
+
] }),
|
|
173
|
+
workspace.createHref && /* @__PURE__ */ jsxs(Link, { href: workspace.createHref, to: workspace.createHref, onClick: close, className: rowClass, children: [
|
|
174
|
+
/* @__PURE__ */ jsx("svg", { "aria-hidden": true, className: "h-4 w-4 shrink-0 text-muted-foreground", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.75", children: /* @__PURE__ */ jsx("path", { d: "M12 5v14M5 12h14" }) }),
|
|
175
|
+
/* @__PURE__ */ jsxs("span", { className: "min-w-0 flex-1 truncate", children: [
|
|
176
|
+
"New ",
|
|
177
|
+
noun.singular
|
|
178
|
+
] })
|
|
179
|
+
] })
|
|
180
|
+
] })
|
|
181
|
+
]
|
|
182
|
+
}
|
|
183
|
+
)
|
|
184
|
+
] });
|
|
185
|
+
}
|
|
186
|
+
|
|
17
187
|
// src/workspace-react/companion.tsx
|
|
18
|
-
import { forwardRef, useCallback, useEffect, useImperativeHandle, useRef, useState } from "react";
|
|
188
|
+
import { forwardRef, useCallback as useCallback2, useEffect, useImperativeHandle, useRef, useState as useState2 } from "react";
|
|
19
189
|
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@tangle-network/sandbox-ui/primitives";
|
|
20
190
|
import { WorkspaceLayout } from "@tangle-network/sandbox-ui/workspace";
|
|
21
191
|
import { FlaskConical, FolderOpen, GitCompare, Monitor, Terminal } from "lucide-react";
|
|
22
|
-
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
192
|
+
import { Fragment, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
23
193
|
var companionTools = [
|
|
24
194
|
{ id: "files", label: "Files", Icon: FolderOpen },
|
|
25
195
|
{ id: "agent", label: "Agent", Icon: FlaskConical },
|
|
@@ -30,7 +200,7 @@ var companionTools = [
|
|
|
30
200
|
function createAgentWorkspaceCompanionTabs(tools) {
|
|
31
201
|
return companionTools.flatMap(({ id, label, Icon }) => {
|
|
32
202
|
const renderContent = tools[id];
|
|
33
|
-
return renderContent ? [{ id, label, icon: /* @__PURE__ */
|
|
203
|
+
return renderContent ? [{ id, label, icon: /* @__PURE__ */ jsx2(Icon, { className: "h-3.5 w-3.5", "aria-hidden": true }), keepMounted: true, renderContent }] : [];
|
|
34
204
|
});
|
|
35
205
|
}
|
|
36
206
|
var AgentWorkspaceCompanion = forwardRef(function AgentWorkspaceCompanion2({
|
|
@@ -51,10 +221,10 @@ var AgentWorkspaceCompanion = forwardRef(function AgentWorkspaceCompanion2({
|
|
|
51
221
|
className
|
|
52
222
|
}, ref) {
|
|
53
223
|
const tabs = customTabs ?? createAgentWorkspaceCompanionTabs(tools ?? {});
|
|
54
|
-
const [uncontrolledOpen, setOpen] =
|
|
224
|
+
const [uncontrolledOpen, setOpen] = useState2(defaultOpen);
|
|
55
225
|
const open = controlledOpen ?? uncontrolledOpen;
|
|
56
|
-
const [selection, setSelection] =
|
|
57
|
-
const [visits, setVisits] =
|
|
226
|
+
const [selection, setSelection] = useState2({ key: persistenceKey, id: defaultActiveTabId });
|
|
227
|
+
const [visits, setVisits] = useState2(() => ({ key: persistenceKey, ids: /* @__PURE__ */ new Set() }));
|
|
58
228
|
const requested = activeTabId ?? (selection.key === persistenceKey ? selection.id : defaultActiveTabId);
|
|
59
229
|
const active = tabs.find((tab) => tab.id === requested)?.id ?? tabs[0]?.id;
|
|
60
230
|
const visited = visits.key === persistenceKey ? visits.ids : /* @__PURE__ */ new Set();
|
|
@@ -105,7 +275,7 @@ var AgentWorkspaceCompanion = forwardRef(function AgentWorkspaceCompanion2({
|
|
|
105
275
|
return ids.has(active) ? previous : { key: persistenceKey, ids: /* @__PURE__ */ new Set([...ids, active]) };
|
|
106
276
|
});
|
|
107
277
|
}, [open, active, persistenceKey]);
|
|
108
|
-
const selectTab =
|
|
278
|
+
const selectTab = useCallback2((id) => {
|
|
109
279
|
if (!tabs.some((tab) => tab.id === id)) return false;
|
|
110
280
|
setSelection({ key: persistenceKey, id });
|
|
111
281
|
onActiveTabChange?.(id);
|
|
@@ -117,7 +287,7 @@ var AgentWorkspaceCompanion = forwardRef(function AgentWorkspaceCompanion2({
|
|
|
117
287
|
}
|
|
118
288
|
return true;
|
|
119
289
|
}, [tabs, persistenceKey, storageKey, onActiveTabChange]);
|
|
120
|
-
const changeOpen =
|
|
290
|
+
const changeOpen = useCallback2((next) => {
|
|
121
291
|
setOpen(next);
|
|
122
292
|
onOpenChange?.(next);
|
|
123
293
|
}, [onOpenChange]);
|
|
@@ -128,8 +298,8 @@ var AgentWorkspaceCompanion = forwardRef(function AgentWorkspaceCompanion2({
|
|
|
128
298
|
return true;
|
|
129
299
|
}
|
|
130
300
|
}), [selectTab, changeOpen]);
|
|
131
|
-
if (tabs.length === 0 && !navigation) return /* @__PURE__ */
|
|
132
|
-
return /* @__PURE__ */
|
|
301
|
+
if (tabs.length === 0 && !navigation) return /* @__PURE__ */ jsx2(Fragment, { children });
|
|
302
|
+
return /* @__PURE__ */ jsx2(Tabs, { value: active, onValueChange: selectTab, className: `flex h-full min-h-0 min-w-0 flex-1 flex-col ${className ?? ""}`, children: /* @__PURE__ */ jsx2(
|
|
133
303
|
WorkspaceLayout,
|
|
134
304
|
{
|
|
135
305
|
className: "h-full min-h-0 min-w-0 flex-1",
|
|
@@ -138,7 +308,7 @@ var AgentWorkspaceCompanion = forwardRef(function AgentWorkspaceCompanion2({
|
|
|
138
308
|
center: children,
|
|
139
309
|
left: navigation?.content,
|
|
140
310
|
leftContentClassName: "py-0",
|
|
141
|
-
leftHeader: navigation && (navigation.header !== void 0 ? navigation.header : /* @__PURE__ */
|
|
311
|
+
leftHeader: navigation && (navigation.header !== void 0 ? navigation.header : /* @__PURE__ */ jsx2("span", { className: "text-sm font-medium", children: navigation.label ?? "Chats" })),
|
|
142
312
|
leftOpen: navigation?.open,
|
|
143
313
|
onLeftOpenChange: navigation?.onOpenChange,
|
|
144
314
|
leftLabel: navigation?.label ?? "Chats",
|
|
@@ -154,15 +324,15 @@ var AgentWorkspaceCompanion = forwardRef(function AgentWorkspaceCompanion2({
|
|
|
154
324
|
persistenceKey,
|
|
155
325
|
minRightWidth: 280,
|
|
156
326
|
rightContentClassName: "flex flex-col overflow-hidden",
|
|
157
|
-
rightHeader: tabs.length > 0 ? /* @__PURE__ */
|
|
327
|
+
rightHeader: tabs.length > 0 ? /* @__PURE__ */ jsx2(TabsList, { "aria-label": label, className: "h-9 max-w-full justify-start overflow-x-auto bg-transparent p-0", children: tabs.map((tab) => /* @__PURE__ */ jsxs2(TabsTrigger, { value: tab.id, className: "gap-1.5 px-2.5 text-sm", children: [
|
|
158
328
|
tab.icon,
|
|
159
|
-
/* @__PURE__ */
|
|
329
|
+
/* @__PURE__ */ jsx2("span", { children: tab.label })
|
|
160
330
|
] }, tab.id)) }) : void 0,
|
|
161
331
|
right: tabs.length > 0 ? tabs.map((tab) => {
|
|
162
332
|
const isActive = tab.id === active;
|
|
163
333
|
const retained = tab.keepMounted && visited.has(tab.id);
|
|
164
334
|
if (!(open && isActive) && !retained) return null;
|
|
165
|
-
return /* @__PURE__ */
|
|
335
|
+
return /* @__PURE__ */ jsx2(
|
|
166
336
|
TabsContent,
|
|
167
337
|
{
|
|
168
338
|
value: tab.id,
|
|
@@ -178,8 +348,395 @@ var AgentWorkspaceCompanion = forwardRef(function AgentWorkspaceCompanion2({
|
|
|
178
348
|
) }, persistenceKey);
|
|
179
349
|
});
|
|
180
350
|
|
|
351
|
+
// src/workspace-react/workspace-list.tsx
|
|
352
|
+
import { useId, useMemo, useState as useState3 } from "react";
|
|
353
|
+
import { Fragment as Fragment2, jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
354
|
+
var SEARCH_THRESHOLD2 = 8;
|
|
355
|
+
var FIELD_CELL = "hidden w-32 min-w-0 shrink-0 md:block";
|
|
356
|
+
var DATE_CELL = "w-20 shrink-0 text-right sm:w-24";
|
|
357
|
+
function DefaultLink2({ href, to, ...props }) {
|
|
358
|
+
return /* @__PURE__ */ jsx3("a", { href: href ?? to, ...props });
|
|
359
|
+
}
|
|
360
|
+
function capitalize2(text) {
|
|
361
|
+
return text.charAt(0).toLocaleUpperCase() + text.slice(1);
|
|
362
|
+
}
|
|
363
|
+
function defaultFormatDate(value) {
|
|
364
|
+
const sameYear = value.getFullYear() === (/* @__PURE__ */ new Date()).getFullYear();
|
|
365
|
+
return value.toLocaleDateString(void 0, sameYear ? { month: "short", day: "numeric" } : { month: "short", day: "numeric", year: "numeric" });
|
|
366
|
+
}
|
|
367
|
+
function present(value) {
|
|
368
|
+
return value !== null && value !== void 0 && value !== false && value !== "";
|
|
369
|
+
}
|
|
370
|
+
function toDate(value) {
|
|
371
|
+
if (value === null || value === void 0 || value === "") return null;
|
|
372
|
+
const date = value instanceof Date ? value : new Date(value);
|
|
373
|
+
return Number.isNaN(date.getTime()) ? null : date;
|
|
374
|
+
}
|
|
375
|
+
function usefulDescription(item) {
|
|
376
|
+
const text = item.description?.trim();
|
|
377
|
+
if (!text) return null;
|
|
378
|
+
return text.toLocaleLowerCase() === item.name.trim().toLocaleLowerCase() ? null : text;
|
|
379
|
+
}
|
|
380
|
+
function WorkspaceList({
|
|
381
|
+
items,
|
|
382
|
+
noun = DEFAULT_WORKSPACE_NOUN,
|
|
383
|
+
title,
|
|
384
|
+
description,
|
|
385
|
+
layout = "list",
|
|
386
|
+
fields = [],
|
|
387
|
+
create,
|
|
388
|
+
empty,
|
|
389
|
+
rename,
|
|
390
|
+
remove,
|
|
391
|
+
removeConsequence,
|
|
392
|
+
actions,
|
|
393
|
+
children,
|
|
394
|
+
LinkComponent,
|
|
395
|
+
formatDate = defaultFormatDate
|
|
396
|
+
}) {
|
|
397
|
+
const Link = LinkComponent ?? DefaultLink2;
|
|
398
|
+
const headingId = useId();
|
|
399
|
+
const [query, setQuery] = useState3("");
|
|
400
|
+
const [renaming, setRenaming] = useState3(null);
|
|
401
|
+
const [renameValue, setRenameValue] = useState3("");
|
|
402
|
+
const [removing, setRemoving] = useState3(null);
|
|
403
|
+
const [creating, setCreating] = useState3(false);
|
|
404
|
+
const [createValue, setCreateValue] = useState3("");
|
|
405
|
+
const [busy, setBusy] = useState3(false);
|
|
406
|
+
const [error, setError] = useState3(null);
|
|
407
|
+
const search = query.trim().toLocaleLowerCase();
|
|
408
|
+
const visible = useMemo(
|
|
409
|
+
() => search ? items.filter((item) => item.name.toLocaleLowerCase().includes(search)) : items,
|
|
410
|
+
[items, search]
|
|
411
|
+
);
|
|
412
|
+
const createLabel = create?.label ?? `New ${noun.singular}`;
|
|
413
|
+
const openCreate = () => {
|
|
414
|
+
setError(null);
|
|
415
|
+
setCreateValue("");
|
|
416
|
+
setCreating(true);
|
|
417
|
+
};
|
|
418
|
+
const createControl = create ? /* @__PURE__ */ jsx3(CreateButton, { create: create.onCreate && !create.href ? { ...create, onSelect: openCreate } : create, label: createLabel, Link }) : null;
|
|
419
|
+
const submitCreate = () => {
|
|
420
|
+
const name = createValue.trim();
|
|
421
|
+
if (!name || !create?.onCreate) return;
|
|
422
|
+
void run(() => create.onCreate(name), () => setCreating(false));
|
|
423
|
+
};
|
|
424
|
+
const hasDates = items.some((item) => toDate(item.updatedAt) !== null);
|
|
425
|
+
const hasMenu = Boolean(rename) || Boolean(remove) || Boolean(actions);
|
|
426
|
+
const menuFor = (item) => [
|
|
427
|
+
...rename ? [{ id: "rename", label: "Rename", onSelect: () => {
|
|
428
|
+
setError(null);
|
|
429
|
+
setRenaming(item);
|
|
430
|
+
setRenameValue(item.name);
|
|
431
|
+
} }] : [],
|
|
432
|
+
...(actions?.(item) ?? []).map((action) => ({ id: action.id, label: action.label, onSelect: () => action.onSelect(item) })),
|
|
433
|
+
...remove ? [{ id: "delete", label: "Delete", destructive: true, onSelect: () => {
|
|
434
|
+
setError(null);
|
|
435
|
+
setRemoving(item);
|
|
436
|
+
} }] : []
|
|
437
|
+
];
|
|
438
|
+
const run = async (work, done) => {
|
|
439
|
+
setBusy(true);
|
|
440
|
+
setError(null);
|
|
441
|
+
try {
|
|
442
|
+
await work();
|
|
443
|
+
done();
|
|
444
|
+
} catch (cause) {
|
|
445
|
+
setError(cause instanceof Error && cause.message ? cause.message : "That did not save. Try again.");
|
|
446
|
+
} finally {
|
|
447
|
+
setBusy(false);
|
|
448
|
+
}
|
|
449
|
+
};
|
|
450
|
+
const submitRename = () => {
|
|
451
|
+
if (!renaming || !rename) return;
|
|
452
|
+
const name = renameValue.trim();
|
|
453
|
+
if (!name || name === renaming.name) {
|
|
454
|
+
setRenaming(null);
|
|
455
|
+
return;
|
|
456
|
+
}
|
|
457
|
+
void run(() => rename(renaming, name), () => setRenaming(null));
|
|
458
|
+
};
|
|
459
|
+
return /* @__PURE__ */ jsxs3("section", { "aria-labelledby": headingId, className: "mx-auto w-full max-w-5xl px-4 py-6 sm:px-6 sm:py-8 lg:px-8", children: [
|
|
460
|
+
/* @__PURE__ */ jsxs3("header", { className: "flex flex-wrap items-start justify-between gap-x-4 gap-y-3", children: [
|
|
461
|
+
/* @__PURE__ */ jsxs3("div", { className: "min-w-0 flex-1", children: [
|
|
462
|
+
/* @__PURE__ */ jsx3("h1", { id: headingId, className: "text-xl font-semibold tracking-tight text-foreground", children: title ?? capitalize2(noun.plural) }),
|
|
463
|
+
description != null && /* @__PURE__ */ jsx3("div", { className: "mt-1 max-w-prose text-sm text-muted-foreground", children: description })
|
|
464
|
+
] }),
|
|
465
|
+
items.length > 0 && createControl
|
|
466
|
+
] }),
|
|
467
|
+
children != null && /* @__PURE__ */ jsx3("div", { className: "mt-6", children }),
|
|
468
|
+
items.length === 0 ? /* @__PURE__ */ jsxs3("div", { className: "mt-6 flex flex-col items-center rounded-xl border border-dashed border-border px-6 py-14 text-center", children: [
|
|
469
|
+
/* @__PURE__ */ jsx3("span", { "aria-hidden": true, className: "flex h-10 w-10 items-center justify-center rounded-lg bg-primary/10 text-primary", children: /* @__PURE__ */ jsxs3("svg", { className: "h-5 w-5", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.75", children: [
|
|
470
|
+
/* @__PURE__ */ jsx3("rect", { x: "4", y: "4", width: "6.5", height: "6.5", rx: "1.5" }),
|
|
471
|
+
/* @__PURE__ */ jsx3("rect", { x: "13.5", y: "4", width: "6.5", height: "6.5", rx: "1.5" }),
|
|
472
|
+
/* @__PURE__ */ jsx3("rect", { x: "4", y: "13.5", width: "6.5", height: "6.5", rx: "1.5" }),
|
|
473
|
+
/* @__PURE__ */ jsx3("path", { d: "M16.75 13.5v6.5M13.5 16.75H20" })
|
|
474
|
+
] }) }),
|
|
475
|
+
/* @__PURE__ */ jsx3("h2", { className: "mt-4 text-base font-semibold text-foreground", children: empty?.title ?? `No ${noun.plural} yet` }),
|
|
476
|
+
empty?.description && /* @__PURE__ */ jsx3("p", { className: "mt-1.5 max-w-sm text-sm text-muted-foreground", children: empty.description }),
|
|
477
|
+
createControl && /* @__PURE__ */ jsx3("div", { className: "mt-5", children: createControl })
|
|
478
|
+
] }) : /* @__PURE__ */ jsxs3(Fragment2, { children: [
|
|
479
|
+
items.length > SEARCH_THRESHOLD2 && /* @__PURE__ */ jsx3("div", { className: "mt-6", children: /* @__PURE__ */ jsx3(
|
|
480
|
+
"input",
|
|
481
|
+
{
|
|
482
|
+
type: "search",
|
|
483
|
+
"aria-label": `Search ${noun.plural}`,
|
|
484
|
+
placeholder: `Search ${noun.plural}`,
|
|
485
|
+
value: query,
|
|
486
|
+
onChange: (event) => setQuery(event.target.value),
|
|
487
|
+
className: "h-9 w-full max-w-sm rounded-md border border-border bg-background px-3 text-sm text-foreground placeholder:text-muted-foreground"
|
|
488
|
+
}
|
|
489
|
+
) }),
|
|
490
|
+
visible.length === 0 ? /* @__PURE__ */ jsxs3("p", { role: "status", className: "mt-6 rounded-xl border border-border px-4 py-8 text-center text-sm text-muted-foreground", children: [
|
|
491
|
+
"No ",
|
|
492
|
+
noun.plural,
|
|
493
|
+
" match \u201C",
|
|
494
|
+
query.trim(),
|
|
495
|
+
"\u201D.",
|
|
496
|
+
" ",
|
|
497
|
+
/* @__PURE__ */ jsx3("button", { type: "button", onClick: () => setQuery(""), className: "font-medium text-foreground underline underline-offset-2", children: "Clear search" })
|
|
498
|
+
] }) : layout === "grid" ? /* @__PURE__ */ jsx3("ul", { className: `grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3 ${items.length > SEARCH_THRESHOLD2 ? "mt-3" : "mt-6"}`, children: visible.map((item) => /* @__PURE__ */ jsx3(GridCard, { item, fields, menu: menuFor(item), Link, formatDate }, item.id)) }) : /* @__PURE__ */ jsxs3("div", { className: `overflow-hidden rounded-xl border border-border bg-card ${items.length > SEARCH_THRESHOLD2 ? "mt-3" : "mt-6"}`, children: [
|
|
499
|
+
fields.length > 0 && /* @__PURE__ */ jsxs3("div", { "aria-hidden": true, className: "hidden items-center gap-3 border-b border-border px-4 py-2 text-xs font-medium text-muted-foreground md:flex", children: [
|
|
500
|
+
/* @__PURE__ */ jsx3("span", { className: "w-10 shrink-0" }),
|
|
501
|
+
/* @__PURE__ */ jsx3("span", { className: "min-w-0 flex-1", children: "Name" }),
|
|
502
|
+
fields.map((field) => /* @__PURE__ */ jsx3("span", { className: `${FIELD_CELL} truncate`, children: field.label }, field.id)),
|
|
503
|
+
/* @__PURE__ */ jsx3("span", { className: DATE_CELL, children: hasDates ? "Updated" : "" }),
|
|
504
|
+
hasMenu && /* @__PURE__ */ jsx3("span", { className: "w-8 shrink-0" })
|
|
505
|
+
] }),
|
|
506
|
+
/* @__PURE__ */ jsx3("ul", { className: "divide-y divide-border", children: visible.map((item) => /* @__PURE__ */ jsx3(ListRow, { item, fields, menu: menuFor(item), reserveMenu: hasMenu, Link, formatDate }, item.id)) })
|
|
507
|
+
] })
|
|
508
|
+
] }),
|
|
509
|
+
renaming && /* @__PURE__ */ jsxs3(
|
|
510
|
+
ActionDialog,
|
|
511
|
+
{
|
|
512
|
+
title: `Rename ${noun.singular}`,
|
|
513
|
+
onClose: () => setRenaming(null),
|
|
514
|
+
busy,
|
|
515
|
+
error,
|
|
516
|
+
footer: /* @__PURE__ */ jsxs3(Fragment2, { children: [
|
|
517
|
+
/* @__PURE__ */ jsx3(ActionDialogButton, { variant: "ghost", onClick: () => setRenaming(null), disabled: busy, children: "Cancel" }),
|
|
518
|
+
/* @__PURE__ */ jsx3(ActionDialogButton, { onClick: submitRename, disabled: busy || !renameValue.trim(), children: "Save" })
|
|
519
|
+
] }),
|
|
520
|
+
children: [
|
|
521
|
+
/* @__PURE__ */ jsx3("label", { htmlFor: `${headingId}-rename`, className: "text-xs text-muted-foreground", children: "Name" }),
|
|
522
|
+
/* @__PURE__ */ jsx3(
|
|
523
|
+
"input",
|
|
524
|
+
{
|
|
525
|
+
id: `${headingId}-rename`,
|
|
526
|
+
value: renameValue,
|
|
527
|
+
autoFocus: true,
|
|
528
|
+
onChange: (event) => setRenameValue(event.target.value),
|
|
529
|
+
onKeyDown: (event) => {
|
|
530
|
+
if (event.key === "Enter" && !busy) {
|
|
531
|
+
event.preventDefault();
|
|
532
|
+
submitRename();
|
|
533
|
+
}
|
|
534
|
+
},
|
|
535
|
+
className: "mt-1.5 h-9 w-full rounded-md border border-border bg-background px-3 text-sm text-foreground"
|
|
536
|
+
}
|
|
537
|
+
)
|
|
538
|
+
]
|
|
539
|
+
}
|
|
540
|
+
),
|
|
541
|
+
creating && create?.onCreate && /* @__PURE__ */ jsxs3(
|
|
542
|
+
ActionDialog,
|
|
543
|
+
{
|
|
544
|
+
title: createLabel,
|
|
545
|
+
onClose: () => setCreating(false),
|
|
546
|
+
busy,
|
|
547
|
+
error,
|
|
548
|
+
footer: /* @__PURE__ */ jsxs3(Fragment2, { children: [
|
|
549
|
+
/* @__PURE__ */ jsx3(ActionDialogButton, { variant: "ghost", onClick: () => setCreating(false), disabled: busy, children: "Cancel" }),
|
|
550
|
+
/* @__PURE__ */ jsx3(ActionDialogButton, { onClick: submitCreate, disabled: busy || !createValue.trim(), children: "Create" })
|
|
551
|
+
] }),
|
|
552
|
+
children: [
|
|
553
|
+
/* @__PURE__ */ jsx3("label", { htmlFor: `${headingId}-create`, className: "text-xs text-muted-foreground", children: "Name" }),
|
|
554
|
+
/* @__PURE__ */ jsx3(
|
|
555
|
+
"input",
|
|
556
|
+
{
|
|
557
|
+
id: `${headingId}-create`,
|
|
558
|
+
value: createValue,
|
|
559
|
+
autoFocus: true,
|
|
560
|
+
placeholder: create.namePlaceholder ?? `${capitalize2(noun.singular)} name`,
|
|
561
|
+
onChange: (event) => setCreateValue(event.target.value),
|
|
562
|
+
onKeyDown: (event) => {
|
|
563
|
+
if (event.key === "Enter" && !busy) {
|
|
564
|
+
event.preventDefault();
|
|
565
|
+
submitCreate();
|
|
566
|
+
}
|
|
567
|
+
},
|
|
568
|
+
className: "mt-1.5 h-9 w-full rounded-md border border-border bg-background px-3 text-sm text-foreground placeholder:text-muted-foreground"
|
|
569
|
+
}
|
|
570
|
+
)
|
|
571
|
+
]
|
|
572
|
+
}
|
|
573
|
+
),
|
|
574
|
+
removing && remove && /* @__PURE__ */ jsx3(
|
|
575
|
+
ActionDialog,
|
|
576
|
+
{
|
|
577
|
+
title: `Delete ${noun.singular}?`,
|
|
578
|
+
onClose: () => setRemoving(null),
|
|
579
|
+
busy,
|
|
580
|
+
error,
|
|
581
|
+
footer: /* @__PURE__ */ jsxs3(Fragment2, { children: [
|
|
582
|
+
/* @__PURE__ */ jsx3(ActionDialogButton, { variant: "ghost", onClick: () => setRemoving(null), disabled: busy, children: "Cancel" }),
|
|
583
|
+
/* @__PURE__ */ jsx3(ActionDialogButton, { variant: "destructive", onClick: () => void run(() => remove(removing), () => setRemoving(null)), disabled: busy, children: "Delete" })
|
|
584
|
+
] }),
|
|
585
|
+
children: /* @__PURE__ */ jsx3("p", { className: "break-words text-sm text-muted-foreground", children: removeConsequence?.(removing) ?? `\u201C${removing.name}\u201D and everything in it will be deleted. This cannot be undone.` })
|
|
586
|
+
}
|
|
587
|
+
)
|
|
588
|
+
] });
|
|
589
|
+
}
|
|
590
|
+
function UpdatedAt({ value, formatDate, className = "shrink-0" }) {
|
|
591
|
+
const date = toDate(value);
|
|
592
|
+
if (!date) return /* @__PURE__ */ jsx3("span", { className });
|
|
593
|
+
return (
|
|
594
|
+
// Server and browser can format a date differently (zone, locale); the
|
|
595
|
+
// browser's reading is the one the user should see.
|
|
596
|
+
/* @__PURE__ */ jsx3("time", { dateTime: date.toISOString(), suppressHydrationWarning: true, className: `${className} text-xs tabular-nums text-muted-foreground`, children: formatDate(date) })
|
|
597
|
+
);
|
|
598
|
+
}
|
|
599
|
+
function ListRow({ item, fields, menu, reserveMenu, Link, formatDate }) {
|
|
600
|
+
const detail = usefulDescription(item);
|
|
601
|
+
const mobileFields = fields.filter((field) => present(item.values?.[field.id]));
|
|
602
|
+
return /* @__PURE__ */ jsxs3("li", { className: "group relative isolate flex min-h-16 items-center gap-3 px-4 py-3 transition-colors hover:bg-accent/60", children: [
|
|
603
|
+
item.avatar ?? /* @__PURE__ */ jsx3(WorkspaceInitial, { name: item.name, size: "lg" }),
|
|
604
|
+
/* @__PURE__ */ jsxs3("div", { className: "min-w-0 flex-1", children: [
|
|
605
|
+
/* @__PURE__ */ jsx3(
|
|
606
|
+
Link,
|
|
607
|
+
{
|
|
608
|
+
href: item.href,
|
|
609
|
+
to: item.href,
|
|
610
|
+
title: item.name,
|
|
611
|
+
className: "block truncate text-sm font-medium text-foreground after:absolute after:inset-0 after:content-[''] focus-visible:outline-none focus-visible:after:rounded-[inherit] focus-visible:after:ring-2 focus-visible:after:ring-inset focus-visible:after:ring-ring",
|
|
612
|
+
children: item.name
|
|
613
|
+
}
|
|
614
|
+
),
|
|
615
|
+
detail && /* @__PURE__ */ jsx3("p", { className: "truncate text-xs text-muted-foreground", title: detail, children: detail }),
|
|
616
|
+
mobileFields.length > 0 && /* @__PURE__ */ jsx3("p", { className: "truncate text-xs text-muted-foreground md:hidden", children: mobileFields.map((field, index) => /* @__PURE__ */ jsxs3("span", { children: [
|
|
617
|
+
index > 0 && " \xB7 ",
|
|
618
|
+
/* @__PURE__ */ jsxs3("span", { className: "sr-only", children: [
|
|
619
|
+
field.label,
|
|
620
|
+
": "
|
|
621
|
+
] }),
|
|
622
|
+
item.values[field.id]
|
|
623
|
+
] }, field.id)) })
|
|
624
|
+
] }),
|
|
625
|
+
fields.map((field) => /* @__PURE__ */ jsxs3("div", { className: `${FIELD_CELL} truncate text-sm text-muted-foreground`, children: [
|
|
626
|
+
/* @__PURE__ */ jsxs3("span", { className: "sr-only", children: [
|
|
627
|
+
field.label,
|
|
628
|
+
": "
|
|
629
|
+
] }),
|
|
630
|
+
present(item.values?.[field.id]) ? item.values[field.id] : "\u2014"
|
|
631
|
+
] }, field.id)),
|
|
632
|
+
/* @__PURE__ */ jsx3(UpdatedAt, { value: item.updatedAt, formatDate, className: DATE_CELL }),
|
|
633
|
+
menu.length > 0 ? /* @__PURE__ */ jsx3(ItemMenu, { item, entries: menu }) : reserveMenu ? /* @__PURE__ */ jsx3("span", { className: "w-8 shrink-0" }) : null
|
|
634
|
+
] });
|
|
635
|
+
}
|
|
636
|
+
function GridCard({ item, fields, menu, Link, formatDate }) {
|
|
637
|
+
const detail = usefulDescription(item);
|
|
638
|
+
const shownFields = fields.filter((field) => present(item.values?.[field.id]));
|
|
639
|
+
return /* @__PURE__ */ jsxs3("li", { className: "group relative isolate flex min-h-36 flex-col overflow-hidden rounded-xl border border-border bg-card p-4 transition-[border-color,box-shadow] hover:border-primary/40 hover:shadow-sm", children: [
|
|
640
|
+
/* @__PURE__ */ jsx3("span", { "aria-hidden": true, className: "pointer-events-none absolute inset-x-0 top-0 -z-10 h-16 bg-gradient-to-b from-primary/[0.07] to-transparent" }),
|
|
641
|
+
/* @__PURE__ */ jsxs3("div", { className: "flex items-start gap-3", children: [
|
|
642
|
+
item.avatar ?? /* @__PURE__ */ jsx3(WorkspaceInitial, { name: item.name, size: "lg" }),
|
|
643
|
+
/* @__PURE__ */ jsxs3("div", { className: "min-w-0 flex-1 pt-0.5", children: [
|
|
644
|
+
/* @__PURE__ */ jsx3(
|
|
645
|
+
Link,
|
|
646
|
+
{
|
|
647
|
+
href: item.href,
|
|
648
|
+
to: item.href,
|
|
649
|
+
title: item.name,
|
|
650
|
+
className: "line-clamp-2 break-words text-sm font-semibold text-foreground after:absolute after:inset-0 after:content-[''] focus-visible:outline-none focus-visible:after:rounded-xl focus-visible:after:ring-2 focus-visible:after:ring-inset focus-visible:after:ring-ring",
|
|
651
|
+
children: item.name
|
|
652
|
+
}
|
|
653
|
+
),
|
|
654
|
+
detail && /* @__PURE__ */ jsx3("p", { className: "mt-0.5 truncate text-xs text-muted-foreground", title: detail, children: detail })
|
|
655
|
+
] }),
|
|
656
|
+
menu.length > 0 && /* @__PURE__ */ jsx3(ItemMenu, { item, entries: menu })
|
|
657
|
+
] }),
|
|
658
|
+
/* @__PURE__ */ jsxs3("div", { className: "mt-auto flex items-end justify-between gap-3 pt-4", children: [
|
|
659
|
+
shownFields.length > 0 ? /* @__PURE__ */ jsx3("dl", { className: "flex min-w-0 flex-wrap gap-x-4 gap-y-1 text-xs", children: shownFields.map((field) => /* @__PURE__ */ jsxs3("div", { className: "flex min-w-0 gap-1", children: [
|
|
660
|
+
/* @__PURE__ */ jsx3("dt", { className: "text-muted-foreground", children: field.label }),
|
|
661
|
+
/* @__PURE__ */ jsx3("dd", { className: "truncate font-medium text-foreground", children: item.values?.[field.id] })
|
|
662
|
+
] }, field.id)) }) : /* @__PURE__ */ jsx3("span", {}),
|
|
663
|
+
/* @__PURE__ */ jsx3(UpdatedAt, { value: item.updatedAt, formatDate })
|
|
664
|
+
] })
|
|
665
|
+
] });
|
|
666
|
+
}
|
|
667
|
+
function ItemMenu({ item, entries }) {
|
|
668
|
+
const [open, setOpen] = useState3(false);
|
|
669
|
+
const panelId = useId();
|
|
670
|
+
const { containerRef, triggerRef, panelRef, triggerProps } = usePopover(open, setOpen);
|
|
671
|
+
return /* @__PURE__ */ jsxs3("div", { ref: containerRef, className: "relative z-10 shrink-0", children: [
|
|
672
|
+
/* @__PURE__ */ jsx3(
|
|
673
|
+
"button",
|
|
674
|
+
{
|
|
675
|
+
type: "button",
|
|
676
|
+
...triggerProps,
|
|
677
|
+
"aria-label": `Actions for ${item.name}`,
|
|
678
|
+
"aria-controls": open ? panelId : void 0,
|
|
679
|
+
onClick: () => setOpen(!open),
|
|
680
|
+
className: "flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground transition hover:bg-muted hover:text-foreground focus-visible:opacity-100 aria-expanded:opacity-100 [@media(hover:hover)]:opacity-0 [@media(hover:hover)]:group-hover:opacity-100",
|
|
681
|
+
children: /* @__PURE__ */ jsxs3("svg", { "aria-hidden": true, className: "h-4 w-4", viewBox: "0 0 24 24", fill: "currentColor", children: [
|
|
682
|
+
/* @__PURE__ */ jsx3("circle", { cx: "5", cy: "12", r: "1.6" }),
|
|
683
|
+
/* @__PURE__ */ jsx3("circle", { cx: "12", cy: "12", r: "1.6" }),
|
|
684
|
+
/* @__PURE__ */ jsx3("circle", { cx: "19", cy: "12", r: "1.6" })
|
|
685
|
+
] })
|
|
686
|
+
}
|
|
687
|
+
),
|
|
688
|
+
/* @__PURE__ */ jsx3(
|
|
689
|
+
PopoverSurface,
|
|
690
|
+
{
|
|
691
|
+
open,
|
|
692
|
+
id: panelId,
|
|
693
|
+
role: "menu",
|
|
694
|
+
"aria-label": `Actions for ${item.name}`,
|
|
695
|
+
side: "below",
|
|
696
|
+
align: "end",
|
|
697
|
+
triggerRef,
|
|
698
|
+
panelRef,
|
|
699
|
+
className: `w-44 overflow-hidden rounded-md border border-card-edge bg-popover py-1 ${OVERLAY_SHADOW}`,
|
|
700
|
+
children: entries.map((entry, index) => /* @__PURE__ */ jsx3(
|
|
701
|
+
"button",
|
|
702
|
+
{
|
|
703
|
+
type: "button",
|
|
704
|
+
role: "menuitem",
|
|
705
|
+
onClick: () => {
|
|
706
|
+
setOpen(false);
|
|
707
|
+
triggerRef.current?.focus();
|
|
708
|
+
entry.onSelect();
|
|
709
|
+
},
|
|
710
|
+
className: `block w-full px-3 py-1.5 text-left text-sm transition ${entry.destructive ? "text-destructive hover:bg-destructive/10" : "text-foreground hover:bg-accent"} ${entry.destructive && index > 0 ? "mt-1 border-t border-border pt-2" : ""}`,
|
|
711
|
+
children: entry.label
|
|
712
|
+
},
|
|
713
|
+
entry.id
|
|
714
|
+
))
|
|
715
|
+
}
|
|
716
|
+
)
|
|
717
|
+
] });
|
|
718
|
+
}
|
|
719
|
+
function CreateButton({
|
|
720
|
+
create,
|
|
721
|
+
label,
|
|
722
|
+
Link
|
|
723
|
+
}) {
|
|
724
|
+
const className = "inline-flex h-9 shrink-0 items-center gap-1.5 rounded-md bg-primary px-3.5 text-sm font-medium text-primary-foreground transition hover:opacity-90 active:scale-[0.98]";
|
|
725
|
+
const icon = /* @__PURE__ */ jsx3("svg", { "aria-hidden": true, className: "h-4 w-4", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: /* @__PURE__ */ jsx3("path", { d: "M12 5v14M5 12h14" }) });
|
|
726
|
+
if (create.href) {
|
|
727
|
+
return /* @__PURE__ */ jsxs3(Link, { href: create.href, to: create.href, className, children: [
|
|
728
|
+
icon,
|
|
729
|
+
label
|
|
730
|
+
] });
|
|
731
|
+
}
|
|
732
|
+
return /* @__PURE__ */ jsxs3("button", { type: "button", onClick: create.onSelect, className, children: [
|
|
733
|
+
icon,
|
|
734
|
+
label
|
|
735
|
+
] });
|
|
736
|
+
}
|
|
737
|
+
|
|
181
738
|
// src/workspace-react/index.tsx
|
|
182
|
-
import { jsx as
|
|
739
|
+
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
183
740
|
function routePathFromHref(href, base) {
|
|
184
741
|
const path = href.split(/[?#]/, 1)[0] ?? "";
|
|
185
742
|
const root = base.replace(/\/+$/, "");
|
|
@@ -194,6 +751,8 @@ function AgentWorkspaceLayout({
|
|
|
194
751
|
apps,
|
|
195
752
|
activeRoute,
|
|
196
753
|
activeId,
|
|
754
|
+
product,
|
|
755
|
+
workspace,
|
|
197
756
|
...sidebarProps
|
|
198
757
|
}) {
|
|
199
758
|
const sessionNav = sessions ? (() => {
|
|
@@ -271,12 +830,27 @@ function AgentWorkspaceLayout({
|
|
|
271
830
|
...appGroup ? [appGroup] : [],
|
|
272
831
|
...sessionNav ? [sessionNav] : []
|
|
273
832
|
];
|
|
833
|
+
const hideBelow = sidebarProps.hideBelow ?? "lg";
|
|
834
|
+
const identityProps = product ? {
|
|
835
|
+
logo: product.mark,
|
|
836
|
+
logoHref: product.href,
|
|
837
|
+
railHeaderContent: /* @__PURE__ */ jsx4(
|
|
838
|
+
AgentRailIdentity,
|
|
839
|
+
{
|
|
840
|
+
product,
|
|
841
|
+
workspace,
|
|
842
|
+
hideBelow,
|
|
843
|
+
LinkComponent: sidebarProps.LinkComponent
|
|
844
|
+
}
|
|
845
|
+
)
|
|
846
|
+
} : {};
|
|
274
847
|
const layoutProps = {
|
|
275
|
-
hideBelow
|
|
848
|
+
hideBelow,
|
|
276
849
|
railLabels: true,
|
|
850
|
+
...identityProps,
|
|
277
851
|
...sidebarProps
|
|
278
852
|
};
|
|
279
|
-
return /* @__PURE__ */
|
|
853
|
+
return /* @__PURE__ */ jsx4(
|
|
280
854
|
SidebarLayout,
|
|
281
855
|
{
|
|
282
856
|
...layoutProps,
|
|
@@ -287,8 +861,12 @@ function AgentWorkspaceLayout({
|
|
|
287
861
|
);
|
|
288
862
|
}
|
|
289
863
|
export {
|
|
864
|
+
AgentRailIdentity,
|
|
290
865
|
AgentWorkspaceCompanion,
|
|
291
866
|
AgentWorkspaceLayout,
|
|
867
|
+
DEFAULT_WORKSPACE_NOUN,
|
|
868
|
+
WorkspaceInitial,
|
|
869
|
+
WorkspaceList,
|
|
292
870
|
WorkspaceSwitcher,
|
|
293
871
|
createAgentWorkspaceCompanionTabs
|
|
294
872
|
};
|