ai-design-system 0.1.97 → 0.1.98
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/components/composites/SessionHeader/SessionHeader.tsx +46 -40
- package/components/features/ChatPanel/ChatPanel.tsx +13 -0
- package/dist/index.cjs +9 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +62 -51
- package/dist/index.js +9 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -20,12 +20,14 @@ import type { FileDownloadResult } from '@/components/composites/FileTreeExplore
|
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
export interface SessionHeaderProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
23
|
+
title?: string;
|
|
23
24
|
sessions?: ChatSessionInfo[];
|
|
24
25
|
activeSessionId?: string | null;
|
|
25
26
|
onNewSession?: () => void;
|
|
26
27
|
onCloseSession?: (id: string) => void;
|
|
27
28
|
onSelectSession?: (id: string) => void;
|
|
28
29
|
onDownloadSession?: () => Promise<FileDownloadResult | undefined>;
|
|
30
|
+
showActions?: boolean;
|
|
29
31
|
}
|
|
30
32
|
|
|
31
33
|
/**
|
|
@@ -35,7 +37,7 @@ export interface SessionHeaderProps extends React.HTMLAttributes<HTMLDivElement>
|
|
|
35
37
|
* and a dropdown history of past sessions.
|
|
36
38
|
*/
|
|
37
39
|
export const SessionHeader = React.forwardRef<HTMLDivElement, SessionHeaderProps>(
|
|
38
|
-
({ sessions, activeSessionId, onNewSession, onCloseSession, onSelectSession, onDownloadSession, className, ...props }, ref) => {
|
|
40
|
+
({ title, sessions, activeSessionId, onNewSession, onCloseSession, onSelectSession, onDownloadSession, showActions = true, className, ...props }, ref) => {
|
|
39
41
|
const activeSession = sessions?.find(s => s.id === activeSessionId);
|
|
40
42
|
const downloadRef = React.useRef<HTMLAnchorElement>(null);
|
|
41
43
|
|
|
@@ -53,6 +55,10 @@ export const SessionHeader = React.forwardRef<HTMLDivElement, SessionHeaderProps
|
|
|
53
55
|
URL.revokeObjectURL(url);
|
|
54
56
|
}, [onDownloadSession]);
|
|
55
57
|
|
|
58
|
+
const displayTitle = title || (activeSessionId
|
|
59
|
+
? (activeSession?.title || 'Untitled Session')
|
|
60
|
+
: 'New Session');
|
|
61
|
+
|
|
56
62
|
return (
|
|
57
63
|
<div
|
|
58
64
|
ref={ref}
|
|
@@ -61,48 +67,48 @@ export const SessionHeader = React.forwardRef<HTMLDivElement, SessionHeaderProps
|
|
|
61
67
|
>
|
|
62
68
|
<div className="flex items-center space-x-2 overflow-hidden">
|
|
63
69
|
<span className="text-sm font-medium truncate">
|
|
64
|
-
{
|
|
65
|
-
? (activeSession?.title || 'Untitled Session')
|
|
66
|
-
: 'New Session'}
|
|
70
|
+
{displayTitle}
|
|
67
71
|
</span>
|
|
68
72
|
</div>
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
<
|
|
73
|
-
|
|
74
|
-
)}
|
|
75
|
-
<Button variant="ghost" size="icon" onClick={onNewSession} className="h-8 w-8" title="New Session">
|
|
76
|
-
<Icon name="plus" className="h-4 w-4" />
|
|
77
|
-
</Button>
|
|
78
|
-
|
|
79
|
-
<DropdownMenu>
|
|
80
|
-
<DropdownMenuTrigger asChild>
|
|
81
|
-
<Button variant="ghost" size="icon" className="h-8 w-8">
|
|
82
|
-
<Icon name="clock" className="h-4 w-4" />
|
|
73
|
+
{showActions && (
|
|
74
|
+
<div className="flex items-center space-x-1 flex-none">
|
|
75
|
+
{onDownloadSession && (
|
|
76
|
+
<Button variant="ghost" size="icon" onClick={handleDownloadClick} className="h-8 w-8" title="Download Chat History">
|
|
77
|
+
<Icon name="download" className="h-4 w-4" />
|
|
83
78
|
</Button>
|
|
84
|
-
|
|
85
|
-
<
|
|
86
|
-
<
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
79
|
+
)}
|
|
80
|
+
<Button variant="ghost" size="icon" onClick={onNewSession} className="h-8 w-8" title="New Session">
|
|
81
|
+
<Icon name="plus" className="h-4 w-4" />
|
|
82
|
+
</Button>
|
|
83
|
+
|
|
84
|
+
<DropdownMenu>
|
|
85
|
+
<DropdownMenuTrigger asChild>
|
|
86
|
+
<Button variant="ghost" size="icon" className="h-8 w-8">
|
|
87
|
+
<Icon name="clock" className="h-4 w-4" />
|
|
88
|
+
</Button>
|
|
89
|
+
</DropdownMenuTrigger>
|
|
90
|
+
<DropdownMenuContent align="end" className="w-64 max-h-80 overflow-y-auto">
|
|
91
|
+
<DropdownMenuLabel>Chat History</DropdownMenuLabel>
|
|
92
|
+
<DropdownMenuSeparator />
|
|
93
|
+
{sessions && sessions.length > 0 ? (
|
|
94
|
+
sessions.map((session) => (
|
|
95
|
+
<DropdownMenuItem
|
|
96
|
+
key={session.id}
|
|
97
|
+
onClick={() => onSelectSession?.(session.id)}
|
|
98
|
+
className="flex flex-col items-start py-2 cursor-pointer"
|
|
99
|
+
>
|
|
100
|
+
<span className="text-sm font-medium truncate w-full">{session.title || 'Untitled Session'}</span>
|
|
101
|
+
<span className="text-xs text-muted-foreground">{new Date(session.created_at).toLocaleString()}</span>
|
|
102
|
+
</DropdownMenuItem>
|
|
103
|
+
))
|
|
104
|
+
) : (
|
|
105
|
+
<div className="p-4 text-sm text-center text-muted-foreground">No previous sessions</div>
|
|
106
|
+
)}
|
|
107
|
+
</DropdownMenuContent>
|
|
108
|
+
</DropdownMenu>
|
|
109
|
+
<a ref={downloadRef} style={{ display: 'none' }} />
|
|
110
|
+
</div>
|
|
111
|
+
)}
|
|
106
112
|
</div>
|
|
107
113
|
);
|
|
108
114
|
}
|
|
@@ -204,6 +204,15 @@ export interface ChatPanelProps {
|
|
|
204
204
|
* @default true
|
|
205
205
|
*/
|
|
206
206
|
showHeader?: boolean;
|
|
207
|
+
/**
|
|
208
|
+
* Title override for the session header
|
|
209
|
+
*/
|
|
210
|
+
sessionTitle?: string;
|
|
211
|
+
/**
|
|
212
|
+
* Whether to show action buttons in the session header
|
|
213
|
+
* @default true
|
|
214
|
+
*/
|
|
215
|
+
showSessionActions?: boolean;
|
|
207
216
|
}
|
|
208
217
|
|
|
209
218
|
/**
|
|
@@ -249,6 +258,8 @@ export const ChatPanel = React.memo<ChatPanelProps>(
|
|
|
249
258
|
onTaskClick,
|
|
250
259
|
enableSpeech = true,
|
|
251
260
|
showHeader = true,
|
|
261
|
+
sessionTitle,
|
|
262
|
+
showSessionActions = true,
|
|
252
263
|
}) => {
|
|
253
264
|
// File change queue state
|
|
254
265
|
const [fileChangeState, setFileChangeState] = React.useState<
|
|
@@ -405,6 +416,8 @@ export const ChatPanel = React.memo<ChatPanelProps>(
|
|
|
405
416
|
{/* Chat Session Header */}
|
|
406
417
|
{showHeader && (
|
|
407
418
|
<SessionHeader
|
|
419
|
+
title={sessionTitle}
|
|
420
|
+
showActions={showSessionActions}
|
|
408
421
|
sessions={sessions}
|
|
409
422
|
activeSessionId={activeSessionId}
|
|
410
423
|
onNewSession={onNewSession}
|
package/dist/index.cjs
CHANGED
|
@@ -7786,7 +7786,7 @@ var ApprovalCard = React3__namespace.memo(
|
|
|
7786
7786
|
ApprovalCard.displayName = "ApprovalCard";
|
|
7787
7787
|
var SessionHeader = React3__namespace.forwardRef(
|
|
7788
7788
|
(_a, ref) => {
|
|
7789
|
-
var _b = _a, { sessions, activeSessionId, onNewSession, onCloseSession, onSelectSession, onDownloadSession, className } = _b, props = __objRest(_b, ["sessions", "activeSessionId", "onNewSession", "onCloseSession", "onSelectSession", "onDownloadSession", "className"]);
|
|
7789
|
+
var _b = _a, { title, sessions, activeSessionId, onNewSession, onCloseSession, onSelectSession, onDownloadSession, showActions = true, className } = _b, props = __objRest(_b, ["title", "sessions", "activeSessionId", "onNewSession", "onCloseSession", "onSelectSession", "onDownloadSession", "showActions", "className"]);
|
|
7790
7790
|
const activeSession = sessions == null ? void 0 : sessions.find((s) => s.id === activeSessionId);
|
|
7791
7791
|
const downloadRef = React3__namespace.useRef(null);
|
|
7792
7792
|
const handleDownloadClick = React3__namespace.useCallback(async () => {
|
|
@@ -7802,6 +7802,7 @@ var SessionHeader = React3__namespace.forwardRef(
|
|
|
7802
7802
|
}
|
|
7803
7803
|
URL.revokeObjectURL(url);
|
|
7804
7804
|
}, [onDownloadSession]);
|
|
7805
|
+
const displayTitle = title || (activeSessionId ? (activeSession == null ? void 0 : activeSession.title) || "Untitled Session" : "New Session");
|
|
7805
7806
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
7806
7807
|
"div",
|
|
7807
7808
|
__spreadProps(__spreadValues({
|
|
@@ -7809,8 +7810,8 @@ var SessionHeader = React3__namespace.forwardRef(
|
|
|
7809
7810
|
className: `flex flex-none items-center justify-between px-4 py-2 border-b border-border bg-background ${className || ""}`
|
|
7810
7811
|
}, props), {
|
|
7811
7812
|
children: [
|
|
7812
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center space-x-2 overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm font-medium truncate", children:
|
|
7813
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center space-x-1 flex-none", children: [
|
|
7813
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center space-x-2 overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm font-medium truncate", children: displayTitle }) }),
|
|
7814
|
+
showActions && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center space-x-1 flex-none", children: [
|
|
7814
7815
|
onDownloadSession && /* @__PURE__ */ jsxRuntime.jsx(Button2, { variant: "ghost", size: "icon", onClick: handleDownloadClick, className: "h-8 w-8", title: "Download Chat History", children: /* @__PURE__ */ jsxRuntime.jsx(Icon, { name: "download", className: "h-4 w-4" }) }),
|
|
7815
7816
|
/* @__PURE__ */ jsxRuntime.jsx(Button2, { variant: "ghost", size: "icon", onClick: onNewSession, className: "h-8 w-8", title: "New Session", children: /* @__PURE__ */ jsxRuntime.jsx(Icon, { name: "plus", className: "h-4 w-4" }) }),
|
|
7816
7817
|
/* @__PURE__ */ jsxRuntime.jsxs(DropdownMenu2, { children: [
|
|
@@ -8039,7 +8040,9 @@ var ChatPanel = React3__namespace.memo(
|
|
|
8039
8040
|
onTaskStopAll,
|
|
8040
8041
|
onTaskClick,
|
|
8041
8042
|
enableSpeech = true,
|
|
8042
|
-
showHeader = true
|
|
8043
|
+
showHeader = true,
|
|
8044
|
+
sessionTitle,
|
|
8045
|
+
showSessionActions = true
|
|
8043
8046
|
}) => {
|
|
8044
8047
|
const [fileChangeState, setFileChangeState] = React3__namespace.useState("approval-requested");
|
|
8045
8048
|
const [approval, setApproval] = React3__namespace.useState({});
|
|
@@ -8161,6 +8164,8 @@ var ChatPanel = React3__namespace.memo(
|
|
|
8161
8164
|
showHeader && /* @__PURE__ */ jsxRuntime.jsx(
|
|
8162
8165
|
SessionHeader,
|
|
8163
8166
|
{
|
|
8167
|
+
title: sessionTitle,
|
|
8168
|
+
showActions: showSessionActions,
|
|
8164
8169
|
sessions,
|
|
8165
8170
|
activeSessionId,
|
|
8166
8171
|
onNewSession,
|