@stack-spot/ai-chat-widget 1.20.2 → 1.21.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/CHANGELOG.md +7 -0
- package/dist/app-metadata.json +5 -5
- package/dist/components/ProgressBar.d.ts +5 -1
- package/dist/components/ProgressBar.d.ts.map +1 -1
- package/dist/components/ProgressBar.js +8 -8
- package/dist/components/ProgressBar.js.map +1 -1
- package/dist/layout.css +2 -1
- package/dist/views/Chat/ChatMessage.d.ts +2 -2
- package/dist/views/Chat/ChatMessage.d.ts.map +1 -1
- package/dist/views/Chat/ChatMessage.js +4 -4
- package/dist/views/Chat/ChatMessage.js.map +1 -1
- package/dist/views/Chat/styled.d.ts.map +1 -1
- package/dist/views/Chat/styled.js +7 -4
- package/dist/views/Chat/styled.js.map +1 -1
- package/dist/views/MessageInput/ButtonBar.d.ts +17 -0
- package/dist/views/MessageInput/ButtonBar.d.ts.map +1 -0
- package/dist/views/MessageInput/ButtonBar.js +16 -0
- package/dist/views/MessageInput/ButtonBar.js.map +1 -0
- package/dist/views/MessageInput/InfoBar.d.ts.map +1 -1
- package/dist/views/MessageInput/InfoBar.js +2 -2
- package/dist/views/MessageInput/InfoBar.js.map +1 -1
- package/dist/views/MessageInput/SelectContent.d.ts +2 -0
- package/dist/views/MessageInput/SelectContent.d.ts.map +1 -0
- package/dist/views/MessageInput/SelectContent.js +48 -0
- package/dist/views/MessageInput/SelectContent.js.map +1 -0
- package/dist/views/MessageInput/dictionary.js +2 -2
- package/dist/views/MessageInput/dictionary.js.map +1 -1
- package/dist/views/MessageInput/index.d.ts.map +1 -1
- package/dist/views/MessageInput/index.js +4 -8
- package/dist/views/MessageInput/index.js.map +1 -1
- package/dist/views/MessageInput/styled.d.ts +6 -1
- package/dist/views/MessageInput/styled.d.ts.map +1 -1
- package/dist/views/MessageInput/styled.js +55 -45
- package/dist/views/MessageInput/styled.js.map +1 -1
- package/package.json +2 -2
- package/src/app-metadata.json +5 -5
- package/src/components/ProgressBar.tsx +15 -8
- package/src/layout.css +2 -1
- package/src/views/Chat/ChatMessage.tsx +8 -8
- package/src/views/Chat/styled.ts +7 -4
- package/src/views/MessageInput/ButtonBar.tsx +55 -0
- package/src/views/MessageInput/InfoBar.tsx +6 -2
- package/src/views/MessageInput/SelectContent.tsx +74 -0
- package/src/views/MessageInput/dictionary.ts +2 -2
- package/src/views/MessageInput/index.tsx +8 -18
- package/src/views/MessageInput/styled.ts +57 -46
- package/dist/views/MessageInput/ButtonGroup.d.ts +0 -29
- package/dist/views/MessageInput/ButtonGroup.d.ts.map +0 -1
- package/dist/views/MessageInput/ButtonGroup.js +0 -34
- package/dist/views/MessageInput/ButtonGroup.js.map +0 -1
- package/src/views/MessageInput/ButtonGroup.tsx +0 -109
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { listToClass } from '@stack-spot/portal-theme'
|
|
1
|
+
import { listToClass, theme } from '@stack-spot/portal-theme'
|
|
2
2
|
import { interpolate } from '@stack-spot/portal-translate'
|
|
3
3
|
import { useCallback, useEffect, useRef, useState } from 'react'
|
|
4
4
|
import { AdaptiveTextArea } from '../../components/AdaptiveTextArea'
|
|
@@ -9,7 +9,7 @@ import { ChatEntry } from '../../state/ChatEntry'
|
|
|
9
9
|
import { checkIsTrial } from '../../utils/check-is-trial'
|
|
10
10
|
import { AgentSelector } from './AgentSelector'
|
|
11
11
|
import { ButtonAgent } from './ButtonAgent'
|
|
12
|
-
import {
|
|
12
|
+
import { ButtonBar } from './ButtonBar'
|
|
13
13
|
import { useUserEntryHistoryShortcut } from './chat-entry-history'
|
|
14
14
|
import { useMessageInputDictionary } from './dictionary'
|
|
15
15
|
import { InfoBar } from './InfoBar'
|
|
@@ -24,7 +24,7 @@ import { MAX_INPUT_HEIGHT, MessageInputBox, MIN_INPUT_HEIGHT } from './styled'
|
|
|
24
24
|
export const MessageInput = () => {
|
|
25
25
|
const t = useMessageInputDictionary()
|
|
26
26
|
const [focused, setFocused] = useState(false)
|
|
27
|
-
const [
|
|
27
|
+
const [, setExpanded] = useState(true)
|
|
28
28
|
const expansionLocked = useRef(false)
|
|
29
29
|
const chat = useCurrentChat()
|
|
30
30
|
const isLoading = useCurrentChatState('isLoading') ?? false
|
|
@@ -43,7 +43,6 @@ export const MessageInput = () => {
|
|
|
43
43
|
const prompt = code && !quickCommandRegex.test(message) ? `${message}\n\`\`\`${language}\n${code}\n\`\`\`` : message
|
|
44
44
|
chat.pushMessage(ChatEntry.createUserEntry(prompt, true))
|
|
45
45
|
chat.set('nextMessage', '')
|
|
46
|
-
setFocused(false)
|
|
47
46
|
}, [chat])
|
|
48
47
|
|
|
49
48
|
const onKeyDown = useCallback((event: React.KeyboardEvent<HTMLTextAreaElement>) => {
|
|
@@ -60,9 +59,7 @@ export const MessageInput = () => {
|
|
|
60
59
|
}, [isLoading])
|
|
61
60
|
|
|
62
61
|
return (
|
|
63
|
-
<MessageInputBox aria-busy={isLoading} className="message-input">
|
|
64
|
-
<ProgressBar visible={isLoading} shimmer />
|
|
65
|
-
<InfoBar />
|
|
62
|
+
<MessageInputBox aria-busy={isLoading} className="message-input" $inputFocused={focused}>
|
|
66
63
|
<div className="wrapper-action">
|
|
67
64
|
<QuickCommandSelector inputRef={textAreaRef} isTrial={isTrial} />
|
|
68
65
|
<AgentSelector inputRef={textAreaRef} isTrial={isTrial} />
|
|
@@ -70,7 +67,6 @@ export const MessageInput = () => {
|
|
|
70
67
|
<ButtonAgent />
|
|
71
68
|
<AdaptiveTextArea
|
|
72
69
|
ref={textAreaRef}
|
|
73
|
-
disabled={isLoading}
|
|
74
70
|
placeholder={agentLabel && interpolate(t.placeholder, agentLabel)}
|
|
75
71
|
onChange={e => chat.set('nextMessage', e.target.value)}
|
|
76
72
|
value={value}
|
|
@@ -82,18 +78,12 @@ export const MessageInput = () => {
|
|
|
82
78
|
onResetSize={() => !expansionLocked.current && setExpanded(true)}
|
|
83
79
|
maxHeight={isMinimized ? MIN_INPUT_HEIGHT : MAX_INPUT_HEIGHT}
|
|
84
80
|
/>
|
|
85
|
-
<ButtonGroup
|
|
86
|
-
onSend={onSend}
|
|
87
|
-
onCancel={() => chat.abort()}
|
|
88
|
-
expanded={expanded}
|
|
89
|
-
isLoading={isLoading}
|
|
90
|
-
setExpanded={(value) => {
|
|
91
|
-
setExpanded(value)
|
|
92
|
-
expansionLocked.current = expanded
|
|
93
|
-
}}
|
|
94
|
-
/>
|
|
95
81
|
</div>
|
|
96
82
|
</div>
|
|
83
|
+
<ProgressBar visible={true} animate={isLoading}
|
|
84
|
+
backgroundColor={isLoading || !focused ? theme.color.light[600] : theme.color.primary[500]} />
|
|
85
|
+
<InfoBar />
|
|
86
|
+
<ButtonBar focused={focused} onSend={onSend} isLoading={isLoading} />
|
|
97
87
|
</MessageInputBox>
|
|
98
88
|
)
|
|
99
89
|
}
|
|
@@ -2,18 +2,60 @@ import { IconButton } from '@citric/ui'
|
|
|
2
2
|
import { theme } from '@stack-spot/portal-theme'
|
|
3
3
|
import { styled } from 'styled-components'
|
|
4
4
|
|
|
5
|
-
const INFO_BAR_HEIGHT =
|
|
5
|
+
const INFO_BAR_HEIGHT = 38
|
|
6
6
|
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
|
|
10
|
+
export const SelectionBarWrapper = styled.div<{$inputFocused?: boolean}>`
|
|
11
|
+
display: inline-flex;
|
|
12
|
+
justify-content: space-between;
|
|
13
|
+
position: relative;
|
|
14
|
+
padding: 8px;
|
|
15
|
+
background-color: ${theme.color.light[500]};
|
|
16
|
+
border-bottom-left-radius: 4px;
|
|
17
|
+
border-bottom-right-radius: 4px;
|
|
18
|
+
border: 2px solid ${({ $inputFocused }) => theme.color.light[$inputFocused ? 600 : 500]};
|
|
19
|
+
border-top: none;
|
|
20
|
+
|
|
21
|
+
.selection-list {
|
|
22
|
+
opacity: 0;
|
|
23
|
+
transition: height 0.4s, opacity 0.3s;
|
|
24
|
+
}
|
|
25
|
+
.visible {
|
|
26
|
+
opacity: 1;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.selection-list-content {
|
|
30
|
+
background-color: ${theme.color.light[500]};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
ul {
|
|
34
|
+
list-style: none;
|
|
35
|
+
padding: 0;
|
|
36
|
+
margin: 12px;
|
|
37
|
+
min-width: 225px;
|
|
38
|
+
}
|
|
39
|
+
li {
|
|
40
|
+
cursor: pointer;
|
|
41
|
+
svg {
|
|
42
|
+
width: 16px;
|
|
43
|
+
height: 16px;
|
|
44
|
+
}
|
|
45
|
+
&:hover {
|
|
46
|
+
background-color: ${theme.color.light[600]}
|
|
47
|
+
}
|
|
48
|
+
a:hover {
|
|
49
|
+
background-color: ${theme.color.light[600]}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
`
|
|
53
|
+
|
|
54
|
+
export const MessageInputBox = styled.div<{$inputFocused?: boolean}>`
|
|
11
55
|
display: flex;
|
|
12
56
|
flex-direction: column;
|
|
13
57
|
|
|
14
58
|
> .info-bar {
|
|
15
|
-
margin-top: 8px;
|
|
16
|
-
margin-bottom: -3px;
|
|
17
59
|
position: relative;
|
|
18
60
|
overflow: hidden;
|
|
19
61
|
|
|
@@ -33,14 +75,14 @@ export const MessageInputBox = styled.div`
|
|
|
33
75
|
top: 0;
|
|
34
76
|
left: 0;
|
|
35
77
|
right: 0;
|
|
36
|
-
border-top-left-radius: 10px;
|
|
37
|
-
border-top-right-radius: 10px;
|
|
38
78
|
height: ${INFO_BAR_HEIGHT}px;
|
|
39
|
-
padding:
|
|
79
|
+
padding-top: 8px;
|
|
40
80
|
background-color: ${theme.color.light[500]};
|
|
41
81
|
display: flex;
|
|
42
82
|
flex-direction: row;
|
|
43
|
-
gap:
|
|
83
|
+
gap: 4px;
|
|
84
|
+
border-right: 2px solid ${({ $inputFocused }) => theme.color.light[$inputFocused ? 600 : 500]};
|
|
85
|
+
border-left: 2px solid ${({ $inputFocused }) => theme.color.light[$inputFocused ? 600 : 500]};
|
|
44
86
|
|
|
45
87
|
.list-overflow {
|
|
46
88
|
max-width: calc(100% - 30px); // close button + gap
|
|
@@ -93,16 +135,19 @@ export const MessageInputBox = styled.div`
|
|
|
93
135
|
flex-direction: row;
|
|
94
136
|
gap: 8px;
|
|
95
137
|
align-items: end;
|
|
96
|
-
border-radius: 4px;
|
|
97
|
-
border:
|
|
98
|
-
|
|
138
|
+
border-top-left-radius: 4px;
|
|
139
|
+
border-top-right-radius: 4px;
|
|
140
|
+
border: 2px solid ${theme.color.light[500]};
|
|
141
|
+
|
|
142
|
+
background-color: ${theme.color.light[500]};
|
|
99
143
|
padding: 10px 8px;
|
|
100
144
|
transition: border-color 0.3s, background-color 0.3s;
|
|
101
145
|
|
|
102
146
|
&.focused {
|
|
103
|
-
border
|
|
147
|
+
border: 2px solid ${theme.color.light[600]};
|
|
104
148
|
}
|
|
105
149
|
|
|
150
|
+
|
|
106
151
|
&.disabled {
|
|
107
152
|
background-color: ${theme.color.light[500]};
|
|
108
153
|
}
|
|
@@ -121,43 +166,9 @@ export const MessageInputBox = styled.div`
|
|
|
121
166
|
button {
|
|
122
167
|
border: none;
|
|
123
168
|
border-radius: 2px;
|
|
124
|
-
opacity: 0.6;
|
|
125
169
|
transition: background-color 0.2s, opacity 0.2s;
|
|
126
|
-
background-color: transparent;
|
|
127
170
|
padding: 0;
|
|
128
171
|
|
|
129
|
-
svg {
|
|
130
|
-
fill: ${theme.color.light[700]};
|
|
131
|
-
width: 16px;
|
|
132
|
-
height: 16px;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
&:hover {
|
|
136
|
-
background-color: ${theme.color.light[500]};
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
&.send {
|
|
140
|
-
background-color: ${theme.color.inverse[500]};
|
|
141
|
-
&:hover {
|
|
142
|
-
opacity: 1;
|
|
143
|
-
}
|
|
144
|
-
svg {
|
|
145
|
-
fill: ${theme.color.inverse.contrastText};
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
&.expand {
|
|
150
|
-
svg {
|
|
151
|
-
transition: transform 0.3s;
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
&.collapsed {
|
|
156
|
-
svg {
|
|
157
|
-
transform: rotate(180deg);
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
|
|
161
172
|
&.agent {
|
|
162
173
|
border-radius: 50%;
|
|
163
174
|
opacity: 1;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
interface ButtonGroupProps {
|
|
2
|
-
/**
|
|
3
|
-
* Whether or not the button group is expanded.
|
|
4
|
-
*/
|
|
5
|
-
expanded: boolean;
|
|
6
|
-
/**
|
|
7
|
-
* A function to set the button group as expanded or collapsed.
|
|
8
|
-
*/
|
|
9
|
-
setExpanded: React.Dispatch<React.SetStateAction<boolean>>;
|
|
10
|
-
/**
|
|
11
|
-
* Whether or not the message is currently being sent. This is used to decide which button to show: send or cancel.
|
|
12
|
-
*/
|
|
13
|
-
isLoading: boolean;
|
|
14
|
-
/**
|
|
15
|
-
* A function to run when the send button is clicked.
|
|
16
|
-
*/
|
|
17
|
-
onSend: () => void;
|
|
18
|
-
/**
|
|
19
|
-
* A function to run when the cancel button is clicked.
|
|
20
|
-
*/
|
|
21
|
-
onCancel: () => void;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Renders the button group at right bottom side of the message input. This includes the send button as well as the buttons to open the
|
|
25
|
-
* editor, change the stack, etc.
|
|
26
|
-
*/
|
|
27
|
-
export declare const ButtonGroup: ({ onSend, onCancel, expanded, setExpanded, isLoading }: ButtonGroupProps) => import("react/jsx-runtime").JSX.Element;
|
|
28
|
-
export {};
|
|
29
|
-
//# sourceMappingURL=ButtonGroup.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ButtonGroup.d.ts","sourceRoot":"","sources":["../../../src/views/MessageInput/ButtonGroup.tsx"],"names":[],"mappings":"AAOA,UAAU,gBAAgB;IACxB;;OAEG;IACH,QAAQ,EAAE,OAAO,CAAC;IAClB;;OAEG;IACH,WAAW,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC;IAC3D;;OAEG;IACH,SAAS,EAAE,OAAO,CAAC;IACnB;;OAEG;IACH,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB;;OAEG;IACH,QAAQ,EAAE,MAAM,IAAI,CAAC;CACtB;AAED;;;GAGG;AACH,eAAO,MAAM,WAAW,2DAA4D,gBAAgB,4CA0EnG,CAAA"}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { ChevronRight, Code, KnowledgeSource, Send, Spaces, Stack, Times } from '@citric/icons';
|
|
3
|
-
import { IconButton } from '@citric/ui';
|
|
4
|
-
import { listToClass } from '@stack-spot/portal-theme';
|
|
5
|
-
import { useEffect, useRef } from 'react';
|
|
6
|
-
import { useCurrentChatState, useWidget } from '../../context/hooks.js';
|
|
7
|
-
import { useMessageInputDictionary } from './dictionary.js';
|
|
8
|
-
/**
|
|
9
|
-
* Renders the button group at right bottom side of the message input. This includes the send button as well as the buttons to open the
|
|
10
|
-
* editor, change the stack, etc.
|
|
11
|
-
*/
|
|
12
|
-
export const ButtonGroup = ({ onSend, onCancel, expanded, setExpanded, isLoading }) => {
|
|
13
|
-
const t = useMessageInputDictionary();
|
|
14
|
-
const widget = useWidget();
|
|
15
|
-
const featureButtonsWidth = useRef();
|
|
16
|
-
const featureButtons = useRef(null);
|
|
17
|
-
const features = useCurrentChatState('features');
|
|
18
|
-
const hasFeatureButtons = features.workspace || features.knowledgeSource || features.stack || features.editor;
|
|
19
|
-
useEffect(() => {
|
|
20
|
-
if (!featureButtons.current)
|
|
21
|
-
return;
|
|
22
|
-
const isHidden = featureButtons.current.style.width === '0px';
|
|
23
|
-
featureButtons.current.style.width = 'auto';
|
|
24
|
-
featureButtonsWidth.current = featureButtons.current.clientWidth;
|
|
25
|
-
if (isHidden)
|
|
26
|
-
featureButtons.current.style.width = '0px';
|
|
27
|
-
else
|
|
28
|
-
featureButtons.current.style.width = `${featureButtonsWidth.current}px`;
|
|
29
|
-
},
|
|
30
|
-
// don't use the whole features object here, it would make every chat tab change rerun this effect.
|
|
31
|
-
[features.workspace, features.knowledgeSource, features.stack, features.editor]);
|
|
32
|
-
return (_jsxs("div", { className: "button-group", children: [hasFeatureButtons && _jsxs(_Fragment, { children: [_jsxs("div", { ref: featureButtons, className: listToClass(['feature-buttons', expanded && 'expanded']), style: { width: expanded ? featureButtonsWidth.current : 0 }, children: [features.workspace && (_jsx(IconButton, { "aria-label": t.spot, title: t.spot, onClick: () => widget.set('panel', 'workspace'), children: _jsx(Spaces, {}) })), features.knowledgeSource && (_jsx(IconButton, { "aria-label": t.knowledgeSource, title: t.knowledgeSource, onClick: () => widget.set('panel', 'ks'), children: _jsx(KnowledgeSource, {}) })), features.stack && (_jsx(IconButton, { "aria-label": t.stack, title: t.stack, onClick: () => widget.set('panel', 'stack'), children: _jsx(Stack, {}) })), features.editor && (_jsx(IconButton, { "aria-label": t.code, title: t.code, onClick: () => widget.set('panel', 'editor'), children: _jsx(Code, {}) }))] }), _jsx(IconButton, { title: expanded ? t.collapse : t.expand, className: listToClass(['expand', !expanded && 'collapsed']), "aria-label": expanded ? t.collapse : t.expand, onClick: () => setExpanded(v => !v), children: _jsx(ChevronRight, {}) })] }), isLoading ? (_jsx(IconButton, { "aria-label": t.cancel, onClick: onCancel, className: "send", title: t.cancel, children: _jsx(Times, {}) })) : (_jsx(IconButton, { "aria-label": t.send, onClick: onSend, className: "send", title: t.send, children: _jsx(Send, {}) }))] }));
|
|
33
|
-
};
|
|
34
|
-
//# sourceMappingURL=ButtonGroup.js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@@ -1,109 +0,0 @@
|
|
|
1
|
-
import { ChevronRight, Code, KnowledgeSource, Send, Spaces, Stack, Times } from '@citric/icons'
|
|
2
|
-
import { IconButton } from '@citric/ui'
|
|
3
|
-
import { listToClass } from '@stack-spot/portal-theme'
|
|
4
|
-
import { useEffect, useRef } from 'react'
|
|
5
|
-
import { useCurrentChatState, useWidget } from '../../context/hooks'
|
|
6
|
-
import { useMessageInputDictionary } from './dictionary'
|
|
7
|
-
|
|
8
|
-
interface ButtonGroupProps {
|
|
9
|
-
/**
|
|
10
|
-
* Whether or not the button group is expanded.
|
|
11
|
-
*/
|
|
12
|
-
expanded: boolean,
|
|
13
|
-
/**
|
|
14
|
-
* A function to set the button group as expanded or collapsed.
|
|
15
|
-
*/
|
|
16
|
-
setExpanded: React.Dispatch<React.SetStateAction<boolean>>,
|
|
17
|
-
/**
|
|
18
|
-
* Whether or not the message is currently being sent. This is used to decide which button to show: send or cancel.
|
|
19
|
-
*/
|
|
20
|
-
isLoading: boolean,
|
|
21
|
-
/**
|
|
22
|
-
* A function to run when the send button is clicked.
|
|
23
|
-
*/
|
|
24
|
-
onSend: () => void,
|
|
25
|
-
/**
|
|
26
|
-
* A function to run when the cancel button is clicked.
|
|
27
|
-
*/
|
|
28
|
-
onCancel: () => void,
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Renders the button group at right bottom side of the message input. This includes the send button as well as the buttons to open the
|
|
33
|
-
* editor, change the stack, etc.
|
|
34
|
-
*/
|
|
35
|
-
export const ButtonGroup = ({ onSend, onCancel, expanded, setExpanded, isLoading }: ButtonGroupProps) => {
|
|
36
|
-
const t = useMessageInputDictionary()
|
|
37
|
-
const widget = useWidget()
|
|
38
|
-
const featureButtonsWidth = useRef<number | undefined>()
|
|
39
|
-
const featureButtons = useRef<HTMLDivElement>(null)
|
|
40
|
-
const features = useCurrentChatState('features')
|
|
41
|
-
const hasFeatureButtons = features.workspace || features.knowledgeSource || features.stack || features.editor
|
|
42
|
-
|
|
43
|
-
useEffect(
|
|
44
|
-
() => {
|
|
45
|
-
if (!featureButtons.current) return
|
|
46
|
-
const isHidden = featureButtons.current.style.width === '0px'
|
|
47
|
-
featureButtons.current.style.width = 'auto'
|
|
48
|
-
featureButtonsWidth.current = featureButtons.current.clientWidth
|
|
49
|
-
if (isHidden) featureButtons.current.style.width = '0px'
|
|
50
|
-
else featureButtons.current.style.width = `${featureButtonsWidth.current}px`
|
|
51
|
-
},
|
|
52
|
-
// don't use the whole features object here, it would make every chat tab change rerun this effect.
|
|
53
|
-
[features.workspace, features.knowledgeSource, features.stack, features.editor],
|
|
54
|
-
)
|
|
55
|
-
|
|
56
|
-
return (
|
|
57
|
-
<div className="button-group">
|
|
58
|
-
{hasFeatureButtons && <>
|
|
59
|
-
<div
|
|
60
|
-
ref={featureButtons}
|
|
61
|
-
className={listToClass(['feature-buttons', expanded && 'expanded'])}
|
|
62
|
-
style={{ width: expanded ? featureButtonsWidth.current : 0 }}
|
|
63
|
-
>
|
|
64
|
-
{features.workspace && (
|
|
65
|
-
<IconButton aria-label={t.spot} title={t.spot} onClick={() => widget.set('panel', 'workspace')}>
|
|
66
|
-
<Spaces />
|
|
67
|
-
</IconButton>
|
|
68
|
-
)}
|
|
69
|
-
{features.knowledgeSource && (
|
|
70
|
-
<IconButton
|
|
71
|
-
aria-label={t.knowledgeSource}
|
|
72
|
-
title={t.knowledgeSource}
|
|
73
|
-
onClick={() => widget.set('panel', 'ks')}
|
|
74
|
-
>
|
|
75
|
-
<KnowledgeSource />
|
|
76
|
-
</IconButton>
|
|
77
|
-
)}
|
|
78
|
-
{features.stack && (
|
|
79
|
-
<IconButton aria-label={t.stack} title={t.stack} onClick={() => widget.set('panel', 'stack')}>
|
|
80
|
-
<Stack />
|
|
81
|
-
</IconButton>
|
|
82
|
-
)}
|
|
83
|
-
{features.editor && (
|
|
84
|
-
<IconButton aria-label={t.code} title={t.code} onClick={() => widget.set('panel', 'editor')}>
|
|
85
|
-
<Code />
|
|
86
|
-
</IconButton>
|
|
87
|
-
)}
|
|
88
|
-
</div>
|
|
89
|
-
<IconButton
|
|
90
|
-
title={expanded ? t.collapse : t.expand}
|
|
91
|
-
className={listToClass(['expand', !expanded && 'collapsed'])}
|
|
92
|
-
aria-label={expanded ? t.collapse : t.expand}
|
|
93
|
-
onClick={() => setExpanded(v => !v)}
|
|
94
|
-
>
|
|
95
|
-
<ChevronRight />
|
|
96
|
-
</IconButton>
|
|
97
|
-
</>}
|
|
98
|
-
{isLoading ? (
|
|
99
|
-
<IconButton aria-label={t.cancel} onClick={onCancel} className="send" title={t.cancel}>
|
|
100
|
-
<Times />
|
|
101
|
-
</IconButton>
|
|
102
|
-
) : (
|
|
103
|
-
<IconButton aria-label={t.send} onClick={onSend} className="send" title={t.send}>
|
|
104
|
-
<Send />
|
|
105
|
-
</IconButton>
|
|
106
|
-
)}
|
|
107
|
-
</div>
|
|
108
|
-
)
|
|
109
|
-
}
|