@stack-spot/ai-chat-widget 1.14.8 → 1.15.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 +2 -2
- package/dist/views/MessageInput/ButtonGroup.js +2 -2
- package/dist/views/MessageInput/ButtonGroup.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 +2 -0
- package/dist/views/MessageInput/dictionary.js.map +1 -1
- package/dist/views/Workspaces.d.ts.map +1 -1
- package/dist/views/Workspaces.js +49 -38
- package/dist/views/Workspaces.js.map +1 -1
- package/package.json +1 -1
- package/src/app-metadata.json +2 -2
- package/src/views/MessageInput/ButtonGroup.tsx +3 -3
- package/src/views/MessageInput/dictionary.ts +2 -0
- package/src/views/Workspaces.tsx +51 -40
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [1.15.0](https://github.com/stack-spot/portal-ai-chat-widget/compare/ai-chat-widget@v1.14.8...ai-chat-widget@v1.15.0) (2025-04-24)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* Change to space ([#117](https://github.com/stack-spot/portal-ai-chat-widget/issues/117)) ([57d0681](https://github.com/stack-spot/portal-ai-chat-widget/commit/57d06816838b8bb24fdfddc1867e5d64d7e929fc))
|
|
9
|
+
|
|
3
10
|
## [1.14.8](https://github.com/stack-spot/portal-ai-chat-widget/compare/ai-chat-widget@v1.14.7...ai-chat-widget@v1.14.8) (2025-04-23)
|
|
4
11
|
|
|
5
12
|
|
package/dist/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.15.0",
|
|
4
|
+
"date": "Thu Apr 24 2025 17:27:32 GMT+0000 (Coordinated Universal Time)",
|
|
5
5
|
"dependencies": [
|
|
6
6
|
{
|
|
7
7
|
"name": "@stack-spot/app-metadata",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { ChevronRight, Code, KnowledgeSource, Send, Stack, Times
|
|
2
|
+
import { ChevronRight, Circle, Code, KnowledgeSource, Send, Stack, Times } from '@citric/icons';
|
|
3
3
|
import { IconButton } from '@citric/ui';
|
|
4
4
|
import { listToClass } from '@stack-spot/portal-theme';
|
|
5
5
|
import { useEffect, useRef } from 'react';
|
|
@@ -29,6 +29,6 @@ export const ButtonGroup = ({ onSend, onCancel, expanded, setExpanded, isLoading
|
|
|
29
29
|
},
|
|
30
30
|
// don't use the whole features object here, it would make every chat tab change rerun this effect.
|
|
31
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.
|
|
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.space, title: t.space, onClick: () => widget.set('panel', 'workspace'), children: _jsx(Circle, {}) })), 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
33
|
};
|
|
34
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,
|
|
1
|
+
{"version":3,"file":"ButtonGroup.js","sourceRoot":"","sources":["../../../src/views/MessageInput/ButtonGroup.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,eAAe,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AAC/F,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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CAAC,QAAQ,IAAI,WAAW,CAAC,CAAC,gBAChD,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,EAC5C,OAAO,EAAE,GAAG,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,YAEnC,KAAC,YAAY,KAAG,GACL,IACZ,EACF,SAAS,CAAC,CAAC,CAAC,CACX,KAAC,UAAU,kBAAa,CAAC,CAAC,MAAM,EAAE,OAAO,EAAE,QAAQ,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,2 +1,2 @@
|
|
|
1
|
-
export declare const useMessageInputDictionary: () => Record<"code" | "placeholder" | "selected" | "send" | "cancel" | "stack" | "workspace" | "knowledgeSource" | "agent" | "remove" | "collapse" | "expand" | "removeConfig" | "removeStack" | "removeWorkspace" | "removeKS" | "removeSelection", string>;
|
|
1
|
+
export declare const useMessageInputDictionary: () => Record<"code" | "placeholder" | "selected" | "send" | "cancel" | "stack" | "workspace" | "knowledgeSource" | "agent" | "remove" | "space" | "collapse" | "expand" | "removeConfig" | "removeStack" | "removeWorkspace" | "removeKS" | "removeSelection", 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":"AA6CA,eAAO,MAAM,yBAAyB,wQAAiC,CAAA"}
|
|
@@ -4,6 +4,7 @@ const dictionary = {
|
|
|
4
4
|
stack: 'Select stack',
|
|
5
5
|
code: 'Open code editor',
|
|
6
6
|
workspace: 'Select workspace',
|
|
7
|
+
space: 'Select space',
|
|
7
8
|
knowledgeSource: 'Select knowledge sources',
|
|
8
9
|
agent: 'Select agent',
|
|
9
10
|
collapse: 'Hide buttons',
|
|
@@ -23,6 +24,7 @@ const dictionary = {
|
|
|
23
24
|
stack: 'Selecionar stack',
|
|
24
25
|
code: 'Abrir editor de código',
|
|
25
26
|
workspace: 'Selecionar workspace',
|
|
27
|
+
space: 'Select Space',
|
|
26
28
|
knowledgeSource: 'Selecionar knowledge sources',
|
|
27
29
|
agent: 'Selecionar agente',
|
|
28
30
|
collapse: 'Esconder botões',
|
|
@@ -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,SAAS,EAAE,kBAAkB;QAC7B,eAAe,EAAE,0BAA0B;QAC3C,KAAK,EAAE,cAAc;QACrB,QAAQ,EAAE,cAAc;QACxB,MAAM,EAAE,cAAc;QACtB,IAAI,EAAE,cAAc;QACpB,WAAW,EAAE,eAAe;QAC5B,MAAM,EAAE,QAAQ;QAChB,YAAY,EAAE,8BAA8B;QAC5C,WAAW,EAAE,8BAA8B;QAC3C,eAAe,EAAE,kCAAkC;QACnD,QAAQ,EAAE,kCAAkC;QAC5C,QAAQ,EAAE,UAAU;QACpB,eAAe,EAAE,+BAA+B;QAChD,MAAM,EAAE,QAAQ;KACjB;IACD,EAAE,EAAE;QACF,K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KAAK,EAAE,kBAAkB;QACzB,IAAI,EAAE,wBAAwB;QAC9B,SAAS,EAAE,sBAAsB;QACjC,KAAK,EAAE,cAAc;QACrB,eAAe,EAAE,8BAA8B;QAC/C,KAAK,EAAE,mBAAmB;QAC1B,QAAQ,EAAE,iBAAiB;QAC3B,MAAM,EAAE,gBAAgB;QACxB,IAAI,EAAE,iBAAiB;QACvB,WAAW,EAAE,kBAAkB;QAC/B,MAAM,EAAE,UAAU;QAClB,YAAY,EAAE,gCAAgC;QAC9C,WAAW,EAAE,6BAA6B;QAC1C,eAAe,EAAE,iCAAiC;QAClD,QAAQ,EAAE,qCAAqC;QAC/C,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":"Workspaces.d.ts","sourceRoot":"","sources":["../../src/views/Workspaces.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Workspaces.d.ts","sourceRoot":"","sources":["../../src/views/Workspaces.tsx"],"names":[],"mappings":"AAcA;;GAEG;AACH,eAAO,MAAM,UAAU,YActB,CAAA"}
|
package/dist/views/Workspaces.js
CHANGED
|
@@ -2,9 +2,10 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
2
2
|
import { Button } from '@citric/core';
|
|
3
3
|
import { Search } from '@citric/icons';
|
|
4
4
|
import { Placeholder } from '@stack-spot/portal-components/Placeholder';
|
|
5
|
-
import {
|
|
5
|
+
import { workspaceAiClient } from '@stack-spot/portal-network';
|
|
6
6
|
import { useTranslate } from '@stack-spot/portal-translate';
|
|
7
7
|
import { useEffect, useMemo, useState } from 'react';
|
|
8
|
+
import { ButtonFavorite } from '../components/ButtonFavorite.js';
|
|
8
9
|
import { DescribedRadioGroup } from '../components/form/DescribedRadioGroup.js';
|
|
9
10
|
import { IconInput } from '../components/IconInput.js';
|
|
10
11
|
import { RightPanelTabs } from '../components/RightPanelTabs.js';
|
|
@@ -29,73 +30,83 @@ const WorkspacesPanel = () => {
|
|
|
29
30
|
const t = useTranslate(dictionary);
|
|
30
31
|
const chat = useCurrentChat();
|
|
31
32
|
return _jsx(RightPanelTabs, { tabs: [
|
|
32
|
-
|
|
33
|
-
{ title: t.all, content: _jsx(WorkspaceSourcesTab, {}, "all") },
|
|
33
|
+
{ title: t.favorites, content: _jsx(WorkspaceSourcesTab, { visibility: "favorite" }, "favorite") },
|
|
34
|
+
{ title: t.all, content: _jsx(WorkspaceSourcesTab, { visibility: "all" }, "all") },
|
|
34
35
|
] }, chat.id);
|
|
35
36
|
};
|
|
36
|
-
const WorkspaceSourcesTab = () => {
|
|
37
|
+
const WorkspaceSourcesTab = ({ visibility }) => {
|
|
37
38
|
const t = useTranslate(dictionary);
|
|
38
39
|
const { close } = useRightPanel();
|
|
39
40
|
const chat = useCurrentChat();
|
|
40
41
|
const [filter, setFilter] = useState('');
|
|
41
|
-
|
|
42
|
-
// const [value, setValue] = useState<WorkspaceResponse | undefined>(workspaces.find(w => w.id === chat.get('workspace')?.id))
|
|
43
|
-
const workspaces = workspaceClient.workspaces.useQuery({ aclOnly: false });
|
|
42
|
+
const workspaces = workspaceAiClient.workspacesAi.useQuery({ visibility });
|
|
44
43
|
const [value, setValue] = useState(workspaces.find(w => w.id === chat.get('workspace')?.id));
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
//
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
//
|
|
64
|
-
|
|
65
|
-
|
|
44
|
+
const listFavorites = workspaceAiClient.workspacesAi.useQuery({ visibility: 'favorite' });
|
|
45
|
+
const [addFavorite, pendingAddFav] = workspaceAiClient.addFavoriteWorkspaceAi.useMutation();
|
|
46
|
+
const [removeFavorite, pendingRemoveFav] = workspaceAiClient.removeFavoriteWorkspaceAi.useMutation();
|
|
47
|
+
// eslint-disable-next-line no-async-promise-executor
|
|
48
|
+
const onAddFavorite = async (idOrSlug) => new Promise(async (resolve, reject) => {
|
|
49
|
+
try {
|
|
50
|
+
await addFavorite({ workspaceId: idOrSlug });
|
|
51
|
+
await workspaceAiClient.workspacesAi.invalidate();
|
|
52
|
+
if (!pendingAddFav) {
|
|
53
|
+
resolve(true);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
catch (error) {
|
|
57
|
+
// eslint-disable-next-line no-console
|
|
58
|
+
console.error(error);
|
|
59
|
+
reject(error);
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
// eslint-disable-next-line no-async-promise-executor
|
|
63
|
+
const onRemoveFavorite = (idOrSlug) => new Promise(async (resolve, reject) => {
|
|
64
|
+
try {
|
|
65
|
+
await removeFavorite({ workspaceId: idOrSlug });
|
|
66
|
+
await workspaceAiClient.workspacesAi.invalidate();
|
|
67
|
+
if (!pendingRemoveFav) {
|
|
68
|
+
resolve(true);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
catch (error) {
|
|
72
|
+
// eslint-disable-next-line no-console
|
|
73
|
+
console.error(error);
|
|
74
|
+
reject(error);
|
|
75
|
+
}
|
|
76
|
+
});
|
|
66
77
|
const filtered = useMemo(
|
|
67
78
|
// Recreate the list so that the favorites list is taken into account
|
|
68
|
-
() => filter ? workspaces.filter(w => w === value || w.name.toLocaleLowerCase().includes(filter.toLocaleLowerCase())) : workspaces, [workspaces, filter, value]);
|
|
79
|
+
() => filter ? workspaces.filter(w => w === value || w.name.toLocaleLowerCase().includes(filter.toLocaleLowerCase())) : [...workspaces], [workspaces, filter, value, listFavorites]);
|
|
69
80
|
function submit() {
|
|
70
81
|
if (value)
|
|
71
82
|
chat.set('workspace', { id: value.id, label: value.name });
|
|
72
83
|
close();
|
|
73
84
|
}
|
|
74
|
-
return (_jsxs(_Fragment, { children: [_jsxs("div", { className: "content", children: [_jsx(IconInput, { icon: _jsx(Search, {}), value: filter, onChange: setFilter, className: "search" }), !!filtered.length && _jsx(DescribedRadioGroup, { options: filtered, keygen: w => w.id, value: value, onChange: setValue, renderLabel: w => w.name, renderDescription: w => w.description, optionClassName: w => (w === value && filter && !w.name.toLocaleLowerCase().includes(filter.toLocaleLowerCase()))
|
|
85
|
+
return (_jsxs(_Fragment, { children: [_jsxs("div", { className: "content", children: [_jsx(IconInput, { icon: _jsx(Search, {}), value: filter, onChange: setFilter, className: "search" }), !!filtered.length && _jsx(DescribedRadioGroup, { options: filtered, keygen: w => w.id, value: value, onChange: setValue, renderLabel: w => w.name, renderDescription: w => w.description, renderAfterElement: ({ id }) => _jsx(ButtonFavorite, { favorite: { idOrSlug: id, listFavorites, onAddFavorite, onRemoveFavorite } }), optionClassName: w => (w === value && filter && !w.name.toLocaleLowerCase().includes(filter.toLocaleLowerCase()))
|
|
75
86
|
? 'filtered-out'
|
|
76
87
|
: '', className: "option-list" }), !!workspaces.length && !filtered.length &&
|
|
77
88
|
_jsx(Placeholder, { title: t.noSearchResults, description: t.noSearchResultsDescription, className: "no-data-placeholder" }), !workspaces.length && _jsx(Placeholder, { title: t.noData, description: t.noDataDescription })] }), !!filtered.length && _jsx(Button, { onClick: submit, disabled: !value, children: t.apply })] }));
|
|
78
89
|
};
|
|
79
90
|
const dictionary = {
|
|
80
91
|
en: {
|
|
81
|
-
title: '
|
|
82
|
-
description: 'By selecting a
|
|
92
|
+
title: 'Spaces',
|
|
93
|
+
description: 'By selecting a space, its Knowledge Sources (KSs), Agents, Quick Commands and Stacks Ai will be consulted to generate the answers.',
|
|
83
94
|
apply: 'Apply',
|
|
84
95
|
noSearchResults: "Your search didn't yield results.",
|
|
85
96
|
noSearchResultsDescription: 'Please, try another search term.',
|
|
86
|
-
noData: 'There are no
|
|
87
|
-
noDataDescription: 'Use the AI portal to create new
|
|
97
|
+
noData: 'There are no spaces yet.',
|
|
98
|
+
noDataDescription: 'Use the AI portal to create new spaces.',
|
|
88
99
|
all: 'All',
|
|
89
100
|
favorites: 'Favorites',
|
|
90
101
|
},
|
|
91
102
|
pt: {
|
|
92
|
-
title: '
|
|
93
|
-
description: 'Ao selecionar um
|
|
103
|
+
title: 'Spaces',
|
|
104
|
+
description: 'Ao selecionar um space, seus Knowledge Sources (KSs), Agentes, Quick Commands e Stacks Ai serão consultados para gerar as respostas.',
|
|
94
105
|
apply: 'Aplicar',
|
|
95
106
|
noSearchResults: 'Sua busca não produziu resultados',
|
|
96
107
|
noSearchResultsDescription: 'Por favor, tente outra busca.',
|
|
97
|
-
noData: 'Ainda não há
|
|
98
|
-
noDataDescription: 'Use o Portal AI para criar novos
|
|
108
|
+
noData: 'Ainda não há spaces.',
|
|
109
|
+
noDataDescription: 'Use o Portal AI para criar novos spaces.',
|
|
99
110
|
all: 'Todos',
|
|
100
111
|
favorites: 'Favoritos',
|
|
101
112
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Workspaces.js","sourceRoot":"","sources":["../../src/views/Workspaces.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AACrC,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,2CAA2C,CAAA;AACvE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"Workspaces.js","sourceRoot":"","sources":["../../src/views/Workspaces.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AACrC,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,2CAA2C,CAAA;AACvE,OAAO,EAAE,iBAAiB,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AAiB,EAAE,0CAA0C;QAC7D,GAAG,EAAE,OAAO;QACZ,SAAS,EAAE,WAAW;KACvB;CACmB,CAAA"}
|
package/package.json
CHANGED
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.15.0",
|
|
4
|
+
"date": "Thu Apr 24 2025 17:27:32 GMT+0000 (Coordinated Universal Time)",
|
|
5
5
|
"dependencies": [
|
|
6
6
|
{
|
|
7
7
|
"name": "@stack-spot/app-metadata",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ChevronRight, Code, KnowledgeSource, Send, Stack, Times
|
|
1
|
+
import { ChevronRight, Circle, Code, KnowledgeSource, Send, Stack, Times } from '@citric/icons'
|
|
2
2
|
import { IconButton } from '@citric/ui'
|
|
3
3
|
import { listToClass } from '@stack-spot/portal-theme'
|
|
4
4
|
import { useEffect, useRef } from 'react'
|
|
@@ -62,8 +62,8 @@ export const ButtonGroup = ({ onSend, onCancel, expanded, setExpanded, isLoading
|
|
|
62
62
|
style={{ width: expanded ? featureButtonsWidth.current : 0 }}
|
|
63
63
|
>
|
|
64
64
|
{features.workspace && (
|
|
65
|
-
<IconButton aria-label={t.
|
|
66
|
-
<
|
|
65
|
+
<IconButton aria-label={t.space} title={t.space} onClick={() => widget.set('panel', 'workspace')}>
|
|
66
|
+
<Circle />
|
|
67
67
|
</IconButton>
|
|
68
68
|
)}
|
|
69
69
|
{features.knowledgeSource && (
|
|
@@ -5,6 +5,7 @@ const dictionary = {
|
|
|
5
5
|
stack: 'Select stack',
|
|
6
6
|
code: 'Open code editor',
|
|
7
7
|
workspace: 'Select workspace',
|
|
8
|
+
space: 'Select space',
|
|
8
9
|
knowledgeSource: 'Select knowledge sources',
|
|
9
10
|
agent: 'Select agent',
|
|
10
11
|
collapse: 'Hide buttons',
|
|
@@ -24,6 +25,7 @@ const dictionary = {
|
|
|
24
25
|
stack: 'Selecionar stack',
|
|
25
26
|
code: 'Abrir editor de código',
|
|
26
27
|
workspace: 'Selecionar workspace',
|
|
28
|
+
space: 'Select Space',
|
|
27
29
|
knowledgeSource: 'Selecionar knowledge sources',
|
|
28
30
|
agent: 'Selecionar agente',
|
|
29
31
|
collapse: 'Esconder botões',
|
package/src/views/Workspaces.tsx
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { Button } from '@citric/core'
|
|
2
2
|
import { Search } from '@citric/icons'
|
|
3
3
|
import { Placeholder } from '@stack-spot/portal-components/Placeholder'
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { workspaceAiClient } from '@stack-spot/portal-network'
|
|
5
|
+
import { WorkspaceResponse, WorkspaceVisibilityLevelEnum } from '@stack-spot/portal-network/api/workspace-ai'
|
|
6
6
|
import { Dictionary, useTranslate } from '@stack-spot/portal-translate'
|
|
7
7
|
import { useEffect, useMemo, useState } from 'react'
|
|
8
|
+
import { ButtonFavorite } from '../components/ButtonFavorite'
|
|
8
9
|
import { DescribedRadioGroup } from '../components/form/DescribedRadioGroup'
|
|
9
10
|
import { IconInput } from '../components/IconInput'
|
|
10
11
|
import { RightPanelTabs } from '../components/RightPanelTabs'
|
|
@@ -35,50 +36,58 @@ const WorkspacesPanel = () => {
|
|
|
35
36
|
const chat = useCurrentChat()
|
|
36
37
|
|
|
37
38
|
return <RightPanelTabs key={chat.id} tabs={[
|
|
38
|
-
|
|
39
|
-
{ title: t.all, content: <WorkspaceSourcesTab key="all" /> },
|
|
39
|
+
{ title: t.favorites, content: <WorkspaceSourcesTab key="favorite" visibility="favorite" /> },
|
|
40
|
+
{ title: t.all, content: <WorkspaceSourcesTab key="all" visibility="all" /> },
|
|
40
41
|
]}
|
|
41
42
|
/>
|
|
42
43
|
}
|
|
43
44
|
|
|
44
|
-
const WorkspaceSourcesTab = () => {
|
|
45
|
+
const WorkspaceSourcesTab = ({ visibility }: {visibility: WorkspaceVisibilityLevelEnum}) => {
|
|
45
46
|
const t = useTranslate(dictionary)
|
|
46
47
|
const { close } = useRightPanel()
|
|
47
48
|
const chat = useCurrentChat()
|
|
48
49
|
const [filter, setFilter] = useState('')
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
const
|
|
50
|
+
const workspaces = workspaceAiClient.workspacesAi.useQuery({ visibility })
|
|
51
|
+
const [value, setValue] = useState<WorkspaceResponse | undefined>(workspaces.find(w => w.id === chat.get('workspace')?.id))
|
|
52
|
+
const listFavorites = workspaceAiClient.workspacesAi.useQuery({ visibility: 'favorite' })
|
|
52
53
|
|
|
53
|
-
const [
|
|
54
|
-
|
|
54
|
+
const [addFavorite, pendingAddFav] = workspaceAiClient.addFavoriteWorkspaceAi.useMutation()
|
|
55
|
+
const [removeFavorite, pendingRemoveFav] = workspaceAiClient.removeFavoriteWorkspaceAi.useMutation()
|
|
55
56
|
|
|
56
|
-
//
|
|
57
|
-
|
|
57
|
+
// eslint-disable-next-line no-async-promise-executor
|
|
58
|
+
const onAddFavorite = async(idOrSlug: string) => new Promise<boolean>(async (resolve, reject) => {
|
|
59
|
+
try {
|
|
60
|
+
await addFavorite({ workspaceId: idOrSlug })
|
|
61
|
+
await workspaceAiClient.workspacesAi.invalidate()
|
|
62
|
+
if (!pendingAddFav) {
|
|
63
|
+
resolve(true)
|
|
64
|
+
}
|
|
65
|
+
} catch (error) {
|
|
66
|
+
// eslint-disable-next-line no-console
|
|
67
|
+
console.error(error)
|
|
68
|
+
reject(error)
|
|
69
|
+
}
|
|
70
|
+
})
|
|
58
71
|
|
|
59
|
-
//
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
// // eslint-disable-next-line no-console
|
|
74
|
-
// console.error(error)
|
|
75
|
-
// }
|
|
76
|
-
// }
|
|
72
|
+
// eslint-disable-next-line no-async-promise-executor
|
|
73
|
+
const onRemoveFavorite = (idOrSlug: string) => new Promise<boolean>(async (resolve, reject) => {
|
|
74
|
+
try {
|
|
75
|
+
await removeFavorite({ workspaceId: idOrSlug })
|
|
76
|
+
await workspaceAiClient.workspacesAi.invalidate()
|
|
77
|
+
if (!pendingRemoveFav) {
|
|
78
|
+
resolve(true)
|
|
79
|
+
}
|
|
80
|
+
} catch (error) {
|
|
81
|
+
// eslint-disable-next-line no-console
|
|
82
|
+
console.error(error)
|
|
83
|
+
reject(error)
|
|
84
|
+
}
|
|
85
|
+
})
|
|
77
86
|
|
|
78
87
|
const filtered = useMemo(
|
|
79
88
|
// Recreate the list so that the favorites list is taken into account
|
|
80
|
-
() => filter ? workspaces.filter(w => w === value || w.name.toLocaleLowerCase().includes(filter.toLocaleLowerCase())) : workspaces,
|
|
81
|
-
[workspaces, filter, value],
|
|
89
|
+
() => filter ? workspaces.filter(w => w === value || w.name.toLocaleLowerCase().includes(filter.toLocaleLowerCase())) : [...workspaces],
|
|
90
|
+
[workspaces, filter, value, listFavorites],
|
|
82
91
|
)
|
|
83
92
|
|
|
84
93
|
function submit() {
|
|
@@ -96,6 +105,8 @@ const WorkspaceSourcesTab = () => {
|
|
|
96
105
|
onChange={setValue}
|
|
97
106
|
renderLabel={w => w.name}
|
|
98
107
|
renderDescription={w => w.description}
|
|
108
|
+
renderAfterElement={({ id }) =>
|
|
109
|
+
<ButtonFavorite favorite={{ idOrSlug: id, listFavorites, onAddFavorite, onRemoveFavorite }} />}
|
|
99
110
|
optionClassName={w => (w === value && filter && !w.name.toLocaleLowerCase().includes(filter.toLocaleLowerCase()))
|
|
100
111
|
? 'filtered-out'
|
|
101
112
|
: ''
|
|
@@ -113,24 +124,24 @@ const WorkspaceSourcesTab = () => {
|
|
|
113
124
|
|
|
114
125
|
const dictionary = {
|
|
115
126
|
en: {
|
|
116
|
-
title: '
|
|
117
|
-
description: 'By selecting a
|
|
127
|
+
title: 'Spaces',
|
|
128
|
+
description: 'By selecting a space, its Knowledge Sources (KSs), Agents, Quick Commands and Stacks Ai will be consulted to generate the answers.',
|
|
118
129
|
apply: 'Apply',
|
|
119
130
|
noSearchResults: "Your search didn't yield results.",
|
|
120
131
|
noSearchResultsDescription: 'Please, try another search term.',
|
|
121
|
-
noData: 'There are no
|
|
122
|
-
noDataDescription: 'Use the AI portal to create new
|
|
132
|
+
noData: 'There are no spaces yet.',
|
|
133
|
+
noDataDescription: 'Use the AI portal to create new spaces.',
|
|
123
134
|
all: 'All',
|
|
124
135
|
favorites: 'Favorites',
|
|
125
136
|
},
|
|
126
137
|
pt: {
|
|
127
|
-
title: '
|
|
128
|
-
description: 'Ao selecionar um
|
|
138
|
+
title: 'Spaces',
|
|
139
|
+
description: 'Ao selecionar um space, seus Knowledge Sources (KSs), Agentes, Quick Commands e Stacks Ai serão consultados para gerar as respostas.',
|
|
129
140
|
apply: 'Aplicar',
|
|
130
141
|
noSearchResults: 'Sua busca não produziu resultados',
|
|
131
142
|
noSearchResultsDescription: 'Por favor, tente outra busca.',
|
|
132
|
-
noData: 'Ainda não há
|
|
133
|
-
noDataDescription: 'Use o Portal AI para criar novos
|
|
143
|
+
noData: 'Ainda não há spaces.',
|
|
144
|
+
noDataDescription: 'Use o Portal AI para criar novos spaces.',
|
|
134
145
|
all: 'Todos',
|
|
135
146
|
favorites: 'Favoritos',
|
|
136
147
|
},
|