@stack-spot/ai-chat-widget 1.24.3 → 1.25.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 +14 -0
- package/dist/app-metadata.json +3 -3
- package/dist/chat-interceptors/send-message.js +3 -3
- package/dist/chat-interceptors/send-message.js.map +1 -1
- package/dist/components/FileDescription.d.ts +10 -0
- package/dist/components/FileDescription.d.ts.map +1 -0
- package/dist/components/FileDescription.js +85 -0
- package/dist/components/FileDescription.js.map +1 -0
- package/dist/state/ChatEntry.d.ts +9 -0
- package/dist/state/ChatEntry.d.ts.map +1 -1
- package/dist/state/ChatEntry.js.map +1 -1
- package/dist/state/ChatState.d.ts +5 -0
- package/dist/state/ChatState.d.ts.map +1 -1
- package/dist/state/ChatState.js +6 -0
- package/dist/state/ChatState.js.map +1 -1
- package/dist/state/constants.d.ts +5 -0
- package/dist/state/constants.d.ts.map +1 -0
- package/dist/state/constants.js +9 -0
- package/dist/state/constants.js.map +1 -0
- package/dist/state/types.d.ts +4 -0
- package/dist/state/types.d.ts.map +1 -1
- package/dist/utils/chat.d.ts +2 -1
- package/dist/utils/chat.d.ts.map +1 -1
- package/dist/utils/chat.js +2 -1
- package/dist/utils/chat.js.map +1 -1
- package/dist/utils/upload/FileUpload.d.ts +21 -0
- package/dist/utils/upload/FileUpload.d.ts.map +1 -0
- package/dist/utils/upload/FileUpload.js +55 -0
- package/dist/utils/upload/FileUpload.js.map +1 -0
- package/dist/utils/upload/UploadManager.d.ts +40 -0
- package/dist/utils/upload/UploadManager.d.ts.map +1 -0
- package/dist/utils/upload/UploadManager.js +131 -0
- package/dist/utils/upload/UploadManager.js.map +1 -0
- package/dist/utils/upload/context.d.ts +15 -0
- package/dist/utils/upload/context.d.ts.map +1 -0
- package/dist/utils/upload/context.js +37 -0
- package/dist/utils/upload/context.js.map +1 -0
- package/dist/utils/upload/errors.d.ts +17 -0
- package/dist/utils/upload/errors.d.ts.map +1 -0
- package/dist/utils/upload/errors.js +27 -0
- package/dist/utils/upload/errors.js.map +1 -0
- package/dist/utils/upload/types.d.ts +7 -0
- package/dist/utils/upload/types.d.ts.map +1 -0
- package/dist/utils/upload/types.js +2 -0
- package/dist/utils/upload/types.js.map +1 -0
- package/dist/utils/upload/utils.d.ts +4 -0
- package/dist/utils/upload/utils.d.ts.map +1 -0
- package/dist/utils/upload/utils.js +10 -0
- package/dist/utils/upload/utils.js.map +1 -0
- package/dist/views/Chat/AgentInfo.d.ts +2 -1
- package/dist/views/Chat/AgentInfo.d.ts.map +1 -1
- package/dist/views/Chat/AgentInfo.js +2 -2
- package/dist/views/Chat/AgentInfo.js.map +1 -1
- package/dist/views/Chat/ChatMessage.d.ts +1 -1
- package/dist/views/Chat/ChatMessage.d.ts.map +1 -1
- package/dist/views/Chat/ChatMessage.js +26 -7
- 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 +23 -1
- package/dist/views/Chat/styled.js.map +1 -1
- package/dist/views/MessageInput/{InfoBar.d.ts → ContextBar.d.ts} +2 -2
- package/dist/views/MessageInput/ContextBar.d.ts.map +1 -0
- package/dist/views/MessageInput/{InfoBar.js → ContextBar.js} +5 -5
- package/dist/views/MessageInput/ContextBar.js.map +1 -0
- package/dist/views/MessageInput/SelectContent.d.ts.map +1 -1
- package/dist/views/MessageInput/SelectContent.js +14 -17
- package/dist/views/MessageInput/SelectContent.js.map +1 -1
- package/dist/views/MessageInput/UploadBar.d.ts +2 -0
- package/dist/views/MessageInput/UploadBar.d.ts.map +1 -0
- package/dist/views/MessageInput/UploadBar.js +47 -0
- package/dist/views/MessageInput/UploadBar.js.map +1 -0
- package/dist/views/MessageInput/dictionary.d.ts +1 -1
- package/dist/views/MessageInput/dictionary.d.ts.map +1 -1
- package/dist/views/MessageInput/dictionary.js +18 -4
- 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 +46 -5
- 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 +56 -27
- package/dist/views/MessageInput/styled.js.map +1 -1
- package/dist/views/Steps/dictionary.d.ts +1 -1
- package/package.json +2 -2
- package/src/app-metadata.json +3 -3
- package/src/chat-interceptors/send-message.ts +3 -3
- package/src/components/FileDescription.tsx +114 -0
- package/src/state/ChatEntry.ts +10 -0
- package/src/state/ChatState.ts +6 -0
- package/src/state/constants.ts +12 -0
- package/src/state/types.ts +5 -0
- package/src/utils/chat.ts +3 -1
- package/src/utils/upload/FileUpload.ts +64 -0
- package/src/utils/upload/UploadManager.ts +147 -0
- package/src/utils/upload/context.tsx +44 -0
- package/src/utils/upload/errors.ts +34 -0
- package/src/utils/upload/types.ts +7 -0
- package/src/utils/upload/utils.ts +12 -0
- package/src/views/Chat/AgentInfo.tsx +3 -2
- package/src/views/Chat/ChatMessage.tsx +139 -113
- package/src/views/Chat/styled.ts +23 -1
- package/src/views/MessageInput/{InfoBar.tsx → ContextBar.tsx} +9 -9
- package/src/views/MessageInput/SelectContent.tsx +17 -21
- package/src/views/MessageInput/UploadBar.tsx +69 -0
- package/src/views/MessageInput/dictionary.ts +18 -4
- package/src/views/MessageInput/index.tsx +77 -32
- package/src/views/MessageInput/styled.ts +56 -27
- package/dist/views/MessageInput/InfoBar.d.ts.map +0 -1
- package/dist/views/MessageInput/InfoBar.js.map +0 -1
|
@@ -8,7 +8,7 @@ import { useCallback, useMemo } from 'react';
|
|
|
8
8
|
import { FadingOverflow } from '../../components/FadingOverflow.js';
|
|
9
9
|
import { useCurrentChat, useCurrentChatState } from '../../context/hooks.js';
|
|
10
10
|
import { useMessageInputDictionary } from './dictionary.js';
|
|
11
|
-
const
|
|
11
|
+
const ContextBadge = ({ label, color, dismiss, onDismiss }) => (_jsx(Badge, { appearance: "square", palette: color, className: "context-badge", afterElement: onDismiss &&
|
|
12
12
|
_jsx(IconButton, { appearance: "square", colorIcon: `${color}.800`, onClick: onDismiss, title: dismiss, "arial-label": dismiss, children: _jsx(TimesMini, {}) }), children: _jsx(Text, { nowrapEllipsis: true, children: label }) }));
|
|
13
13
|
/**
|
|
14
14
|
* This renders the bar on top of the textarea to send the message. This tells:
|
|
@@ -17,7 +17,7 @@ const InfoBadge = ({ label, color, dismiss, onDismiss }) => (_jsx(Badge, { appea
|
|
|
17
17
|
* - which stack is being used;
|
|
18
18
|
* - which knowledge sources are being used.
|
|
19
19
|
*/
|
|
20
|
-
export const
|
|
20
|
+
export const ContextBar = () => {
|
|
21
21
|
const t = useMessageInputDictionary();
|
|
22
22
|
const chat = useCurrentChat();
|
|
23
23
|
const currentStack = useCurrentChatState('stack');
|
|
@@ -30,7 +30,7 @@ export const InfoBar = () => {
|
|
|
30
30
|
const onDismiss = features.knowledgeSource
|
|
31
31
|
? (() => chat.set('knowledgeSources', currentKnowledgeSources.filter(({ id }) => id !== ks.id)))
|
|
32
32
|
: undefined;
|
|
33
|
-
return _jsx("li", { children: _jsx(
|
|
33
|
+
return _jsx("li", { children: _jsx(ContextBadge, { label: ks.label, dismiss: t.removeKS, color: "teal", onDismiss: onDismiss }) }, ks.id);
|
|
34
34
|
}), [currentKnowledgeSources]);
|
|
35
35
|
const shouldRenderRemoveAllButton = (currentSelection
|
|
36
36
|
|| (features.stack && currentStack)
|
|
@@ -49,6 +49,6 @@ export const InfoBar = () => {
|
|
|
49
49
|
const editor = loader.__getMonacoInstance()?.editor;
|
|
50
50
|
editor?.getEditors()[0].setSelection({ startLineNumber: 0, endLineNumber: 0, endColumn: 0, startColumn: 0 });
|
|
51
51
|
}, []);
|
|
52
|
-
return (_jsxs("div", { className: listToClass(['info-bar', visible && 'visible']), children: [_jsx("div", { className: "space" }), _jsxs("div", { className: "content", children: [shouldRenderRemoveAllButton && (_jsx(IconButton, { appearance: "square", color: "light", "aria-label": t.removeConfig, title: t.removeConfig, onClick: removeAll, children: _jsx(TimesMini, {}) })), _jsx(FadingOverflow, { className: "list-overflow", scroll: "arrows", enableHorizontalScrollWithVerticalWheel: true, children: _jsxs("ul", { children: [currentSelection && (_jsx("li", { children: _jsx(
|
|
52
|
+
return (_jsxs("div", { className: listToClass(['info-bar', 'context-bar', visible && 'visible']), children: [_jsx("div", { className: "space" }), _jsxs("div", { className: "content", children: [shouldRenderRemoveAllButton && (_jsx(IconButton, { appearance: "square", color: "light", "aria-label": t.removeConfig, title: t.removeConfig, onClick: removeAll, children: _jsx(TimesMini, {}) })), _jsx(FadingOverflow, { className: "list-overflow", scroll: "arrows", enableHorizontalScrollWithVerticalWheel: true, children: _jsxs("ul", { children: [currentSelection && (_jsx("li", { children: _jsx(ContextBadge, { label: t.selected, dismiss: t.removeSelection, color: "blue", onDismiss: removeCodeSelection }) })), currentStack && (_jsx("li", { children: _jsx(ContextBadge, { label: currentStack.label, dismiss: t.removeStack, color: "cyan", onDismiss: features.stack ? (() => chat.set('stack', undefined)) : undefined }) })), currentWorkspace && (_jsx("li", { children: _jsx(ContextBadge, { label: currentWorkspace.label, dismiss: t.removeWorkspace, color: "pink", onDismiss: features.workspace ? (() => chat.set('workspace', undefined)) : undefined }) })), ksToRender] }) })] })] }));
|
|
53
53
|
};
|
|
54
|
-
//# sourceMappingURL=
|
|
54
|
+
//# sourceMappingURL=ContextBar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ContextBar.js","sourceRoot":"","sources":["../../../src/views/MessageInput/ContextBar.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AACnC,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AACzC,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAA;AAC7C,OAAO,EAAoB,WAAW,EAAE,MAAM,0BAA0B,CAAA;AACxE,OAAO,EAAE,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AC,OAAO,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,GAC5E,GACC,CACN,EACA,gBAAgB,IAAI,CACnB,uBACE,KAAC,YAAY,IACX,KAAK,EAAE,gBAAgB,CAAC,KAAK,EAC7B,OAAO,EAAE,CAAC,CAAC,eAAe,EAC1B,KAAK,EAAC,MAAM,EACZ,SAAS,EAAE,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,GACpF,GACC,CACN,EACA,UAAU,IACR,GACU,IACb,IACF,CACP,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectContent.d.ts","sourceRoot":"","sources":["../../../src/views/MessageInput/SelectContent.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"SelectContent.d.ts","sourceRoot":"","sources":["../../../src/views/MessageInput/SelectContent.tsx"],"names":[],"mappings":"AAWA,eAAO,MAAM,aAAa,sDAyEzB,CAAA"}
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { KnowledgeSource, Plus, Spaces, Stack } from '@citric/icons';
|
|
2
|
+
import { DocumentUpload, KnowledgeSource, Plus, Spaces, Stack } from '@citric/icons';
|
|
3
3
|
import { IconButton } from '@citric/ui';
|
|
4
4
|
import { SelectionList } from '@stack-spot/portal-components/SelectionList';
|
|
5
|
-
import { useTranslate } from '@stack-spot/portal-translate';
|
|
6
5
|
import { useMemo, useState } from 'react';
|
|
7
6
|
import { useCurrentChatState, useWidget } from '../../context/hooks.js';
|
|
7
|
+
import { useUploadManager } from '../../utils/upload/context.js';
|
|
8
|
+
import { useMessageInputDictionary } from './dictionary.js';
|
|
8
9
|
export const SelectContent = () => {
|
|
9
10
|
const widget = useWidget();
|
|
10
11
|
const [visibleMenu, setVisibleMenu] = useState(false);
|
|
11
12
|
const features = useCurrentChatState('features');
|
|
13
|
+
const t = useMessageInputDictionary();
|
|
14
|
+
const uploadManager = useUploadManager();
|
|
12
15
|
const hasFeatureButtons = features.workspace || features.knowledgeSource || features.stack;
|
|
13
|
-
const t = useTranslate(dictionary);
|
|
14
16
|
const itemConfigs = [
|
|
15
17
|
{
|
|
16
18
|
key: 'knowledgeSource',
|
|
@@ -42,19 +44,14 @@ export const SelectContent = () => {
|
|
|
42
44
|
})), [features, widget]);
|
|
43
45
|
if (!hasFeatureButtons)
|
|
44
46
|
return null;
|
|
45
|
-
return (_jsxs(_Fragment, { children: [_jsx(IconButton, { id: "button-content-select", color: "light", appearance: "square", role: "button", title: visibleMenu ? t.collapse : t.expand, "data-test-hint": "button-options", "aria-label": visibleMenu ? t.collapse : t.expand, onClick: () => setVisibleMenu(state => !state), children: _jsx(Plus, {}) }), _jsx(SelectionList, {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
},
|
|
55
|
-
pt: {
|
|
56
|
-
expand: 'Mostrar opções',
|
|
57
|
-
collapse: 'Esconder opções',
|
|
58
|
-
},
|
|
47
|
+
return (_jsxs(_Fragment, { children: [_jsx(IconButton, { id: "button-content-select", color: "light", appearance: "square", role: "button", title: visibleMenu ? t.collapse : t.expand, "data-test-hint": "button-options", "aria-label": visibleMenu ? t.collapse : t.expand, "aria-controls": "chatMessageMenu", onClick: () => setVisibleMenu(state => !state), children: _jsx(Plus, {}) }), _jsx(SelectionList, { className: "message-menu", id: "chatMessageMenu", visible: visibleMenu, onHide: () => setVisibleMenu(false), items: [
|
|
48
|
+
...listItems,
|
|
49
|
+
{
|
|
50
|
+
label: t.upload,
|
|
51
|
+
onClick: () => uploadManager.open(),
|
|
52
|
+
className: 'upload-item',
|
|
53
|
+
icon: _jsx(DocumentUpload, {}),
|
|
54
|
+
},
|
|
55
|
+
] })] }));
|
|
59
56
|
};
|
|
60
57
|
//# sourceMappingURL=SelectContent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectContent.js","sourceRoot":"","sources":["../../../src/views/MessageInput/SelectContent.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;
|
|
1
|
+
{"version":3,"file":"SelectContent.js","sourceRoot":"","sources":["../../../src/views/MessageInput/SelectContent.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AACpF,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,6CAA6C,CAAA;AAC3E,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AACzC,OAAO,EAAE,mBAAmB,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAA;AAC7D,OAAO,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAA;AAKxD,MAAM,CAAC,MAAM,aAAa,GAAG,GAAG,EAAE;IAChC,MAAM,MAAM,GAAG,SAAS,EAAE,CAAA;IAC1B,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAA;IACrD,MAAM,QAAQ,GAAG,mBAAmB,CAAC,UAAU,CAAC,CAAA;IAChD,MAAM,CAAC,GAAG,yBAAyB,EAAE,CAAA;IACrC,MAAM,aAAa,GAAG,gBAAgB,EAAE,CAAA;IACxC,MAAM,iBAAiB,GAAG,QAAQ,CAAC,SAAS,IAAI,QAAQ,CAAC,eAAe,IAAI,QAAQ,CAAC,KAA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QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,mBACjC,iBAAiB,EAC/B,OAAO,EAAE,GAAG,EAAE,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,YAC9C,KAAC,IAAI,KAAG,GACG,EACb,KAAC,aAAa,IACZ,SAAS,EAAC,cAAc,EACxB,EAAE,EAAC,iBAAiB,EACpB,OAAO,EAAE,WAAW,EACpB,MAAM,EAAE,GAAG,EAAE,CAAC,cAAc,CAAC,KAAK,CAAC,EACnC,KAAK,EAAE;oBACL,GAAG,SAAS;oBACZ;wBACE,KAAK,EAAE,CAAC,CAAC,MAAM;wBACf,OAAO,EAAE,GAAG,EAAE,CAAC,aAAa,CAAC,IAAI,EAAE;wBACnC,SAAS,EAAE,aAAa;wBACxB,IAAI,EAAE,KAAC,cAAc,KAAG;qBACzB;iBACF,GACD,IACD,CACJ,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UploadBar.d.ts","sourceRoot":"","sources":["../../../src/views/MessageInput/UploadBar.tsx"],"names":[],"mappings":"AAiCA,eAAO,MAAM,SAAS,+CAmCrB,CAAA"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { listToClass } from '@stack-spot/portal-theme';
|
|
3
|
+
import { interpolate } from '@stack-spot/portal-translate';
|
|
4
|
+
import { useMemo } from 'react';
|
|
5
|
+
import { FadingOverflow } from '../../components/FadingOverflow.js';
|
|
6
|
+
import { FileDescription } from '../../components/FileDescription.js';
|
|
7
|
+
import { useCurrentChat } from '../../context/hooks.js';
|
|
8
|
+
import { ChatEntry } from '../../state/ChatEntry.js';
|
|
9
|
+
import { useUploadErrorEffect, useUploadManager, useUploads, useUploadStatus } from '../../utils/upload/context.js';
|
|
10
|
+
import { FileIsTooLarge, MaxFilesReached } from '../../utils/upload/errors.js';
|
|
11
|
+
import { useMessageInputDictionary } from './dictionary.js';
|
|
12
|
+
function createImageFromFile(file) {
|
|
13
|
+
return _jsx("img", { src: URL.createObjectURL(file), alt: file.name });
|
|
14
|
+
}
|
|
15
|
+
const UploadItem = ({ upload }) => {
|
|
16
|
+
const uploadManager = useUploadManager();
|
|
17
|
+
const icon = upload.file.type.toLowerCase().startsWith('image/') ? createImageFromFile(upload.file) : undefined;
|
|
18
|
+
const status = useUploadStatus(upload);
|
|
19
|
+
return _jsx(FileDescription, { fileName: upload.file.name, icon: icon, onRemove: () => uploadManager.remove(upload), onRetry: () => upload.retry(), status: status });
|
|
20
|
+
};
|
|
21
|
+
export const UploadBar = () => {
|
|
22
|
+
const uploads = useUploads();
|
|
23
|
+
const listItems = useMemo(() => uploads.map((up) => _jsx("li", { children: _jsx(UploadItem, { upload: up }) }, up.id)), [uploads]);
|
|
24
|
+
const t = useMessageInputDictionary();
|
|
25
|
+
const chat = useCurrentChat();
|
|
26
|
+
const visible = !!uploads.length;
|
|
27
|
+
useUploadErrorEffect((errors) => {
|
|
28
|
+
const sizeErrors = errors.filter(e => e instanceof FileIsTooLarge);
|
|
29
|
+
const maxItemsErrors = errors.filter(e => e instanceof MaxFilesReached);
|
|
30
|
+
const maxSize = sizeErrors[0]?.maxSize;
|
|
31
|
+
const maxItems = maxItemsErrors[0]?.maxFiles;
|
|
32
|
+
const sizeErrorsNames = sizeErrors.map(e => e.fileName);
|
|
33
|
+
const maxItemsErrorsNames = maxItemsErrors.map(e => e.fileName);
|
|
34
|
+
const lines = [];
|
|
35
|
+
if (sizeErrors.length) {
|
|
36
|
+
lines.push(`${interpolate(t.uploadSizeError, `${maxSize.value} ${maxSize.unit}`)}\n- ${sizeErrorsNames.join('\n- ')}`);
|
|
37
|
+
}
|
|
38
|
+
if (maxItemsErrors.length) {
|
|
39
|
+
lines.push(`${interpolate(t.uploadItemLimitError, maxItems)}\n- ${maxItemsErrorsNames.join('\n- ')}`);
|
|
40
|
+
}
|
|
41
|
+
if (!lines.length)
|
|
42
|
+
return;
|
|
43
|
+
chat.pushMessage(new ChatEntry({ agentType: 'system', type: 'md', content: lines.join('\n\n') }));
|
|
44
|
+
});
|
|
45
|
+
return (_jsxs("div", { className: listToClass(['info-bar', 'upload-bar', visible && 'visible']), children: [_jsx("div", { className: "space" }), _jsx("div", { className: "content", children: _jsx(FadingOverflow, { className: "list-overflow", scroll: "arrows", enableHorizontalScrollWithVerticalWheel: true, children: _jsx("ul", { children: listItems }) }) })] }));
|
|
46
|
+
};
|
|
47
|
+
//# sourceMappingURL=UploadBar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UploadBar.js","sourceRoot":"","sources":["../../../src/views/MessageInput/UploadBar.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAA;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAC/B,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAA;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAA;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AACjD,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAChH,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAE3E,OAAO,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAA;AAMxD,SAAS,mBAAmB,CAAC,IAAU;IACrC,OAAO,cAAK,GAAG,EAAE,GAAG,CAAC,eAAe,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,IAAI,GAAI,CAAA;AAChE,CAAC;AAED,MAAM,UAAU,GAAG,CAAC,EAAE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AU,EAAE,YAAY,EAAE,OAAO,IAAI,SAAS,CAAC,CAAC,aAC3E,cAAK,SAAS,EAAC,OAAO,GAAO,EAC7B,cAAK,SAAS,EAAC,SAAS,YACtB,KAAC,cAAc,IAAC,SAAS,EAAC,eAAe,EAAC,MAAM,EAAC,QAAQ,EAAC,uCAAuC,kBAC/F,uBAAK,SAAS,GAAM,GACL,GACb,IACF,CACP,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const useMessageInputDictionary: () => Record<"code" | "placeholder" | "selected" | "send" | "cancel" | "stack" | "knowledgeSource" | "agent" | "remove" | "collapse" | "
|
|
1
|
+
export declare const useMessageInputDictionary: () => Record<"code" | "placeholder" | "selected" | "send" | "cancel" | "stack" | "knowledgeSource" | "agent" | "remove" | "collapse" | "upload" | "spot" | "removeConfig" | "removeStack" | "removeWorkspace" | "removeKS" | "removeSelection" | "expand" | "uploadSizeError" | "uploadItemLimitError" | "cantSendBecauseOfUploadError" | "cantSendBecauseOfUploadProgress" | "cantSendBecauseOfEmptyContent", string>;
|
|
2
2
|
//# sourceMappingURL=dictionary.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dictionary.d.ts","sourceRoot":"","sources":["../../../src/views/MessageInput/dictionary.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"dictionary.d.ts","sourceRoot":"","sources":["../../../src/views/MessageInput/dictionary.ts"],"names":[],"mappings":"AAyDA,eAAO,MAAM,yBAAyB,wZAAiC,CAAA"}
|
|
@@ -6,8 +6,6 @@ const dictionary = {
|
|
|
6
6
|
spot: 'Select spot',
|
|
7
7
|
knowledgeSource: 'Select knowledge sources',
|
|
8
8
|
agent: 'Select agent',
|
|
9
|
-
collapse: 'Hide buttons',
|
|
10
|
-
expand: 'Show buttons',
|
|
11
9
|
send: 'Send message',
|
|
12
10
|
placeholder: 'Message to $0 or use / or @.',
|
|
13
11
|
cancel: 'Cancel',
|
|
@@ -18,6 +16,14 @@ const dictionary = {
|
|
|
18
16
|
selected: 'Selected',
|
|
19
17
|
removeSelection: 'Remove current code selection',
|
|
20
18
|
remove: 'Remove',
|
|
19
|
+
upload: 'Upload file',
|
|
20
|
+
expand: 'Expand options',
|
|
21
|
+
collapse: 'Collapse options',
|
|
22
|
+
uploadSizeError: 'The following files were not added to the upload list because they\'re larger than $1:',
|
|
23
|
+
uploadItemLimitError: 'The following files were not added because no more than $1 items may be uploaded at a time:',
|
|
24
|
+
cantSendBecauseOfUploadError: 'Can\'t send the message because one of the files in the upload list could not be uploaded. Please, retry it or remove it from the list.',
|
|
25
|
+
cantSendBecauseOfUploadProgress: 'Please wait until all files are uploaded before sending the message. You can also cancel the upload by removing it from the list of uploads.',
|
|
26
|
+
cantSendBecauseOfEmptyContent: 'You can\'t send empty messages. Please write some text or upload a file.',
|
|
21
27
|
},
|
|
22
28
|
pt: {
|
|
23
29
|
stack: 'Selecionar stack',
|
|
@@ -25,8 +31,6 @@ const dictionary = {
|
|
|
25
31
|
spot: 'Selecionar spot',
|
|
26
32
|
knowledgeSource: 'Selecionar knowledge sources',
|
|
27
33
|
agent: 'Selecionar agente',
|
|
28
|
-
collapse: 'Esconder botões',
|
|
29
|
-
expand: 'Mostrar botões',
|
|
30
34
|
send: 'Enviar mensagem',
|
|
31
35
|
placeholder: 'Mensagem para $0 ou use / ou @.',
|
|
32
36
|
cancel: 'Cancelar',
|
|
@@ -37,6 +41,16 @@ const dictionary = {
|
|
|
37
41
|
selected: 'Selecionado',
|
|
38
42
|
removeSelection: 'Desfazer seleção de código',
|
|
39
43
|
remove: 'Remover',
|
|
44
|
+
upload: 'Enviar arquivo',
|
|
45
|
+
expand: 'Mostrar opções',
|
|
46
|
+
collapse: 'Esconder opções',
|
|
47
|
+
uploadSizeError: 'Os seguintes arquivos não foram adicionados à lista de upload porque eles são maiores que $0:',
|
|
48
|
+
uploadItemLimitError: 'Os seguintes arquivos não foram adicionados à lista de upload porque é permitido enviar no máximo $0 arquivos por vez:',
|
|
49
|
+
uploadError: 'Ocorreu um erro ao enviar o arquivo "$0".',
|
|
50
|
+
unknownUploadError: 'Ocorreu um erro ao enviar os arquivos.',
|
|
51
|
+
cantSendBecauseOfUploadError: 'Não é possível enviar a mensagem, pois um dos arquivos na lista de uploads não pôde ser enviado. Por favor, tente enviá-lo novamente ou remova-o da lista.',
|
|
52
|
+
cantSendBecauseOfUploadProgress: 'Por favor aguarde todos os uploads de arquivos antes de enviar a mensagem. Você pode cancelar o upload removendo o arquivo da lista de uploads.',
|
|
53
|
+
cantSendBecauseOfEmptyContent: 'Não é possível enviar mensagens vazia. Por favor, escreva algum texto ou envie um arquivo.',
|
|
40
54
|
},
|
|
41
55
|
};
|
|
42
56
|
export const useMessageInputDictionary = () => useTranslate(dictionary);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dictionary.js","sourceRoot":"","sources":["../../../src/views/MessageInput/dictionary.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,YAAY,EAAE,MAAM,8BAA8B,CAAA;AAEvE,MAAM,UAAU,GAAG;IACjB,EAAE,EAAE;QACF,KAAK,EAAE,cAAc;QACrB,IAAI,EAAE,kBAAkB;QACxB,IAAI,EAAE,aAAa;QACnB,eAAe,EAAE,0BAA0B;QAC3C,KAAK,EAAE,cAAc;QACrB,
|
|
1
|
+
{"version":3,"file":"dictionary.js","sourceRoot":"","sources":["../../../src/views/MessageInput/dictionary.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,YAAY,EAAE,MAAM,8BAA8B,CAAA;AAEvE,MAAM,UAAU,GAAG;IACjB,EAAE,EAAE;QACF,KAAK,EAAE,cAAc;QACrB,IAAI,EAAE,kBAAkB;QACxB,IAAI,EAAE,aAAa;QACnB,eAAe,EAAE,0BAA0B;QAC3C,KAAK,EAAE,cAAc;QACrB,IAAI,EAAE,cAAc;QACpB,WAAW,EAAE,8BAA8B;QAC3C,MAAM,EAAE,QAAQ;QAChB,YAAY,EA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@@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/views/MessageInput/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/views/MessageInput/index.tsx"],"names":[],"mappings":"AAoBA;;;;GAIG;AACH,eAAO,MAAM,YAAY,+CA8GxB,CAAA"}
|
|
@@ -8,14 +8,16 @@ import { useCurrentChat, useCurrentChatState, useWidgetState } from '../../conte
|
|
|
8
8
|
import { quickCommandRegex } from '../../regex.js';
|
|
9
9
|
import { ChatEntry } from '../../state/ChatEntry.js';
|
|
10
10
|
import { checkIsTrial } from '../../utils/check-is-trial.js';
|
|
11
|
+
import { UploadProvider } from '../../utils/upload/context.js';
|
|
11
12
|
import { AgentSelector } from './AgentSelector.js';
|
|
12
13
|
import { ButtonAgent } from './ButtonAgent.js';
|
|
13
14
|
import { ButtonBar } from './ButtonBar.js';
|
|
14
15
|
import { useUserEntryHistoryShortcut } from './chat-entry-history.js';
|
|
16
|
+
import { ContextBar } from './ContextBar.js';
|
|
15
17
|
import { useMessageInputDictionary } from './dictionary.js';
|
|
16
|
-
import { InfoBar } from './InfoBar.js';
|
|
17
18
|
import { QuickCommandSelector } from './QuickCommandSelector.js';
|
|
18
19
|
import { MAX_INPUT_HEIGHT, MessageInputBox, MIN_INPUT_HEIGHT } from './styled.js';
|
|
20
|
+
import { UploadBar } from './UploadBar.js';
|
|
19
21
|
/**
|
|
20
22
|
* This renders the MessageInput part of the layout which includes the progress bar, the actual textarea, the badges telling what is
|
|
21
23
|
* going to be used for the question and the buttons to send, cancel, set the workspace, among others. This also includes the Quick
|
|
@@ -34,15 +36,54 @@ export const MessageInput = () => {
|
|
|
34
36
|
const agentLabel = useCurrentChatState('agent')?.label;
|
|
35
37
|
const { handleKeyDown, handleKeyUp } = useUserEntryHistoryShortcut();
|
|
36
38
|
const isTrial = checkIsTrial();
|
|
39
|
+
const checkSendRequirements = useCallback(() => {
|
|
40
|
+
if (chat.uploadManager.status === 'error') {
|
|
41
|
+
chat.pushMessage(new ChatEntry({
|
|
42
|
+
agentType: 'system',
|
|
43
|
+
type: 'text',
|
|
44
|
+
content: t.cantSendBecauseOfUploadError,
|
|
45
|
+
}));
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
if (chat.uploadManager.status === 'uploading') {
|
|
49
|
+
chat.pushMessage(new ChatEntry({
|
|
50
|
+
agentType: 'system',
|
|
51
|
+
type: 'text',
|
|
52
|
+
content: t.cantSendBecauseOfUploadProgress,
|
|
53
|
+
}));
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
if (!chat.get('nextMessage') && !chat.uploadManager.get().length) {
|
|
57
|
+
chat.pushMessage(new ChatEntry({
|
|
58
|
+
agentType: 'system',
|
|
59
|
+
type: 'text',
|
|
60
|
+
content: t.cantSendBecauseOfEmptyContent,
|
|
61
|
+
}));
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
return true;
|
|
65
|
+
}, [chat]);
|
|
37
66
|
const onSend = useCallback(async () => {
|
|
38
67
|
const message = chat.get('nextMessage');
|
|
39
|
-
|
|
68
|
+
const canSend = checkSendRequirements();
|
|
69
|
+
if (!canSend)
|
|
40
70
|
return;
|
|
41
71
|
const code = chat.get('codeSelection');
|
|
42
72
|
const language = chat.get('codeLanguage');
|
|
43
|
-
const prompt = code && !quickCommandRegex.test(message) ? `${message}\n\`\`\`${language}\n${code}\n\`\`\`` : message;
|
|
44
|
-
chat.pushMessage(ChatEntry
|
|
73
|
+
const prompt = code && !quickCommandRegex.test(message ?? '') ? `${message}\n\`\`\`${language}\n${code}\n\`\`\`` : message;
|
|
74
|
+
chat.pushMessage(new ChatEntry({
|
|
75
|
+
type: 'md',
|
|
76
|
+
agentType: 'user',
|
|
77
|
+
content: prompt || '',
|
|
78
|
+
upload: chat.uploadManager.get().map(up => ({
|
|
79
|
+
id: up.uploadId, // we know that all files have been uploaded, so they have an id
|
|
80
|
+
name: up.file.name,
|
|
81
|
+
image: up.file.type.toLowerCase().startsWith('image/') ? URL.createObjectURL(up.file) : undefined,
|
|
82
|
+
})),
|
|
83
|
+
updated: new Date().toISOString(),
|
|
84
|
+
}));
|
|
45
85
|
chat.set('nextMessage', '');
|
|
86
|
+
chat.uploadManager.reset();
|
|
46
87
|
}, [chat]);
|
|
47
88
|
const onKeyDown = useCallback((event) => {
|
|
48
89
|
if (!event.shiftKey && event.key === 'Enter') {
|
|
@@ -55,6 +96,6 @@ export const MessageInput = () => {
|
|
|
55
96
|
if (!isLoading)
|
|
56
97
|
textAreaRef.current?.focus();
|
|
57
98
|
}, [isLoading]);
|
|
58
|
-
return (_jsxs(MessageInputBox, { "aria-busy": isLoading, className: "message-input", "$inputFocused": focused, children: [_jsxs("div", { className: "wrapper-action", children: [_jsx(QuickCommandSelector, { inputRef: textAreaRef, isTrial: isTrial }), _jsx(AgentSelector, { inputRef: textAreaRef, isTrial: isTrial }), _jsxs("div", { className: listToClass(['action-box', focused && 'focused', isLoading && 'disabled']), children: [_jsx(ButtonAgent, {}), _jsx(AdaptiveTextArea, { ref: textAreaRef, placeholder: agentLabel && interpolate(t.placeholder, agentLabel), onChange: e => chat.set('nextMessage', e.target.value), value: value, onFocus: () => setFocused(true), onBlur: () => setFocused(false), onKeyDown: onKeyDown, onKeyUp: handleKeyUp, onIncreaseSize: () => setExpanded(false), onResetSize: () => !expansionLocked.current && setExpanded(true), maxHeight: isMinimized ? MIN_INPUT_HEIGHT : MAX_INPUT_HEIGHT })] })] }), _jsx(ProgressBar, { visible: true, animate: isLoading, backgroundColor: isLoading || !focused ? theme.color.light[500] : theme.color.primary[500] }), _jsx(
|
|
99
|
+
return (_jsx(UploadProvider, { value: chat.uploadManager, children: _jsxs(MessageInputBox, { "aria-busy": isLoading, className: "message-input", "$inputFocused": focused, children: [_jsxs("div", { className: "wrapper-action", children: [_jsx(QuickCommandSelector, { inputRef: textAreaRef, isTrial: isTrial }), _jsx(AgentSelector, { inputRef: textAreaRef, isTrial: isTrial }), _jsxs("div", { className: listToClass(['action-box', focused && 'focused', isLoading && 'disabled']), children: [_jsx(ButtonAgent, {}), _jsx(AdaptiveTextArea, { ref: textAreaRef, placeholder: agentLabel && interpolate(t.placeholder, agentLabel), onChange: e => chat.set('nextMessage', e.target.value), value: value, onFocus: () => setFocused(true), onBlur: () => setFocused(false), onKeyDown: onKeyDown, onKeyUp: handleKeyUp, onIncreaseSize: () => setExpanded(false), onResetSize: () => !expansionLocked.current && setExpanded(true), maxHeight: isMinimized ? MIN_INPUT_HEIGHT : MAX_INPUT_HEIGHT })] })] }), _jsx(ProgressBar, { visible: true, animate: isLoading, backgroundColor: isLoading || !focused ? theme.color.light[500] : theme.color.primary[500] }), _jsx(ContextBar, {}), _jsx(UploadBar, {}), _jsx(ButtonBar, { onSend: onSend, isLoading: isLoading })] }) }));
|
|
59
100
|
};
|
|
60
101
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/views/MessageInput/index.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAA;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAA;AAC1D,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAChE,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAA;AACpE,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAA;AAC1D,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AACzF,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAA;AACzD,OAAO,EAAE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AK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,GAAI,EAChG,KAAC,UAAU,KAAG,EACd,KAAC,SAAS,KAAG,EACb,KAAC,SAAS,IAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,GAAI,IACnC,GACH,CAClB,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styled.d.ts","sourceRoot":"","sources":["../../../src/views/MessageInput/styled.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"styled.d.ts","sourceRoot":"","sources":["../../../src/views/MessageInput/styled.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,gBAAgB,MAAM,CAAA;AACnC,eAAO,MAAM,gBAAgB,KAAK,CAAA;AAElC,eAAO,MAAM,mBAAmB,wOAyC/B,CAAA;AAED,eAAO,MAAM,eAAe;oBAA+B,OAAO;YAkPjE,CAAA"}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { IconButton } from '@citric/ui';
|
|
2
2
|
import { theme } from '@stack-spot/portal-theme';
|
|
3
3
|
import { styled } from 'styled-components';
|
|
4
|
-
const
|
|
5
|
-
const
|
|
4
|
+
const CONTEXT_BAR_HEIGHT = 38;
|
|
5
|
+
const CONTEXT_BAR_DISPLACEMENT = 4;
|
|
6
|
+
const UPLOAD_BAR_HEIGHT = 60;
|
|
7
|
+
const UPLOAD_BAR_DISPLACEMENT = 4;
|
|
6
8
|
export const MAX_INPUT_HEIGHT = 300;
|
|
7
9
|
export const MIN_INPUT_HEIGHT = 24;
|
|
8
10
|
export const SelectionBarWrapper = styled.div `
|
|
@@ -57,7 +59,7 @@ export const MessageInputBox = styled.div `
|
|
|
57
59
|
|
|
58
60
|
&.visible {
|
|
59
61
|
> .space {
|
|
60
|
-
height:
|
|
62
|
+
height: var(--space-height, 'auto');
|
|
61
63
|
}
|
|
62
64
|
}
|
|
63
65
|
|
|
@@ -71,17 +73,15 @@ export const MessageInputBox = styled.div `
|
|
|
71
73
|
top: 0;
|
|
72
74
|
left: 0;
|
|
73
75
|
right: 0;
|
|
74
|
-
height:
|
|
76
|
+
height: var(--content-height, 'auto');
|
|
75
77
|
padding-top: 8px;
|
|
76
78
|
background-color: ${theme.color.light[500]};
|
|
77
79
|
display: flex;
|
|
78
80
|
flex-direction: row;
|
|
79
81
|
gap: 4px;
|
|
80
|
-
border-right: 2px solid ${({ $inputFocused }) => theme.color.light[$inputFocused ? 600 : 500]};
|
|
81
|
-
border-left: 2px solid ${({ $inputFocused }) => theme.color.light[$inputFocused ? 600 : 500]};
|
|
82
82
|
|
|
83
83
|
.list-overflow {
|
|
84
|
-
max-width: calc(100% -
|
|
84
|
+
max-width: calc(100% - var(--list-margins, 0px));
|
|
85
85
|
height: 24px;
|
|
86
86
|
&:first-child {
|
|
87
87
|
margin-left: 0.25rem; // space added to the left when the close all button isn't rendered
|
|
@@ -97,31 +97,54 @@ export const MessageInputBox = styled.div `
|
|
|
97
97
|
align-items: center;
|
|
98
98
|
gap: 6px;
|
|
99
99
|
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
100
102
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
gap: 4px;
|
|
106
|
-
line-height: 0.75rem;
|
|
107
|
-
white-space: nowrap;
|
|
108
|
-
|
|
109
|
-
${IconButton} {
|
|
110
|
-
padding: 4px 0;
|
|
111
|
-
background: none;
|
|
112
|
-
border: none;
|
|
113
|
-
width: auto;
|
|
114
|
-
height: auto;
|
|
103
|
+
> .context-bar {
|
|
104
|
+
--space-height: ${CONTEXT_BAR_HEIGHT - CONTEXT_BAR_DISPLACEMENT}px;
|
|
105
|
+
--content-height: ${CONTEXT_BAR_HEIGHT}px;
|
|
106
|
+
--list-margins: 30px; // close button width + gap
|
|
115
107
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
108
|
+
.context-badge > span {
|
|
109
|
+
display: flex;
|
|
110
|
+
flex-direction: row;
|
|
111
|
+
align-items: center;
|
|
112
|
+
gap: 4px;
|
|
113
|
+
line-height: 0.75rem;
|
|
114
|
+
white-space: nowrap;
|
|
115
|
+
|
|
116
|
+
${IconButton} {
|
|
117
|
+
padding: 4px 0;
|
|
118
|
+
background: none;
|
|
119
|
+
border: none;
|
|
120
|
+
width: auto;
|
|
121
|
+
height: auto;
|
|
122
|
+
|
|
123
|
+
svg {
|
|
124
|
+
width: auto;
|
|
125
|
+
height: 12px;
|
|
120
126
|
}
|
|
121
127
|
}
|
|
122
128
|
}
|
|
123
129
|
}
|
|
124
130
|
|
|
131
|
+
> .upload-bar {
|
|
132
|
+
--space-height: ${UPLOAD_BAR_HEIGHT - UPLOAD_BAR_DISPLACEMENT}px;
|
|
133
|
+
--content-height: ${UPLOAD_BAR_HEIGHT}px;
|
|
134
|
+
--list-margins: 12px; // margins from .list-overflow
|
|
135
|
+
|
|
136
|
+
.list-overflow {
|
|
137
|
+
margin: 0 6px !important;
|
|
138
|
+
.scroll-to-left, .scroll-to-right {
|
|
139
|
+
top: 11px;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
input[type="file"] {
|
|
144
|
+
display: none;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
125
148
|
.wrapper-action {
|
|
126
149
|
position: relative;
|
|
127
150
|
|
|
@@ -150,8 +173,6 @@ export const MessageInputBox = styled.div `
|
|
|
150
173
|
}
|
|
151
174
|
}
|
|
152
175
|
|
|
153
|
-
|
|
154
|
-
|
|
155
176
|
.button-group {
|
|
156
177
|
display: flex;
|
|
157
178
|
flex-direction: row;
|
|
@@ -249,6 +270,14 @@ export const MessageInputBox = styled.div `
|
|
|
249
270
|
}
|
|
250
271
|
}
|
|
251
272
|
|
|
273
|
+
.message-menu {
|
|
274
|
+
position: absolute;
|
|
275
|
+
bottom: 34px;
|
|
276
|
+
.upload-item {
|
|
277
|
+
border-top: 1px solid ${theme.color.light[600]};
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
|
|
252
281
|
textarea {
|
|
253
282
|
resize: none;
|
|
254
283
|
border: none;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styled.js","sourceRoot":"","sources":["../../../src/views/MessageInput/styled.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AACvC,OAAO,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAA;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAE1C,MAAM,
|
|
1
|
+
{"version":3,"file":"styled.js","sourceRoot":"","sources":["../../../src/views/MessageInput/styled.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AACvC,OAAO,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAA;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAE1C,MAAM,kBAAkB,GAAG,EAAE,CAAA;AAC7B,MAAM,wBAAwB,GAAG,CAAC,CAAA;AAClC,MAAM,iBAAiB,GAAG,EAAE,CAAA;AAC5B,MAAM,uBAAuB,GAAG,CAAC,CAAA;AACjC,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAG,CAAA;AACnC,MAAM,CAAC,MAAM,gBAAgB,GAAG,EAAE,CAAA;AAElC,MAAM,CAAC,MAAM,mBAAmB,GAAG,MAAM,CAAC,GAAG,CAAA;;;;;sBAKvB,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC;;;;;;;;;;;;;;wBAcpB,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC;;;;;;;;;;;;;;;;0BAgBpB,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC;;;0BAGtB,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC;;;CAG/C,CAAA;AAED,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC,GAAG,CAA2B;;;;;;;;;;;;;;;;;;;;;;;;;;0BA0B1C,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;sBA0B1B,kBAAkB,GAAG,wBAAwB;wBAC3C,kBAAkB;;;;;;;;;;;QAWlC,UAAU;;;;;;;;;;;;;;;;sBAgBI,iBAAiB,GAAG,uBAAuB;wBACzC,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;0BA0Bf,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC;;0BAEtB,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC;;;;;4BAKpB,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC;;;;;4BAKtB,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAyD5C,UAAU;;;;;;;;;;;;;;8BAcc,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC;8BACtB,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC;;;;;;;;gCAQpB,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC;;;;;;;oBAOlC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,YAAY;;;;;;;;;;;;;;;;;;;8BAmBpB,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC;;;;;;;;;cAStC,gBAAgB;;;;;;;;CAQ7B,CAAA"}
|
|
@@ -34,6 +34,6 @@ export declare const dictionary: {
|
|
|
34
34
|
input: string;
|
|
35
35
|
};
|
|
36
36
|
};
|
|
37
|
-
export declare function useStepsDictionary(): Record<"input" | "step" | "
|
|
37
|
+
export declare function useStepsDictionary(): Record<"input" | "step" | "pending" | "steps" | "tools" | "answer" | "running" | "planning" | "unknown" | "stepsPanelDescription" | "response" | "executionTime" | "nextAttempt" | "previousAttempt", string>;
|
|
38
38
|
export type ToolsDictionary = typeof dictionary['en'];
|
|
39
39
|
//# sourceMappingURL=dictionary.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stack-spot/ai-chat-widget",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.25.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"@citric/core": "^6.4.0",
|
|
14
14
|
"@stack-spot/portal-components": "^2.22.1",
|
|
15
15
|
"@citric/icons": "^5.13.0",
|
|
16
|
-
"@stack-spot/portal-network": "^0.
|
|
16
|
+
"@stack-spot/portal-network": "^0.139.0",
|
|
17
17
|
"@citric/ui": "^6.10.2",
|
|
18
18
|
"@stack-spot/portal-theme": "^1.0.0",
|
|
19
19
|
"@stack-spot/portal-translate": "^1.1.0",
|
package/src/app-metadata.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stack-spot/ai-chat-widget",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"date": "
|
|
3
|
+
"version": "1.25.0",
|
|
4
|
+
"date": "Tue Jun 10 2025 19:45:00 GMT+0000 (Coordinated Universal Time)",
|
|
5
5
|
"dependencies": [
|
|
6
6
|
{
|
|
7
7
|
"name": "@stack-spot/app-metadata",
|
|
@@ -113,7 +113,7 @@
|
|
|
113
113
|
},
|
|
114
114
|
{
|
|
115
115
|
"name": "@stack-spot/portal-network",
|
|
116
|
-
"version": "0.
|
|
116
|
+
"version": "0.139.0(@stack-spot/auth@5.3.2)(@stack-spot/opa@2.5.0(@stack-spot/auth@5.3.2)(react-dom@18.2.0(react@18.2.0))(react@18.2.0))(@stack-spot/portal-translate@1.1.0(react-dom@18.2.0(react@18.2.0))(react@18.2.0))(@tanstack/react-query@5.59.16(react@18.2.0))(react-dom@18.2.0(react@18.2.0))(react@18.2.0)"
|
|
117
117
|
},
|
|
118
118
|
{
|
|
119
119
|
"name": "@stack-spot/portal-theme",
|
|
@@ -36,7 +36,7 @@ function createEntryValueFromChatResponse(
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
function buildPrompt(content: string, data?: any) {
|
|
39
|
-
if (data === undefined || data === '' || data === null) return content
|
|
39
|
+
if (data === undefined || data === '' || data === null) return content || '.' // prevents empty strings
|
|
40
40
|
return typeof data === 'string' ? data : JSON.stringify(data)
|
|
41
41
|
}
|
|
42
42
|
|
|
@@ -53,12 +53,12 @@ function buildPrompt(content: string, data?: any) {
|
|
|
53
53
|
export async function sendMessageInterceptor(entry: ChatEntry, chat: ChatState, signal: AbortSignal) {
|
|
54
54
|
const { agentType, content, data } = entry.getValue()
|
|
55
55
|
if (agentType !== 'user') return
|
|
56
|
-
const context = buildConversationContext(chat)
|
|
56
|
+
const context = buildConversationContext(chat, entry)
|
|
57
57
|
chat.set('isLoading', true)
|
|
58
58
|
const untitled = chat.untitled
|
|
59
59
|
const isFirstMessage = chat.getMessages().length === 1
|
|
60
60
|
if (untitled) {
|
|
61
|
-
chat.set('label', content)
|
|
61
|
+
chat.set('label', content || entry.getValue().upload?.[0]?.name || 'Chat')
|
|
62
62
|
chat.untitled = false
|
|
63
63
|
}
|
|
64
64
|
const stream = aiClient.sendChatMessage({ context, user_prompt: buildPrompt(content, data) })
|