@nextclaw/agent-chat-ui 0.2.21 → 0.3.0

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.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as react from 'react';
2
- import { RefObject } from 'react';
2
+ import { ReactNode, RefObject } from 'react';
3
3
  import * as react_jsx_runtime from 'react/jsx-runtime';
4
4
 
5
5
  type ChatTexts = {
@@ -170,12 +170,14 @@ type ChatToolActionViewModel = {
170
170
  kind: "open-session";
171
171
  sessionId: string;
172
172
  sessionKind: "child" | "session";
173
+ agentId?: string;
173
174
  label?: string;
174
175
  parentSessionId?: string;
175
176
  };
176
177
  type ChatToolPartViewModel = {
177
178
  kind: "call" | "result";
178
179
  toolName: string;
180
+ agentId?: string;
179
181
  summary?: string;
180
182
  inputLabel?: string;
181
183
  input?: string;
@@ -255,6 +257,7 @@ type ChatMessageListProps = {
255
257
  texts: ChatMessageTexts;
256
258
  className?: string;
257
259
  onToolAction?: (action: ChatToolActionViewModel) => void;
260
+ renderToolAgent?: (agentId: string) => ReactNode;
258
261
  };
259
262
 
260
263
  type ChatInputBarHandle = {
package/dist/index.js CHANGED
@@ -2781,7 +2781,7 @@ function ToolCardContent({ children, className }) {
2781
2781
  }
2782
2782
 
2783
2783
  // src/components/chat/ui/chat-message-list/tool-card/tool-card-header.tsx
2784
- import { ChevronDown as ChevronDown2, ChevronRight } from "lucide-react";
2784
+ import { ArrowUpRight, ChevronDown as ChevronDown2, ChevronRight } from "lucide-react";
2785
2785
 
2786
2786
  // src/components/chat/ui/chat-message-list/tool-card/tool-card-status.tsx
2787
2787
  import { Check as Check4, Loader2, AlertTriangle, Minus } from "lucide-react";
@@ -2803,12 +2803,38 @@ function ToolStatusLabel({ card }) {
2803
2803
 
2804
2804
  // src/components/chat/ui/chat-message-list/tool-card/tool-card-header.tsx
2805
2805
  import { Fragment as Fragment3, jsx as jsx20, jsxs as jsxs12 } from "react/jsx-runtime";
2806
+ function ToolCardSessionActionButton({
2807
+ action,
2808
+ onAction
2809
+ }) {
2810
+ const isChildSession = action.sessionKind === "child";
2811
+ const label = isChildSession ? "Open child session" : "Open session";
2812
+ const handleClick = (event) => {
2813
+ event.stopPropagation();
2814
+ onAction(action);
2815
+ };
2816
+ return /* @__PURE__ */ jsx20(
2817
+ "button",
2818
+ {
2819
+ type: "button",
2820
+ onClick: handleClick,
2821
+ className: cn(
2822
+ "inline-flex items-center gap-1.5 rounded-full border px-2 py-1 text-[10px] font-semibold uppercase tracking-[0.08em] transition-colors",
2823
+ "border-amber-200/80 bg-white/80 text-amber-800 hover:bg-amber-50"
2824
+ ),
2825
+ "aria-label": label,
2826
+ title: label,
2827
+ children: /* @__PURE__ */ jsx20(ArrowUpRight, { className: "h-3 w-3", strokeWidth: 2.5 })
2828
+ }
2829
+ );
2830
+ }
2806
2831
  function ToolCardHeader({
2807
2832
  card,
2808
2833
  icon: Icon2,
2809
2834
  expanded,
2810
2835
  canExpand,
2811
2836
  hideSummary = false,
2837
+ actionSlot,
2812
2838
  onToggle
2813
2839
  }) {
2814
2840
  const summaryPart = hideSummary ? "" : card.summary?.replace(/^(command|path|args|query|input):\s*/i, "") ?? "";
@@ -2832,6 +2858,7 @@ function ToolCardHeader({
2832
2858
  ] })
2833
2859
  ] }),
2834
2860
  /* @__PURE__ */ jsxs12("div", { className: "flex items-center gap-3 shrink-0", children: [
2861
+ actionSlot,
2835
2862
  /* @__PURE__ */ jsx20(ToolStatusLabel, { card }),
2836
2863
  canExpand && (expanded ? /* @__PURE__ */ jsx20(ChevronDown2, { className: "h-4 w-4 text-amber-400/80", strokeWidth: 3 }) : /* @__PURE__ */ jsx20(ChevronRight, { className: "h-4 w-4 text-amber-400/80", strokeWidth: 3 }))
2837
2864
  ] })
@@ -2839,6 +2866,12 @@ function ToolCardHeader({
2839
2866
  }
2840
2867
  );
2841
2868
  }
2869
+ function ToolCardHeaderSessionAction({
2870
+ action,
2871
+ onAction
2872
+ }) {
2873
+ return /* @__PURE__ */ jsx20(ToolCardSessionActionButton, { action, onAction });
2874
+ }
2842
2875
 
2843
2876
  // src/components/chat/hooks/use-sticky-bottom-scroll.ts
2844
2877
  import { useEffect as useEffect7, useLayoutEffect as useLayoutEffect2, useRef as useRef6 } from "react";
@@ -3506,7 +3539,8 @@ function SearchSnippetView({ card }) {
3506
3539
  }
3507
3540
  function GenericToolCard({
3508
3541
  card,
3509
- onToolAction
3542
+ onToolAction,
3543
+ renderToolAgent
3510
3544
  }) {
3511
3545
  const input = card.input?.trim() ?? "";
3512
3546
  const output = card.output?.trim() ?? "";
@@ -3529,6 +3563,16 @@ function GenericToolCard({
3529
3563
  icon: Globe,
3530
3564
  expanded,
3531
3565
  canExpand: hasContent || isRunning,
3566
+ actionSlot: card.agentId || card.action && onToolAction ? /* @__PURE__ */ jsxs15(Fragment5, { children: [
3567
+ card.agentId && renderToolAgent ? renderToolAgent(card.agentId) : null,
3568
+ card.action && onToolAction ? /* @__PURE__ */ jsx23(
3569
+ ToolCardHeaderSessionAction,
3570
+ {
3571
+ action: card.action,
3572
+ onAction: onToolAction
3573
+ }
3574
+ ) : null
3575
+ ] }) : void 0,
3532
3576
  onToggle
3533
3577
  }
3534
3578
  ),
@@ -3542,16 +3586,7 @@ function GenericToolCard({
3542
3586
  tone: card.statusTone === "error" ? "error" : "output",
3543
3587
  children: output
3544
3588
  }
3545
- ),
3546
- card.action && onToolAction ? /* @__PURE__ */ jsx23("div", { className: "pt-2", children: /* @__PURE__ */ jsx23(
3547
- "button",
3548
- {
3549
- type: "button",
3550
- onClick: () => onToolAction(card.action),
3551
- className: "rounded-md border border-amber-300/70 bg-white/80 px-3 py-1.5 text-[11px] font-semibold text-amber-900 transition-colors hover:bg-amber-100/70",
3552
- children: card.action.sessionKind === "child" ? "Open child session" : "Open session"
3553
- }
3554
- ) }) : null
3589
+ )
3555
3590
  ] })
3556
3591
  ] });
3557
3592
  }
@@ -3572,7 +3607,8 @@ function isSearchTool(name) {
3572
3607
  }
3573
3608
  function ChatToolCard({
3574
3609
  card,
3575
- onToolAction
3610
+ onToolAction,
3611
+ renderToolAgent
3576
3612
  }) {
3577
3613
  if (isTerminalTool(card.toolName)) {
3578
3614
  return /* @__PURE__ */ jsx24(TerminalExecutionView, { card });
@@ -3583,7 +3619,14 @@ function ChatToolCard({
3583
3619
  if (isSearchTool(card.toolName)) {
3584
3620
  return /* @__PURE__ */ jsx24(SearchSnippetView, { card });
3585
3621
  }
3586
- return /* @__PURE__ */ jsx24(GenericToolCard, { card, onToolAction });
3622
+ return /* @__PURE__ */ jsx24(
3623
+ GenericToolCard,
3624
+ {
3625
+ card,
3626
+ onToolAction,
3627
+ renderToolAgent
3628
+ }
3629
+ );
3587
3630
  }
3588
3631
 
3589
3632
  // src/components/chat/ui/chat-message-list/chat-unknown-part.tsx
@@ -3602,7 +3645,7 @@ function ChatUnknownPart(props) {
3602
3645
  // src/components/chat/ui/chat-message-list/chat-message.tsx
3603
3646
  import { jsx as jsx26 } from "react/jsx-runtime";
3604
3647
  var ChatMessage = memo(function ChatMessage2(props) {
3605
- const { message, texts, onToolAction } = props;
3648
+ const { message, texts, onToolAction, renderToolAgent } = props;
3606
3649
  const { role } = message;
3607
3650
  const isUser = role === "user";
3608
3651
  const isMessageInProgress = message.status === "pending" || message.status === "streaming";
@@ -3650,7 +3693,14 @@ var ChatMessage = memo(function ChatMessage2(props) {
3650
3693
  );
3651
3694
  }
3652
3695
  if (type === "tool-card") {
3653
- return /* @__PURE__ */ jsx26("div", { className: "mt-0.5", children: /* @__PURE__ */ jsx26(ChatToolCard, { card: part.card, onToolAction }) }, `tool-${index}`);
3696
+ return /* @__PURE__ */ jsx26("div", { className: "mt-0.5", children: /* @__PURE__ */ jsx26(
3697
+ ChatToolCard,
3698
+ {
3699
+ card: part.card,
3700
+ onToolAction,
3701
+ renderToolAgent
3702
+ }
3703
+ ) }, `tool-${index}`);
3654
3704
  }
3655
3705
  if (type === "file") {
3656
3706
  return /* @__PURE__ */ jsx26(
@@ -3770,7 +3820,8 @@ function ChatMessageList(props) {
3770
3820
  {
3771
3821
  message,
3772
3822
  texts: props.texts,
3773
- onToolAction: props.onToolAction
3823
+ onToolAction: props.onToolAction,
3824
+ renderToolAgent: props.renderToolAgent
3774
3825
  }
3775
3826
  ),
3776
3827
  /* @__PURE__ */ jsx28("div", { className: cn("flex items-center gap-2", isUser && "justify-end"), children: isGenerating ? /* @__PURE__ */ jsx28(ChatMessageTypingFooter, {}) : /* @__PURE__ */ jsxs18(Fragment6, { children: [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nextclaw/agent-chat-ui",
3
- "version": "0.2.21",
3
+ "version": "0.3.0",
4
4
  "private": false,
5
5
  "description": "Reusable Nextclaw agent chat UI primitives and default skin.",
6
6
  "type": "module",