@stack-spot/ai-chat-widget 1.17.0 → 1.18.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 +7 -0
- package/dist/StackspotAIWidget.js +1 -1
- package/dist/app-metadata.json +4 -4
- package/dist/components/ComponentNavigator.d.ts +21 -0
- package/dist/components/ComponentNavigator.d.ts.map +1 -0
- package/dist/components/ComponentNavigator.js +33 -0
- package/dist/components/ComponentNavigator.js.map +1 -0
- package/dist/components/ListGroup.d.ts +46 -0
- package/dist/components/ListGroup.d.ts.map +1 -0
- package/dist/components/ListGroup.js +16 -0
- package/dist/components/ListGroup.js.map +1 -0
- package/dist/components/RightPanelForm.d.ts.map +1 -1
- package/dist/components/RightPanelForm.js +29 -1
- package/dist/components/RightPanelForm.js.map +1 -1
- package/dist/components/Selector/index.js +5 -5
- package/dist/components/Selector/index.js.map +1 -1
- package/dist/components/Selector/styled.d.ts +3 -1
- package/dist/components/Selector/styled.d.ts.map +1 -1
- package/dist/components/Selector/styled.js +2 -1
- package/dist/components/Selector/styled.js.map +1 -1
- package/dist/components/WorkspaceTabNavigator.d.ts +15 -0
- package/dist/components/WorkspaceTabNavigator.d.ts.map +1 -0
- package/dist/components/WorkspaceTabNavigator.js +95 -0
- package/dist/components/WorkspaceTabNavigator.js.map +1 -0
- package/dist/components/form/DescribedCheckboxGroup.d.ts.map +1 -1
- package/dist/components/form/DescribedCheckboxGroup.js +23 -2
- package/dist/components/form/DescribedCheckboxGroup.js.map +1 -1
- package/dist/views/Agents/AgentsPanel.d.ts.map +1 -1
- package/dist/views/Agents/AgentsPanel.js +19 -11
- package/dist/views/Agents/AgentsPanel.js.map +1 -1
- package/dist/views/Agents/AgentsTab.d.ts +9 -3
- package/dist/views/Agents/AgentsTab.d.ts.map +1 -1
- package/dist/views/Agents/AgentsTab.js +25 -7
- package/dist/views/Agents/AgentsTab.js.map +1 -1
- package/dist/views/Agents/dictionary.d.ts +1 -1
- package/dist/views/Agents/dictionary.d.ts.map +1 -1
- package/dist/views/Agents/dictionary.js +2 -0
- package/dist/views/Agents/dictionary.js.map +1 -1
- package/dist/views/ChatHistory/utils.d.ts.map +1 -1
- package/dist/views/ChatHistory/utils.js +8 -3
- package/dist/views/ChatHistory/utils.js.map +1 -1
- package/dist/views/KnowledgeSources.d.ts +12 -0
- package/dist/views/KnowledgeSources.d.ts.map +1 -1
- package/dist/views/KnowledgeSources.js +20 -6
- package/dist/views/KnowledgeSources.js.map +1 -1
- package/dist/views/MessageInput/AgentSelector.d.ts.map +1 -1
- package/dist/views/MessageInput/AgentSelector.js +4 -3
- package/dist/views/MessageInput/AgentSelector.js.map +1 -1
- package/dist/views/MessageInput/ButtonGroup.js +2 -2
- package/dist/views/MessageInput/ButtonGroup.js.map +1 -1
- package/dist/views/MessageInput/QuickCommandSelector.d.ts.map +1 -1
- package/dist/views/MessageInput/QuickCommandSelector.js +9 -3
- 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 +2 -0
- package/dist/views/MessageInput/dictionary.js.map +1 -1
- package/dist/views/Stacks.d.ts +9 -0
- package/dist/views/Stacks.d.ts.map +1 -1
- package/dist/views/Stacks.js +37 -14
- package/dist/views/Stacks.js.map +1 -1
- package/dist/views/Workspaces/WorkspacesTab.d.ts +20 -0
- package/dist/views/Workspaces/WorkspacesTab.d.ts.map +1 -0
- package/dist/views/Workspaces/WorkspacesTab.js +64 -0
- package/dist/views/Workspaces/WorkspacesTab.js.map +1 -0
- package/dist/views/{Workspaces.d.ts → Workspaces/index.d.ts} +1 -1
- package/dist/views/Workspaces/index.d.ts.map +1 -0
- package/dist/views/Workspaces/index.js +76 -0
- package/dist/views/Workspaces/index.js.map +1 -0
- package/package.json +3 -3
- package/src/app-metadata.json +4 -4
- package/src/components/ComponentNavigator.tsx +78 -0
- package/src/components/ListGroup.tsx +76 -0
- package/src/components/RightPanelForm.tsx +29 -1
- package/src/components/Selector/index.tsx +5 -5
- package/src/components/Selector/styled.ts +3 -2
- package/src/components/WorkspaceTabNavigator.tsx +170 -0
- package/src/components/form/DescribedCheckboxGroup.tsx +45 -14
- package/src/views/Agents/AgentsPanel.tsx +21 -11
- package/src/views/Agents/AgentsTab.tsx +42 -9
- package/src/views/Agents/dictionary.ts +3 -0
- package/src/views/ChatHistory/utils.ts +9 -3
- package/src/views/KnowledgeSources.tsx +37 -14
- package/src/views/MessageInput/AgentSelector.tsx +4 -3
- package/src/views/MessageInput/ButtonGroup.tsx +3 -3
- package/src/views/MessageInput/QuickCommandSelector.tsx +10 -3
- package/src/views/MessageInput/dictionary.ts +2 -0
- package/src/views/Stacks.tsx +57 -17
- package/src/views/Workspaces/WorkspacesTab.tsx +117 -0
- package/src/views/Workspaces/index.tsx +85 -0
- package/dist/views/Workspaces.d.ts.map +0 -1
- package/dist/views/Workspaces.js +0 -103
- package/dist/views/Workspaces.js.map +0 -1
- package/src/views/Workspaces.tsx +0 -137
package/src/views/Workspaces.tsx
DELETED
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
import { Button } from '@citric/core'
|
|
2
|
-
import { Search } from '@citric/icons'
|
|
3
|
-
import { Placeholder } from '@stack-spot/portal-components/Placeholder'
|
|
4
|
-
import { workspaceClient } from '@stack-spot/portal-network'
|
|
5
|
-
import { WorkspaceReadResponse } from '@stack-spot/portal-network/api/workspace'
|
|
6
|
-
import { Dictionary, useTranslate } from '@stack-spot/portal-translate'
|
|
7
|
-
import { useEffect, useMemo, useState } from 'react'
|
|
8
|
-
import { DescribedRadioGroup } from '../components/form/DescribedRadioGroup'
|
|
9
|
-
import { IconInput } from '../components/IconInput'
|
|
10
|
-
import { RightPanelTabs } from '../components/RightPanelTabs'
|
|
11
|
-
import { useCurrentChat, useWidget, useWidgetState } from '../context/hooks'
|
|
12
|
-
import { useRightPanel } from '../right-panel/hooks'
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Renders the Workspace selection form in the Right Panel if this is the panel that is currently opened.
|
|
16
|
-
*/
|
|
17
|
-
export const Workspaces = () => {
|
|
18
|
-
const t = useTranslate(dictionary)
|
|
19
|
-
const panel = useWidgetState('panel')
|
|
20
|
-
const { open } = useRightPanel()
|
|
21
|
-
const widget = useWidget()
|
|
22
|
-
const chat = useCurrentChat()
|
|
23
|
-
|
|
24
|
-
useEffect(() => {
|
|
25
|
-
if (panel === 'workspace') open(
|
|
26
|
-
<WorkspacesPanel key={chat.id} />,
|
|
27
|
-
{ title: t.title, description: t.description, onClose: () => widget.set('panel', undefined) },
|
|
28
|
-
)
|
|
29
|
-
}, [panel, t, chat.id])
|
|
30
|
-
return null
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const WorkspacesPanel = () => {
|
|
34
|
-
const t = useTranslate(dictionary)
|
|
35
|
-
const chat = useCurrentChat()
|
|
36
|
-
|
|
37
|
-
return <RightPanelTabs key={chat.id} tabs={[
|
|
38
|
-
// { title: t.favorites, content: <WorkspaceSourcesTab key="favorite" visibility="favorite" /> },
|
|
39
|
-
{ title: t.all, content: <WorkspaceSourcesTab key="all" /> },
|
|
40
|
-
]}
|
|
41
|
-
/>
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
const WorkspaceSourcesTab = () => {
|
|
45
|
-
const t = useTranslate(dictionary)
|
|
46
|
-
const { close } = useRightPanel()
|
|
47
|
-
const chat = useCurrentChat()
|
|
48
|
-
const [filter, setFilter] = useState('')
|
|
49
|
-
// const workspaces = workspaceAiClient.workspacesAi.useQuery({ visibility })
|
|
50
|
-
// const [value, setValue] = useState<WorkspaceResponse | undefined>(workspaces.find(w => w.id === chat.get('workspace')?.id))
|
|
51
|
-
const workspaces = workspaceClient.workspaces.useQuery({ aclOnly: false })
|
|
52
|
-
|
|
53
|
-
const [value, setValue] = useState<WorkspaceReadResponse | undefined>(workspaces.find(w => w.id === chat.get('workspace')?.id))
|
|
54
|
-
// const listFavorites = workspaceAiClient.workspacesAi.useQuery({ visibility: 'favorite' })
|
|
55
|
-
|
|
56
|
-
// const [addFavorite, pendingAddFav] = workspaceAiClient.addFavoriteWorkspaceAi.useMutation()
|
|
57
|
-
// const [removeFavorite, pendingRemoveFav] = workspaceAiClient.removeFavoriteWorkspaceAi.useMutation()
|
|
58
|
-
|
|
59
|
-
// const onAddFavorite = async(idOrSlug: string) => {
|
|
60
|
-
// try {
|
|
61
|
-
// await addFavorite({ workspaceId: idOrSlug })
|
|
62
|
-
// await workspaceAiClient.workspacesAi.invalidate()
|
|
63
|
-
// } catch (error) {
|
|
64
|
-
// // eslint-disable-next-line no-console
|
|
65
|
-
// console.error(error)
|
|
66
|
-
// }
|
|
67
|
-
// }
|
|
68
|
-
// const onRemoveFavorite = async(idOrSlug: string) => {
|
|
69
|
-
// try {
|
|
70
|
-
// await removeFavorite({ workspaceId: idOrSlug })
|
|
71
|
-
// await workspaceAiClient.workspacesAi.invalidate()
|
|
72
|
-
// } catch (error) {
|
|
73
|
-
// // eslint-disable-next-line no-console
|
|
74
|
-
// console.error(error)
|
|
75
|
-
// }
|
|
76
|
-
// }
|
|
77
|
-
|
|
78
|
-
const filtered = useMemo(
|
|
79
|
-
// 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],
|
|
82
|
-
)
|
|
83
|
-
|
|
84
|
-
function submit() {
|
|
85
|
-
if (value) chat.set('workspace', { id: value.id, label: value.name })
|
|
86
|
-
close()
|
|
87
|
-
}
|
|
88
|
-
return (
|
|
89
|
-
<>
|
|
90
|
-
<div className="content">
|
|
91
|
-
<IconInput icon={<Search />} value={filter} onChange={setFilter} className="search" />
|
|
92
|
-
{!!filtered.length && <DescribedRadioGroup
|
|
93
|
-
options={filtered}
|
|
94
|
-
keygen={w => w.id}
|
|
95
|
-
value={value}
|
|
96
|
-
onChange={setValue}
|
|
97
|
-
renderLabel={w => w.name}
|
|
98
|
-
renderDescription={w => w.description}
|
|
99
|
-
optionClassName={w => (w === value && filter && !w.name.toLocaleLowerCase().includes(filter.toLocaleLowerCase()))
|
|
100
|
-
? 'filtered-out'
|
|
101
|
-
: ''
|
|
102
|
-
}
|
|
103
|
-
className="option-list"
|
|
104
|
-
/>}
|
|
105
|
-
{!!workspaces.length && !filtered.length &&
|
|
106
|
-
<Placeholder title={t.noSearchResults} description={t.noSearchResultsDescription} className="no-data-placeholder" />}
|
|
107
|
-
{!workspaces.length && <Placeholder title={t.noData} description={t.noDataDescription} />}
|
|
108
|
-
</div>
|
|
109
|
-
{!!filtered.length && <Button onClick={submit} disabled={!value}>{t.apply}</Button>}
|
|
110
|
-
</>
|
|
111
|
-
)
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
const dictionary = {
|
|
115
|
-
en: {
|
|
116
|
-
title: 'Workspaces',
|
|
117
|
-
description: 'By selecting a workspace, its Knowledge Sources (KSs) will be consulted to generate the answers.',
|
|
118
|
-
apply: 'Apply',
|
|
119
|
-
noSearchResults: "Your search didn't yield results.",
|
|
120
|
-
noSearchResultsDescription: 'Please, try another search term.',
|
|
121
|
-
noData: 'There are no workspaces yet.',
|
|
122
|
-
noDataDescription: 'Use the AI portal to create new workspaces.',
|
|
123
|
-
all: 'All',
|
|
124
|
-
favorites: 'Favorites',
|
|
125
|
-
},
|
|
126
|
-
pt: {
|
|
127
|
-
title: 'Workspaces',
|
|
128
|
-
description: 'Ao selecionar um workspace, seus Knowledge Sources (KSs) serão consultados para gerar as respostas.',
|
|
129
|
-
apply: 'Aplicar',
|
|
130
|
-
noSearchResults: 'Sua busca não produziu resultados',
|
|
131
|
-
noSearchResultsDescription: 'Por favor, tente outra busca.',
|
|
132
|
-
noData: 'Ainda não há workspace.',
|
|
133
|
-
noDataDescription: 'Use o Portal AI para criar novos workspaces.',
|
|
134
|
-
all: 'Todos',
|
|
135
|
-
favorites: 'Favoritos',
|
|
136
|
-
},
|
|
137
|
-
} satisfies Dictionary
|