@stack-spot/ai-chat-widget 1.21.1 → 1.22.0-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.
Files changed (64) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/app-metadata.json +3 -3
  3. package/dist/chat-interceptors/quick-commands.d.ts.map +1 -1
  4. package/dist/chat-interceptors/quick-commands.js +11 -5
  5. package/dist/chat-interceptors/quick-commands.js.map +1 -1
  6. package/dist/components/QuickStartButton.d.ts +1 -7
  7. package/dist/components/QuickStartButton.d.ts.map +1 -1
  8. package/dist/components/QuickStartButton.js +4 -44
  9. package/dist/components/QuickStartButton.js.map +1 -1
  10. package/dist/components/TabManager.d.ts.map +1 -1
  11. package/dist/components/TabManager.js +5 -2
  12. package/dist/components/TabManager.js.map +1 -1
  13. package/dist/layout.css +0 -1
  14. package/dist/types.d.ts +2 -1
  15. package/dist/types.d.ts.map +1 -1
  16. package/dist/views/Chat/ChatMessage.d.ts.map +1 -1
  17. package/dist/views/Chat/ChatMessage.js +13 -4
  18. package/dist/views/Chat/ChatMessage.js.map +1 -1
  19. package/dist/views/Chat/styled.d.ts.map +1 -1
  20. package/dist/views/Chat/styled.js +3 -0
  21. package/dist/views/Chat/styled.js.map +1 -1
  22. package/dist/views/ChatTabSelection.d.ts.map +1 -1
  23. package/dist/views/ChatTabSelection.js +5 -2
  24. package/dist/views/ChatTabSelection.js.map +1 -1
  25. package/dist/views/Home/BuiltInAgent.d.ts.map +1 -1
  26. package/dist/views/Home/BuiltInAgent.js +5 -6
  27. package/dist/views/Home/BuiltInAgent.js.map +1 -1
  28. package/dist/views/Home/CustomAgent.d.ts.map +1 -1
  29. package/dist/views/Home/CustomAgent.js +1 -2
  30. package/dist/views/Home/CustomAgent.js.map +1 -1
  31. package/dist/views/Home/index.js +2 -2
  32. package/dist/views/Home/styled.d.ts.map +1 -1
  33. package/dist/views/Home/styled.js +17 -6
  34. package/dist/views/Home/styled.js.map +1 -1
  35. package/dist/views/MessageInput/ButtonBar.d.ts +1 -5
  36. package/dist/views/MessageInput/ButtonBar.d.ts.map +1 -1
  37. package/dist/views/MessageInput/ButtonBar.js +2 -2
  38. package/dist/views/MessageInput/ButtonBar.js.map +1 -1
  39. package/dist/views/MessageInput/SelectContent.js +2 -2
  40. package/dist/views/MessageInput/SelectContent.js.map +1 -1
  41. package/dist/views/MessageInput/index.js +1 -1
  42. package/dist/views/MessageInput/index.js.map +1 -1
  43. package/dist/views/MessageInput/styled.d.ts +1 -3
  44. package/dist/views/MessageInput/styled.d.ts.map +1 -1
  45. package/dist/views/MessageInput/styled.js +4 -5
  46. package/dist/views/MessageInput/styled.js.map +1 -1
  47. package/package.json +2 -2
  48. package/src/app-metadata.json +3 -3
  49. package/src/chat-interceptors/quick-commands.ts +14 -5
  50. package/src/components/QuickStartButton.tsx +9 -57
  51. package/src/components/TabManager.tsx +28 -12
  52. package/src/layout.css +0 -1
  53. package/src/types.ts +2 -1
  54. package/src/views/Chat/ChatMessage.tsx +89 -14
  55. package/src/views/Chat/styled.ts +3 -0
  56. package/src/views/ChatTabSelection.tsx +5 -2
  57. package/src/views/Home/BuiltInAgent.tsx +7 -15
  58. package/src/views/Home/CustomAgent.tsx +0 -3
  59. package/src/views/Home/index.tsx +2 -2
  60. package/src/views/Home/styled.ts +17 -6
  61. package/src/views/MessageInput/ButtonBar.tsx +2 -6
  62. package/src/views/MessageInput/SelectContent.tsx +2 -2
  63. package/src/views/MessageInput/index.tsx +2 -2
  64. package/src/views/MessageInput/styled.ts +5 -6
@@ -1,6 +1,6 @@
1
1
  import { Box, Button, Checkbox, Flex, IconBox, Input, Label, Radio, Text } from '@citric/core'
2
- import { Cog, Copy, Dislike, DislikeFill, Like, LikeFill, TimesCircle } from '@citric/icons'
3
- import { Badge, IconButton } from '@citric/ui'
2
+ import { Check, Cog, Copy, Dislike, DislikeFill, Like, LikeFill, TimesCircle } from '@citric/icons'
3
+ import { Badge, IconButton, Tooltip } from '@citric/ui'
4
4
  import { agentClient } from '@stack-spot/portal-network'
5
5
  import { listToClass } from '@stack-spot/portal-theme'
6
6
  import { Dictionary, useTranslate } from '@stack-spot/portal-translate'
@@ -185,7 +185,10 @@ export const ChatMessage = ({ message, isLast, beforeMessage, afterMessage }: Pr
185
185
  const chat = useCurrentChat()
186
186
  const agentId = entry.agent?.id ?? ''
187
187
  const [agent] = agentClient.agentById.useStatefulQuery({ agentId, builtIn: !!entry?.agent?.builtIn }, { enabled: !!agentId })
188
+ const [copied, setCopied] = useState(false)
189
+ const [showUserButtonCopy, setShowUserButtonCopy] = useState(false)
188
190
 
191
+
189
192
  useChatScrollToBottomEffect(ref, [entry])
190
193
 
191
194
  const detailKS = useCallback(({ name, slug, documentScore, documentId }: Required<TextChatEntry>['knowledgeSources'][number]) => {
@@ -250,6 +253,12 @@ export const ChatMessage = ({ message, isLast, beforeMessage, afterMessage }: Pr
250
253
  )}
251
254
  </>, [entry, isLast, runAction])
252
255
 
256
+ const handleCopy = () => {
257
+ onCopyAll(entry, chat)
258
+ setCopied(true)
259
+ setTimeout(() => setCopied(false), 2000)
260
+ }
261
+
253
262
  const renderContent = () => {
254
263
  if (entry.type === 'md') {
255
264
  return <>
@@ -277,9 +286,13 @@ export const ChatMessage = ({ message, isLast, beforeMessage, afterMessage }: Pr
277
286
  widget.set('panel', 'tools')
278
287
  }
279
288
 
289
+
280
290
  return (entry.content || entry.error || !!entry.steps?.length) && (
281
- <li key={entry.messageId} className={entry.agentType} ref={ref}>
282
- <div className="chat-message" ref={chatRef} onKeyDown={handleKeyDown} tabIndex={0}>
291
+ <li key={entry.messageId} className={entry.agentType} ref={ref}
292
+ >
293
+ <div className="chat-message" ref={chatRef} onKeyDown={handleKeyDown} tabIndex={0}
294
+ onMouseEnter={entry.agentType === 'user' ? () => setShowUserButtonCopy(true) : undefined}
295
+ onMouseLeave={entry.agentType === 'user' ? () => setShowUserButtonCopy(false) : undefined}>
283
296
  <div className={`user-info ${entry.agentType}`}>{userInfo}</div>
284
297
  {beforeMessage && createElement(beforeMessage, { message })}
285
298
  {(entry.content || entry.steps) && <div className={listToClass(['message-content', entry.card && 'card', entry.type])}>
@@ -290,13 +303,14 @@ export const ChatMessage = ({ message, isLast, beforeMessage, afterMessage }: Pr
290
303
 
291
304
  {!!entry.steps?.length && <StepsList steps={entry.steps} chatId={chat.id} messageId={message.id} />}
292
305
  </div>}
306
+
307
+ {entry.error && (
308
+ <div className="error">
309
+ <IconBox size="xs"><TimesCircle /></IconBox>
310
+ <Text appearance="microtext1">{entry.error}</Text>
311
+ </div>
312
+ )}
293
313
  </div>
294
- {entry.error && (
295
- <div className="error">
296
- <IconBox size="xs"><TimesCircle /></IconBox>
297
- <Text appearance="microtext1">{entry.error}</Text>
298
- </div>
299
- )}
300
314
  {afterMessage && createElement(afterMessage, { message })}
301
315
  {!!entry.tools?.length && <StackedBadge
302
316
  aria-label={t.openToolsPanel}
@@ -319,12 +333,37 @@ export const ChatMessage = ({ message, isLast, beforeMessage, afterMessage }: Pr
319
333
  </li>
320
334
  ))}</ul>
321
335
  </div>}
322
- {shouldShowFooter && <div className="message-footer">
336
+
337
+ {shouldShowFooter && <div className="message-footer"
338
+ onMouseEnter={entry.agentType === 'user' ? () => setShowUserButtonCopy(true) : undefined}
339
+ onMouseLeave={entry.agentType === 'user' ? () => setShowUserButtonCopy(false) : undefined}>
340
+
323
341
  {entry.agentType === 'bot' && !entry.error && <div className="message-actions">
342
+
324
343
  {entry.type === 'md' && (
325
- <IconButton appearance="square" color="light" title={t.copy} aria-label={t.copy} onClick={() => onCopyAll(entry, chat)}>
326
- <Copy />
327
- </IconButton>
344
+ copied ? (
345
+ <Tooltip text={t.copied} position={'right'}>
346
+ <IconButton
347
+ appearance="square"
348
+ colorBg="light"
349
+ title={t.copied}
350
+ aria-label={t.copied}
351
+ onClick={handleCopy}
352
+ >
353
+ <Check />
354
+ </IconButton>
355
+ </Tooltip>
356
+ ) : (
357
+ <IconButton
358
+ appearance="square"
359
+ color="light"
360
+ title={t.copy}
361
+ aria-label={t.copy}
362
+ onClick={handleCopy}
363
+ >
364
+ <Copy />
365
+ </IconButton>
366
+ )
328
367
  )}
329
368
  {entry.messageId && (
330
369
  <>
@@ -337,6 +376,40 @@ export const ChatMessage = ({ message, isLast, beforeMessage, afterMessage }: Pr
337
376
  </>
338
377
  )}
339
378
  </div>}
379
+
380
+ {entry.agentType === 'user' && (
381
+ <div className="message-actions">
382
+ {copied ? (
383
+ <Tooltip text={t.copied} position={'left'}>
384
+ <IconButton
385
+ appearance="square"
386
+ colorBg="light"
387
+ title={t.copied}
388
+ aria-label={t.copied}
389
+ size="sm"
390
+ >
391
+ <Check />
392
+ </IconButton>
393
+ </Tooltip>
394
+ ) : (
395
+ showUserButtonCopy && (
396
+ <div className="action-bar">
397
+ <IconButton
398
+ appearance="square"
399
+ color="light"
400
+ title={t.copy}
401
+ aria-label={t.copy}
402
+ onClick={handleCopy}
403
+ size="sm"
404
+ >
405
+ <Copy className="copy-btn"/>
406
+ </IconButton>
407
+ </div>
408
+ )
409
+ )}
410
+ </div>
411
+ )}
412
+
340
413
  <Text as="label" appearance="microtext1" className="chat-date">
341
414
  {dateFormatter.formatForChatMessage(date)}
342
415
  </Text>
@@ -352,6 +425,7 @@ const dictionary = {
352
425
  dislike: 'Dislike',
353
426
  tools: 'Tools',
354
427
  openToolsPanel: 'Open the tools panel to see more details.',
428
+ copied: 'Copied',
355
429
  },
356
430
  pt: {
357
431
  copy: 'Copiar',
@@ -359,5 +433,6 @@ const dictionary = {
359
433
  dislike: 'Não gostei',
360
434
  tools: 'Ferramentas',
361
435
  openToolsPanel: 'Abrir o painel de ferramentas para ver mais detalhes.',
436
+ copied: 'Copiado',
362
437
  },
363
438
  } satisfies Dictionary
@@ -61,11 +61,14 @@ export const ChatList: IStyledComponentBase<
61
61
  .message-footer {
62
62
  display: flex;
63
63
  flex-direction: row;
64
+ align-items: center;
65
+ gap: 8px;
64
66
 
65
67
  .message-actions {
66
68
  display: flex;
67
69
  flex-direction: row;
68
70
  gap: 4px;
71
+ height: 26px;
69
72
  }
70
73
 
71
74
  .chat-date {
@@ -41,13 +41,14 @@ export const ChatTabSelection = () => {
41
41
  () => {
42
42
  const actions: ButtonAction[] = [{
43
43
  icon: <Plus />,
44
- label: t.newChat,
44
+ ariaLabel: t.newChat,
45
45
  onClick: create,
46
46
  }]
47
47
  if (chatHistory) {
48
48
  actions.push({
49
49
  icon: <Clock />,
50
- label: t.openHistory,
50
+ label: t.history,
51
+ ariaLabel: t.openHistory,
51
52
  className: 'test',
52
53
  style: { marginLeft: 'auto' },
53
54
  onClick: () => widget.set('panel', 'history'),
@@ -71,10 +72,12 @@ export const ChatTabSelection = () => {
71
72
 
72
73
  const dictionary = {
73
74
  en: {
75
+ history: 'History',
74
76
  openHistory: 'Open chat history',
75
77
  newChat: 'New chat',
76
78
  },
77
79
  pt: {
80
+ history: 'Histórico',
78
81
  openHistory: 'Abrir histórico da conversa',
79
82
  newChat: 'Novo chat',
80
83
  },
@@ -1,6 +1,5 @@
1
- import { FaceSmile, KnowledgeSource, QuickCommand } from '@citric/icons'
2
- import { MiniLogo } from '@stack-spot/portal-components/svg'
3
- import { theme } from '@stack-spot/portal-theme'
1
+ import { Text } from '@citric/core'
2
+ import { FaceSmile, KnowledgeSource, QuickCommand, StackSpot } from '@citric/icons'
4
3
  import { Dictionary, useTranslate } from '@stack-spot/portal-translate'
5
4
  import { QuickStartButton } from '../../components/QuickStartButton'
6
5
  import { useCurrentChat } from '../../context/hooks'
@@ -21,35 +20,28 @@ export const BuiltInAgent = ({ username }: HomeProps) => {
21
20
 
22
21
  return (
23
22
  <HomeBox className="home-page">
24
- <h2 className="title">{t.hello}, {username}</h2>
25
- <h3 className="subtitle">{t.subtitle}</h3>
23
+ <Text appearance="h2" className="title">{t.hello}, {username}</Text>
24
+ <Text appearance="h3" className="subtitle">{t.subtitle}</Text>
26
25
  <div className="shortcuts">
27
26
  <QuickStartButton
28
27
  label={t['question.meta']}
29
28
  onClick={() => send(t['question.meta'])}
30
- icon={<MiniLogo />}
31
- background={theme.color.orange[50]}
29
+ icon={<StackSpot />}
32
30
  />
33
31
  <QuickStartButton
34
32
  label={t['question.ks']}
35
33
  onClick={() => send(t['question.ks'])}
36
34
  icon={<KnowledgeSource />}
37
- background={theme.color.cyan[50]}
38
- color={theme.color.cyan[600]}
39
35
  />
40
36
  <QuickStartButton
41
37
  label={t['question.agents']}
42
38
  onClick={() => send(t['question.agents'])}
43
39
  icon={<FaceSmile />}
44
- background={theme.color.pink[50]}
45
- color={theme.color.pink[600]}
46
40
  />
47
41
  <QuickStartButton
48
42
  label={t['question.qc']}
49
43
  onClick={() => send(t['question.qc'])}
50
44
  icon={<QuickCommand />}
51
- background={theme.color.purple[50]}
52
- color={theme.color.purple[600]}
53
45
  />
54
46
  </div>
55
47
  </HomeBox>
@@ -59,7 +51,7 @@ export const BuiltInAgent = ({ username }: HomeProps) => {
59
51
  const dictionary = {
60
52
  en: {
61
53
  hello: 'Hello',
62
- subtitle: "Let's innovate and streamline your coding journey together. Want to lead the change? Just ask!",
54
+ subtitle: 'What really matters takes time, let us help you with the rest.',
63
55
  'question.meta': 'What is StackSpot AI?',
64
56
  'question.ks': 'What are Knowledge Sources?',
65
57
  'question.agents': 'How do Agents work?',
@@ -67,7 +59,7 @@ const dictionary = {
67
59
  },
68
60
  pt: {
69
61
  hello: 'Olá',
70
- subtitle: 'Vamos inovar e simplificar sua jornada de programação juntos. Quer liderar a mudança? É perguntar!',
62
+ subtitle: 'O que realmente importa leva tempo, deixe que a gente cuide do resto.',
71
63
  'question.meta': 'O que é a StackSpot AI?',
72
64
  'question.ks': 'O que são Knowledge Sources?',
73
65
  'question.agents': 'Como funcionam os agentes?',
@@ -1,7 +1,6 @@
1
1
  import { IconBox, Text } from '@citric/core'
2
2
  import { Agent } from '@citric/icons'
3
3
  import { agentClient } from '@stack-spot/portal-network'
4
- import { theme } from '@stack-spot/portal-theme'
5
4
  import { useMemo } from 'react'
6
5
  import { QuickStartButton } from '../../components/QuickStartButton'
7
6
  import { useCurrentChat, useCurrentChatState } from '../../context/hooks'
@@ -20,8 +19,6 @@ export const CustomAgent = () => {
20
19
  key={index}
21
20
  label={prompt}
22
21
  onClick={() => send(prompt)}
23
- background={theme.color.light[500]}
24
- manageOverflow
25
22
  />
26
23
  )), [agent?.suggested_prompts])
27
24
 
@@ -18,10 +18,10 @@ const AgentList = styled.ul`
18
18
  li {
19
19
  flex-shrink: 0;
20
20
  &:first-child {
21
- margin-left: auto;
21
+ /* margin-left: auto; */
22
22
  }
23
23
  &:last-child {
24
- margin-right: auto;
24
+ /* margin-right: auto; */
25
25
  }
26
26
  }
27
27
  `
@@ -1,12 +1,10 @@
1
+ import { theme } from '@stack-spot/portal-theme'
1
2
  import { styled } from 'styled-components'
2
3
 
3
4
  export const HomeBox = styled.div`
4
5
  margin: auto 0;
5
6
 
6
7
  .title, .subtitle {
7
- font-family: 'San Francisco';
8
- font-size: 26px;
9
- font-weight: 600;
10
8
  margin: 0;
11
9
  }
12
10
 
@@ -14,22 +12,34 @@ export const HomeBox = styled.div`
14
12
  display: inline-block;
15
13
  background: linear-gradient(72.81deg, #FF9900 0.96%, #FF6633 100%);
16
14
  background-clip: text;
17
- margin-bottom: 10px;
18
15
  color: transparent;
19
16
  }
20
17
 
21
18
  .subtitle {
22
19
  color: #A0A0A0;
23
- margin-bottom: 20px;
20
+ margin-bottom: 24px;
24
21
  }
25
22
 
26
23
  .shortcuts {
27
24
  display: flex;
28
25
  flex-direction: row;
29
- gap: 15px;
30
26
  li {
31
27
  flex: 1;
32
28
  }
29
+ button {
30
+ padding-left: 0;
31
+ border-radius: 50px;
32
+ padding-inline: 16px;
33
+ font-weight: 400;
34
+ i {
35
+ width: 16px;
36
+ height: 16px;
37
+ margin-right: 8px;
38
+ }
39
+ &:hover, &:visited, &:active, &:focus {
40
+ background-color: ${theme.color.light[600]}
41
+ }
42
+ }
33
43
  }
34
44
 
35
45
  .avatar, .avatar svg {
@@ -53,6 +63,7 @@ export const HomeBox = styled.div`
53
63
  p {
54
64
  overflow: hidden;
55
65
  }
66
+
56
67
  }
57
68
  }
58
69
  }
@@ -15,20 +15,16 @@ interface SelectionBarProps {
15
15
  * Whether or not the message is currently being sent. This is used to decide which button to show: send or cancel.
16
16
  */
17
17
  isLoading?: boolean,
18
- /**
19
- * State to determine whether the input is focused
20
- */
21
- focused?: boolean,
22
18
  }
23
19
 
24
- export const ButtonBar = ({ onSend, isLoading, focused }: SelectionBarProps) => {
20
+ export const ButtonBar = ({ onSend, isLoading }: SelectionBarProps) => {
25
21
  const t = useMessageInputDictionary()
26
22
  const chat = useCurrentChat()
27
23
  const widget = useWidget()
28
24
  const features = useCurrentChatState('features')
29
25
 
30
26
  return (
31
- <SelectionBarWrapper className="button-group" $inputFocused={focused}>
27
+ <SelectionBarWrapper className="button-group">
32
28
  <Flex sx={{ gap: '4px' }}>
33
29
  <SelectContent />
34
30
  {features.editor && (
@@ -1,4 +1,4 @@
1
- import { Clip, KnowledgeSource, Spaces, Stack } from '@citric/icons'
1
+ import { KnowledgeSource, Plus, Spaces, Stack } from '@citric/icons'
2
2
  import { IconButton } from '@citric/ui'
3
3
  import { SelectionList } from '@stack-spot/portal-components/SelectionList'
4
4
  import { Dictionary, useTranslate } from '@stack-spot/portal-translate'
@@ -59,7 +59,7 @@ export const SelectContent = () => {
59
59
  data-test-hint="button-options"
60
60
  aria-label={visibleMenu ? t.collapse : t.expand}
61
61
  onClick={() => setVisibleMenu(state => !state)}>
62
- <Clip />
62
+ <Plus />
63
63
  </IconButton>
64
64
  <SelectionList
65
65
  style={{
@@ -81,9 +81,9 @@ export const MessageInput = () => {
81
81
  </div>
82
82
  </div>
83
83
  <ProgressBar visible={true} animate={isLoading}
84
- backgroundColor={isLoading || !focused ? theme.color.light[600] : theme.color.primary[500]} />
84
+ backgroundColor={isLoading || !focused ? theme.color.light[500] : theme.color.primary[500]} />
85
85
  <InfoBar />
86
- <ButtonBar focused={focused} onSend={onSend} isLoading={isLoading} />
86
+ <ButtonBar onSend={onSend} isLoading={isLoading} />
87
87
  </MessageInputBox>
88
88
  )
89
89
  }
@@ -7,7 +7,7 @@ const INFO_BAR_DISPLACEMENT = 4
7
7
  export const MAX_INPUT_HEIGHT = 300
8
8
  export const MIN_INPUT_HEIGHT = 24
9
9
 
10
- export const SelectionBarWrapper = styled.div<{$inputFocused?: boolean}>`
10
+ export const SelectionBarWrapper = styled.div`
11
11
  display: inline-flex;
12
12
  justify-content: space-between;
13
13
  position: relative;
@@ -15,7 +15,6 @@ export const SelectionBarWrapper = styled.div<{$inputFocused?: boolean}>`
15
15
  background-color: ${theme.color.light[500]};
16
16
  border-bottom-left-radius: 4px;
17
17
  border-bottom-right-radius: 4px;
18
- border: 2px solid ${({ $inputFocused }) => theme.color.light[$inputFocused ? 600 : 500]};
19
18
  border-top: none;
20
19
 
21
20
  .selection-list {
@@ -137,19 +136,19 @@ export const MessageInputBox = styled.div<{$inputFocused?: boolean}>`
137
136
  align-items: end;
138
137
  border-top-left-radius: 4px;
139
138
  border-top-right-radius: 4px;
140
- border: 2px solid ${theme.color.light[500]};
139
+ border: 2px solid ${theme.color.light[300]};
141
140
 
142
- background-color: ${theme.color.light[500]};
141
+ background-color: ${theme.color.light[300]};
143
142
  padding: 10px 8px;
144
143
  transition: border-color 0.3s, background-color 0.3s;
145
144
 
146
145
  &.focused {
147
- border: 2px solid ${theme.color.light[600]};
146
+ border: 2px solid ${theme.color.light[300]};
148
147
  }
149
148
 
150
149
 
151
150
  &.disabled {
152
- background-color: ${theme.color.light[500]};
151
+ background-color: ${theme.color.light[300]};
153
152
  }
154
153
  }
155
154
  }