@kitnai/chat 0.1.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.
Files changed (138) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +314 -0
  3. package/dist/bash-InADTalH.js +6 -0
  4. package/dist/core-AYMC6_lb.js +5874 -0
  5. package/dist/engine-javascript-vq0WuIJl.js +2643 -0
  6. package/dist/github-dark-dimmed-DUshB20C.js +4 -0
  7. package/dist/github-light-JYsPkUQd.js +4 -0
  8. package/dist/javascript-C25yR2R2.js +6 -0
  9. package/dist/json-DxJze_jm.js +6 -0
  10. package/dist/kitn-chat.es.js +6632 -0
  11. package/dist/tsx-B8rCNbgL.js +6 -0
  12. package/dist/typescript-RycA9KXf.js +6 -0
  13. package/package.json +80 -0
  14. package/src/components/attachments.stories.tsx +304 -0
  15. package/src/components/attachments.tsx +394 -0
  16. package/src/components/chain-of-thought.stories.tsx +212 -0
  17. package/src/components/chain-of-thought.tsx +139 -0
  18. package/src/components/chat-container.stories.tsx +188 -0
  19. package/src/components/chat-container.tsx +78 -0
  20. package/src/components/chat-scope-picker.tsx +47 -0
  21. package/src/components/checkpoint.stories.tsx +103 -0
  22. package/src/components/checkpoint.tsx +81 -0
  23. package/src/components/code-block.stories.tsx +151 -0
  24. package/src/components/code-block.tsx +99 -0
  25. package/src/components/context.stories.tsx +180 -0
  26. package/src/components/context.tsx +323 -0
  27. package/src/components/conversation-item.stories.tsx +126 -0
  28. package/src/components/conversation-item.tsx +18 -0
  29. package/src/components/conversation-list.stories.tsx +134 -0
  30. package/src/components/conversation-list.tsx +100 -0
  31. package/src/components/empty.stories.tsx +435 -0
  32. package/src/components/empty.tsx +166 -0
  33. package/src/components/feedback-bar.stories.tsx +101 -0
  34. package/src/components/feedback-bar.tsx +58 -0
  35. package/src/components/file-upload.stories.tsx +157 -0
  36. package/src/components/file-upload.tsx +161 -0
  37. package/src/components/image.stories.tsx +90 -0
  38. package/src/components/image.tsx +67 -0
  39. package/src/components/loader.stories.tsx +182 -0
  40. package/src/components/loader.tsx +333 -0
  41. package/src/components/markdown.stories.tsx +181 -0
  42. package/src/components/markdown.tsx +81 -0
  43. package/src/components/message-narrow.stories.tsx +330 -0
  44. package/src/components/message-skills.stories.tsx +212 -0
  45. package/src/components/message-skills.tsx +36 -0
  46. package/src/components/message.stories.tsx +282 -0
  47. package/src/components/message.tsx +149 -0
  48. package/src/components/model-switcher.stories.tsx +98 -0
  49. package/src/components/model-switcher.tsx +36 -0
  50. package/src/components/prompt-input.stories.tsx +223 -0
  51. package/src/components/prompt-input.tsx +190 -0
  52. package/src/components/prompt-suggestion.stories.tsx +143 -0
  53. package/src/components/prompt-suggestion.tsx +115 -0
  54. package/src/components/reasoning.stories.tsx +141 -0
  55. package/src/components/reasoning.tsx +157 -0
  56. package/src/components/response-stream.tsx +103 -0
  57. package/src/components/scroll-button.stories.tsx +101 -0
  58. package/src/components/scroll-button.tsx +33 -0
  59. package/src/components/slash-command.stories.tsx +164 -0
  60. package/src/components/slash-command.tsx +223 -0
  61. package/src/components/source.stories.tsx +125 -0
  62. package/src/components/source.tsx +129 -0
  63. package/src/components/text-shimmer.stories.tsx +88 -0
  64. package/src/components/text-shimmer.tsx +37 -0
  65. package/src/components/thinking-bar.stories.tsx +88 -0
  66. package/src/components/thinking-bar.tsx +50 -0
  67. package/src/components/tool.stories.tsx +154 -0
  68. package/src/components/tool.tsx +173 -0
  69. package/src/components/voice-input.stories.tsx +84 -0
  70. package/src/components/voice-input.tsx +103 -0
  71. package/src/elements/chat-types.ts +14 -0
  72. package/src/elements/chat.tsx +111 -0
  73. package/src/elements/compiled.css +2 -0
  74. package/src/elements/conversation-list.tsx +26 -0
  75. package/src/elements/css.ts +5 -0
  76. package/src/elements/default-input.tsx +53 -0
  77. package/src/elements/define.tsx +54 -0
  78. package/src/elements/kitn-chat.stories.tsx +105 -0
  79. package/src/elements/kitn-conversation-list.stories.tsx +177 -0
  80. package/src/elements/kitn-prompt-input.stories.tsx +123 -0
  81. package/src/elements/prompt-input.tsx +39 -0
  82. package/src/elements/register.ts +9 -0
  83. package/src/elements/styles.css +12 -0
  84. package/src/index.ts +128 -0
  85. package/src/primitives/chat-config.tsx +76 -0
  86. package/src/primitives/highlighter.ts +150 -0
  87. package/src/primitives/use-auto-resize.ts +31 -0
  88. package/src/primitives/use-stick-to-bottom.ts +43 -0
  89. package/src/primitives/use-text-stream.ts +112 -0
  90. package/src/primitives/use-voice-recorder.ts +50 -0
  91. package/src/stories/chat-panel-layout.stories.tsx +144 -0
  92. package/src/stories/chat-scene.tsx +570 -0
  93. package/src/stories/checkpoint-restore.stories.tsx +224 -0
  94. package/src/stories/context-usage.stories.tsx +155 -0
  95. package/src/stories/conversation-with-reasoning.stories.tsx +151 -0
  96. package/src/stories/conversation-with-sources.stories.tsx +165 -0
  97. package/src/stories/docs/GettingStarted.mdx +76 -0
  98. package/src/stories/docs/Installation.mdx +48 -0
  99. package/src/stories/docs/Integrations.mdx +110 -0
  100. package/src/stories/docs/Introduction.mdx +29 -0
  101. package/src/stories/docs/Theming.mdx +87 -0
  102. package/src/stories/docs/theme-editor/canvas.tsx +32 -0
  103. package/src/stories/docs/theme-editor/inspector.tsx +66 -0
  104. package/src/stories/docs/theme-editor/presets.test.ts +32 -0
  105. package/src/stories/docs/theme-editor/presets.ts +64 -0
  106. package/src/stories/docs/theme-editor/theme-css.test.ts +19 -0
  107. package/src/stories/docs/theme-editor/theme-css.ts +15 -0
  108. package/src/stories/docs/theme-editor/theme-editor.tsx +145 -0
  109. package/src/stories/docs/theme-tokens.tsx +174 -0
  110. package/src/stories/full-chat.stories.tsx +18 -0
  111. package/src/stories/message-actions.stories.tsx +167 -0
  112. package/src/stories/prompt-input-variants.stories.tsx +179 -0
  113. package/src/stories/streaming-response.stories.tsx +234 -0
  114. package/src/stories/theme-editor.stories.tsx +16 -0
  115. package/src/stories/token-reference.stories.tsx +18 -0
  116. package/src/types.ts +41 -0
  117. package/src/ui/avatar.stories.tsx +104 -0
  118. package/src/ui/avatar.tsx +23 -0
  119. package/src/ui/badge.stories.tsx +87 -0
  120. package/src/ui/badge.tsx +21 -0
  121. package/src/ui/button.stories.tsx +146 -0
  122. package/src/ui/button.tsx +37 -0
  123. package/src/ui/collapsible.tsx +14 -0
  124. package/src/ui/dialog.tsx +21 -0
  125. package/src/ui/dropdown.tsx +26 -0
  126. package/src/ui/hover-card.tsx +48 -0
  127. package/src/ui/resizable.stories.tsx +171 -0
  128. package/src/ui/resizable.tsx +219 -0
  129. package/src/ui/scroll-area.tsx +13 -0
  130. package/src/ui/separator.stories.tsx +82 -0
  131. package/src/ui/separator.tsx +10 -0
  132. package/src/ui/skeleton.stories.tsx +338 -0
  133. package/src/ui/skeleton.tsx +16 -0
  134. package/src/ui/textarea.tsx +21 -0
  135. package/src/ui/tooltip.stories.tsx +75 -0
  136. package/src/ui/tooltip.tsx +22 -0
  137. package/src/utils/cn.ts +6 -0
  138. package/theme.css +115 -0
@@ -0,0 +1,570 @@
1
+ import { createSignal, Show, For } from "solid-js";
2
+ import {
3
+ ChatContainer,
4
+ ChatContainerContent,
5
+ ChatContainerScrollAnchor,
6
+ Message,
7
+ MessageAvatar,
8
+ MessageContent,
9
+ MessageActions,
10
+ PromptInput,
11
+ PromptInputTextarea,
12
+ PromptInputActions,
13
+ ConversationList,
14
+ ModelSwitcher,
15
+ PromptSuggestion,
16
+ ScrollButton,
17
+ Button,
18
+ Separator,
19
+ Context,
20
+ ContextTrigger,
21
+ ContextContent,
22
+ ContextContentHeader,
23
+ ContextContentBody,
24
+ ContextContentFooter,
25
+ ContextInputUsage,
26
+ ContextOutputUsage,
27
+ Reasoning,
28
+ ReasoningTrigger,
29
+ ReasoningContent,
30
+ Tool,
31
+ ThinkingBar,
32
+ ChatConfig,
33
+ } from "../index";
34
+ import type { ProseSize } from "../index";
35
+ import type {
36
+ ConversationSummary,
37
+ ConversationGroup,
38
+ ModelOption,
39
+ } from "../types";
40
+ import {
41
+ Attachments,
42
+ Attachment,
43
+ AttachmentPreview,
44
+ AttachmentInfo,
45
+ AttachmentRemove,
46
+ } from "../components/attachments";
47
+ import type { AttachmentData } from "../components/attachments";
48
+ import { ResizablePanelGroup, ResizablePanel, ResizableHandle } from "../ui/resizable";
49
+ import {
50
+ Copy,
51
+ ThumbsUp,
52
+ ThumbsDown,
53
+ RefreshCw,
54
+ ArrowUp,
55
+ Paperclip,
56
+ Globe,
57
+ Mic,
58
+ Pencil,
59
+ Trash,
60
+ Plus,
61
+ MoreHorizontal,
62
+ } from "lucide-solid";
63
+
64
+ const scope = { type: "document" as const };
65
+
66
+ const groups: ConversationGroup[] = [
67
+ { id: "today", name: "Today", sortOrder: 0, createdAt: "2026-04-10" },
68
+ { id: "yesterday", name: "Yesterday", sortOrder: 1, createdAt: "2026-04-09" },
69
+ {
70
+ id: "week",
71
+ name: "Previous 7 Days",
72
+ sortOrder: 2,
73
+ createdAt: "2026-04-05",
74
+ },
75
+ ];
76
+
77
+ const conversations: ConversationSummary[] = [
78
+ {
79
+ id: "1",
80
+ title: "SolidJS reactivity vs React hooks",
81
+ groupId: "today",
82
+ scope,
83
+ messageCount: 8,
84
+ lastMessageAt: "2026-04-10T15:30:00Z",
85
+ updatedAt: "2026-04-10T15:30:00Z",
86
+ },
87
+ {
88
+ id: "2",
89
+ title: "Tailwind v4 migration guide",
90
+ groupId: "today",
91
+ scope,
92
+ messageCount: 14,
93
+ lastMessageAt: "2026-04-10T11:20:00Z",
94
+ updatedAt: "2026-04-10T11:20:00Z",
95
+ },
96
+ {
97
+ id: "3",
98
+ title: "Chrome extension content scripts",
99
+ groupId: "today",
100
+ scope,
101
+ messageCount: 6,
102
+ lastMessageAt: "2026-04-10T09:00:00Z",
103
+ updatedAt: "2026-04-10T09:00:00Z",
104
+ },
105
+ {
106
+ id: "4",
107
+ title: "Vite HMR not working with web workers",
108
+ groupId: "yesterday",
109
+ scope,
110
+ messageCount: 11,
111
+ lastMessageAt: "2026-04-09T17:45:00Z",
112
+ updatedAt: "2026-04-09T17:45:00Z",
113
+ },
114
+ {
115
+ id: "5",
116
+ title: "IndexedDB vs OPFS performance",
117
+ groupId: "yesterday",
118
+ scope,
119
+ messageCount: 9,
120
+ lastMessageAt: "2026-04-09T14:00:00Z",
121
+ updatedAt: "2026-04-09T14:00:00Z",
122
+ },
123
+ {
124
+ id: "6",
125
+ title: "WebSocket reconnection strategies",
126
+ groupId: "week",
127
+ scope,
128
+ messageCount: 7,
129
+ lastMessageAt: "2026-04-07T10:30:00Z",
130
+ updatedAt: "2026-04-07T10:30:00Z",
131
+ },
132
+ {
133
+ id: "7",
134
+ title: "TypeScript discriminated unions",
135
+ groupId: "week",
136
+ scope,
137
+ messageCount: 16,
138
+ lastMessageAt: "2026-04-06T16:20:00Z",
139
+ updatedAt: "2026-04-06T16:20:00Z",
140
+ },
141
+ {
142
+ id: "8",
143
+ title: "CSS container queries",
144
+ groupId: "week",
145
+ scope,
146
+ messageCount: 5,
147
+ lastMessageAt: "2026-04-05T13:00:00Z",
148
+ updatedAt: "2026-04-05T13:00:00Z",
149
+ },
150
+ ];
151
+
152
+ const models: ModelOption[] = [
153
+ { id: "claude-4", name: "Claude 4 Opus", provider: "Anthropic" },
154
+ { id: "claude-4-sonnet", name: "Claude 4 Sonnet", provider: "Anthropic" },
155
+ { id: "gpt-4o", name: "GPT-4o", provider: "OpenAI" },
156
+ ];
157
+
158
+ const assistantResponse1 = `**SolidJS** takes a fundamentally different approach to reactivity compared to React hooks.
159
+
160
+ ### Signals vs useState
161
+
162
+ In SolidJS, signals are **fine-grained reactive primitives** that track their own subscribers. When a signal updates, only the specific DOM nodes that read that signal are updated — no virtual DOM diffing required.
163
+
164
+ \`\`\`typescript
165
+ // SolidJS — runs once, DOM updates surgically
166
+ const [count, setCount] = createSignal(0);
167
+ return <p>{count()}</p>; // only this text node re-renders
168
+
169
+ // React — entire component re-renders
170
+ const [count, setCount] = useState(0);
171
+ return <p>{count}</p>; // whole function re-executes
172
+ \`\`\`
173
+
174
+ ### Key Differences
175
+
176
+ 1. **No re-renders** — SolidJS components run once; only reactive expressions update
177
+ 2. **No dependency arrays** — \`createEffect\` auto-tracks dependencies
178
+ 3. **No stale closures** — signals are getter functions, always current
179
+ 4. **Derived values** are just functions, no \`useMemo\` needed
180
+
181
+ ### When to choose SolidJS
182
+
183
+ - Performance-critical UIs with frequent updates
184
+ - Projects where you want predictable reactivity
185
+ - When you're tired of \`useCallback\` and dependency arrays`;
186
+
187
+ const assistantResponse2 = `\`createEffect\` in SolidJS is synchronous by default and automatically tracks all reactive dependencies read inside it — no dependency array needed.
188
+
189
+ \`\`\`typescript
190
+ // SolidJS — auto-tracks count and name
191
+ createEffect(() => {
192
+ console.log(count(), name());
193
+ });
194
+
195
+ // React — must manually declare deps
196
+ useEffect(() => {
197
+ console.log(count, name);
198
+ }, [count, name]); // easy to get wrong
199
+ \`\`\`
200
+
201
+ The biggest win: **no stale closure bugs**. Since \`count()\` is a function call, you always get the latest value. In React, closures capture the value at render time, which leads to subtle bugs with intervals, timeouts, and event handlers.`;
202
+
203
+ /** The full chat application scene, shared by the Full Chat App story and the
204
+ * theme editor's live preview. `class` controls the root sizing (defaults to
205
+ * full-viewport; the editor passes `h-full` to fit its canvas). */
206
+ export function ChatScene(props: { class?: string }) {
207
+ const [activeId, setActiveId] = createSignal("1");
208
+ const [modelId, setModelId] = createSignal("claude-4");
209
+ const [inputValue, setInputValue] = createSignal("");
210
+ const [proseSize, setProseSize] = createSignal<ProseSize>("base");
211
+ const [attachedFiles, setAttachedFiles] = createSignal<AttachmentData[]>([
212
+ {
213
+ id: 'att-1',
214
+ type: 'file',
215
+ filename: 'benchmark-results.pdf',
216
+ mediaType: 'application/pdf',
217
+ },
218
+ {
219
+ id: 'att-2',
220
+ type: 'file',
221
+ filename: 'solid-vs-react.png',
222
+ mediaType: 'image/png',
223
+ url: 'https://images.unsplash.com/photo-1555949963-aa79dcee981c?w=400&h=400&fit=crop',
224
+ },
225
+ {
226
+ id: 'att-3',
227
+ type: 'source-document',
228
+ filename: 'SolidJS Docs',
229
+ title: 'SolidJS Reactivity',
230
+ url: 'https://solidjs.com/docs',
231
+ },
232
+ ]);
233
+
234
+ return (
235
+ <ChatConfig proseSize={proseSize()}>
236
+ <div class={`${props.class ?? "h-screen"} w-full bg-background overflow-hidden`}>
237
+ <ResizablePanelGroup orientation="horizontal">
238
+ {/* Sidebar */}
239
+ <ResizablePanel defaultSize={20} data-min-size="180" data-max-size="400">
240
+ <ConversationList
241
+ groups={groups}
242
+ conversations={conversations}
243
+ activeId={activeId()}
244
+ onSelect={setActiveId}
245
+ onNewChat={() => {}}
246
+ />
247
+ </ResizablePanel>
248
+ <ResizableHandle withHandle />
249
+ {/* Main Chat Area */}
250
+ <ResizablePanel>
251
+ <main class="flex flex-1 flex-col overflow-hidden h-full">
252
+ {/* Header */}
253
+ <header class="flex h-14 shrink-0 items-center justify-between border-b border-border px-5">
254
+ <div class="text-sm font-semibold text-foreground">
255
+ SolidJS reactivity vs React hooks
256
+ </div>
257
+ <div class="flex items-center gap-2">
258
+ <select
259
+ class="bg-muted/40 text-xs text-muted-foreground rounded-lg px-2 py-1.5 outline-none hover:bg-muted/60 transition-colors cursor-pointer"
260
+ value={proseSize()}
261
+ onChange={(e) => setProseSize(e.currentTarget.value as ProseSize)}
262
+ >
263
+ <option value="xs">Extra Small</option>
264
+ <option value="sm">Small</option>
265
+ <option value="base">Medium</option>
266
+ <option value="lg">Large</option>
267
+ </select>
268
+ <ModelSwitcher
269
+ models={models}
270
+ currentModelId={modelId()}
271
+ onModelChange={setModelId}
272
+ />
273
+ <Context
274
+ usedTokens={12400}
275
+ maxTokens={200000}
276
+ inputTokens={8200}
277
+ outputTokens={4200}
278
+ estimatedCost={0.042}
279
+ >
280
+ <ContextTrigger />
281
+ <ContextContent>
282
+ <ContextContentHeader />
283
+ <ContextContentBody>
284
+ <div class="space-y-1.5">
285
+ <ContextInputUsage />
286
+ <ContextOutputUsage />
287
+ </div>
288
+ </ContextContentBody>
289
+ <ContextContentFooter />
290
+ </ContextContent>
291
+ </Context>
292
+ </div>
293
+ </header>
294
+
295
+ {/* Chat Messages — scrollable */}
296
+ <div class="relative flex-1 overflow-y-auto">
297
+ <ChatContainer class="h-full">
298
+ <ChatContainerContent class="space-y-0 px-5 pt-4 pb-12">
299
+ {/* User message 1 */}
300
+ <Message class="mx-auto flex w-full max-w-3xl flex-col gap-2 px-6 items-end">
301
+ <div class="group flex flex-col items-end gap-1">
302
+ <MessageContent class="bg-muted text-primary max-w-[85%] rounded-3xl px-5 py-2.5">
303
+ Can you explain how SolidJS reactivity differs from React
304
+ hooks? I keep hearing that SolidJS is faster but I don't
305
+ understand why.
306
+ </MessageContent>
307
+ <MessageActions class="flex gap-0 opacity-0 transition-opacity duration-150 group-hover:opacity-100">
308
+ <Button variant="ghost" size="icon-sm" class="rounded-full">
309
+ <Pencil class="size-3.5" />
310
+ </Button>
311
+ <Button variant="ghost" size="icon-sm" class="rounded-full">
312
+ <Copy class="size-3.5" />
313
+ </Button>
314
+ </MessageActions>
315
+ </div>
316
+ </Message>
317
+
318
+ {/* Assistant message 1 */}
319
+ <Message class="mx-auto flex w-full max-w-3xl flex-col gap-2 px-6 items-start">
320
+ <div class="group flex w-full flex-col gap-0">
321
+ <MessageContent
322
+ markdown
323
+ class="text-foreground prose flex-1 rounded-lg bg-transparent p-0"
324
+ >
325
+ {assistantResponse1}
326
+ </MessageContent>
327
+ <MessageActions class="-ml-2.5 flex gap-0 opacity-0 transition-opacity duration-150 group-hover:opacity-100">
328
+ <Button variant="ghost" size="icon-sm" class="rounded-full">
329
+ <Copy class="size-3.5" />
330
+ </Button>
331
+ <Button variant="ghost" size="icon-sm" class="rounded-full">
332
+ <ThumbsUp class="size-3.5" />
333
+ </Button>
334
+ <Button variant="ghost" size="icon-sm" class="rounded-full">
335
+ <ThumbsDown class="size-3.5" />
336
+ </Button>
337
+ <Button variant="ghost" size="icon-sm" class="rounded-full">
338
+ <RefreshCw class="size-3.5" />
339
+ </Button>
340
+ </MessageActions>
341
+ </div>
342
+ </Message>
343
+
344
+ {/* User message 2 */}
345
+ <Message class="mx-auto flex w-full max-w-3xl flex-col gap-2 px-6 items-end">
346
+ <div class="group flex flex-col items-end gap-1">
347
+ <MessageContent class="bg-muted text-primary max-w-[85%] rounded-3xl px-5 py-2.5">
348
+ What about effects? How does createEffect compare to
349
+ useEffect?
350
+ </MessageContent>
351
+ <MessageActions class="flex gap-0 opacity-0 transition-opacity duration-150 group-hover:opacity-100">
352
+ <Button variant="ghost" size="icon-sm" class="rounded-full">
353
+ <Pencil class="size-3.5" />
354
+ </Button>
355
+ <Button variant="ghost" size="icon-sm" class="rounded-full">
356
+ <Copy class="size-3.5" />
357
+ </Button>
358
+ </MessageActions>
359
+ </div>
360
+ </Message>
361
+
362
+ {/* Assistant message 2 — last message, actions always visible */}
363
+ <Message class="mx-auto flex w-full max-w-3xl flex-col gap-2 px-6 items-start">
364
+ <div class="group flex w-full flex-col gap-0">
365
+ <MessageContent
366
+ markdown
367
+ class="text-foreground prose flex-1 rounded-lg bg-transparent p-0"
368
+ >
369
+ {assistantResponse2}
370
+ </MessageContent>
371
+ <MessageActions class="-ml-2.5 flex gap-0">
372
+ <Button variant="ghost" size="icon-sm" class="rounded-full">
373
+ <Copy class="size-3.5" />
374
+ </Button>
375
+ <Button variant="ghost" size="icon-sm" class="rounded-full">
376
+ <ThumbsUp class="size-3.5" />
377
+ </Button>
378
+ <Button variant="ghost" size="icon-sm" class="rounded-full">
379
+ <ThumbsDown class="size-3.5" />
380
+ </Button>
381
+ <Button variant="ghost" size="icon-sm" class="rounded-full">
382
+ <RefreshCw class="size-3.5" />
383
+ </Button>
384
+ </MessageActions>
385
+ </div>
386
+ </Message>
387
+
388
+ {/* User message 3 */}
389
+ <Message class="mx-auto flex w-full max-w-3xl flex-col gap-2 px-6 items-end">
390
+ <div class="group flex flex-col items-end gap-1">
391
+ <MessageContent class="bg-muted text-primary max-w-[85%] rounded-3xl px-5 py-2.5">
392
+ Can you benchmark SolidJS vs React for a list of 10,000 items?
393
+ </MessageContent>
394
+ </div>
395
+ </Message>
396
+
397
+ {/* Assistant message 3 — with reasoning + tool call */}
398
+ <Message class="mx-auto flex w-full max-w-3xl flex-col gap-2 px-6 items-start">
399
+ <div class="group flex w-full flex-col gap-0">
400
+ {/* Reasoning block */}
401
+ <Reasoning class="mb-3">
402
+ <ReasoningTrigger class="text-sm">
403
+ Thought for 4 seconds
404
+ </ReasoningTrigger>
405
+ <ReasoningContent markdown class="mt-1">
406
+ {`I need to create a fair benchmark comparing SolidJS and React rendering performance. Let me think about the approach:
407
+
408
+ - Both frameworks should render the same list of 10,000 items
409
+ - I should measure initial render time and update performance
410
+ - Need to use \`performance.now()\` for accurate timing
411
+ - SolidJS should be significantly faster due to fine-grained reactivity`}
412
+ </ReasoningContent>
413
+ </Reasoning>
414
+
415
+ {/* Tool call */}
416
+ <Tool
417
+ toolPart={{
418
+ type: "run_benchmark",
419
+ state: "output-available",
420
+ input: {
421
+ framework: ["solid", "react"],
422
+ itemCount: 10000,
423
+ iterations: 5,
424
+ },
425
+ output: {
426
+ solid: { avgRenderMs: 12.4, avgUpdateMs: 0.8 },
427
+ react: { avgRenderMs: 89.2, avgUpdateMs: 34.1 },
428
+ },
429
+ toolCallId: "call_abc123",
430
+ }}
431
+ class="mb-3"
432
+ />
433
+
434
+ <MessageContent
435
+ markdown
436
+ class="text-foreground prose flex-1 rounded-lg bg-transparent p-0"
437
+ >
438
+ {`Here are the benchmark results for rendering 10,000 list items:
439
+
440
+ | Metric | SolidJS | React | Difference |
441
+ |--------|---------|-------|-----------|
442
+ | Initial render | 12.4ms | 89.2ms | **7.2x faster** |
443
+ | Single item update | 0.8ms | 34.1ms | **42.6x faster** |
444
+
445
+ SolidJS's fine-grained reactivity really shines here — updating a single item in React triggers a full virtual DOM diff of all 10,000 items, while SolidJS surgically updates only the changed DOM node.`}
446
+ </MessageContent>
447
+ <MessageActions class="-ml-2.5 flex gap-0">
448
+ <Button variant="ghost" size="icon-sm" class="rounded-full">
449
+ <Copy class="size-3.5" />
450
+ </Button>
451
+ <Button variant="ghost" size="icon-sm" class="rounded-full">
452
+ <ThumbsUp class="size-3.5" />
453
+ </Button>
454
+ <Button variant="ghost" size="icon-sm" class="rounded-full">
455
+ <ThumbsDown class="size-3.5" />
456
+ </Button>
457
+ <Button variant="ghost" size="icon-sm" class="rounded-full">
458
+ <RefreshCw class="size-3.5" />
459
+ </Button>
460
+ </MessageActions>
461
+ </div>
462
+ </Message>
463
+
464
+ <ChatContainerScrollAnchor />
465
+ </ChatContainerContent>
466
+
467
+ {/* Scroll button */}
468
+ <div class="absolute bottom-4 left-1/2 flex w-full max-w-3xl -translate-x-1/2 justify-center px-5">
469
+ <ScrollButton class="shadow-sm" />
470
+ </div>
471
+ </ChatContainer>
472
+ </div>
473
+
474
+ {/* Input area — pinned to bottom */}
475
+ <div class="shrink-0 bg-background px-3 pb-3 md:px-5 md:pb-5">
476
+ <div class="mx-auto max-w-3xl">
477
+ {/* Suggestions */}
478
+ <div class="flex gap-2 pb-3 flex-wrap">
479
+ <PromptSuggestion
480
+ onClick={() =>
481
+ setInputValue("How does SolidJS handle context?")
482
+ }
483
+ >
484
+ How does SolidJS handle context?
485
+ </PromptSuggestion>
486
+ <PromptSuggestion
487
+ onClick={() =>
488
+ setInputValue("Show me a SolidJS store example")
489
+ }
490
+ >
491
+ Show me a store example
492
+ </PromptSuggestion>
493
+ <PromptSuggestion
494
+ onClick={() => setInputValue("SolidJS vs Svelte comparison")}
495
+ >
496
+ SolidJS vs Svelte comparison
497
+ </PromptSuggestion>
498
+ </div>
499
+
500
+ {/* Input */}
501
+ <PromptInput
502
+ value={inputValue()}
503
+ onValueChange={setInputValue}
504
+ onSubmit={() => setInputValue("")}
505
+ >
506
+ <div class="flex flex-col">
507
+ {/* Attached files — inside the input container */}
508
+ <Show when={attachedFiles().length > 0}>
509
+ <div class="px-3 pt-3">
510
+ <Attachments variant="inline">
511
+ <For each={attachedFiles()}>
512
+ {(file) => (
513
+ <Attachment
514
+ data={file}
515
+ onRemove={() =>
516
+ setAttachedFiles((prev) =>
517
+ prev.filter((f) => f.id !== file.id)
518
+ )
519
+ }
520
+ >
521
+ <AttachmentPreview />
522
+ <AttachmentInfo />
523
+ <AttachmentRemove />
524
+ </Attachment>
525
+ )}
526
+ </For>
527
+ </Attachments>
528
+ </div>
529
+ </Show>
530
+ <PromptInputTextarea
531
+ placeholder="Ask anything..."
532
+ class="min-h-[44px] pt-3 pl-4"
533
+ />
534
+ <PromptInputActions class="mt-2 flex w-full items-center justify-between gap-2 px-3 pb-3">
535
+ <div class="flex items-center gap-2">
536
+ <Button variant="outline" size="icon-sm" class="rounded-full">
537
+ <Plus class="size-4" />
538
+ </Button>
539
+ <Button variant="outline" size="sm" class="rounded-full gap-1">
540
+ <Globe class="size-4" />
541
+ Search
542
+ </Button>
543
+ <Button variant="outline" size="icon-sm" class="rounded-full">
544
+ <MoreHorizontal class="size-4" />
545
+ </Button>
546
+ </div>
547
+ <div class="flex items-center gap-2">
548
+ <Button variant="outline" size="icon-sm" class="rounded-full">
549
+ <Mic class="size-4" />
550
+ </Button>
551
+ <Button
552
+ size="icon-sm"
553
+ class="rounded-full"
554
+ disabled={!inputValue().trim()}
555
+ >
556
+ <ArrowUp class="size-4" />
557
+ </Button>
558
+ </div>
559
+ </PromptInputActions>
560
+ </div>
561
+ </PromptInput>
562
+ </div>
563
+ </div>
564
+ </main>
565
+ </ResizablePanel>
566
+ </ResizablePanelGroup>
567
+ </div>
568
+ </ChatConfig>
569
+ );
570
+ }