@stack-spot/ai-chat-widget 1.31.2-beta.1 → 1.32.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.
Files changed (65) hide show
  1. package/CHANGELOG.md +25 -7
  2. package/dist/app-metadata.json +3 -3
  3. package/dist/chat-interceptors/quick-commands.d.ts.map +1 -1
  4. package/dist/chat-interceptors/quick-commands.js +16 -71
  5. package/dist/chat-interceptors/quick-commands.js.map +1 -1
  6. package/dist/components/RightPanelContentList.d.ts +10 -0
  7. package/dist/components/RightPanelContentList.d.ts.map +1 -0
  8. package/dist/components/RightPanelContentList.js +7 -0
  9. package/dist/components/RightPanelContentList.js.map +1 -0
  10. package/dist/components/Selector/index.d.ts.map +1 -1
  11. package/dist/components/Selector/index.js +3 -2
  12. package/dist/components/Selector/index.js.map +1 -1
  13. package/dist/features.d.ts +15 -0
  14. package/dist/features.d.ts.map +1 -1
  15. package/dist/features.js +1 -0
  16. package/dist/features.js.map +1 -1
  17. package/dist/layout.css +5 -1
  18. package/dist/state/constants.js +1 -1
  19. package/dist/state/constants.js.map +1 -1
  20. package/dist/views/Agents/AgentDescription.js +1 -1
  21. package/dist/views/Agents/AgentDescription.js.map +1 -1
  22. package/dist/views/Agents/AgentsPanel.d.ts.map +1 -1
  23. package/dist/views/Agents/AgentsPanel.js +24 -15
  24. package/dist/views/Agents/AgentsPanel.js.map +1 -1
  25. package/dist/views/Agents/AgentsTab.d.ts +1 -1
  26. package/dist/views/Agents/AgentsTab.d.ts.map +1 -1
  27. package/dist/views/Agents/dictionary.d.ts +1 -1
  28. package/dist/views/ChatHistory/HistoryItem.d.ts.map +1 -1
  29. package/dist/views/ChatHistory/HistoryItem.js +3 -1
  30. package/dist/views/ChatHistory/HistoryItem.js.map +1 -1
  31. package/dist/views/KSDocument.d.ts.map +1 -1
  32. package/dist/views/KSDocument.js +2 -1
  33. package/dist/views/KSDocument.js.map +1 -1
  34. package/dist/views/KnowledgeSources.d.ts +1 -1
  35. package/dist/views/KnowledgeSources.d.ts.map +1 -1
  36. package/dist/views/KnowledgeSources.js +24 -11
  37. package/dist/views/KnowledgeSources.js.map +1 -1
  38. package/dist/views/MessageInput/AgentSelector.d.ts.map +1 -1
  39. package/dist/views/MessageInput/AgentSelector.js +6 -2
  40. package/dist/views/MessageInput/AgentSelector.js.map +1 -1
  41. package/dist/views/MessageInput/QuickCommandSelector.d.ts.map +1 -1
  42. package/dist/views/MessageInput/QuickCommandSelector.js +9 -4
  43. package/dist/views/MessageInput/QuickCommandSelector.js.map +1 -1
  44. package/dist/views/Stacks.d.ts +1 -1
  45. package/dist/views/Stacks.d.ts.map +1 -1
  46. package/dist/views/Stacks.js +21 -11
  47. package/dist/views/Stacks.js.map +1 -1
  48. package/package.json +2 -2
  49. package/src/app-metadata.json +3 -3
  50. package/src/chat-interceptors/quick-commands.ts +18 -84
  51. package/src/components/RightPanelContentList.tsx +15 -0
  52. package/src/components/Selector/index.tsx +8 -6
  53. package/src/features.ts +17 -0
  54. package/src/index.ts +1 -0
  55. package/src/layout.css +5 -1
  56. package/src/state/constants.ts +1 -1
  57. package/src/views/Agents/AgentDescription.tsx +1 -1
  58. package/src/views/Agents/AgentsPanel.tsx +36 -17
  59. package/src/views/Agents/AgentsTab.tsx +1 -1
  60. package/src/views/ChatHistory/HistoryItem.tsx +2 -1
  61. package/src/views/KSDocument.tsx +2 -1
  62. package/src/views/KnowledgeSources.tsx +38 -14
  63. package/src/views/MessageInput/AgentSelector.tsx +9 -3
  64. package/src/views/MessageInput/QuickCommandSelector.tsx +18 -5
  65. package/src/views/Stacks.tsx +34 -14
@@ -5,18 +5,22 @@ import { aiClient, workspaceAiClient } from '@stack-spot/portal-network'
5
5
  import { GetAiStackResponse, VisibilityLevelEnum } from '@stack-spot/portal-network/api/ai'
6
6
  import { WorkspaceResponse } from '@stack-spot/portal-network/api/workspace-ai'
7
7
  import { Dictionary, useTranslate } from '@stack-spot/portal-translate'
8
- import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
8
+ import { ReactElement, useCallback, useEffect, useMemo, useRef, useState } from 'react'
9
9
  import { ButtonFavorite } from '../components/ButtonFavorite'
10
10
  import { NavigationComponent } from '../components/ComponentNavigator'
11
11
  import { DescribedRadioGroup } from '../components/form/DescribedRadioGroup'
12
12
  import { IconInput } from '../components/IconInput'
13
+ import { RightPanelContentList } from '../components/RightPanelContentList'
13
14
  import { RightPanelTabs } from '../components/RightPanelTabs'
14
15
  import { WorkspaceTabNavigator } from '../components/WorkspaceTabNavigator'
15
16
  import { useCurrentChat, useWidget, useWidgetState } from '../context/hooks'
17
+ import { Scope } from '../features'
16
18
  import { useRightPanel } from '../right-panel/hooks'
17
19
  import { ChatProperties } from '../state/ChatState'
18
20
  import { checkIsTrial } from '../utils/check-is-trial'
19
21
 
22
+ type TabElement = { title: string, content: ReactElement }
23
+
20
24
  /**
21
25
  * Renders the Stack selection form in the Right Panel if this is the panel that is currently opened.
22
26
  */
@@ -41,27 +45,43 @@ const StacksPanel = () => {
41
45
  const chat = useCurrentChat()
42
46
  const isTrial = checkIsTrial()
43
47
  const stack = useRef(chat.get('stack'))
48
+ const features = useWidgetState('features')
49
+ const isGroupResourcesByScope = features?.groupResourcesByScope
50
+ const scopes = features?.scopes ?? []
51
+ const spotId = features?.workspaceId
44
52
 
45
53
  useEffect(() => {
46
54
  stack.current = chat.get('stack')
47
55
  }, [chat])
48
56
 
49
- const tabs = useMemo(() => isTrial ? [
50
- { title: t.favorites, content: <StacksTab key="favorites" visibility="favorite" stack={stack} /> },
51
- { title: t.personal, content: <StacksTab key="personal" visibility="personal" stack={stack} /> },
52
- ]: [
53
- { title: t.favorites, content: <StacksTab key="favorites" visibility="favorite" stack={stack} /> },
54
- { title: t.personal, content: <StacksTab key="personal" visibility="personal" stack={stack} /> },
55
- { title: t.shared, content: <StacksTab key="shared" visibility="shared" stack={stack} /> },
56
- { title: t.spots, content: <StacksTabWorkspace key="workspace" visibility="workspace" stack={stack} /> },
57
- { title: t.account, content: <StacksTab key="account" visibility="account" stack={stack} /> },
58
- ], [t, isTrial])
59
-
60
- return <RightPanelTabs key={chat.id} tabs={tabs} />
57
+ const allTabsMap: Partial<Record<Scope, TabElement>> = {
58
+ favorite: { title: t.favorites, content: <StacksTab key="favorites" visibility="favorite" stack={stack} /> },
59
+ personal: { title: t.personal, content: <StacksTab key="personal" visibility="personal" stack={stack} /> },
60
+ shared: { title: t.shared, content: <StacksTab key="shared" visibility="shared" stack={stack} /> },
61
+ workspace: { title: t.spots, content: <StacksTabWorkspace key="workspace" visibility="workspace" stack={stack} /> },
62
+ account: { title: t.account, content: <StacksTab key="account" visibility="account" stack={stack} /> },
63
+ }
64
+ const defaultScopes: Scope[] = ['favorite', 'personal', 'shared', 'workspace', 'account']
65
+
66
+ const rawScopes: Scope[] = scopes?.length ? scopes : defaultScopes
67
+
68
+ const scopesToRender: Scope[] = isTrial
69
+ ? ['favorite', 'personal']
70
+ : rawScopes
71
+
72
+ const tabs = scopesToRender
73
+ .map(scope => allTabsMap[scope])
74
+ .filter(Boolean) as TabElement[]
75
+
76
+ return (isGroupResourcesByScope ? (
77
+ <RightPanelTabs key={chat.id} tabs={tabs} />
78
+ ) : (
79
+ <RightPanelContentList><StacksTab stack={stack} workspaceId={spotId} /></RightPanelContentList>
80
+ ))
61
81
  }
62
82
 
63
83
  export interface StacksTabProps {
64
- visibility: VisibilityLevelEnum,
84
+ visibility?: VisibilityLevelEnum,
65
85
  workspaceId?: string,
66
86
  stack: React.MutableRefObject<ChatProperties['stack']>,
67
87
  showSubmitButton?: boolean,