@nextclaw/agent-chat-ui 0.1.1

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 NextClaw contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,52 @@
1
+ # @nextclaw/agent-chat-ui
2
+
3
+ Reusable Nextclaw agent chat UI package.
4
+
5
+ This package contains the reusable chat presentation layer extracted from `@nextclaw/ui`:
6
+
7
+ - chat input bar components
8
+ - chat message list components
9
+ - chat view-model types
10
+ - chat-local hooks and utilities
11
+ - default skin primitives used by the chat package itself
12
+
13
+ It intentionally does not include Nextclaw host wiring such as presenter/store access, runtime adapters, page shells, or product-specific business logic.
14
+
15
+ ## Install
16
+
17
+ ```bash
18
+ npm i @nextclaw/agent-chat-ui
19
+ ```
20
+
21
+ ## Development
22
+
23
+ ```bash
24
+ pnpm -C packages/nextclaw-agent-chat-ui tsc
25
+ pnpm -C packages/nextclaw-agent-chat-ui test
26
+ pnpm -C packages/nextclaw-agent-chat-ui build
27
+ ```
28
+
29
+ ## Public API
30
+
31
+ ```ts
32
+ import {
33
+ ChatInputBar,
34
+ ChatMessageList,
35
+ useStickyBottomScroll,
36
+ useCopyFeedback,
37
+ copyText,
38
+ type ChatInputBarProps,
39
+ type ChatMessageListProps
40
+ } from '@nextclaw/agent-chat-ui';
41
+ ```
42
+
43
+ ## Scope
44
+
45
+ - Reusable: presentation, local interaction hooks, UI-owned utils, view-model contracts
46
+ - Not included: Nextclaw containers, adapters to runtime/store types, presenter wiring, page-level chat panels
47
+
48
+ ## Links
49
+
50
+ - Repository: https://github.com/Peiiii/nextclaw
51
+ - Package source: https://github.com/Peiiii/nextclaw/tree/master/packages/nextclaw-agent-chat-ui
52
+ - Product docs: https://docs.nextclaw.io
@@ -0,0 +1,212 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { KeyboardEventHandler, RefObject } from 'react';
3
+
4
+ type ChatTexts = {
5
+ slashLoadingLabel: string;
6
+ slashSectionLabel: string;
7
+ slashEmptyLabel: string;
8
+ slashHintLabel: string;
9
+ slashSkillHintLabel: string;
10
+ sendButtonLabel: string;
11
+ stopButtonLabel: string;
12
+ };
13
+ type ChatSlashItem = {
14
+ key: string;
15
+ title: string;
16
+ subtitle: string;
17
+ description: string;
18
+ detailLines: string[];
19
+ value?: string;
20
+ };
21
+ type ChatSelectedItem = {
22
+ key: string;
23
+ label: string;
24
+ };
25
+ type ChatToolbarIcon = 'sparkles' | 'brain';
26
+ type ChatToolbarAccessoryIcon = ChatToolbarIcon | 'paperclip';
27
+ type ChatToolbarSelectOption = {
28
+ value: string;
29
+ label: string;
30
+ description?: string;
31
+ };
32
+ type ChatToolbarSelect = {
33
+ key: string;
34
+ value?: string;
35
+ placeholder: string;
36
+ selectedLabel?: string;
37
+ icon?: ChatToolbarIcon;
38
+ options: ChatToolbarSelectOption[];
39
+ disabled?: boolean;
40
+ loading?: boolean;
41
+ emptyLabel?: string;
42
+ onValueChange: (value: string) => void;
43
+ };
44
+ type ChatToolbarAccessory = {
45
+ key: string;
46
+ label: string;
47
+ icon?: ChatToolbarAccessoryIcon;
48
+ disabled?: boolean;
49
+ tooltip?: string;
50
+ onClick?: () => void;
51
+ };
52
+ type ChatSkillPickerOption = {
53
+ key: string;
54
+ label: string;
55
+ description?: string;
56
+ badgeLabel?: string;
57
+ };
58
+ type ChatSkillPickerProps = {
59
+ title: string;
60
+ searchPlaceholder: string;
61
+ emptyLabel: string;
62
+ loadingLabel: string;
63
+ isLoading?: boolean;
64
+ manageLabel?: string;
65
+ manageHref?: string;
66
+ options: ChatSkillPickerOption[];
67
+ selectedKeys: string[];
68
+ onSelectedKeysChange: (next: string[]) => void;
69
+ };
70
+ type ChatInputBarActionsProps = {
71
+ sendError?: string | null;
72
+ isSending: boolean;
73
+ canStopGeneration: boolean;
74
+ sendDisabled: boolean;
75
+ stopDisabled: boolean;
76
+ stopHint: string;
77
+ sendButtonLabel: string;
78
+ stopButtonLabel: string;
79
+ onSend: () => Promise<void> | void;
80
+ onStop: () => Promise<void> | void;
81
+ };
82
+ type ChatInputBarToolbarProps = {
83
+ selects: ChatToolbarSelect[];
84
+ accessories?: ChatToolbarAccessory[];
85
+ skillPicker?: ChatSkillPickerProps | null;
86
+ actions: ChatInputBarActionsProps;
87
+ };
88
+ type ChatInlineHint = {
89
+ tone: 'neutral' | 'warning';
90
+ loading?: boolean;
91
+ text?: string;
92
+ actionLabel?: string;
93
+ onAction?: () => void;
94
+ };
95
+ type ChatSlashMenuProps = {
96
+ isOpen: boolean;
97
+ isLoading: boolean;
98
+ items: ChatSlashItem[];
99
+ activeIndex: number;
100
+ activeItem: ChatSlashItem | null;
101
+ texts: Pick<ChatTexts, 'slashLoadingLabel' | 'slashSectionLabel' | 'slashEmptyLabel' | 'slashHintLabel' | 'slashSkillHintLabel'>;
102
+ onSelectItem: (item: ChatSlashItem) => void;
103
+ onOpenChange: (open: boolean) => void;
104
+ onSetActiveIndex: (index: number) => void;
105
+ };
106
+ type ChatInputBarProps = {
107
+ value: string;
108
+ placeholder: string;
109
+ disabled: boolean;
110
+ onValueChange: (value: string) => void;
111
+ onKeyDown: KeyboardEventHandler<HTMLTextAreaElement>;
112
+ slashMenu: ChatSlashMenuProps;
113
+ hint?: ChatInlineHint | null;
114
+ selectedItems: {
115
+ items: ChatSelectedItem[];
116
+ onRemove: (key: string) => void;
117
+ };
118
+ toolbar: ChatInputBarToolbarProps;
119
+ };
120
+ type ChatMessageRole = 'user' | 'assistant' | 'tool' | 'system' | 'message';
121
+ type ChatToolPartViewModel = {
122
+ kind: 'call' | 'result';
123
+ toolName: string;
124
+ summary?: string;
125
+ output?: string;
126
+ hasResult: boolean;
127
+ titleLabel: string;
128
+ outputLabel: string;
129
+ emptyLabel: string;
130
+ };
131
+ type ChatMessagePartViewModel = {
132
+ type: 'markdown';
133
+ text: string;
134
+ } | {
135
+ type: 'reasoning';
136
+ text: string;
137
+ label: string;
138
+ } | {
139
+ type: 'tool-card';
140
+ card: ChatToolPartViewModel;
141
+ } | {
142
+ type: 'unknown';
143
+ label: string;
144
+ rawType: string;
145
+ text?: string;
146
+ };
147
+ type ChatMessageViewModel = {
148
+ id: string;
149
+ role: ChatMessageRole;
150
+ roleLabel: string;
151
+ timestampLabel: string;
152
+ parts: ChatMessagePartViewModel[];
153
+ status?: string;
154
+ };
155
+ type ChatMessageTexts = {
156
+ copyCodeLabel: string;
157
+ copiedCodeLabel: string;
158
+ typingLabel: string;
159
+ };
160
+ type ChatMessageListProps = {
161
+ messages: ChatMessageViewModel[];
162
+ isSending: boolean;
163
+ hasStreamingDraft: boolean;
164
+ texts: ChatMessageTexts;
165
+ className?: string;
166
+ };
167
+
168
+ declare function ChatInputBar(props: ChatInputBarProps): react_jsx_runtime.JSX.Element;
169
+
170
+ declare function ChatMessageList(props: ChatMessageListProps): react_jsx_runtime.JSX.Element;
171
+
172
+ type UseActiveItemScrollParams = {
173
+ containerRef: RefObject<HTMLElement>;
174
+ activeIndex: number;
175
+ itemCount: number;
176
+ isEnabled: boolean;
177
+ getItemSelector?: (index: number) => string;
178
+ };
179
+ declare function useActiveItemScroll(params: UseActiveItemScrollParams): void;
180
+
181
+ type UseCopyFeedbackParams = {
182
+ text: string;
183
+ resetDelayMs?: number;
184
+ };
185
+ type UseCopyFeedbackResult = {
186
+ copied: boolean;
187
+ copy: () => Promise<void>;
188
+ };
189
+ declare function useCopyFeedback(params: UseCopyFeedbackParams): UseCopyFeedbackResult;
190
+
191
+ type UseElementWidthResult<T extends HTMLElement> = {
192
+ elementRef: RefObject<T>;
193
+ width: number | null;
194
+ };
195
+ declare function useElementWidth<T extends HTMLElement>(): UseElementWidthResult<T>;
196
+
197
+ type UseStickyBottomScrollParams = {
198
+ scrollRef: RefObject<HTMLElement>;
199
+ resetKey: string | null;
200
+ isLoading: boolean;
201
+ hasContent: boolean;
202
+ contentVersion: unknown;
203
+ stickyThresholdPx?: number;
204
+ };
205
+ type UseStickyBottomScrollResult = {
206
+ onScroll: () => void;
207
+ };
208
+ declare function useStickyBottomScroll(params: UseStickyBottomScrollParams): UseStickyBottomScrollResult;
209
+
210
+ declare function copyText(text: string): Promise<boolean>;
211
+
212
+ export { type ChatInlineHint, ChatInputBar, type ChatInputBarActionsProps, type ChatInputBarProps, type ChatInputBarToolbarProps, ChatMessageList, type ChatMessageListProps, type ChatMessagePartViewModel, type ChatMessageRole, type ChatMessageTexts, type ChatMessageViewModel, type ChatSelectedItem, type ChatSkillPickerOption, type ChatSkillPickerProps, type ChatSlashItem, type ChatSlashMenuProps, type ChatTexts, type ChatToolPartViewModel, type ChatToolbarAccessory, type ChatToolbarAccessoryIcon, type ChatToolbarIcon, type ChatToolbarSelect, type ChatToolbarSelectOption, copyText, useActiveItemScroll, useCopyFeedback, useElementWidth, useStickyBottomScroll };