@sveda-ai/solid 0.3.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.
Files changed (69) hide show
  1. package/LICENSE +557 -0
  2. package/README.md +18 -0
  3. package/dist/appearance.d.ts +9 -0
  4. package/dist/appearance.d.ts.map +1 -0
  5. package/dist/components/SvedaChat.d.ts +16 -0
  6. package/dist/components/SvedaChat.d.ts.map +1 -0
  7. package/dist/components/SvedaComposer.d.ts +17 -0
  8. package/dist/components/SvedaComposer.d.ts.map +1 -0
  9. package/dist/components/SvedaMessageList.d.ts +11 -0
  10. package/dist/components/SvedaMessageList.d.ts.map +1 -0
  11. package/dist/components/SvedaMinimizedTrigger.d.ts +10 -0
  12. package/dist/components/SvedaMinimizedTrigger.d.ts.map +1 -0
  13. package/dist/components/SvedaQuickPrompts.d.ts +14 -0
  14. package/dist/components/SvedaQuickPrompts.d.ts.map +1 -0
  15. package/dist/components/SvedaTabs.d.ts +14 -0
  16. package/dist/components/SvedaTabs.d.ts.map +1 -0
  17. package/dist/components/SvedaToolbar.d.ts +21 -0
  18. package/dist/components/SvedaToolbar.d.ts.map +1 -0
  19. package/dist/components/SvedaWelcome.d.ts +20 -0
  20. package/dist/components/SvedaWelcome.d.ts.map +1 -0
  21. package/dist/components/shell/ChatHistoryList.d.ts +11 -0
  22. package/dist/components/shell/ChatHistoryList.d.ts.map +1 -0
  23. package/dist/components/shell/SvedaFrameTicks.d.ts +2 -0
  24. package/dist/components/shell/SvedaFrameTicks.d.ts.map +1 -0
  25. package/dist/components/shell/SvedaResizeHandles.d.ts +8 -0
  26. package/dist/components/shell/SvedaResizeHandles.d.ts.map +1 -0
  27. package/dist/hooks/useSvedaChat.d.ts +33 -0
  28. package/dist/hooks/useSvedaChat.d.ts.map +1 -0
  29. package/dist/hooks/useSvedaChatPage.d.ts +99 -0
  30. package/dist/hooks/useSvedaChatPage.d.ts.map +1 -0
  31. package/dist/hooks/useSvedaStreaming.d.ts +44 -0
  32. package/dist/hooks/useSvedaStreaming.d.ts.map +1 -0
  33. package/dist/i18n/index.d.ts +16 -0
  34. package/dist/i18n/index.d.ts.map +1 -0
  35. package/dist/index.d.ts +26 -0
  36. package/dist/index.d.ts.map +1 -0
  37. package/dist/index.js +1557 -0
  38. package/dist/launcherIcons.d.ts +7 -0
  39. package/dist/launcherIcons.d.ts.map +1 -0
  40. package/dist/lib/utils.d.ts +3 -0
  41. package/dist/lib/utils.d.ts.map +1 -0
  42. package/dist/provider.d.ts +65 -0
  43. package/dist/provider.d.ts.map +1 -0
  44. package/dist/styles.css +38 -0
  45. package/package.json +71 -0
  46. package/src/appearance.ts +75 -0
  47. package/src/chat.css +35 -0
  48. package/src/components/SvedaChat.tsx +381 -0
  49. package/src/components/SvedaComposer.tsx +116 -0
  50. package/src/components/SvedaMessageList.tsx +89 -0
  51. package/src/components/SvedaMinimizedTrigger.tsx +40 -0
  52. package/src/components/SvedaQuickPrompts.tsx +36 -0
  53. package/src/components/SvedaTabs.tsx +109 -0
  54. package/src/components/SvedaToolbar.tsx +140 -0
  55. package/src/components/SvedaWelcome.tsx +50 -0
  56. package/src/components/shell/ChatHistoryList.tsx +158 -0
  57. package/src/components/shell/SvedaFrameTicks.tsx +22 -0
  58. package/src/components/shell/SvedaResizeHandles.tsx +49 -0
  59. package/src/hooks/useSvedaChat.ts +97 -0
  60. package/src/hooks/useSvedaChatPage.ts +644 -0
  61. package/src/hooks/useSvedaStreaming.ts +102 -0
  62. package/src/i18n/index.ts +61 -0
  63. package/src/index.ts +113 -0
  64. package/src/launcherIcons.ts +41 -0
  65. package/src/lib/utils.ts +6 -0
  66. package/src/markdown.css +96 -0
  67. package/src/provider.tsx +196 -0
  68. package/src/styles.css +6 -0
  69. package/src/theme.css +137 -0
@@ -0,0 +1,381 @@
1
+ import { Plus } from 'lucide-solid';
2
+ import { Show, createMemo, createSignal, type Component, type JSX } from 'solid-js';
3
+ import { useSvedaChatPage } from '../hooks/useSvedaChatPage';
4
+ import type { SvedaAgentTasksPayload } from '../hooks/useSvedaChatPage';
5
+ import { useSvedaConfig, useSvedaContext, type SvedaModelOption, type SvedaQuickPrompt } from '../provider';
6
+ import { cn } from '../lib/utils';
7
+ import { SvedaComposer } from './SvedaComposer';
8
+ import { SvedaMessageList } from './SvedaMessageList';
9
+ import { SvedaMinimizedTrigger } from './SvedaMinimizedTrigger';
10
+ import { SvedaQuickPrompts } from './SvedaQuickPrompts';
11
+ import { SvedaTabs } from './SvedaTabs';
12
+ import { SvedaToolbar } from './SvedaToolbar';
13
+ import { SvedaWelcome } from './SvedaWelcome';
14
+ import { ChatHistoryList } from './shell/ChatHistoryList';
15
+ import { SvedaFrameTicks } from './shell/SvedaFrameTicks';
16
+ import { SvedaResizeHandles } from './shell/SvedaResizeHandles';
17
+
18
+ export interface SvedaChatProps {
19
+ models?: SvedaModelOption[];
20
+ quickPrompts?: SvedaQuickPrompt[];
21
+ brandName?: string;
22
+ brandLogo?: string;
23
+ pageUrl?: string;
24
+ onNavigate?: (url: string) => void;
25
+ notify?: (kind: 'error', message: string) => void;
26
+ agentTasksSubscribe?: (
27
+ onPayload: (payload: SvedaAgentTasksPayload) => void,
28
+ ) => void | (() => void);
29
+ }
30
+
31
+ export const SvedaChat: Component<SvedaChatProps> = props => {
32
+ const config = useSvedaConfig();
33
+ const ctx = useSvedaContext();
34
+
35
+ const chat = useSvedaChatPage({
36
+ models: () => props.models ?? config.models,
37
+ quickPrompts: () => props.quickPrompts ?? config.quickPrompts,
38
+ brandName: () => props.brandName,
39
+ brandLogo: () => props.brandLogo,
40
+ pageUrl: () => props.pageUrl,
41
+ onNavigate: props.onNavigate,
42
+ notify: props.notify,
43
+ agentTasksSubscribe: props.agentTasksSubscribe,
44
+ });
45
+
46
+ const [pendingDeleteChatId, setPendingDeleteChatId] = createSignal<string | null>(null);
47
+ const [pendingRenameChatId, setPendingRenameChatId] = createSignal<string | null>(null);
48
+ const [renameTitle, setRenameTitle] = createSignal('');
49
+
50
+ const handleNewChat = () => {
51
+ chat.handleNewChat();
52
+ if (chat.isMobile()) {
53
+ chat.setShowHistorySidebar(false);
54
+ }
55
+ };
56
+
57
+ const handleSelectChat = (chatId: string) => {
58
+ void chat.handleSelectChat(chatId);
59
+ if (chat.isMobile()) {
60
+ chat.setShowHistorySidebar(false);
61
+ }
62
+ };
63
+
64
+ const confirmDelete = () => {
65
+ const chatId = pendingDeleteChatId();
66
+ if (chatId) {
67
+ void chat.deleteChat(chatId);
68
+ }
69
+ setPendingDeleteChatId(null);
70
+ };
71
+
72
+ const confirmRename = () => {
73
+ const chatId = pendingRenameChatId();
74
+ const title = renameTitle().trim();
75
+ if (chatId && title) {
76
+ chat.renameChat(chatId, title);
77
+ }
78
+ setPendingRenameChatId(null);
79
+ setRenameTitle('');
80
+ };
81
+
82
+ const historyAsideClass = createMemo(() =>
83
+ cn(
84
+ 'sveda-chat-surface flex min-h-0 w-80 shrink-0 flex-col overflow-hidden bg-background',
85
+ chat.isMobile()
86
+ ? 'h-full max-w-[88vw] border-r border-border'
87
+ : chat.fillHost
88
+ ? 'h-full border-r border-border'
89
+ : chat.viewMode() === 'fixed'
90
+ ? 'absolute right-full top-0 z-10 h-full border-r border-border'
91
+ : 'h-full rounded-[var(--sveda-radius)] border border-border',
92
+ ),
93
+ );
94
+
95
+ const nonImmersiveShellClass = createMemo(() =>
96
+ chat.isMobile() || chat.viewMode() === 'fixed'
97
+ ? 'relative flex h-full min-h-0 min-w-0 flex-1 flex-row'
98
+ : chat.fillHost
99
+ ? 'relative flex h-full min-h-0 min-w-0 w-full flex-row items-stretch overflow-hidden'
100
+ : 'relative flex min-h-0 flex-row items-stretch gap-2',
101
+ );
102
+
103
+ const cardClass = createMemo(() =>
104
+ cn('sveda-chat-surface relative flex min-h-0 flex-col overflow-visible', {
105
+ 'sveda-chat-frame': chat.viewMode() === 'floating' && !chat.isMobile() && !chat.fillHost,
106
+ 'border-0': chat.fillHost || chat.isMobile(),
107
+ 'h-full min-w-0 flex-1 rounded-none': chat.isMobile(),
108
+ 'h-full min-w-0 flex-1 rounded-none border-b-0 border-l border-r-0 border-t-0 border-border':
109
+ chat.viewMode() === 'fixed' && !chat.isMobile(),
110
+ 'rounded-[var(--sveda-radius)]': chat.viewMode() === 'floating',
111
+ 'rounded-none': chat.isMobile() || chat.viewMode() === 'fixed',
112
+ 'min-w-0 shrink-0': chat.viewMode() === 'floating' && !chat.isMobile() && !chat.fillHost,
113
+ 'h-full min-w-0 flex-1': chat.viewMode() === 'floating' && !chat.isMobile() && chat.fillHost,
114
+ }),
115
+ );
116
+
117
+ const toolbar = (immersiveDesktop: boolean): JSX.Element => (
118
+ <SvedaToolbar
119
+ isMobile={chat.isMobile()}
120
+ viewMode={chat.viewMode()}
121
+ isImmersiveDesktop={immersiveDesktop}
122
+ showHistorySidebar={chat.showHistorySidebar()}
123
+ title={chat.headerTitle()}
124
+ viewModeFloatingLabel={chat.t('viewModeFloating')}
125
+ viewModeFixedLabel={chat.t('viewModeFixed')}
126
+ immersiveEnterLabel={chat.t('immersiveModeEnter')}
127
+ immersiveExitLabel={chat.t('immersiveModeExit')}
128
+ immersiveBrandName={chat.brandDisplayName()}
129
+ immersiveBrandLogo={chat.brandLogo() ?? undefined}
130
+ onToggleHistorySidebar={() => chat.setShowHistorySidebar(!chat.showHistorySidebar())}
131
+ onEnterImmersive={chat.enterImmersiveMode}
132
+ onExitImmersive={chat.exitImmersiveMode}
133
+ onToggleViewMode={chat.toggleViewMode}
134
+ onMinimize={chat.minimizeChat}
135
+ />
136
+ );
137
+
138
+ const thread = (compact: boolean): JSX.Element => (
139
+ <>
140
+ <SvedaTabs
141
+ tabs={chat.openChatTabs()}
142
+ currentChatId={chat.currentChat()?.id}
143
+ streamingChatIds={chat.streamingChatIds()}
144
+ unreadChatIds={chat.unreadChatIds()}
145
+ compact={compact}
146
+ onSelectChat={handleSelectChat}
147
+ onCloseTab={id => void chat.closeChatTab(id)}
148
+ onNewChat={handleNewChat}
149
+ />
150
+ <Show
151
+ when={chat.hasUserMessages()}
152
+ fallback={
153
+ <SvedaWelcome
154
+ inputMessage={chat.inputMessage()}
155
+ onInputMessage={chat.setInputMessage}
156
+ isLoading={chat.isLoading() || chat.isLoadingChatHistory()}
157
+ confirmationPending={chat.confirmationPending()}
158
+ hasCurrentChat={chat.hasCurrentChat()}
159
+ isStreaming={chat.isStreaming()}
160
+ showQuickPromptButtons={chat.showQuickPromptButtons()}
161
+ quickPromptButtons={chat.quickPromptButtons()}
162
+ quickPromptsTitle={chat.t('quickPromptsTitle')}
163
+ onSend={() => void chat.sendMessage()}
164
+ onStop={() => chat.stopStreaming()}
165
+ onSendQuickPrompt={prompt => void chat.sendQuickPrompt(prompt)}
166
+ />
167
+ }
168
+ >
169
+ <SvedaMessageList
170
+ messages={chat.messages()}
171
+ isLoading={chat.isLoading() || chat.isLoadingChatHistory()}
172
+ isThinking={chat.isThinking()}
173
+ thinkingMessage={chat.thinkingMessage()}
174
+ />
175
+ <Show when={chat.showQuickPromptButtons()}>
176
+ <SvedaQuickPrompts
177
+ class="shrink-0 px-4 pb-1 pt-0"
178
+ prompts={chat.quickPromptButtons()}
179
+ title={chat.t('quickPromptsTitle')}
180
+ disabled={chat.isLoading() || chat.isStreaming() || chat.confirmationPending()}
181
+ onSelect={prompt => void chat.sendQuickPrompt(prompt)}
182
+ />
183
+ </Show>
184
+ <SvedaComposer
185
+ value={chat.inputMessage()}
186
+ onInput={chat.setInputMessage}
187
+ isLoading={chat.isLoading() || chat.isLoadingChatHistory()}
188
+ confirmationPending={chat.confirmationPending()}
189
+ hasCurrentChat={chat.hasCurrentChat()}
190
+ isStreaming={chat.isStreaming()}
191
+ onSend={() => void chat.sendMessage()}
192
+ onStop={() => chat.stopStreaming()}
193
+ />
194
+ </Show>
195
+ </>
196
+ );
197
+
198
+ const newChatButton = (): JSX.Element => (
199
+ <button
200
+ type="button"
201
+ class="inline-flex w-full items-center justify-center gap-2 bg-primary px-3 py-2 font-mono text-[11px] tracking-[0.14em] text-primary-foreground"
202
+ onClick={handleNewChat}
203
+ >
204
+ <Plus class="h-4 w-4" />
205
+ {chat.t('newChat')}
206
+ </button>
207
+ );
208
+
209
+ const historyColumn = (): JSX.Element => (
210
+ <>
211
+ <div class="border-b border-border/50 p-3">{newChatButton()}</div>
212
+ <div class="min-h-0 flex-1">
213
+ <ChatHistoryList
214
+ histories={chat.sortedHistories()}
215
+ currentChatId={chat.currentChat()?.id}
216
+ onSelectChat={handleSelectChat}
217
+ onDeleteChat={chatId => setPendingDeleteChatId(chatId)}
218
+ onRenameChat={chatId => {
219
+ const history = chat.sortedHistories().find(item => item.id === chatId);
220
+ setPendingRenameChatId(chatId);
221
+ setRenameTitle(history?.title ?? '');
222
+ }}
223
+ />
224
+ </div>
225
+ </>
226
+ );
227
+
228
+ return (
229
+ <div class={chat.shellClass()} style={chat.chatShellStyle()}>
230
+ <Show when={!chat.isMinimized()}>
231
+ <div
232
+ class={
233
+ chat.isMobile() || chat.viewMode() === 'fixed' || chat.fillHost
234
+ ? 'flex h-full min-h-0 w-full min-w-0 flex-1'
235
+ : chat.viewMode() === 'immersive'
236
+ ? 'flex h-full min-h-0 w-full min-w-0 flex-1 flex-col'
237
+ : 'flex gap-2'
238
+ }
239
+ >
240
+ <Show
241
+ when={chat.isImmersiveDesktop()}
242
+ fallback={
243
+ <div class={nonImmersiveShellClass()} style={chat.floatShellStyle()}>
244
+ <Show when={chat.showHistorySidebar() && !chat.isMobile()}>
245
+ <aside class={historyAsideClass()}>{historyColumn()}</aside>
246
+ </Show>
247
+ <div class={cardClass()} style={chat.chatCardStyle()}>
248
+ <div class="sveda-chat-surface relative flex flex-1 flex-col overflow-hidden p-0">
249
+ <div class="flex min-h-0 flex-1 flex-col">
250
+ {toolbar(false)}
251
+ {thread(true)}
252
+ </div>
253
+ </div>
254
+ <Show when={chat.viewMode() === 'floating' && !chat.isMobile() && !chat.fillHost}>
255
+ <SvedaFrameTicks />
256
+ </Show>
257
+ <SvedaResizeHandles
258
+ isMobile={chat.isMobile()}
259
+ viewMode={chat.viewMode()}
260
+ onStartResize={chat.startResize}
261
+ />
262
+ </div>
263
+ </div>
264
+ }
265
+ >
266
+ <div class="sveda-chat-surface flex h-full min-h-0 w-full flex-1 flex-col">
267
+ {toolbar(true)}
268
+ <div class="flex min-h-0 flex-1 flex-row">
269
+ <aside class="sveda-chat-surface flex w-[min(20rem,33vw)] shrink-0 flex-col border-r border-border">
270
+ {historyColumn()}
271
+ </aside>
272
+ <div class="sveda-chat-surface flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden">
273
+ <div class="mx-auto flex min-h-0 w-full max-w-7xl flex-1 flex-col overflow-hidden px-4 md:px-6">
274
+ {thread(false)}
275
+ </div>
276
+ </div>
277
+ </div>
278
+ </div>
279
+ </Show>
280
+ </div>
281
+ </Show>
282
+
283
+ <Show when={chat.isMobile() && chat.showHistorySidebar() && !chat.isMinimized()}>
284
+ <div
285
+ class="fixed inset-0 z-[60] flex bg-black/40"
286
+ onClick={() => chat.setShowHistorySidebar(false)}
287
+ >
288
+ <aside
289
+ class="sveda-chat-surface flex h-full w-80 max-w-[88vw] flex-col bg-background"
290
+ onClick={event => event.stopPropagation()}
291
+ >
292
+ {historyColumn()}
293
+ </aside>
294
+ </div>
295
+ </Show>
296
+
297
+ <Show when={chat.isMinimized() && !chat.isMobile() && !ctx.hideLauncher}>
298
+ <SvedaMinimizedTrigger
299
+ label={chat.launcherLabel()}
300
+ icon={chat.launcherIcon()}
301
+ logoSrc={chat.launcherImage()}
302
+ logoAlt={chat.t('assistantLogoAlt')}
303
+ onOpen={() => void chat.openChat()}
304
+ />
305
+ </Show>
306
+
307
+ <Show when={pendingDeleteChatId()}>
308
+ <div
309
+ class="fixed inset-0 z-[70] flex items-center justify-center bg-black/40 p-4"
310
+ role="dialog"
311
+ aria-modal="true"
312
+ >
313
+ <div class="w-full max-w-sm border border-border bg-card p-4 text-card-foreground shadow-lg">
314
+ <h3 class="text-base font-semibold">{chat.t('commonDelete')}</h3>
315
+ <p class="mt-2 text-sm text-muted-foreground">{chat.t('confirmDeleteChat')}</p>
316
+ <div class="mt-4 flex justify-end gap-2">
317
+ <button
318
+ type="button"
319
+ class="border border-border px-3 py-2 text-sm"
320
+ onClick={() => setPendingDeleteChatId(null)}
321
+ >
322
+ {chat.t('commonCancel')}
323
+ </button>
324
+ <button
325
+ type="button"
326
+ class="bg-primary px-3 py-2 text-sm text-primary-foreground"
327
+ onClick={confirmDelete}
328
+ >
329
+ {chat.t('commonDelete')}
330
+ </button>
331
+ </div>
332
+ </div>
333
+ </div>
334
+ </Show>
335
+
336
+ <Show when={pendingRenameChatId()}>
337
+ <div
338
+ class="fixed inset-0 z-[70] flex items-center justify-center bg-black/40 p-4"
339
+ role="dialog"
340
+ aria-modal="true"
341
+ >
342
+ <div class="w-full max-w-sm border border-border bg-card p-4 text-card-foreground shadow-lg">
343
+ <h3 class="text-base font-semibold">{chat.t('renameChat')}</h3>
344
+ <input
345
+ value={renameTitle()}
346
+ placeholder={chat.t('renameChatPlaceholder')}
347
+ class="mt-3 h-10 w-full border border-input bg-input px-3 text-sm outline-none"
348
+ onInput={event => setRenameTitle(event.currentTarget.value)}
349
+ onKeyDown={event => {
350
+ if (event.key === 'Enter') {
351
+ confirmRename();
352
+ }
353
+ }}
354
+ />
355
+ <div class="mt-4 flex justify-end gap-2">
356
+ <button
357
+ type="button"
358
+ class="border border-border px-3 py-2 text-sm"
359
+ onClick={() => {
360
+ setPendingRenameChatId(null);
361
+ setRenameTitle('');
362
+ }}
363
+ >
364
+ {chat.t('commonCancel')}
365
+ </button>
366
+ <button
367
+ type="button"
368
+ class="bg-primary px-3 py-2 text-sm text-primary-foreground"
369
+ onClick={confirmRename}
370
+ >
371
+ {chat.t('commonSave')}
372
+ </button>
373
+ </div>
374
+ </div>
375
+ </div>
376
+ </Show>
377
+ </div>
378
+ );
379
+ };
380
+
381
+ export default SvedaChat;
@@ -0,0 +1,116 @@
1
+ import { Loader2, Send, Square } from 'lucide-solid';
2
+ import { type Component, type JSX, Show, createMemo } from 'solid-js';
3
+ import { useSvedaT } from '../i18n/index';
4
+ import { cn } from '../lib/utils';
5
+
6
+ export interface SvedaComposerProps {
7
+ value: string;
8
+ onInput: (value: string) => void;
9
+ isLoading?: boolean;
10
+ confirmationPending?: boolean;
11
+ hasCurrentChat?: boolean;
12
+ isStreaming?: boolean;
13
+ statusBanner?: string;
14
+ noBorder?: boolean;
15
+ onSend: () => void;
16
+ onStop: () => void;
17
+ bottomLeft?: JSX.Element;
18
+ bottomOutside?: JSX.Element;
19
+ }
20
+
21
+ const controlIconClass = 'h-4 w-4';
22
+ const sendButtonClass =
23
+ 'inline-flex h-8 w-8 items-center justify-center rounded-none border border-dashed border-primary bg-primary text-primary-foreground hover:opacity-90 disabled:opacity-50';
24
+ const streamStopButtonClass =
25
+ 'inline-flex h-8 w-8 items-center justify-center rounded-none border border-dashed border-destructive text-destructive hover:bg-destructive/10';
26
+ const controlToolbarClass =
27
+ 'flex items-center justify-between border-t border-dashed border-foreground px-2 py-1';
28
+
29
+ export const SvedaComposer: Component<SvedaComposerProps> = props => {
30
+ const t = useSvedaT();
31
+
32
+ const composerDisabled = createMemo(
33
+ () => Boolean(props.isLoading || props.confirmationPending || props.isStreaming),
34
+ );
35
+ const canSend = createMemo(
36
+ () => props.value.trim().length > 0 && Boolean(props.hasCurrentChat),
37
+ );
38
+ const hasStatusBanner = createMemo(() => String(props.statusBanner || '').trim() !== '');
39
+
40
+ const handleKeyPress = (event: KeyboardEvent) => {
41
+ if (event.key === 'Enter' && !event.shiftKey) {
42
+ event.preventDefault();
43
+ if (!composerDisabled() && canSend()) {
44
+ props.onSend();
45
+ }
46
+ }
47
+ };
48
+
49
+ return (
50
+ <div
51
+ class={
52
+ props.noBorder
53
+ ? 'flex flex-shrink-0 flex-col bg-transparent p-4'
54
+ : 'flex flex-shrink-0 flex-col bg-background p-3'
55
+ }
56
+ >
57
+ <Show when={hasStatusBanner()}>
58
+ <div class="mb-3 flex items-center gap-2 border border-dashed border-foreground bg-muted px-3 py-2 font-mono text-[11px] tracking-[0.08em] text-muted-foreground">
59
+ <Loader2 class="h-4 w-4 shrink-0 animate-spin" />
60
+ <span class="leading-snug">{props.statusBanner}</span>
61
+ </div>
62
+ </Show>
63
+
64
+ <div class="sveda-chat-frame relative flex flex-col bg-background transition-colors">
65
+ <textarea
66
+ value={props.value}
67
+ onInput={event => props.onInput(event.currentTarget.value)}
68
+ onKeyPress={handleKeyPress}
69
+ placeholder={t('typeMessage')}
70
+ disabled={composerDisabled()}
71
+ class="sveda-chat-input-textarea max-h-[250px] min-h-[60px] w-full resize-none border-0 bg-transparent p-3 font-sans text-sm text-foreground shadow-none !outline-none !ring-0 placeholder:font-mono placeholder:text-[11px] placeholder:tracking-[0.08em] placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-0 focus-visible:ring-offset-0"
72
+ style={{ height: '60px', outline: 'none', 'box-shadow': 'none' }}
73
+ />
74
+
75
+ <div class={controlToolbarClass}>
76
+ <div class="flex min-w-0 flex-1 items-center gap-1">
77
+ <div class="min-w-0 flex-1">{props.bottomLeft}</div>
78
+ </div>
79
+
80
+ <div class="flex items-center gap-1">
81
+ <Show
82
+ when={props.isStreaming}
83
+ fallback={
84
+ <button
85
+ type="button"
86
+ class={sendButtonClass}
87
+ disabled={composerDisabled() || !canSend()}
88
+ aria-label={t('sendMessage') || 'Send'}
89
+ onClick={() => props.onSend()}
90
+ >
91
+ <Show
92
+ when={props.isLoading}
93
+ fallback={<Send class={controlIconClass} />}
94
+ >
95
+ <Loader2 class={cn(controlIconClass, 'animate-spin')} />
96
+ </Show>
97
+ </button>
98
+ }
99
+ >
100
+ <button
101
+ type="button"
102
+ class={streamStopButtonClass}
103
+ aria-label={t('stopGenerating') || 'Stop'}
104
+ onClick={() => props.onStop()}
105
+ >
106
+ <Square class={controlIconClass} />
107
+ </button>
108
+ </Show>
109
+ </div>
110
+ </div>
111
+ </div>
112
+
113
+ <div class="mt-2">{props.bottomOutside}</div>
114
+ </div>
115
+ );
116
+ };
@@ -0,0 +1,89 @@
1
+ import {
2
+ getUserMessageText,
3
+ messageHasVisibleAssistantContent,
4
+ renderMarkdown,
5
+ type SvedaChatMessageLike,
6
+ } from '@sveda-ai/chat';
7
+ import { For, Show, type Component, createMemo } from 'solid-js';
8
+ import { useSvedaT } from '../i18n/index';
9
+ import { cn } from '../lib/utils';
10
+
11
+ export interface SvedaMessageListProps {
12
+ messages: SvedaChatMessageLike[];
13
+ isLoading?: boolean;
14
+ isThinking?: boolean;
15
+ thinkingMessage?: string;
16
+ class?: string;
17
+ }
18
+
19
+ const assistantText = (message: SvedaChatMessageLike): string => {
20
+ if (!Array.isArray(message.parts)) {
21
+ return typeof message.content === 'string' ? message.content : '';
22
+ }
23
+ return message.parts
24
+ .filter(part => part.type === 'text' && Boolean(part.text?.trim()))
25
+ .map(part => String(part.text ?? ''))
26
+ .join('\n\n');
27
+ };
28
+
29
+ export const SvedaMessageList: Component<SvedaMessageListProps> = props => {
30
+ const t = useSvedaT();
31
+
32
+ const visibleMessages = createMemo(() =>
33
+ (props.messages ?? []).filter(message => {
34
+ if (message.role === 'user') {
35
+ return getUserMessageText(message).length > 0;
36
+ }
37
+ if (message.role === 'assistant') {
38
+ return messageHasVisibleAssistantContent(message);
39
+ }
40
+ return false;
41
+ }),
42
+ );
43
+
44
+ return (
45
+ <div
46
+ data-sveda-messages
47
+ class={cn('flex min-h-0 flex-1 flex-col gap-3 overflow-y-auto px-4 py-3', props.class)}
48
+ >
49
+ <For each={visibleMessages()}>
50
+ {message => (
51
+ <div
52
+ class={cn(
53
+ 'max-w-[92%] rounded-[var(--sveda-radius)] px-3 py-2 text-sm',
54
+ message.role === 'user'
55
+ ? 'ml-auto border border-border bg-muted text-foreground'
56
+ : 'mr-auto border border-border/60 bg-background text-foreground',
57
+ )}
58
+ >
59
+ <Show
60
+ when={message.role === 'user'}
61
+ fallback={
62
+ <div
63
+ class="sveda-markdown prose prose-sm max-w-none dark:prose-invert"
64
+ // eslint-disable-next-line solid/no-innerhtml
65
+ innerHTML={renderMarkdown(assistantText(message))}
66
+ />
67
+ }
68
+ >
69
+ <p class="whitespace-pre-wrap">{getUserMessageText(message)}</p>
70
+ </Show>
71
+ </div>
72
+ )}
73
+ </For>
74
+
75
+ <Show when={props.isThinking}>
76
+ <div class="mr-auto flex items-center gap-2 px-1 font-mono text-[11px] tracking-[0.08em] text-muted-foreground">
77
+ <span class="inline-block h-2 w-2 animate-pulse rounded-full bg-primary" />
78
+ {props.thinkingMessage || t('thinking') || 'Thinking…'}
79
+ </div>
80
+ </Show>
81
+
82
+ <Show when={props.isLoading && !props.isThinking && visibleMessages().length === 0}>
83
+ <div class="px-1 font-mono text-[11px] tracking-[0.08em] text-muted-foreground">
84
+ {t('loading') || 'Loading…'}
85
+ </div>
86
+ </Show>
87
+ </div>
88
+ );
89
+ };
@@ -0,0 +1,40 @@
1
+ import { type Component, Show } from 'solid-js';
2
+ import { Dynamic } from 'solid-js/web';
3
+ import { svedaLauncherIconComponent } from '../launcherIcons';
4
+ import { cn } from '../lib/utils';
5
+
6
+ export interface SvedaMinimizedTriggerProps {
7
+ label: string;
8
+ icon?: string;
9
+ logoSrc?: string;
10
+ logoAlt?: string;
11
+ onOpen: () => void;
12
+ }
13
+
14
+ const triggerClass =
15
+ 'inline-flex h-auto min-w-0 items-center justify-center gap-2 rounded-none border border-primary bg-primary px-3.5 py-2 font-mono text-[11px] tracking-[0.14em] text-primary-foreground shadow-none transition-opacity hover:opacity-90 [&_svg]:!h-3.5 [&_svg]:!w-3.5';
16
+
17
+ export const SvedaMinimizedTrigger: Component<SvedaMinimizedTriggerProps> = props => {
18
+ return (
19
+ <button type="button" class={cn(triggerClass)} onClick={() => props.onOpen()}>
20
+ <Show
21
+ when={props.logoSrc}
22
+ fallback={
23
+ <Dynamic
24
+ component={svedaLauncherIconComponent(props.icon ?? 'sparkles')}
25
+ class="h-6 w-6 flex-shrink-0"
26
+ />
27
+ }
28
+ >
29
+ <img
30
+ src={props.logoSrc}
31
+ alt={props.logoAlt ?? ''}
32
+ class="h-6 w-6 flex-shrink-0 object-cover min-[1872px]:h-10 min-[1872px]:w-10"
33
+ />
34
+ </Show>
35
+ <Show when={props.label}>
36
+ <span class="font-mono text-[11px] font-normal tracking-[0.14em]">{props.label}</span>
37
+ </Show>
38
+ </button>
39
+ );
40
+ };
@@ -0,0 +1,36 @@
1
+ import { For, type Component } from 'solid-js';
2
+ import { cn } from '../lib/utils';
3
+
4
+ export interface SvedaQuickPromptItem {
5
+ label: string;
6
+ prompt: string;
7
+ }
8
+
9
+ export interface SvedaQuickPromptsProps {
10
+ prompts: SvedaQuickPromptItem[];
11
+ title: string;
12
+ disabled?: boolean;
13
+ class?: string;
14
+ onSelect: (prompt: string) => void;
15
+ }
16
+
17
+ export const SvedaQuickPrompts: Component<SvedaQuickPromptsProps> = props => {
18
+ return (
19
+ <div class={cn('w-full', props.class)} role="group" aria-label={props.title}>
20
+ <div class="quick-prompts-row -mx-1 flex gap-2 overflow-x-auto px-1 pb-1">
21
+ <For each={props.prompts}>
22
+ {prompt => (
23
+ <button
24
+ type="button"
25
+ class="h-8 shrink-0 rounded-[var(--sveda-radius)] border border-border/60 bg-muted/80 px-3 text-xs font-normal text-muted-foreground shadow-none hover:bg-muted hover:text-foreground disabled:opacity-50"
26
+ disabled={props.disabled}
27
+ onClick={() => props.onSelect(prompt.prompt)}
28
+ >
29
+ {prompt.label}
30
+ </button>
31
+ )}
32
+ </For>
33
+ </div>
34
+ </div>
35
+ );
36
+ };