@stack-spot/ai-chat-widget 1.5.2 → 1.7.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.
- package/CHANGELOG.md +12 -0
- package/dist/app-metadata.json +7 -7
- package/dist/chat-interceptors/send-message.d.ts.map +1 -1
- package/dist/chat-interceptors/send-message.js +16 -8
- package/dist/chat-interceptors/send-message.js.map +1 -1
- package/dist/components/AdaptiveTextArea.d.ts.map +1 -1
- package/dist/components/AdaptiveTextArea.js +7 -1
- package/dist/components/AdaptiveTextArea.js.map +1 -1
- package/dist/components/Selector/index.d.ts +20 -0
- package/dist/components/Selector/index.d.ts.map +1 -0
- package/dist/components/Selector/index.js +134 -0
- package/dist/components/Selector/index.js.map +1 -0
- package/dist/components/Selector/styled.d.ts +2 -0
- package/dist/components/Selector/styled.d.ts.map +1 -0
- package/dist/components/Selector/styled.js +144 -0
- package/dist/components/Selector/styled.js.map +1 -0
- package/dist/regex.d.ts +1 -0
- package/dist/regex.d.ts.map +1 -1
- package/dist/regex.js +1 -0
- package/dist/regex.js.map +1 -1
- package/dist/views/Agents/AgentsTab.js +4 -4
- package/dist/views/Agents/AgentsTab.js.map +1 -1
- package/dist/views/Chat/AgentInfo.js +1 -1
- package/dist/views/Home/CustomAgent.js +3 -3
- package/dist/views/Home/CustomAgent.js.map +1 -1
- package/dist/views/Home/styled.js +1 -1
- package/dist/views/MessageInput/AgentSelector.d.ts +4 -0
- package/dist/views/MessageInput/AgentSelector.d.ts.map +1 -0
- package/dist/views/MessageInput/AgentSelector.js +31 -0
- package/dist/views/MessageInput/AgentSelector.js.map +1 -0
- package/dist/views/MessageInput/ButtonAgent.d.ts +2 -0
- package/dist/views/MessageInput/ButtonAgent.d.ts.map +1 -0
- package/dist/views/MessageInput/ButtonAgent.js +17 -0
- package/dist/views/MessageInput/ButtonAgent.js.map +1 -0
- package/dist/views/MessageInput/ButtonGroup.d.ts +1 -1
- package/dist/views/MessageInput/ButtonGroup.d.ts.map +1 -1
- package/dist/views/MessageInput/ButtonGroup.js +4 -6
- package/dist/views/MessageInput/ButtonGroup.js.map +1 -1
- package/dist/views/MessageInput/QuickCommandSelector.d.ts +2 -11
- package/dist/views/MessageInput/QuickCommandSelector.d.ts.map +1 -1
- package/dist/views/MessageInput/QuickCommandSelector.js +17 -130
- package/dist/views/MessageInput/QuickCommandSelector.js.map +1 -1
- 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 +4 -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 -1
- 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 +51 -144
- package/dist/views/MessageInput/styled.js.map +1 -1
- package/package.json +1 -1
- package/src/app-metadata.json +7 -7
- package/src/chat-interceptors/send-message.ts +14 -7
- package/src/components/AdaptiveTextArea.tsx +8 -1
- package/src/components/Selector/index.tsx +245 -0
- package/src/components/Selector/styled.ts +145 -0
- package/src/regex.ts +1 -0
- package/src/views/Agents/AgentsTab.tsx +4 -4
- package/src/views/Chat/AgentInfo.tsx +1 -1
- package/src/views/Home/CustomAgent.tsx +3 -3
- package/src/views/Home/styled.ts +1 -1
- package/src/views/MessageInput/AgentSelector.tsx +35 -0
- package/src/views/MessageInput/ButtonAgent.tsx +36 -0
- package/src/views/MessageInput/ButtonGroup.tsx +3 -10
- package/src/views/MessageInput/QuickCommandSelector.tsx +21 -205
- package/src/views/MessageInput/dictionary.ts +4 -2
- package/src/views/MessageInput/index.tsx +8 -3
- package/src/views/MessageInput/styled.ts +51 -144
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AgentSelector.d.ts","sourceRoot":"","sources":["../../../src/views/MessageInput/AgentSelector.tsx"],"names":[],"mappings":"AAQA,eAAO,MAAM,aAAa,iBAAkB;IAAE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC,mBAAmB,GAAG,gBAAgB,CAAC,CAAA;CAAE,4CA0BhH,CAAA"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Agent } from '@citric/icons';
|
|
3
|
+
import { agentClient } from '@stack-spot/portal-network';
|
|
4
|
+
import { useCallback } from 'react';
|
|
5
|
+
import { Selector } from '../../components/Selector/index.js';
|
|
6
|
+
import { useCurrentChat, useCurrentChatState } from '../../context/hooks.js';
|
|
7
|
+
import { agentRegex } from '../../regex.js';
|
|
8
|
+
export const AgentSelector = ({ inputRef }) => {
|
|
9
|
+
const chat = useCurrentChat();
|
|
10
|
+
const onSelectItem = useCallback((agent) => {
|
|
11
|
+
const newValue = `@${agent.slug}`;
|
|
12
|
+
chat.set('nextMessage', undefined);
|
|
13
|
+
chat.set('agent', { id: agent.id, label: agent.slug, image: agent.avatar, builtIn: false });
|
|
14
|
+
if (!inputRef.current)
|
|
15
|
+
return;
|
|
16
|
+
inputRef.current.value = newValue;
|
|
17
|
+
inputRef.current.focus();
|
|
18
|
+
}, []);
|
|
19
|
+
return _jsx(Selector, { inputRef: inputRef, selectorConfig: {
|
|
20
|
+
resourceName: 'Agent',
|
|
21
|
+
shortcut: '@',
|
|
22
|
+
icon: _jsx(Agent, {}),
|
|
23
|
+
imageProp: 'avatar',
|
|
24
|
+
regex: agentRegex,
|
|
25
|
+
url: '/agent/',
|
|
26
|
+
data: () => agentClient.agents.useQuery({}),
|
|
27
|
+
isEnabled: useCurrentChatState('features').agent,
|
|
28
|
+
onSelect: onSelectItem,
|
|
29
|
+
} });
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=AgentSelector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AgentSelector.js","sourceRoot":"","sources":["../../../src/views/MessageInput/AgentSelector.tsx"],"names":[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YACd,IAAI,EAAE,GAAG,EAAE,CAAE,WAAW,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC5C,SAAS,EAAE,mBAAmB,CAAC,UAAU,CAAC,CAAC,KAAK;YAChD,QAAQ,EAAE,YAAY;SACvB,GACD,CAAA;AACJ,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ButtonAgent.d.ts","sourceRoot":"","sources":["../../../src/views/MessageInput/ButtonAgent.tsx"],"names":[],"mappings":"AAOA,eAAO,MAAM,WAAW,+CA4BvB,CAAA"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Flex, IconBox } from '@citric/core';
|
|
3
|
+
import { Agent, TimesMini } from '@citric/icons';
|
|
4
|
+
import { IconButton, Tooltip } from '@citric/ui';
|
|
5
|
+
import { MiniLogo } from '@stack-spot/portal-components/svg';
|
|
6
|
+
import { useCurrentChat, useCurrentChatState, useWidget } from '../../context/hooks.js';
|
|
7
|
+
import { useMessageInputDictionary } from './dictionary.js';
|
|
8
|
+
export const ButtonAgent = () => {
|
|
9
|
+
const t = useMessageInputDictionary();
|
|
10
|
+
const widget = useWidget();
|
|
11
|
+
const chat = useCurrentChat();
|
|
12
|
+
const agent = useCurrentChatState('agent');
|
|
13
|
+
const features = useCurrentChatState('features');
|
|
14
|
+
return (_jsx("div", { className: "button-group", children: features.agent && (_jsxs("div", { className: "group-agent", children: [_jsx(IconButton, { "aria-label": t.agent, title: t.agent, className: "agent", onClick: () => widget.set('panel', 'agent'), children: _jsx(MiniLogo, {}) }), agent?.id &&
|
|
15
|
+
_jsx(Tooltip, { text: t.remove, children: _jsxs(IconButton, { "aria-label": t.remove, className: "agent agent-selected", onClick: () => chat.set('agent', undefined), children: [agent?.image ? _jsx("img", { src: agent.image, className: "image" }) : _jsx(IconBox, { className: "image", size: "xs", children: _jsx(Agent, {}) }), _jsx(Flex, { className: "icon-remove", alignContent: "center", justifyContent: "center", children: _jsx(TimesMini, {}) })] }) })] })) }));
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=ButtonAgent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ButtonAgent.js","sourceRoot":"","sources":["../../../src/views/MessageInput/ButtonAgent.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAC5C,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAChD,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,mCAAmC,CAAA;AAC5D,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AACpF,OAAO,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAA;AAExD,MAAM,CAAC,MAAM,WAAW,GAAG,GAAG,EAAE;IAC9B,MAAM,CAAC,GAAG,yBAAyB,EAAE,CAAA;IACrC,MAAM,MAAM,GAAG,SAAS,EAAE,CAAA;IAC1B,MAAM,IAAI,GAAG,cAAc,EAAE,CAAA;IAC7B,MAAM,KAAK,GAAG,mBAAmB,CAAC,OAAO,CAAC,CAAA;IAC1C,MAAM,QAAQ,GAAG,mBAAmB,CAAC,UAAU,CAAC,CAAA;IAEhD,OAAO,CACL,cAAK,SAAS,EAAC,cAAc,YAC1B,QAAQ,CAAC,KAAK,IAAI,CACjB,eAAK,SAAS,EAAC,aAAa,aAC1B,KAAC,UAAU,kBAAa,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC,KAAK,EAAE,SAAS,EAAC,OAAO,EAAC,OAAO,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,OAAO,CAAC,YAC5G,KAAC,QAAQ,KAAG,GACD,EACZ,KAAK,EAAE,EAAE;oBACR,KAAC,OAAO,IAAC,IAAI,EAAE,CAAC,CAAC,MAAM,YACrB,MAAC,UAAU,kBAAa,CAAC,CAAC,MAAM,EAAE,SAAS,EAAC,sBAAsB,EAAC,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,SAAS,CAAC,aAC3G,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,cAAK,GAAG,EAAE,KAAK,CAAC,KAAK,EAAE,SAAS,EAAC,OAAO,GAAG,CAAC,CAAC,CAAC,KAAC,OAAO,IAAC,SAAS,EAAC,OAAO,EAAC,IAAI,EAAC,IAAI,YAAC,KAAC,KAAK,KAAG,GAAU,EACtH,KAAC,IAAI,IAAC,SAAS,EAAC,aAAa,EAAC,YAAY,EAAC,QAAQ,EAAC,cAAc,EAAC,QAAQ,YACzE,KAAC,SAAS,KAAG,GACR,IACI,GACL,IAER,CACP,GACG,CACP,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -22,7 +22,7 @@ interface ButtonGroupProps {
|
|
|
22
22
|
}
|
|
23
23
|
/**
|
|
24
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
|
|
25
|
+
* editor, change the stack, etc.
|
|
26
26
|
*/
|
|
27
27
|
export declare const ButtonGroup: ({ onSend, onCancel, expanded, setExpanded, isLoading }: ButtonGroupProps) => import("react/jsx-runtime").JSX.Element;
|
|
28
28
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ButtonGroup.d.ts","sourceRoot":"","sources":["../../../src/views/MessageInput/ButtonGroup.tsx"],"names":[],"mappings":"
|
|
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,23 +1,21 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { ChevronRight, Code, KnowledgeSource, Send, Stack, Times, Workspace } from '@citric/icons';
|
|
3
3
|
import { IconButton } from '@citric/ui';
|
|
4
|
-
import { MiniLogo } from '@stack-spot/portal-components/svg';
|
|
5
4
|
import { listToClass } from '@stack-spot/portal-theme';
|
|
6
5
|
import { useEffect, useRef } from 'react';
|
|
7
6
|
import { useCurrentChatState, useWidget } from '../../context/hooks.js';
|
|
8
7
|
import { useMessageInputDictionary } from './dictionary.js';
|
|
9
8
|
/**
|
|
10
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
|
|
11
|
-
* editor, change the
|
|
10
|
+
* editor, change the stack, etc.
|
|
12
11
|
*/
|
|
13
12
|
export const ButtonGroup = ({ onSend, onCancel, expanded, setExpanded, isLoading }) => {
|
|
14
13
|
const t = useMessageInputDictionary();
|
|
15
14
|
const widget = useWidget();
|
|
16
15
|
const featureButtonsWidth = useRef();
|
|
17
16
|
const featureButtons = useRef(null);
|
|
18
|
-
const agent = useCurrentChatState('agent');
|
|
19
17
|
const features = useCurrentChatState('features');
|
|
20
|
-
const hasFeatureButtons = features.
|
|
18
|
+
const hasFeatureButtons = features.workspace || features.knowledgeSource || features.stack || features.editor;
|
|
21
19
|
useEffect(() => {
|
|
22
20
|
if (!featureButtons.current)
|
|
23
21
|
return;
|
|
@@ -30,7 +28,7 @@ export const ButtonGroup = ({ onSend, onCancel, expanded, setExpanded, isLoading
|
|
|
30
28
|
featureButtons.current.style.width = `${featureButtonsWidth.current}px`;
|
|
31
29
|
},
|
|
32
30
|
// don't use the whole features object here, it would make every chat tab change rerun this effect.
|
|
33
|
-
[features.
|
|
34
|
-
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.
|
|
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.workspace, title: t.workspace, onClick: () => widget.set('panel', 'workspace'), children: _jsx(Workspace, {}) })), 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, {}) }))] }));
|
|
35
33
|
};
|
|
36
34
|
//# sourceMappingURL=ButtonGroup.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ButtonGroup.js","sourceRoot":"","sources":["../../../src/views/MessageInput/ButtonGroup.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,eAAe,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAClG,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AACvC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"ButtonGroup.js","sourceRoot":"","sources":["../../../src/views/MessageInput/ButtonGroup.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,eAAe,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAClG,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAA;AACzC,OAAO,EAAE,mBAAmB,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AACpE,OAAO,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAA;AAyBxD;;;GAGG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,WAAW,EAAE,SAAS,EAAoB,EAAE,EAAE;IACtG,MAAM,CAAC,GAAG,yBAAyB,EAAE,CAAA;IACrC,MAAM,MAAM,GAAG,SAAS,EAAE,CAAA;IAC1B,MAAM,mBAAmB,GAAG,MAAM,EAAsB,CAAA;IACxD,MAAM,cAAc,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAA;IACnD,MAAM,QAAQ,GAAG,mBAAmB,CAAC,UAAU,CAAC,CAAA;IAChD,MAAM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,EAAE,SAAS,EAAC,MAAM,EAAC,KAAK,EAAE,CAAC,CAAC,MAAM,YACnF,KAAC,KAAK,KAAG,GACE,CACd,CAAC,CAAC,CAAC,CACF,KAAC,UAAU,kBAAa,CAAC,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAC,MAAM,EAAC,KAAK,EAAE,CAAC,CAAC,IAAI,YAC7E,KAAC,IAAI,KAAG,GACG,CACd,IACG,CACP,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -1,13 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* A reference to the input this quick commands panel is attached to.
|
|
4
|
-
*/
|
|
1
|
+
export declare const QuickCommandSelector: ({ inputRef }: {
|
|
5
2
|
inputRef: React.RefObject<HTMLTextAreaElement | HTMLInputElement>;
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* This renders the floating Quick Commands panel that allows the user to select a quick command. This appears whenever the user types "/"
|
|
9
|
-
* in the textarea.
|
|
10
|
-
*/
|
|
11
|
-
export declare const QuickCommandSelector: ({ inputRef }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
12
|
-
export {};
|
|
3
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
13
4
|
//# sourceMappingURL=QuickCommandSelector.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QuickCommandSelector.d.ts","sourceRoot":"","sources":["../../../src/views/MessageInput/QuickCommandSelector.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"QuickCommandSelector.d.ts","sourceRoot":"","sources":["../../../src/views/MessageInput/QuickCommandSelector.tsx"],"names":[],"mappings":"AAQA,eAAO,MAAM,oBAAoB,iBAAkB;IAAE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC,mBAAmB,GAAG,gBAAgB,CAAC,CAAA;CAAE,4CAyBvH,CAAA"}
|
|
@@ -1,142 +1,29 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { ExternalLink, QuickCommand } from '@citric/icons';
|
|
4
|
-
import { IconButton } from '@citric/ui';
|
|
5
|
-
import { useKeyboardControls } from '@stack-spot/portal-components';
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { QuickCommand } from '@citric/icons';
|
|
6
3
|
import { aiClient } from '@stack-spot/portal-network';
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { Fading } from '../../components/Fading.js';
|
|
10
|
-
import { FallbackBoundary } from '../../components/FallbackBoundary/index.js';
|
|
4
|
+
import { useCallback } from 'react';
|
|
5
|
+
import { Selector } from '../../components/Selector/index.js';
|
|
11
6
|
import { useCurrentChat, useCurrentChatState } from '../../context/hooks.js';
|
|
12
7
|
import { quickCommandRegex } from '../../regex.js';
|
|
13
|
-
|
|
14
|
-
const sections = [undefined, 'personal', 'workspace', 'account', 'shared'];
|
|
15
|
-
const CommandListItem = ({ qc, onSelect }) => {
|
|
16
|
-
const t = useTranslate(dictionary);
|
|
17
|
-
return (_jsxs("li", { children: [_jsxs("button", { className: "qc", onClick: () => onSelect(qc.slug),
|
|
18
|
-
// the following line prevents a new line character in the message when the user presses enter to select a qc.
|
|
19
|
-
onKeyDown: e => e.key === 'Enter' && e.preventDefault(), onFocus: e => e.target.closest('li')?.classList.add('focus'), onBlur: e => e.target.closest('li')?.classList.remove('focus'), children: [_jsxs("p", { className: "qc-title", children: ["/", qc.slug] }), _jsx("p", { className: "qc-description", children: qc.description })] }), _jsx(IconButton, { as: "a", title: t.openQC, "aria-label": t.openQC, href: `${getUrlToStackSpotAI()}/quick-command/${qc.slug}`, target: "_blank", children: _jsx(ExternalLink, {}) })] }));
|
|
20
|
-
};
|
|
21
|
-
const CommandList = ({ filter, visibility, onSelect }) => {
|
|
22
|
-
const t = useTranslate(dictionary);
|
|
23
|
-
const quickCommands = aiClient.quickCommands.useQuery({ order: 'a-to-z' });
|
|
24
|
-
let filtered = quickCommands;
|
|
25
|
-
if (visibility || filter) {
|
|
26
|
-
const lowerFilter = filter?.toLocaleLowerCase();
|
|
27
|
-
filtered = quickCommands.filter(qc => (!lowerFilter || qc.slug.toLocaleLowerCase().startsWith(lowerFilter)) && (!visibility || qc.visibility_level === visibility));
|
|
28
|
-
}
|
|
29
|
-
if (!quickCommands.length)
|
|
30
|
-
return _jsx(Text, { className: "empty", colorScheme: "light.700", children: t.noData });
|
|
31
|
-
if (!filtered.length)
|
|
32
|
-
return _jsx(Text, { className: "empty", colorScheme: "light.700", children: t.noResults });
|
|
33
|
-
return (_jsx("ul", { className: "command-list", children: filtered.map(qc => _jsx(CommandListItem, { qc: qc, onSelect: onSelect }, qc.id)) }));
|
|
34
|
-
};
|
|
35
|
-
const SelectorContent = ({ filter, onClose, inputRef }) => {
|
|
36
|
-
const t = useTranslate(dictionary);
|
|
37
|
-
const ref = useRef(null);
|
|
8
|
+
export const QuickCommandSelector = ({ inputRef }) => {
|
|
38
9
|
const chat = useCurrentChat();
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
const newValue = `/${slug}`;
|
|
10
|
+
const onSelectItem = useCallback((qc) => {
|
|
11
|
+
const newValue = `/${qc.slug}`;
|
|
42
12
|
chat.set('nextMessage', newValue);
|
|
43
|
-
onClose();
|
|
44
13
|
if (!inputRef.current)
|
|
45
14
|
return;
|
|
46
|
-
// the following line prevents bugs by setting the text area value before react gets the chance to.
|
|
47
15
|
inputRef.current.value = newValue;
|
|
48
16
|
inputRef.current.focus();
|
|
49
17
|
}, []);
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
return (_jsxs("div", { ref: ref, children: [_jsxs("header", { children: [_jsx(IconBox, { children: _jsx(QuickCommand, {}) }), _jsx(Text, { as: "h3", children: "QUICK COMMANDS" })] }), _jsxs("div", { className: "body", children: [_jsx("ul", { className: "tabs", children: sections.map(createSectionItem) }), _jsx(FallbackBoundary, { message: t.error, mini: true, children: _jsx(CommandList, { onSelect: onSelectQC, filter: filter, visibility: visibility }) })] })] }));
|
|
62
|
-
};
|
|
63
|
-
/**
|
|
64
|
-
* This renders the floating Quick Commands panel that allows the user to select a quick command. This appears whenever the user types "/"
|
|
65
|
-
* in the textarea.
|
|
66
|
-
*/
|
|
67
|
-
export const QuickCommandSelector = ({ inputRef }) => {
|
|
68
|
-
const value = useCurrentChatState('nextMessage') ?? '';
|
|
69
|
-
const filter = useMemo(() => value === '/' || quickCommandRegex.test(value) ? value.substring(1) : undefined, [value]);
|
|
70
|
-
const [isClosed, setClosed] = useState(false);
|
|
71
|
-
const selectorRef = useRef(null);
|
|
72
|
-
const isEnabled = useCurrentChatState('features').quickCommands;
|
|
73
|
-
const shouldRender = isEnabled && filter !== undefined && !isClosed;
|
|
74
|
-
// Resets the closed state whenever the message input is cleared
|
|
75
|
-
useEffect(() => {
|
|
76
|
-
if (!value)
|
|
77
|
-
setClosed(false);
|
|
78
|
-
}, [value]);
|
|
79
|
-
// Creates the following behavior while the user types in the message input:
|
|
80
|
-
// auto-complete on tab; move focus to the qc panel on press up or down; and close the qc panel on esc.
|
|
81
|
-
useEffect(() => {
|
|
82
|
-
function getFirst() {
|
|
83
|
-
return selectorRef.current?.querySelector('.qc');
|
|
84
|
-
}
|
|
85
|
-
function onKeyDown(event) {
|
|
86
|
-
const key = event.key;
|
|
87
|
-
if (!selectorRef.current)
|
|
88
|
-
return;
|
|
89
|
-
if (key === 'Tab') {
|
|
90
|
-
getFirst()?.click();
|
|
91
|
-
event.preventDefault();
|
|
92
|
-
}
|
|
93
|
-
else if (key === 'ArrowDown' || key === 'ArrowUp') {
|
|
94
|
-
getFirst()?.focus();
|
|
95
|
-
event.preventDefault();
|
|
96
|
-
}
|
|
97
|
-
if (key === 'Escape') {
|
|
98
|
-
setClosed(true);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
inputRef.current?.addEventListener('keydown', onKeyDown);
|
|
102
|
-
return () => inputRef.current?.removeEventListener('keydown', onKeyDown);
|
|
103
|
-
}, []);
|
|
104
|
-
// Closes the panel when the user clicks outside the qc panel or the message input.
|
|
105
|
-
useEffect(() => {
|
|
106
|
-
if (!shouldRender)
|
|
107
|
-
return;
|
|
108
|
-
function onClickOut(e) {
|
|
109
|
-
const target = e.target;
|
|
110
|
-
if (!selectorRef.current?.contains(target) && !inputRef.current?.contains(target))
|
|
111
|
-
setClosed(true);
|
|
112
|
-
}
|
|
113
|
-
document.addEventListener('click', onClickOut);
|
|
114
|
-
return () => document.removeEventListener('click', onClickOut);
|
|
115
|
-
}, [shouldRender]);
|
|
116
|
-
return (_jsx(Fading, { visible: shouldRender, ref: selectorRef, className: "quick-command-selector", children: _jsx(SelectorContent, { filter: filter, onClose: () => setClosed(true), inputRef: inputRef }) }));
|
|
117
|
-
};
|
|
118
|
-
const dictionary = {
|
|
119
|
-
en: {
|
|
120
|
-
all: 'All',
|
|
121
|
-
personal: 'Personal',
|
|
122
|
-
account: 'Account',
|
|
123
|
-
shared: 'Shared',
|
|
124
|
-
workspace: 'Workspace',
|
|
125
|
-
error: 'Could not load the quick commands.',
|
|
126
|
-
noData: 'You don\'t have any quick command yet.',
|
|
127
|
-
noResults: 'There are no quick commands to show here.',
|
|
128
|
-
openQC: 'Open this quick command\'s settings in a new tab.',
|
|
129
|
-
},
|
|
130
|
-
pt: {
|
|
131
|
-
all: 'Todos',
|
|
132
|
-
personal: 'Pessoal',
|
|
133
|
-
account: 'Conta',
|
|
134
|
-
shared: 'Compartilhado',
|
|
135
|
-
workspace: 'Workspace',
|
|
136
|
-
error: 'Não foi possível carregar os quick commands.',
|
|
137
|
-
noData: 'Você ainda não possui quick commands.',
|
|
138
|
-
noResults: 'Não há quick commands para mostrar aqui.',
|
|
139
|
-
openQC: 'Abra as configurações deste quick command em uma nova aba.',
|
|
140
|
-
},
|
|
18
|
+
return _jsx(Selector, { inputRef: inputRef, selectorConfig: {
|
|
19
|
+
resourceName: 'Quick Command',
|
|
20
|
+
shortcut: '/',
|
|
21
|
+
icon: _jsx(QuickCommand, {}),
|
|
22
|
+
url: '/quick-command/',
|
|
23
|
+
regex: quickCommandRegex,
|
|
24
|
+
data: () => aiClient.quickCommands.useQuery({ order: 'a-to-z' }),
|
|
25
|
+
isEnabled: useCurrentChatState('features').quickCommands,
|
|
26
|
+
onSelect: onSelectItem,
|
|
27
|
+
} });
|
|
141
28
|
};
|
|
142
29
|
//# sourceMappingURL=QuickCommandSelector.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QuickCommandSelector.js","sourceRoot":"","sources":["../../../src/views/MessageInput/QuickCommandSelector.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"QuickCommandSelector.js","sourceRoot":"","sources":["../../../src/views/MessageInput/QuickCommandSelector.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAA;AAErD,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAA;AACnC,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAA;AACpD,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AACzE,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAE/C,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,EAAE,QAAQ,EAAyE,EAAE,EAAE;IAC1H,MAAM,IAAI,GAAG,cAAc,EAAE,CAAA;IAE7B,MAAM,YAAY,GAAG,WAAW,CAAC,CAAC,EAA4B,EAAE,EAAE;QAChE,MAAM,QAAQ,GAAG,IAAI,EAAE,CAAC,IAAI,EAAE,CAAA;QAC9B,IAAI,CAAC,GAAG,CAAC,aAAa,EAAE,QAAQ,CAAC,CAAA;QAEjC,IAAI,CAAC,QAAQ,CAAC,OAAO;YAAE,OAAM;QAC7B,QAAQ,CAAC,OAAO,CAAC,KAAK,GAAG,QAAQ,CAAA;QACjC,QAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,CAAA;IAC1B,CAAC,EAAE,EAAE,CAAC,CAAA;IAEN,OAAO,KAAC,QAAQ,IACd,QAAQ,EAAE,QAAQ,EAClB,cAAc,EAAE;YACd,YAAY,EAAE,eAAe;YAC7B,QAAQ,EAAE,GAAG;YACb,IAAI,EAAE,KAAC,YAAY,KAAG;YACtB,GAAG,EAAE,iBAAiB;YACtB,KAAK,EAAE,iBAAiB;YACxB,IAAI,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC;YAChE,SAAS,EAAE,mBAAmB,CAAC,UAAU,CAAC,CAAC,aAAa;YACxD,QAAQ,EAAE,YAAY;SACvB,GACD,CAAA;AACJ,CAAC,CAAA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const useMessageInputDictionary: () => Record<"cancel" | "code" | "placeholder" | "selected" | "stack" | "workspace" | "knowledgeSource" | "agent" | "send" | "collapse" | "expand" | "removeConfig" | "removeStack" | "removeWorkspace" | "removeKS" | "removeSelection", string>;
|
|
1
|
+
export declare const useMessageInputDictionary: () => Record<"cancel" | "code" | "placeholder" | "selected" | "stack" | "workspace" | "knowledgeSource" | "agent" | "send" | "collapse" | "expand" | "removeConfig" | "removeStack" | "removeWorkspace" | "removeKS" | "removeSelection" | "remove", 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":"AA2CA,eAAO,MAAM,yBAAyB,8PAAiC,CAAA"}
|
|
@@ -9,7 +9,7 @@ const dictionary = {
|
|
|
9
9
|
collapse: 'Hide buttons',
|
|
10
10
|
expand: 'Show buttons',
|
|
11
11
|
send: 'Send message',
|
|
12
|
-
placeholder: '
|
|
12
|
+
placeholder: 'Message to %s',
|
|
13
13
|
cancel: 'Cancel',
|
|
14
14
|
removeConfig: 'Remove all the configuration',
|
|
15
15
|
removeStack: 'Stop using the current stack',
|
|
@@ -17,6 +17,7 @@ const dictionary = {
|
|
|
17
17
|
removeKS: 'Stop using this knowledge source',
|
|
18
18
|
selected: 'Selected',
|
|
19
19
|
removeSelection: 'Remove current code selection',
|
|
20
|
+
remove: 'Remove',
|
|
20
21
|
},
|
|
21
22
|
pt: {
|
|
22
23
|
stack: 'Selecionar stack',
|
|
@@ -27,7 +28,7 @@ const dictionary = {
|
|
|
27
28
|
collapse: 'Esconder botões',
|
|
28
29
|
expand: 'Mostrar botões',
|
|
29
30
|
send: 'Enviar mensagem',
|
|
30
|
-
placeholder: '
|
|
31
|
+
placeholder: 'Mensagem para %s',
|
|
31
32
|
cancel: 'Cancelar',
|
|
32
33
|
removeConfig: 'Remover todas as configurações',
|
|
33
34
|
removeStack: 'Parar de usar a stack atual',
|
|
@@ -35,6 +36,7 @@ const dictionary = {
|
|
|
35
36
|
removeKS: 'Parar de usar este knowledge source',
|
|
36
37
|
selected: 'Selecionado',
|
|
37
38
|
removeSelection: 'Desfazer seleção de código',
|
|
39
|
+
remove: 'Remover',
|
|
38
40
|
},
|
|
39
41
|
};
|
|
40
42
|
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,cA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QAAQ,EAAE,aAAa;QACvB,eAAe,EAAE,4BAA4B;QAC7C,MAAM,EAAE,SAAS;KAClB;CACmB,CAAA;AAEtB,MAAM,CAAC,MAAM,yBAAyB,GAAG,GAAG,EAAE,CAAC,YAAY,CAAC,UAAU,CAAC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
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":"AAeA;;;;GAIG;AACH,eAAO,MAAM,YAAY,+CAoExB,CAAA"}
|
|
@@ -6,6 +6,8 @@ import { ProgressBar } from '../../components/ProgressBar.js';
|
|
|
6
6
|
import { useCurrentChat, useCurrentChatState, useWidgetState } from '../../context/hooks.js';
|
|
7
7
|
import { quickCommandRegex } from '../../regex.js';
|
|
8
8
|
import { ChatEntry } from '../../state/ChatEntry.js';
|
|
9
|
+
import { AgentSelector } from './AgentSelector.js';
|
|
10
|
+
import { ButtonAgent } from './ButtonAgent.js';
|
|
9
11
|
import { ButtonGroup } from './ButtonGroup.js';
|
|
10
12
|
import { useMessageInputDictionary } from './dictionary.js';
|
|
11
13
|
import { InfoBar } from './InfoBar.js';
|
|
@@ -26,6 +28,7 @@ export const MessageInput = () => {
|
|
|
26
28
|
const value = useCurrentChatState('nextMessage') ?? '';
|
|
27
29
|
const isMinimized = useWidgetState('isMinimized');
|
|
28
30
|
const textAreaRef = useRef(null);
|
|
31
|
+
const agentLabel = useCurrentChatState('agent')?.label ?? 'Stackspot AI';
|
|
29
32
|
const onSend = useCallback(async () => {
|
|
30
33
|
const message = chat.get('nextMessage');
|
|
31
34
|
if (!message)
|
|
@@ -47,7 +50,7 @@ export const MessageInput = () => {
|
|
|
47
50
|
if (!isLoading)
|
|
48
51
|
textAreaRef.current?.focus();
|
|
49
52
|
}, [isLoading]);
|
|
50
|
-
return (_jsxs(MessageInputBox, { "aria-busy": isLoading, className: "message-input", children: [_jsx(ProgressBar, { visible: isLoading, shimmer: true }), _jsx(InfoBar, {}), _jsxs("div", { className: listToClass(['action-box', focused && 'focused', isLoading && 'disabled']), children: [_jsx(
|
|
53
|
+
return (_jsxs(MessageInputBox, { "aria-busy": isLoading, className: "message-input", children: [_jsx(ProgressBar, { visible: isLoading, shimmer: true }), _jsx(InfoBar, {}), _jsx(QuickCommandSelector, { inputRef: textAreaRef }), _jsx(AgentSelector, { inputRef: textAreaRef }), _jsxs("div", { className: listToClass(['action-box', focused && 'focused', isLoading && 'disabled']), children: [_jsx(ButtonAgent, {}), _jsx(AdaptiveTextArea, { ref: textAreaRef, disabled: isLoading, placeholder: t.placeholder.replace('%s', agentLabel), onChange: e => chat.set('nextMessage', e.target.value), value: value, onFocus: () => setFocused(true), onBlur: () => setFocused(false), onKeyDown: onKeyDown, onIncreaseSize: () => setExpanded(false), onResetSize: () => !expansionLocked.current && setExpanded(true), maxHeight: isMinimized ? MIN_INPUT_HEIGHT : MAX_INPUT_HEIGHT }), _jsx(ButtonGroup, { onSend: onSend, onCancel: () => chat.abort(), expanded: expanded, isLoading: isLoading, setExpanded: (value) => {
|
|
51
54
|
setExpanded(value);
|
|
52
55
|
expansionLocked.current = expanded;
|
|
53
56
|
} })] })] }));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/views/MessageInput/index.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AACtD,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,qBAA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AAC,KAAK,EAAE,EAAE;4BACrB,WAAW,CAAC,KAAK,CAAC,CAAA;4BAClB,eAAe,CAAC,OAAO,GAAG,QAAQ,CAAA;wBACpC,CAAC,GACD,IACE,IACU,CACnB,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styled.d.ts","sourceRoot":"","sources":["../../../src/views/MessageInput/styled.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,gBAAgB,MAAM,CAAA;AACnC,eAAO,MAAM,gBAAgB,KAAK,CAAA;AAElC,eAAO,MAAM,eAAe,
|
|
1
|
+
{"version":3,"file":"styled.d.ts","sourceRoot":"","sources":["../../../src/views/MessageInput/styled.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,gBAAgB,MAAM,CAAA;AACnC,eAAO,MAAM,gBAAgB,KAAK,CAAA;AAElC,eAAO,MAAM,eAAe,wOAkP3B,CAAA"}
|