@stack-spot/ai-chat-widget 0.10.0 → 1.0.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.
- package/dist/AbortedError.d.ts +5 -0
- package/dist/AbortedError.d.ts.map +1 -0
- package/dist/AbortedError.js +7 -0
- package/dist/AbortedError.js.map +1 -0
- package/dist/StackspotAIWidget.d.ts.map +1 -1
- package/dist/StackspotAIWidget.js +11 -3
- package/dist/StackspotAIWidget.js.map +1 -1
- package/dist/chat-interceptors/CustomInputs.d.ts +19 -0
- package/dist/chat-interceptors/CustomInputs.d.ts.map +1 -0
- package/dist/chat-interceptors/CustomInputs.js +62 -0
- package/dist/chat-interceptors/CustomInputs.js.map +1 -0
- package/dist/chat-interceptors/quick-command-questions.d.ts +4 -0
- package/dist/chat-interceptors/quick-command-questions.d.ts.map +1 -0
- package/dist/chat-interceptors/quick-command-questions.js +18 -0
- package/dist/chat-interceptors/quick-command-questions.js.map +1 -0
- package/dist/chat-interceptors/quick-commands.d.ts +3 -1
- package/dist/chat-interceptors/quick-commands.d.ts.map +1 -1
- package/dist/chat-interceptors/quick-commands.js +250 -8
- package/dist/chat-interceptors/quick-commands.js.map +1 -1
- package/dist/chat-interceptors/send-message.d.ts +1 -1
- package/dist/chat-interceptors/send-message.d.ts.map +1 -1
- package/dist/chat-interceptors/send-message.js +18 -14
- package/dist/chat-interceptors/send-message.js.map +1 -1
- package/dist/components/AdaptiveTextArea.d.ts +1 -1
- package/dist/components/AdaptiveTextArea.d.ts.map +1 -1
- package/dist/components/AdaptiveTextArea.js +6 -4
- package/dist/components/AdaptiveTextArea.js.map +1 -1
- package/dist/components/AutoFocus.d.ts +6 -0
- package/dist/components/AutoFocus.d.ts.map +1 -0
- package/dist/components/AutoFocus.js +15 -0
- package/dist/components/AutoFocus.js.map +1 -0
- package/dist/components/Fading.d.ts +15 -0
- package/dist/components/Fading.d.ts.map +1 -0
- package/dist/components/Fading.js +31 -0
- package/dist/components/Fading.js.map +1 -0
- package/dist/components/FallbackBoundary/ErrorBoundary.d.ts +3 -0
- package/dist/components/FallbackBoundary/ErrorBoundary.d.ts.map +1 -1
- package/dist/components/FallbackBoundary/ErrorBoundary.js +18 -4
- package/dist/components/FallbackBoundary/ErrorBoundary.js.map +1 -1
- package/dist/components/FallbackBoundary/Loading.js +1 -1
- package/dist/components/FallbackBoundary/Loading.js.map +1 -1
- package/dist/components/FallbackBoundary/index.d.ts +6 -1
- package/dist/components/FallbackBoundary/index.d.ts.map +1 -1
- package/dist/components/FallbackBoundary/index.js +1 -1
- package/dist/components/FallbackBoundary/index.js.map +1 -1
- package/dist/components/OverlayMenu.d.ts +1 -1
- package/dist/components/OverlayMenu.d.ts.map +1 -1
- package/dist/components/OverlayMenu.js +26 -9
- package/dist/components/OverlayMenu.js.map +1 -1
- package/dist/components/RightPanelForm.d.ts.map +1 -1
- package/dist/components/RightPanelForm.js +5 -4
- package/dist/components/RightPanelForm.js.map +1 -1
- package/dist/components/Tooltip/Tooltip.d.ts +3 -1
- package/dist/components/Tooltip/Tooltip.d.ts.map +1 -1
- package/dist/components/Tooltip/Tooltip.js +14 -5
- package/dist/components/Tooltip/Tooltip.js.map +1 -1
- package/dist/components/Tooltip/TooltipAPI.d.ts +2 -2
- package/dist/components/Tooltip/TooltipAPI.d.ts.map +1 -1
- package/dist/components/Tooltip/TooltipAPI.js +51 -51
- package/dist/components/Tooltip/TooltipAPI.js.map +1 -1
- package/dist/layout.css +5 -0
- package/dist/regex.d.ts +2 -0
- package/dist/regex.d.ts.map +1 -0
- package/dist/regex.js +2 -0
- package/dist/regex.js.map +1 -0
- package/dist/right-panel/DefaultPanel.d.ts.map +1 -1
- package/dist/right-panel/DefaultPanel.js +3 -1
- package/dist/right-panel/DefaultPanel.js.map +1 -1
- package/dist/right-panel/constants.d.ts +2 -0
- package/dist/right-panel/constants.d.ts.map +1 -0
- package/dist/right-panel/constants.js +2 -0
- package/dist/right-panel/constants.js.map +1 -0
- package/dist/right-panel/hooks.d.ts.map +1 -1
- package/dist/right-panel/hooks.js +2 -1
- package/dist/right-panel/hooks.js.map +1 -1
- package/dist/state/ChatEntry.d.ts +8 -8
- package/dist/state/ChatEntry.d.ts.map +1 -1
- package/dist/state/ChatEntry.js +4 -16
- package/dist/state/ChatEntry.js.map +1 -1
- package/dist/state/ChatState.d.ts +13 -1
- package/dist/state/ChatState.d.ts.map +1 -1
- package/dist/state/ChatState.js +38 -3
- package/dist/state/ChatState.js.map +1 -1
- package/dist/state/ObservableState.d.ts +1 -1
- package/dist/state/ObservableState.d.ts.map +1 -1
- package/dist/state/ObservableState.js.map +1 -1
- package/dist/utils/chat.d.ts.map +1 -1
- package/dist/utils/chat.js +3 -2
- package/dist/utils/chat.js.map +1 -1
- package/dist/utils/knowledge-source.d.ts +2 -2
- package/dist/utils/knowledge-source.d.ts.map +1 -1
- package/dist/utils/knowledge-source.js +4 -6
- package/dist/utils/knowledge-source.js.map +1 -1
- package/dist/utils/programming-languages.d.ts +1 -0
- package/dist/utils/programming-languages.d.ts.map +1 -1
- package/dist/utils/programming-languages.js +1 -0
- package/dist/utils/programming-languages.js.map +1 -1
- package/dist/utils/string.d.ts +2 -0
- package/dist/utils/string.d.ts.map +1 -0
- package/dist/utils/string.js +7 -0
- package/dist/utils/string.js.map +1 -0
- package/dist/utils/url.d.ts +2 -0
- package/dist/utils/url.d.ts.map +1 -0
- package/dist/utils/url.js +8 -0
- package/dist/utils/url.js.map +1 -0
- package/dist/views/Chat/ChatMessage.d.ts +2 -1
- package/dist/views/Chat/ChatMessage.d.ts.map +1 -1
- package/dist/views/Chat/ChatMessage.js +38 -5
- package/dist/views/Chat/ChatMessage.js.map +1 -1
- package/dist/views/Chat/ChatMessages.d.ts.map +1 -1
- package/dist/views/Chat/ChatMessages.js +1 -1
- package/dist/views/Chat/ChatMessages.js.map +1 -1
- package/dist/views/Chat/styled.d.ts.map +1 -1
- package/dist/views/Chat/styled.js +31 -0
- package/dist/views/Chat/styled.js.map +1 -1
- package/dist/views/ChatHistory/ChatHistoryPanel.d.ts.map +1 -1
- package/dist/views/ChatHistory/ChatHistoryPanel.js +2 -1
- package/dist/views/ChatHistory/ChatHistoryPanel.js.map +1 -1
- package/dist/views/ChatHistory/HistoryItem.d.ts.map +1 -1
- package/dist/views/ChatHistory/HistoryItem.js +10 -1
- package/dist/views/ChatHistory/HistoryItem.js.map +1 -1
- package/dist/views/Editor.d.ts.map +1 -1
- package/dist/views/Editor.js +3 -4
- package/dist/views/Editor.js.map +1 -1
- package/dist/views/MessageInput/ButtonGroup.d.ts +1 -1
- package/dist/views/MessageInput/ButtonGroup.d.ts.map +1 -1
- package/dist/views/MessageInput/QuickCommandSelector.d.ts +6 -0
- package/dist/views/MessageInput/QuickCommandSelector.d.ts.map +1 -0
- package/dist/views/MessageInput/QuickCommandSelector.js +137 -0
- package/dist/views/MessageInput/QuickCommandSelector.js.map +1 -0
- package/dist/views/MessageInput/index.d.ts.map +1 -1
- package/dist/views/MessageInput/index.js +10 -4
- package/dist/views/MessageInput/index.js.map +1 -1
- package/dist/views/MessageInput/styled.d.ts.map +1 -1
- package/dist/views/MessageInput/styled.js +137 -0
- package/dist/views/MessageInput/styled.js.map +1 -1
- package/package.json +3 -3
- package/src/AbortedError.ts +7 -0
- package/src/StackspotAIWidget.tsx +13 -3
- package/src/chat-interceptors/CustomInputs.ts +70 -0
- package/src/chat-interceptors/quick-command-questions.ts +15 -0
- package/src/chat-interceptors/quick-commands.ts +270 -7
- package/src/chat-interceptors/send-message.ts +27 -15
- package/src/components/AdaptiveTextArea.tsx +9 -4
- package/src/components/AutoFocus.tsx +20 -0
- package/src/components/Fading.tsx +46 -0
- package/src/components/FallbackBoundary/ErrorBoundary.tsx +26 -3
- package/src/components/FallbackBoundary/Loading.tsx +1 -1
- package/src/components/FallbackBoundary/index.tsx +7 -2
- package/src/components/OverlayMenu.tsx +59 -19
- package/src/components/RightPanelForm.tsx +12 -9
- package/src/components/Tooltip/Tooltip.tsx +24 -5
- package/src/components/Tooltip/TooltipAPI.ts +42 -42
- package/src/layout.css +5 -0
- package/src/regex.ts +1 -0
- package/src/right-panel/DefaultPanel.tsx +14 -9
- package/src/right-panel/constants.ts +1 -0
- package/src/right-panel/hooks.tsx +2 -1
- package/src/state/ChatEntry.ts +7 -20
- package/src/state/ChatState.ts +41 -3
- package/src/state/ObservableState.ts +1 -1
- package/src/utils/chat.ts +3 -2
- package/src/utils/knowledge-source.ts +6 -8
- package/src/utils/programming-languages.ts +2 -0
- package/src/utils/string.ts +6 -0
- package/src/utils/url.ts +8 -0
- package/src/views/Chat/ChatMessage.tsx +67 -13
- package/src/views/Chat/ChatMessages.tsx +4 -1
- package/src/views/Chat/styled.ts +31 -0
- package/src/views/ChatHistory/ChatHistoryPanel.tsx +3 -2
- package/src/views/ChatHistory/HistoryItem.tsx +11 -2
- package/src/views/Editor.tsx +3 -4
- package/src/views/MessageInput/ButtonGroup.tsx +1 -1
- package/src/views/MessageInput/QuickCommandSelector.tsx +210 -0
- package/src/views/MessageInput/index.tsx +12 -4
- package/src/views/MessageInput/styled.ts +137 -0
- package/dist/components/Editor.d.ts +0 -9
- package/dist/components/Editor.d.ts.map +0 -1
- package/dist/components/Editor.js +0 -2
- package/dist/components/Editor.js.map +0 -1
- package/src/components/Editor.tsx +0 -12
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { listToClass } from '@stack-spot/portal-theme'
|
|
2
|
-
import {
|
|
3
|
-
import { useCallback, useRef, useState } from 'react'
|
|
2
|
+
import { useCallback, useEffect, useRef, useState } from 'react'
|
|
4
3
|
import { AdaptiveTextArea } from '../../components/AdaptiveTextArea'
|
|
5
4
|
import { ProgressBar } from '../../components/ProgressBar'
|
|
6
5
|
import { useCurrentChat, useCurrentChatState, useWidgetState } from '../../context/hooks'
|
|
7
6
|
import { MessageInputFeatures } from '../../features'
|
|
7
|
+
import { quickCommandRegex } from '../../regex'
|
|
8
8
|
import { ChatEntry } from '../../state/ChatEntry'
|
|
9
9
|
import { ButtonGroup } from './ButtonGroup'
|
|
10
10
|
import { useMessageInputDictionary } from './dictionary'
|
|
11
11
|
import { InfoBar } from './InfoBar'
|
|
12
|
+
import { QuickCommandSelector } from './QuickCommandSelector'
|
|
12
13
|
import { MAX_INPUT_HEIGHT, MessageInputBox, MIN_INPUT_HEIGHT } from './styled'
|
|
13
14
|
|
|
14
15
|
interface Props {
|
|
@@ -24,13 +25,14 @@ export const MessageInput = ({ features }: Props) => {
|
|
|
24
25
|
const isLoading = useCurrentChatState('isLoading') ?? false
|
|
25
26
|
const value = useCurrentChatState('nextMessage') ?? ''
|
|
26
27
|
const isMinimized = useWidgetState('isMinimized')
|
|
28
|
+
const textAreaRef = useRef<HTMLTextAreaElement>(null)
|
|
27
29
|
|
|
28
30
|
const onSend = useCallback(async () => {
|
|
29
31
|
const message = chat.get('nextMessage')
|
|
30
32
|
if (!message) return
|
|
31
33
|
const code = chat.get('codeSelection')
|
|
32
34
|
const language = chat.get('codeLanguage')
|
|
33
|
-
const prompt = code ? `${message}\n\`\`\`${language}\n${code}\n\`\`\`` : message
|
|
35
|
+
const prompt = code && !quickCommandRegex.test(message) ? `${message}\n\`\`\`${language}\n${code}\n\`\`\`` : message
|
|
34
36
|
chat.pushMessage(ChatEntry.createUserEntry(prompt, true))
|
|
35
37
|
chat.set('nextMessage', '')
|
|
36
38
|
setFocused(false)
|
|
@@ -43,12 +45,18 @@ export const MessageInput = ({ features }: Props) => {
|
|
|
43
45
|
}
|
|
44
46
|
}, [onSend])
|
|
45
47
|
|
|
48
|
+
useEffect(() => {
|
|
49
|
+
if (!isLoading) textAreaRef.current?.focus()
|
|
50
|
+
}, [isLoading])
|
|
51
|
+
|
|
46
52
|
return (
|
|
47
53
|
<MessageInputBox aria-busy={isLoading} className="message-input">
|
|
48
54
|
<ProgressBar visible={isLoading} shimmer />
|
|
49
55
|
<InfoBar />
|
|
50
56
|
<div className={listToClass(['action-box', focused && 'focused', isLoading && 'disabled'])}>
|
|
57
|
+
<QuickCommandSelector inputRef={textAreaRef} />
|
|
51
58
|
<AdaptiveTextArea
|
|
59
|
+
ref={textAreaRef}
|
|
52
60
|
disabled={isLoading}
|
|
53
61
|
placeholder={t.placeholder}
|
|
54
62
|
onChange={e => chat.set('nextMessage', e.target.value)}
|
|
@@ -63,7 +71,7 @@ export const MessageInput = ({ features }: Props) => {
|
|
|
63
71
|
<ButtonGroup
|
|
64
72
|
features={features}
|
|
65
73
|
onSend={onSend}
|
|
66
|
-
onCancel={() =>
|
|
74
|
+
onCancel={() => chat.abort()}
|
|
67
75
|
expanded={expanded}
|
|
68
76
|
isLoading={isLoading}
|
|
69
77
|
setExpanded={(value) => {
|
|
@@ -82,6 +82,7 @@ export const MessageInputBox = styled.div`
|
|
|
82
82
|
|
|
83
83
|
.action-box {
|
|
84
84
|
display: flex;
|
|
85
|
+
position: relative;
|
|
85
86
|
flex-direction: row;
|
|
86
87
|
gap: 4px;
|
|
87
88
|
align-items: end;
|
|
@@ -201,4 +202,140 @@ export const MessageInputBox = styled.div`
|
|
|
201
202
|
box-shadow: none;
|
|
202
203
|
}
|
|
203
204
|
}
|
|
205
|
+
|
|
206
|
+
.quick-command-selector {
|
|
207
|
+
position: absolute;
|
|
208
|
+
border-radius: 4px;
|
|
209
|
+
border: 1px solid ${theme.color.light[600]};
|
|
210
|
+
background-color: ${theme.color.light[500]};
|
|
211
|
+
box-shadow: 0px 2px 16px 0px #0000005C;
|
|
212
|
+
display: flex;
|
|
213
|
+
flex-direction: column;
|
|
214
|
+
width: 480px;
|
|
215
|
+
bottom: 55px;
|
|
216
|
+
|
|
217
|
+
.loading, .error {
|
|
218
|
+
padding-bottom: 26px;
|
|
219
|
+
p {
|
|
220
|
+
width: 200px;
|
|
221
|
+
text-align: center;
|
|
222
|
+
line-height: 20px;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
.empty {
|
|
227
|
+
padding-bottom: 26px;
|
|
228
|
+
width: 200px;
|
|
229
|
+
text-align: center;
|
|
230
|
+
line-height: 20px;
|
|
231
|
+
margin: auto;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
header {
|
|
235
|
+
display: flex;
|
|
236
|
+
flex-direction: row;
|
|
237
|
+
gap: 8px;
|
|
238
|
+
align-items: center;
|
|
239
|
+
padding: 8px;
|
|
240
|
+
font-family: 'San Francisco';
|
|
241
|
+
font-weight: 500;
|
|
242
|
+
font-size: 11px;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
.body {
|
|
246
|
+
display: flex;
|
|
247
|
+
flex-direction: row;
|
|
248
|
+
align-items: center;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
ul {
|
|
252
|
+
margin: 0;
|
|
253
|
+
padding: 0;
|
|
254
|
+
list-style: none;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
ul.tabs {
|
|
258
|
+
display: flex;
|
|
259
|
+
flex-direction: column;
|
|
260
|
+
|
|
261
|
+
li {
|
|
262
|
+
display: flex;
|
|
263
|
+
flex-direction: column;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
button {
|
|
267
|
+
box-sizing: border-box;
|
|
268
|
+
color: ${theme.color.light[700]};
|
|
269
|
+
text-align: left;
|
|
270
|
+
padding: 10px;
|
|
271
|
+
font-weight: 600;
|
|
272
|
+
font-size: 12px;
|
|
273
|
+
transition: background-color 0.3s;
|
|
274
|
+
border-top-right-radius: 4px;
|
|
275
|
+
border-bottom-right-radius: 4px;
|
|
276
|
+
background-color: transparent;
|
|
277
|
+
border: none;
|
|
278
|
+
cursor: pointer;
|
|
279
|
+
outline: none;
|
|
280
|
+
|
|
281
|
+
&:hover, &.active, &:focus {
|
|
282
|
+
background-color: ${theme.color.light[600]};
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
&.active {
|
|
286
|
+
border-left: 1px solid ${theme.color.light.contrastText};
|
|
287
|
+
color: ${theme.color.light.contrastText};
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
ul.command-list {
|
|
293
|
+
align-self: stretch;
|
|
294
|
+
display: flex;
|
|
295
|
+
flex-direction: column;
|
|
296
|
+
gap: 2px;
|
|
297
|
+
overflow-y: auto;
|
|
298
|
+
flex: 1;
|
|
299
|
+
max-height: 170px;
|
|
300
|
+
|
|
301
|
+
li {
|
|
302
|
+
display: flex;
|
|
303
|
+
flex-direction: row;
|
|
304
|
+
align-items: center;
|
|
305
|
+
gap: 8px;
|
|
306
|
+
padding: 8px;
|
|
307
|
+
border-radius: 4px;
|
|
308
|
+
|
|
309
|
+
&:hover, &.focus {
|
|
310
|
+
background-color: ${theme.color.light[600]};
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
button.qc {
|
|
314
|
+
flex: 1;
|
|
315
|
+
border: none;
|
|
316
|
+
text-align: left;
|
|
317
|
+
background-color: transparent;
|
|
318
|
+
text-align: left;
|
|
319
|
+
outline: none;
|
|
320
|
+
overflow: hidden;
|
|
321
|
+
cursor: pointer;
|
|
322
|
+
|
|
323
|
+
.qc-title {
|
|
324
|
+
font-size: 11px;
|
|
325
|
+
margin: 0 0 4px 0;
|
|
326
|
+
color: ${theme.color.light.contrastText};
|
|
327
|
+
text-transform: uppercase;
|
|
328
|
+
text-overflow: ellipsis;
|
|
329
|
+
overflow: hidden;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
.qc-description {
|
|
333
|
+
color: ${theme.color.light[700]};
|
|
334
|
+
font-size: 12px;
|
|
335
|
+
margin: 0;
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
}
|
|
204
341
|
`
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { WithStyle } from '@stack-spot/portal-theme';
|
|
2
|
-
interface Props extends WithStyle {
|
|
3
|
-
value: string;
|
|
4
|
-
onChange: (value: string) => void;
|
|
5
|
-
language: string;
|
|
6
|
-
}
|
|
7
|
-
export declare const Editor: ({}: Props) => null;
|
|
8
|
-
export {};
|
|
9
|
-
//# sourceMappingURL=Editor.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Editor.d.ts","sourceRoot":"","sources":["../../src/components/Editor.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AAGpD,UAAU,KAAM,SAAQ,SAAS;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,eAAO,MAAM,MAAM,OAAQ,KAAK,SAAS,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Editor.js","sourceRoot":"","sources":["../../src/components/Editor.tsx"],"names":[],"mappings":"AAWA,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,EAAS,EAAE,EAAE,CAAC,IAAI,CAAA"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-empty-pattern */
|
|
2
|
-
/* Copiar do portal AI? */
|
|
3
|
-
import { WithStyle } from '@stack-spot/portal-theme'
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
interface Props extends WithStyle {
|
|
7
|
-
value: string,
|
|
8
|
-
onChange: (value: string) => void,
|
|
9
|
-
language: string,
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export const Editor = ({}: Props) => null
|