@nextclaw/agent-chat-ui 0.3.12 → 0.3.13-beta.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
@@ -110,9 +110,20 @@ type ChatInputBarActionsProps = {
110
110
  stopHint: string;
111
111
  sendButtonLabel: string;
112
112
  stopButtonLabel: string;
113
+ contextWindow?: ChatContextWindowIndicator | null;
113
114
  onSend: () => Promise<void> | void;
114
115
  onStop: () => Promise<void> | void;
115
116
  };
117
+ type ChatContextWindowIndicator = {
118
+ label: string;
119
+ percentLabel: string;
120
+ ratio: number;
121
+ tone: "neutral" | "warning" | "danger";
122
+ details: Array<{
123
+ label: string;
124
+ value: string;
125
+ }>;
126
+ };
116
127
  type ChatInputBarToolbarProps = {
117
128
  selects: ChatToolbarSelect[];
118
129
  accessories?: ChatToolbarAccessory[];
@@ -397,4 +408,4 @@ declare function resolveChatComposerSlashTrigger(nodes: ChatComposerNode[], sele
397
408
  end: number;
398
409
  } | null;
399
410
  //#endregion
400
- export { type ChatComposerNode, type ChatComposerSelection, type ChatComposerTextNode, type ChatComposerTokenKind, type ChatComposerTokenNode, type ChatFileOpenActionViewModel, type ChatFileOperationBlockViewModel, type ChatFileOperationLineViewModel, type ChatInlineContentSegmentViewModel, type ChatInlineHint, type ChatInlineTokenViewModel, ChatInputBar, type ChatInputBarActionsProps, type ChatInputBarHandle, type ChatInputBarProps, type ChatInputBarToolbarProps, ChatMessageList, type ChatMessageListProps, ChatMessageMarkdown, type ChatMessagePartViewModel, type ChatMessageRole, type ChatMessageTexts, type ChatMessageViewModel, type ChatSelectedItem, type ChatSkillPickerOption, type ChatSkillPickerProps, type ChatSlashItem, type ChatSlashMenuProps, type ChatTexts, type ChatToolActionViewModel, type ChatToolPartViewModel, type ChatToolbarAccessory, type ChatToolbarAccessoryIcon, type ChatToolbarIcon, type ChatToolbarSelect, type ChatToolbarSelectGroup, type ChatToolbarSelectOption, FileOperationCodeSurface, FileOperationLinesGrid, copyText, createChatComposerNodesFromText, createChatComposerTextNode, createChatComposerTokenNode, createEmptyChatComposerNodes, extractChatComposerTokenKeys, normalizeChatComposerNodes, removeChatComposerTokenNodes, replaceChatComposerRange, resolveChatComposerSlashTrigger, serializeChatComposerDocument, serializeChatComposerPlainText, useActiveItemScroll, useCopyFeedback, useElementWidth, useStickyBottomScroll };
411
+ export { type ChatComposerNode, type ChatComposerSelection, type ChatComposerTextNode, type ChatComposerTokenKind, type ChatComposerTokenNode, type ChatContextWindowIndicator, type ChatFileOpenActionViewModel, type ChatFileOperationBlockViewModel, type ChatFileOperationLineViewModel, type ChatInlineContentSegmentViewModel, type ChatInlineHint, type ChatInlineTokenViewModel, ChatInputBar, type ChatInputBarActionsProps, type ChatInputBarHandle, type ChatInputBarProps, type ChatInputBarToolbarProps, ChatMessageList, type ChatMessageListProps, ChatMessageMarkdown, type ChatMessagePartViewModel, type ChatMessageRole, type ChatMessageTexts, type ChatMessageViewModel, type ChatSelectedItem, type ChatSkillPickerOption, type ChatSkillPickerProps, type ChatSlashItem, type ChatSlashMenuProps, type ChatTexts, type ChatToolActionViewModel, type ChatToolPartViewModel, type ChatToolbarAccessory, type ChatToolbarAccessoryIcon, type ChatToolbarIcon, type ChatToolbarSelect, type ChatToolbarSelectGroup, type ChatToolbarSelectOption, FileOperationCodeSurface, FileOperationLinesGrid, copyText, createChatComposerNodesFromText, createChatComposerTextNode, createChatComposerTokenNode, createEmptyChatComposerNodes, extractChatComposerTokenKeys, normalizeChatComposerNodes, removeChatComposerTokenNodes, replaceChatComposerRange, resolveChatComposerSlashTrigger, serializeChatComposerDocument, serializeChatComposerPlainText, useActiveItemScroll, useCopyFeedback, useElementWidth, useStickyBottomScroll };
package/dist/index.js CHANGED
@@ -367,7 +367,49 @@ function StopIcon() {
367
367
  className: "block h-3 w-3 rounded-[2px] bg-gray-700 shadow-[inset_0_0_0_1px_rgba(17,24,39,0.06)]"
368
368
  });
369
369
  }
370
- function ChatInputBarActions({ sendError, sendErrorDetailsLabel, isSending, canStopGeneration, sendDisabled, stopDisabled, stopHint, sendButtonLabel, stopButtonLabel, onSend, onStop }) {
370
+ function ContextWindowIndicator({ contextWindow }) {
371
+ const { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } = ChatUiPrimitives;
372
+ const clampedRatio = Math.max(0, Math.min(1, contextWindow.ratio));
373
+ const angle = Math.round(clampedRatio * 360);
374
+ const ringColor = "#9ca3af";
375
+ return /* @__PURE__ */ jsx(TooltipProvider, {
376
+ delayDuration: 0,
377
+ children: /* @__PURE__ */ jsxs(Tooltip, { children: [/* @__PURE__ */ jsx(TooltipTrigger, {
378
+ asChild: true,
379
+ children: /* @__PURE__ */ jsxs("button", {
380
+ type: "button",
381
+ className: "relative inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg text-gray-500 transition-colors hover:bg-gray-100 hover:text-gray-700",
382
+ "aria-label": contextWindow.label,
383
+ title: contextWindow.label,
384
+ children: [/* @__PURE__ */ jsx("span", {
385
+ "aria-hidden": "true",
386
+ className: "absolute inset-[7px] rounded-full",
387
+ style: { background: `conic-gradient(${ringColor} ${angle}deg, #e5e7eb 0deg)` }
388
+ }), /* @__PURE__ */ jsx("span", {
389
+ "aria-hidden": "true",
390
+ className: "absolute inset-[10px] rounded-full bg-white"
391
+ })]
392
+ })
393
+ }), /* @__PURE__ */ jsx(TooltipContent, {
394
+ side: "top",
395
+ className: "max-w-[18rem]",
396
+ children: /* @__PURE__ */ jsxs("div", {
397
+ className: "space-y-1.5 text-xs",
398
+ children: [/* @__PURE__ */ jsxs("div", {
399
+ className: "flex items-center justify-between gap-5 font-semibold text-gray-800",
400
+ children: [/* @__PURE__ */ jsx("span", { children: contextWindow.label }), /* @__PURE__ */ jsx("span", { children: contextWindow.percentLabel })]
401
+ }), contextWindow.details.map((detail) => /* @__PURE__ */ jsxs("div", {
402
+ className: "flex items-center justify-between gap-5 text-gray-600",
403
+ children: [/* @__PURE__ */ jsx("span", { children: detail.label }), /* @__PURE__ */ jsx("span", {
404
+ className: "font-medium text-gray-800",
405
+ children: detail.value
406
+ })]
407
+ }, detail.label))]
408
+ })
409
+ })] })
410
+ });
411
+ }
412
+ function ChatInputBarActions({ sendError, sendErrorDetailsLabel, isSending, canStopGeneration, sendDisabled, stopDisabled, stopHint, sendButtonLabel, stopButtonLabel, contextWindow, onSend, onStop }) {
371
413
  const { Popover, PopoverContent, PopoverTrigger, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } = ChatUiPrimitives;
372
414
  const normalizedSendError = sendError?.trim() ?? "";
373
415
  const sendErrorPreview = normalizedSendError ? buildSendErrorPreview(normalizedSendError) : "";
@@ -401,9 +443,9 @@ function ChatInputBarActions({ sendError, sendErrorDetailsLabel, isSending, canS
401
443
  children: normalizedSendError
402
444
  })]
403
445
  })] })]
404
- }) : null, /* @__PURE__ */ jsx("div", {
446
+ }) : null, /* @__PURE__ */ jsxs("div", {
405
447
  className: "flex items-center gap-2",
406
- children: isSending ? canStopGeneration ? /* @__PURE__ */ jsx(ChatButton, {
448
+ children: [contextWindow ? /* @__PURE__ */ jsx(ContextWindowIndicator, { contextWindow }) : null, isSending ? canStopGeneration ? /* @__PURE__ */ jsx(ChatButton, {
407
449
  size: "icon",
408
450
  variant: "outline",
409
451
  className: "h-8 w-8 rounded-full",
@@ -434,7 +476,7 @@ function ChatInputBarActions({ sendError, sendErrorDetailsLabel, isSending, canS
434
476
  onClick: () => void onSend(),
435
477
  disabled: sendDisabled,
436
478
  children: /* @__PURE__ */ jsx(ArrowUp, { className: "h-5 w-5" })
437
- })
479
+ })]
438
480
  })]
439
481
  });
440
482
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nextclaw/agent-chat-ui",
3
- "version": "0.3.12",
3
+ "version": "0.3.13-beta.0",
4
4
  "private": false,
5
5
  "description": "Reusable Nextclaw agent chat UI primitives and default skin.",
6
6
  "type": "module",