@invergent/agent-chat-react 1.4.9 → 1.4.10
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/index.cjs +49 -21
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +49 -21
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -371,7 +371,8 @@ interface SessionTreePanelProps {
|
|
|
371
371
|
/** Treat the root as hidden, so its children appear as top-level rows. */
|
|
372
372
|
hideRoot?: boolean;
|
|
373
373
|
onSessionSelect?: (sessionId: string) => void;
|
|
374
|
+
onSessionDelete?: (sessionId: string) => void;
|
|
374
375
|
}
|
|
375
|
-
declare function SessionTreePanel({ adapter, sessionId, activeSessionId, agentId, title, sessionListLimit, hideRoot, onSessionSelect, }: SessionTreePanelProps): react_jsx_runtime.JSX.Element | null;
|
|
376
|
+
declare function SessionTreePanel({ adapter, sessionId, activeSessionId, agentId, title, sessionListLimit, hideRoot, onSessionSelect, onSessionDelete, }: SessionTreePanelProps): react_jsx_runtime.JSX.Element | null;
|
|
376
377
|
|
|
377
378
|
export { AgentChat, type AgentChatAdapter, type AgentChatAdapterContextValue, AgentChatAdapterProvider, type AgentChatArtifactKind, type AgentChatArtifactMeta, type AgentChatArtifactPayload, type AgentChatChartArtifactSpec, type AgentChatClarifyAnswer, type AgentChatClarifyArgs, type AgentChatClarifyChoice, type AgentChatClarifyQuestion, type AgentChatErrorCategory, type AgentChatErrorInfo, type AgentChatEventStream, type AgentChatEventType, type AgentChatExpertFeedbackRating, type AgentChatHtmlArtifactSpec, type AgentChatMarkdownArtifactSpec, type AgentChatMessage, type AgentChatMessageStatus, type AgentChatProps, type AgentChatRole, type AgentChatRuntimeApi, type AgentChatRuntimeEvent, type AgentChatSession, type AgentChatSessionList, type AgentChatSessionTree, type AgentChatSessionTreeNode, type AgentChatSlashCommand, type AgentChatSseMessageEvent, type AgentChatState, type AgentChatSvgArtifactSpec, type AgentChatSystemKind, type AgentChatTableArtifactSpec, type AgentChatTokenUsage, type AgentChatToolCallInfo, type AgentChatWorkspaceEntry, type AgentChatWorkspaceFile, type AgentChatWorkspaceTree, type AgentChatWorkspaceUpload, type ArtifactKind, type ArtifactPayload, type ChartArtifactSpec, type ChatMessage, type ClarifyAnswer, type ClarifyArgs, type ClarifyChoice, type ClarifyQuestion, type ErrorInfo, type HtmlArtifactSpec, type MarkdownArtifactSpec, MessageResponse, type MessageResponseProps, type RetryIndicator, type SessionTree, type SessionTreeNode, SessionTreePanel, type SessionTreePanelProps, type SvgArtifactSpec, type TableArtifactSpec, type TokenUsage, type ToolCallInfo, type WorkspaceEntry, type WorkspaceFile, type WorkspaceTree, type WorkspaceUpload, useAgentChatAdapterContext, useAgentChatRuntime };
|
package/dist/index.d.ts
CHANGED
|
@@ -371,7 +371,8 @@ interface SessionTreePanelProps {
|
|
|
371
371
|
/** Treat the root as hidden, so its children appear as top-level rows. */
|
|
372
372
|
hideRoot?: boolean;
|
|
373
373
|
onSessionSelect?: (sessionId: string) => void;
|
|
374
|
+
onSessionDelete?: (sessionId: string) => void;
|
|
374
375
|
}
|
|
375
|
-
declare function SessionTreePanel({ adapter, sessionId, activeSessionId, agentId, title, sessionListLimit, hideRoot, onSessionSelect, }: SessionTreePanelProps): react_jsx_runtime.JSX.Element | null;
|
|
376
|
+
declare function SessionTreePanel({ adapter, sessionId, activeSessionId, agentId, title, sessionListLimit, hideRoot, onSessionSelect, onSessionDelete, }: SessionTreePanelProps): react_jsx_runtime.JSX.Element | null;
|
|
376
377
|
|
|
377
378
|
export { AgentChat, type AgentChatAdapter, type AgentChatAdapterContextValue, AgentChatAdapterProvider, type AgentChatArtifactKind, type AgentChatArtifactMeta, type AgentChatArtifactPayload, type AgentChatChartArtifactSpec, type AgentChatClarifyAnswer, type AgentChatClarifyArgs, type AgentChatClarifyChoice, type AgentChatClarifyQuestion, type AgentChatErrorCategory, type AgentChatErrorInfo, type AgentChatEventStream, type AgentChatEventType, type AgentChatExpertFeedbackRating, type AgentChatHtmlArtifactSpec, type AgentChatMarkdownArtifactSpec, type AgentChatMessage, type AgentChatMessageStatus, type AgentChatProps, type AgentChatRole, type AgentChatRuntimeApi, type AgentChatRuntimeEvent, type AgentChatSession, type AgentChatSessionList, type AgentChatSessionTree, type AgentChatSessionTreeNode, type AgentChatSlashCommand, type AgentChatSseMessageEvent, type AgentChatState, type AgentChatSvgArtifactSpec, type AgentChatSystemKind, type AgentChatTableArtifactSpec, type AgentChatTokenUsage, type AgentChatToolCallInfo, type AgentChatWorkspaceEntry, type AgentChatWorkspaceFile, type AgentChatWorkspaceTree, type AgentChatWorkspaceUpload, type ArtifactKind, type ArtifactPayload, type ChartArtifactSpec, type ChatMessage, type ClarifyAnswer, type ClarifyArgs, type ClarifyChoice, type ClarifyQuestion, type ErrorInfo, type HtmlArtifactSpec, type MarkdownArtifactSpec, MessageResponse, type MessageResponseProps, type RetryIndicator, type SessionTree, type SessionTreeNode, SessionTreePanel, type SessionTreePanelProps, type SvgArtifactSpec, type TableArtifactSpec, type TokenUsage, type ToolCallInfo, type WorkspaceEntry, type WorkspaceFile, type WorkspaceTree, type WorkspaceUpload, useAgentChatAdapterContext, useAgentChatRuntime };
|
package/dist/index.js
CHANGED
|
@@ -7839,15 +7839,16 @@ function TreeNodeRow({
|
|
|
7839
7839
|
depth,
|
|
7840
7840
|
activeSessionId,
|
|
7841
7841
|
canStop,
|
|
7842
|
+
canDelete,
|
|
7843
|
+
deletingSessionId,
|
|
7842
7844
|
onSelect,
|
|
7843
|
-
onStop
|
|
7845
|
+
onStop,
|
|
7846
|
+
onDelete
|
|
7844
7847
|
}) {
|
|
7845
7848
|
const [expanded, setExpanded] = useState(true);
|
|
7846
7849
|
const hasChildren = entry.children.length > 0;
|
|
7847
7850
|
const isActive = entry.id === activeSessionId;
|
|
7848
7851
|
const isRunning = entry.status === "active";
|
|
7849
|
-
const messageCount = entry.messageCount ?? 0;
|
|
7850
|
-
const toolCallCount = entry.toolCallCount ?? 0;
|
|
7851
7852
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
7852
7853
|
/* @__PURE__ */ jsxs(
|
|
7853
7854
|
"div",
|
|
@@ -7879,7 +7880,7 @@ function TreeNodeRow({
|
|
|
7879
7880
|
}
|
|
7880
7881
|
) : /* @__PURE__ */ jsx("span", { className: "w-4 h-4 shrink-0" }),
|
|
7881
7882
|
/* @__PURE__ */ jsxs("div", { className: "flex-1 min-w-0 flex items-center gap-1.5", children: [
|
|
7882
|
-
/* @__PURE__ */ jsx("span", { className: "truncate", children: entry.title ??
|
|
7883
|
+
/* @__PURE__ */ jsx("span", { className: "truncate", children: entry.title ?? "session" }),
|
|
7883
7884
|
entry.agentType && /* @__PURE__ */ jsx(Badge, { variant: "outline", className: "h-4 px-1.5 text-[10px]", children: entry.agentType }),
|
|
7884
7885
|
/* @__PURE__ */ jsx(
|
|
7885
7886
|
Badge,
|
|
@@ -7890,20 +7891,6 @@ function TreeNodeRow({
|
|
|
7890
7891
|
}
|
|
7891
7892
|
)
|
|
7892
7893
|
] }),
|
|
7893
|
-
/* @__PURE__ */ jsxs(
|
|
7894
|
-
"span",
|
|
7895
|
-
{
|
|
7896
|
-
className: "text-xs text-faint shrink-0 tabular-nums",
|
|
7897
|
-
"aria-label": `${messageCount} messages, ${toolCallCount} tool calls`,
|
|
7898
|
-
title: `${messageCount} messages, ${toolCallCount} tool calls`,
|
|
7899
|
-
children: [
|
|
7900
|
-
messageCount,
|
|
7901
|
-
"m/",
|
|
7902
|
-
toolCallCount,
|
|
7903
|
-
"t"
|
|
7904
|
-
]
|
|
7905
|
-
}
|
|
7906
|
-
),
|
|
7907
7894
|
isRunning && canStop && /* @__PURE__ */ jsx(
|
|
7908
7895
|
"button",
|
|
7909
7896
|
{
|
|
@@ -7917,6 +7904,21 @@ function TreeNodeRow({
|
|
|
7917
7904
|
title: "Stop sub-agent",
|
|
7918
7905
|
children: /* @__PURE__ */ jsx(SquareIcon, { className: "w-3 h-3", fill: "currentColor" })
|
|
7919
7906
|
}
|
|
7907
|
+
),
|
|
7908
|
+
canDelete && /* @__PURE__ */ jsx(
|
|
7909
|
+
"button",
|
|
7910
|
+
{
|
|
7911
|
+
type: "button",
|
|
7912
|
+
className: "p-1 rounded opacity-0 group-hover:opacity-100 focus-visible:opacity-100 hover:bg-destructive/10 hover:text-destructive disabled:pointer-events-none disabled:opacity-50 transition-all",
|
|
7913
|
+
onClick: (e) => {
|
|
7914
|
+
e.stopPropagation();
|
|
7915
|
+
onDelete(entry.id);
|
|
7916
|
+
},
|
|
7917
|
+
"aria-label": "Delete session",
|
|
7918
|
+
title: "Delete session",
|
|
7919
|
+
disabled: deletingSessionId === entry.id,
|
|
7920
|
+
children: /* @__PURE__ */ jsx(Trash2Icon, { className: "w-3 h-3" })
|
|
7921
|
+
}
|
|
7920
7922
|
)
|
|
7921
7923
|
]
|
|
7922
7924
|
}
|
|
@@ -7928,8 +7930,11 @@ function TreeNodeRow({
|
|
|
7928
7930
|
depth: depth + 1,
|
|
7929
7931
|
activeSessionId,
|
|
7930
7932
|
canStop,
|
|
7933
|
+
canDelete,
|
|
7934
|
+
deletingSessionId,
|
|
7931
7935
|
onSelect,
|
|
7932
|
-
onStop
|
|
7936
|
+
onStop,
|
|
7937
|
+
onDelete
|
|
7933
7938
|
},
|
|
7934
7939
|
child.id
|
|
7935
7940
|
))
|
|
@@ -7943,12 +7948,16 @@ function SessionTreePanel({
|
|
|
7943
7948
|
title = "Running",
|
|
7944
7949
|
sessionListLimit = DEFAULT_SESSION_LIST_LIMIT,
|
|
7945
7950
|
hideRoot = false,
|
|
7946
|
-
onSessionSelect
|
|
7951
|
+
onSessionSelect,
|
|
7952
|
+
onSessionDelete
|
|
7947
7953
|
}) {
|
|
7948
7954
|
const [nodes, setNodes] = useState([]);
|
|
7949
7955
|
const [loading, setLoading] = useState(false);
|
|
7950
7956
|
const [error, setError] = useState(null);
|
|
7951
7957
|
const [hasEverLoaded, setHasEverLoaded] = useState(false);
|
|
7958
|
+
const [deletingSessionId, setDeletingSessionId] = useState(
|
|
7959
|
+
null
|
|
7960
|
+
);
|
|
7952
7961
|
const mounted = useRef(true);
|
|
7953
7962
|
const requestId = useRef(0);
|
|
7954
7963
|
const lastFingerprint = useRef("");
|
|
@@ -8042,6 +8051,22 @@ function SessionTreePanel({
|
|
|
8042
8051
|
},
|
|
8043
8052
|
[adapter, refetch]
|
|
8044
8053
|
);
|
|
8054
|
+
const handleDelete = useCallback(
|
|
8055
|
+
async (id) => {
|
|
8056
|
+
if (!adapter.deleteSession || deletingSessionId) return;
|
|
8057
|
+
setDeletingSessionId(id);
|
|
8058
|
+
try {
|
|
8059
|
+
await adapter.deleteSession({ sessionId: id });
|
|
8060
|
+
onSessionDelete?.(id);
|
|
8061
|
+
await refetch({ silent: true });
|
|
8062
|
+
} catch (e) {
|
|
8063
|
+
setError(e instanceof Error ? e.message : "Failed to delete session");
|
|
8064
|
+
} finally {
|
|
8065
|
+
if (mounted.current) setDeletingSessionId(null);
|
|
8066
|
+
}
|
|
8067
|
+
},
|
|
8068
|
+
[adapter, deletingSessionId, onSessionDelete, refetch]
|
|
8069
|
+
);
|
|
8045
8070
|
if (!hasEverLoaded) return null;
|
|
8046
8071
|
if (nodes.length === 0) return null;
|
|
8047
8072
|
const topLevel = hideRoot ? roots.flatMap((r) => r.children) : roots;
|
|
@@ -8061,8 +8086,11 @@ function SessionTreePanel({
|
|
|
8061
8086
|
depth: 0,
|
|
8062
8087
|
activeSessionId: activeSessionId ?? "",
|
|
8063
8088
|
canStop: Boolean(adapter.stopSession),
|
|
8089
|
+
canDelete: Boolean(adapter.deleteSession),
|
|
8090
|
+
deletingSessionId,
|
|
8064
8091
|
onSelect: handleSelect,
|
|
8065
|
-
onStop: handleStop
|
|
8092
|
+
onStop: handleStop,
|
|
8093
|
+
onDelete: handleDelete
|
|
8066
8094
|
},
|
|
8067
8095
|
entry.id
|
|
8068
8096
|
)) })
|