@molecule/app-chatbot-tester-react 1.0.0 → 1.0.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/README.md +216 -0
- package/package.json +14 -8
package/README.md
ADDED
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
AUTO-GENERATED — DO NOT EDIT THIS FILE.
|
|
3
|
+
Generated by `mlcl sync-docs` from the package's src/index.ts JSDoc + mlcl/registry.json.
|
|
4
|
+
Edits here are overwritten on the next commit (molecule's pre-commit hook regenerates).
|
|
5
|
+
To change this document, edit the module-level JSDoc in src/index.ts.
|
|
6
|
+
Generated: 2026-08-04T01:50:16.055Z
|
|
7
|
+
-->
|
|
8
|
+
|
|
9
|
+
# @molecule/app-chatbot-tester-react
|
|
10
|
+
|
|
11
|
+
> **Auto-generated, AI-first package reference** for the [molecule.dev](https://molecule.dev) ecosystem.
|
|
12
|
+
> It is written to be read by coding agents as much as by people, and is generated from this
|
|
13
|
+
> package's source — edit `src/index.ts` JSDoc, not this file.
|
|
14
|
+
|
|
15
|
+
`@molecule/app-chatbot-tester-react` — sandbox UI shell for live-testing
|
|
16
|
+
conversational AI: optional bot picker, message transcript, input row,
|
|
17
|
+
error display.
|
|
18
|
+
|
|
19
|
+
Stateless about transport. The consumer owns the message array, send
|
|
20
|
+
handler, and bot list; the package handles the layout and composition.
|
|
21
|
+
|
|
22
|
+
Extracted from the ai-chatbot-builder TestChat page; usable for any
|
|
23
|
+
"preview your bot live" UI.
|
|
24
|
+
|
|
25
|
+
## Quick Start
|
|
26
|
+
|
|
27
|
+
```tsx
|
|
28
|
+
import { ChatbotTester, type TesterMessage } from '@molecule/app-chatbot-tester-react'
|
|
29
|
+
|
|
30
|
+
const [messages, setMessages] = useState<TesterMessage[]>([])
|
|
31
|
+
const handleSend = async (text: string) => {
|
|
32
|
+
setMessages((prev) => [...prev, { id: Date.now(), role: 'user', content: text }])
|
|
33
|
+
const reply = await http.post(`/api/conversations/${conversationId}/messages`, { content: text })
|
|
34
|
+
setMessages((prev) => [...prev, { id: reply.id, role: 'assistant', content: reply.content }])
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
;<ChatbotTester
|
|
38
|
+
messages={messages}
|
|
39
|
+
onSend={handleSend}
|
|
40
|
+
loading={sending}
|
|
41
|
+
bots={bots}
|
|
42
|
+
botId={botId}
|
|
43
|
+
onBotChange={setBotId}
|
|
44
|
+
error={error}
|
|
45
|
+
/>
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Type
|
|
49
|
+
|
|
50
|
+
`feature`
|
|
51
|
+
|
|
52
|
+
## Installation
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
npm install @molecule/app-chatbot-tester-react @molecule/app-react @molecule/app-ui @molecule/app-ui-react react
|
|
56
|
+
npm install -D @types/react
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## API
|
|
60
|
+
|
|
61
|
+
### Interfaces
|
|
62
|
+
|
|
63
|
+
#### `ChatbotTesterInputProps`
|
|
64
|
+
|
|
65
|
+
Props for {@link ChatbotTesterInput}.
|
|
66
|
+
|
|
67
|
+
```typescript
|
|
68
|
+
interface ChatbotTesterInputProps {
|
|
69
|
+
value: string
|
|
70
|
+
onChange: (next: string) => void
|
|
71
|
+
onSend: () => void
|
|
72
|
+
loading?: boolean
|
|
73
|
+
placeholder?: string
|
|
74
|
+
sendLabel?: string
|
|
75
|
+
}
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
#### `ChatbotTesterMessagesProps`
|
|
79
|
+
|
|
80
|
+
Props for {@link ChatbotTesterMessages}.
|
|
81
|
+
|
|
82
|
+
```typescript
|
|
83
|
+
interface ChatbotTesterMessagesProps {
|
|
84
|
+
messages: TesterMessage[]
|
|
85
|
+
loading?: boolean
|
|
86
|
+
emptyState?: React.ReactNode
|
|
87
|
+
}
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
#### `ChatbotTesterProps`
|
|
91
|
+
|
|
92
|
+
Props for {@link ChatbotTester}.
|
|
93
|
+
|
|
94
|
+
```typescript
|
|
95
|
+
interface ChatbotTesterProps {
|
|
96
|
+
messages: TesterMessage[]
|
|
97
|
+
loading?: boolean
|
|
98
|
+
/** When provided, send invokes this with the composer text. */
|
|
99
|
+
onSend: (text: string) => void | Promise<void>
|
|
100
|
+
/** Optional bot list — when length >= 2, a picker is rendered. */
|
|
101
|
+
bots?: TesterBotOption[]
|
|
102
|
+
botId?: string
|
|
103
|
+
onBotChange?: (id: string) => void
|
|
104
|
+
/** Last error message — rendered in a `role="alert"` paragraph. */
|
|
105
|
+
error?: ReactNode
|
|
106
|
+
/** Empty-state slot when there are no messages yet. */
|
|
107
|
+
emptyState?: ReactNode
|
|
108
|
+
botPickerLabel?: ReactNode
|
|
109
|
+
inputPlaceholder?: string
|
|
110
|
+
sendLabel?: string
|
|
111
|
+
className?: string
|
|
112
|
+
}
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
#### `TesterBotOption`
|
|
116
|
+
|
|
117
|
+
A selectable bot/agent option shown in the chatbot tester sandbox UI.
|
|
118
|
+
|
|
119
|
+
```typescript
|
|
120
|
+
interface TesterBotOption {
|
|
121
|
+
id: string
|
|
122
|
+
name?: string
|
|
123
|
+
}
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
#### `TesterMessage`
|
|
127
|
+
|
|
128
|
+
A single chat message displayed in the chatbot tester sandbox UI.
|
|
129
|
+
|
|
130
|
+
```typescript
|
|
131
|
+
interface TesterMessage {
|
|
132
|
+
id: string | number
|
|
133
|
+
role: 'user' | 'assistant' | 'system'
|
|
134
|
+
content: string
|
|
135
|
+
timestamp?: string
|
|
136
|
+
}
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### Functions
|
|
140
|
+
|
|
141
|
+
#### `ChatbotTester(props)`
|
|
142
|
+
|
|
143
|
+
Full chatbot tester sandbox.
|
|
144
|
+
|
|
145
|
+
```typescript
|
|
146
|
+
function ChatbotTester({
|
|
147
|
+
messages,
|
|
148
|
+
loading,
|
|
149
|
+
onSend,
|
|
150
|
+
bots,
|
|
151
|
+
botId,
|
|
152
|
+
onBotChange,
|
|
153
|
+
error,
|
|
154
|
+
emptyState,
|
|
155
|
+
botPickerLabel = 'Test bot',
|
|
156
|
+
inputPlaceholder,
|
|
157
|
+
sendLabel,
|
|
158
|
+
className,
|
|
159
|
+
}: ChatbotTesterProps): JSX.Element
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
#### `ChatbotTesterInput(props)`
|
|
163
|
+
|
|
164
|
+
Message composer + send button.
|
|
165
|
+
|
|
166
|
+
```typescript
|
|
167
|
+
function ChatbotTesterInput({
|
|
168
|
+
value,
|
|
169
|
+
onChange,
|
|
170
|
+
onSend,
|
|
171
|
+
loading,
|
|
172
|
+
placeholder = 'Type a message…',
|
|
173
|
+
sendLabel = 'Send',
|
|
174
|
+
}: ChatbotTesterInputProps): JSX.Element
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
#### `ChatbotTesterMessages(props)`
|
|
178
|
+
|
|
179
|
+
Scrollable transcript pane.
|
|
180
|
+
|
|
181
|
+
```typescript
|
|
182
|
+
function ChatbotTesterMessages({
|
|
183
|
+
messages,
|
|
184
|
+
loading,
|
|
185
|
+
emptyState,
|
|
186
|
+
}: ChatbotTesterMessagesProps): JSX.Element
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
## Injection Notes
|
|
190
|
+
|
|
191
|
+
### Requirements
|
|
192
|
+
|
|
193
|
+
Peer dependencies:
|
|
194
|
+
|
|
195
|
+
- `@molecule/app-react` ^1.0.1
|
|
196
|
+
- `@molecule/app-ui` ^1.0.1
|
|
197
|
+
- `@molecule/app-ui-react` ^1.0.1
|
|
198
|
+
- `react` ^18.0.0 || ^19.0.0
|
|
199
|
+
|
|
200
|
+
### Runtime Dependencies
|
|
201
|
+
|
|
202
|
+
- `@molecule/app-react`
|
|
203
|
+
- `@molecule/app-ui`
|
|
204
|
+
- `@molecule/app-ui-react`
|
|
205
|
+
- `react`
|
|
206
|
+
|
|
207
|
+
Built-in labels (`botPickerLabel` default "Test bot", `inputPlaceholder`
|
|
208
|
+
default "Type a message…", `sendLabel` default "Send") are hardcoded
|
|
209
|
+
English — there is no companion locale bond. For localized apps, pass all
|
|
210
|
+
three props with `t('key', {}, { defaultValue: '…' })` values.
|
|
211
|
+
Enter sends; Shift+Enter inserts a newline. The bot picker renders only
|
|
212
|
+
when `bots` has 2+ entries. Styling includes Tailwind classes with
|
|
213
|
+
Material-3 tokens (`bg-surface-container-high`, `border-outline-variant`,
|
|
214
|
+
`text-on-primary`, …) — the app's Tailwind theme must define those tokens
|
|
215
|
+
(the default molecule Tailwind ClassMap bond does); with a non-Tailwind
|
|
216
|
+
ClassMap the bubbles/borders lose their styling.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@molecule/app-chatbot-tester-react",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "Sandbox UI for live-testing chatbots: bot picker, message thread, input area, error region. Extracted from ai-chatbot-builder TestChat.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -17,7 +17,8 @@
|
|
|
17
17
|
}
|
|
18
18
|
},
|
|
19
19
|
"files": [
|
|
20
|
-
"dist"
|
|
20
|
+
"dist",
|
|
21
|
+
"README.md"
|
|
21
22
|
],
|
|
22
23
|
"keywords": [
|
|
23
24
|
"molecule",
|
|
@@ -28,16 +29,21 @@
|
|
|
28
29
|
"react"
|
|
29
30
|
],
|
|
30
31
|
"license": "Apache-2.0",
|
|
32
|
+
"repository": {
|
|
33
|
+
"type": "git",
|
|
34
|
+
"url": "https://github.com/molecule-dev/molecule.git",
|
|
35
|
+
"directory": "packages/app/features/chatbot-tester-react"
|
|
36
|
+
},
|
|
31
37
|
"peerDependencies": {
|
|
32
|
-
"@molecule/app-react": "^1.0.
|
|
33
|
-
"@molecule/app-ui": "^1.0.
|
|
34
|
-
"@molecule/app-ui-react": "^1.0.
|
|
38
|
+
"@molecule/app-react": "^1.0.1",
|
|
39
|
+
"@molecule/app-ui": "^1.0.1",
|
|
40
|
+
"@molecule/app-ui-react": "^1.0.1",
|
|
35
41
|
"react": "^18.0.0 || ^19.0.0"
|
|
36
42
|
},
|
|
37
43
|
"devDependencies": {
|
|
38
|
-
"@molecule/app-react": "1.0.
|
|
39
|
-
"@molecule/app-ui": "1.0.
|
|
40
|
-
"@molecule/app-ui-react": "1.0.
|
|
44
|
+
"@molecule/app-react": "1.0.1",
|
|
45
|
+
"@molecule/app-ui": "1.0.1",
|
|
46
|
+
"@molecule/app-ui-react": "1.0.1",
|
|
41
47
|
"@types/node": "26.1.2",
|
|
42
48
|
"@types/react": "19.2.17",
|
|
43
49
|
"react": "19.2.8",
|