@lobehub/chat 1.2.2 → 1.2.3

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 (100) hide show
  1. package/.stylelintrc.js +1 -0
  2. package/CHANGELOG.md +25 -0
  3. package/README.md +1 -1
  4. package/locales/ar/plugin.json +1 -1
  5. package/locales/ar/portal.json +7 -1
  6. package/locales/bg-BG/plugin.json +1 -1
  7. package/locales/bg-BG/portal.json +7 -1
  8. package/locales/de-DE/plugin.json +1 -1
  9. package/locales/de-DE/portal.json +7 -1
  10. package/locales/en-US/plugin.json +1 -1
  11. package/locales/en-US/portal.json +8 -2
  12. package/locales/es-ES/plugin.json +1 -1
  13. package/locales/es-ES/portal.json +7 -1
  14. package/locales/fr-FR/plugin.json +1 -1
  15. package/locales/fr-FR/portal.json +7 -1
  16. package/locales/it-IT/plugin.json +1 -1
  17. package/locales/it-IT/portal.json +7 -1
  18. package/locales/ja-JP/plugin.json +1 -1
  19. package/locales/ja-JP/portal.json +7 -1
  20. package/locales/ko-KR/plugin.json +1 -1
  21. package/locales/ko-KR/portal.json +7 -1
  22. package/locales/nl-NL/plugin.json +1 -1
  23. package/locales/nl-NL/portal.json +7 -1
  24. package/locales/pl-PL/plugin.json +1 -1
  25. package/locales/pl-PL/portal.json +7 -1
  26. package/locales/pt-BR/plugin.json +1 -1
  27. package/locales/pt-BR/portal.json +7 -1
  28. package/locales/ru-RU/plugin.json +1 -1
  29. package/locales/ru-RU/portal.json +7 -1
  30. package/locales/tr-TR/plugin.json +1 -1
  31. package/locales/tr-TR/portal.json +7 -1
  32. package/locales/vi-VN/plugin.json +1 -1
  33. package/locales/vi-VN/portal.json +7 -1
  34. package/locales/zh-CN/plugin.json +1 -1
  35. package/locales/zh-CN/portal.json +8 -2
  36. package/locales/zh-TW/portal.json +7 -1
  37. package/package.json +6 -7
  38. package/src/app/(main)/@nav/_layout/Mobile.tsx +2 -3
  39. package/src/app/(main)/chat/(workspace)/@conversation/features/ChatInput/Desktop/Footer/DragUpload.tsx +1 -1
  40. package/src/app/(main)/chat/(workspace)/@conversation/features/ChatInput/Desktop/TextArea.tsx +2 -1
  41. package/src/app/(main)/chat/(workspace)/@portal/features/{Tools/ToolUI → ArtifactUI}/Footer.tsx +18 -7
  42. package/src/app/(main)/chat/(workspace)/@portal/features/{Tools/ToolUI → ArtifactUI}/ToolRender.tsx +4 -3
  43. package/src/app/(main)/chat/(workspace)/@portal/features/{Tools/ToolUI → ArtifactUI}/index.tsx +2 -2
  44. package/src/app/(main)/chat/(workspace)/@portal/features/{Tools/ToolList → Artifacts/ArtifactList}/Item/index.tsx +3 -3
  45. package/src/app/(main)/chat/(workspace)/@portal/features/{Tools/ToolList → Artifacts/ArtifactList}/Item/style.ts +3 -2
  46. package/src/app/(main)/chat/(workspace)/@portal/features/Artifacts/ArtifactList/index.tsx +61 -0
  47. package/src/app/(main)/chat/(workspace)/@portal/features/Artifacts/index.tsx +21 -0
  48. package/src/app/(main)/chat/(workspace)/@portal/features/Header.tsx +1 -1
  49. package/src/app/(main)/chat/(workspace)/@portal/index.tsx +12 -6
  50. package/src/app/(main)/chat/(workspace)/@topic/features/SystemRole/style.ts +8 -4
  51. package/src/app/(main)/chat/(workspace)/@topic/features/TopicListContent/TopicItem.tsx +1 -1
  52. package/src/app/(main)/chat/(workspace)/_layout/Desktop/Portal.tsx +7 -7
  53. package/src/app/(main)/chat/(workspace)/_layout/Desktop/TopicPanel.tsx +3 -3
  54. package/src/app/(main)/chat/(workspace)/_layout/Desktop/index.tsx +2 -2
  55. package/src/app/(main)/chat/(workspace)/features/ShareButton/style.ts +6 -6
  56. package/src/app/(main)/chat/@session/_layout/Desktop/PanelBody.tsx +3 -1
  57. package/src/app/(main)/chat/@session/_layout/Desktop/SessionHeader.tsx +1 -1
  58. package/src/app/(main)/chat/@session/features/SessionListContent/ListItem/index.tsx +2 -5
  59. package/src/app/(main)/chat/@session/features/SkeletonList.tsx +2 -3
  60. package/src/app/(main)/chat/features/Migration/Start.tsx +1 -1
  61. package/src/app/(main)/chat/settings/features/SubmitAgentButton/style.ts +4 -3
  62. package/src/app/(main)/market/@detail/features/TokenTag.tsx +2 -1
  63. package/src/app/(main)/market/@detail/features/style.ts +4 -3
  64. package/src/app/(main)/market/_layout/Desktop/DetailSidebar.tsx +1 -1
  65. package/src/app/(main)/market/_layout/Desktop/Hero.tsx +3 -2
  66. package/src/app/(main)/market/features/AgentCard/AgentCardBanner.tsx +1 -1
  67. package/src/app/(main)/market/features/AgentCard/index.tsx +2 -2
  68. package/src/app/(main)/market/features/AgentList.tsx +1 -1
  69. package/src/app/(main)/profile/[[...slugs]]/Client.tsx +4 -3
  70. package/src/app/(main)/settings/_layout/Desktop/SideBar.tsx +4 -2
  71. package/src/app/(main)/settings/about/features/ItemCard.tsx +2 -1
  72. package/src/app/(main)/settings/llm/components/ProviderModelList/ModelFetcher.tsx +5 -1
  73. package/src/app/(main)/settings/llm/components/ProviderModelList/index.tsx +1 -1
  74. package/src/app/(main)/welcome/features/Hero.tsx +1 -1
  75. package/src/components/Menu/index.tsx +4 -3
  76. package/src/components/Notification/index.tsx +4 -4
  77. package/src/database/client/models/message.ts +1 -1
  78. package/src/features/AgentSetting/AgentPlugin/LoadingList.tsx +1 -1
  79. package/src/features/AgentSetting/AgentPlugin/index.tsx +1 -1
  80. package/src/features/Conversation/Error/OllamaBizError/SetupGuide.tsx +3 -3
  81. package/src/features/Conversation/Messages/Tool/Inspector/index.tsx +4 -4
  82. package/src/features/Conversation/Messages/Tool/Inspector/style.ts +2 -1
  83. package/src/features/Conversation/Messages/Tool/index.tsx +1 -1
  84. package/src/features/Conversation/components/BackBottom/style.ts +6 -6
  85. package/src/features/Conversation/components/InboxWelcome/QuestionSuggest.tsx +4 -2
  86. package/src/features/Conversation/components/InboxWelcome/index.tsx +5 -7
  87. package/src/features/PluginsUI/Render/Loading.tsx +4 -4
  88. package/src/features/User/DataStatistics.tsx +2 -1
  89. package/src/features/User/UserPanel/index.tsx +2 -2
  90. package/src/locales/default/plugin.ts +1 -1
  91. package/src/locales/default/portal.ts +8 -2
  92. package/src/store/chat/slices/message/action.ts +1 -1
  93. package/src/store/chat/slices/plugin/action.ts +25 -1
  94. package/src/store/chat/slices/portal/action.test.ts +14 -14
  95. package/src/store/chat/slices/portal/action.ts +5 -5
  96. package/src/store/chat/slices/portal/initialState.ts +3 -3
  97. package/src/store/chat/slices/portal/selectors.test.ts +18 -18
  98. package/src/store/chat/slices/portal/selectors.ts +9 -9
  99. package/src/tools/dalle/Render/Item/index.tsx +2 -2
  100. package/src/app/(main)/chat/(workspace)/@portal/features/Tools/ToolList/index.tsx +0 -39
@@ -55,7 +55,7 @@ class _MessageModel extends BaseModel {
55
55
  const finalList: ChatMessage[] = [];
56
56
 
57
57
  const addItem = (item: ChatMessage) => {
58
- const isExist = finalList.findIndex((i) => item.id === i.id) > -1;
58
+ const isExist = finalList.some((i) => item.id === i.id);
59
59
  if (!isExist) {
60
60
  finalList.push(item);
61
61
  }
@@ -4,7 +4,7 @@ import { createStyles } from 'antd-style';
4
4
  const useStyles = createStyles(({ css, prefixCls }) => ({
5
5
  avatar: css`
6
6
  .${prefixCls}-skeleton-header {
7
- padding-right: 0;
7
+ padding-inline-end: 0;
8
8
  }
9
9
  `,
10
10
  label: css`
@@ -66,7 +66,7 @@ const AgentPlugin = memo(() => {
66
66
 
67
67
  // 检查出不在 installedPlugins 中的插件
68
68
  const deprecatedList = userEnabledPlugins
69
- .filter((pluginId) => installedPlugins.findIndex((p) => p.identifier === pluginId) < 0)
69
+ .filter((pluginId) => !installedPlugins.some((p) => p.identifier === pluginId))
70
70
  .map((id) => ({
71
71
  avatar: <Avatar avatar={'♻️'} />,
72
72
  children: (
@@ -11,15 +11,15 @@ import { ErrorActionContainer } from '@/features/Conversation/Error/style';
11
11
 
12
12
  const useStyles = createStyles(({ css, prefixCls, token }) => ({
13
13
  steps: css`
14
- margin-top: 32px;
14
+ margin-block-start: 32px;
15
15
  &.${prefixCls}-steps-small .${prefixCls}-steps-item-title {
16
- margin-bottom: 16px;
16
+ margin-block-end: 16px;
17
17
  font-size: 16px;
18
18
  font-weight: bold;
19
19
  }
20
20
 
21
21
  .${prefixCls}-steps-item-description {
22
- margin-bottom: 24px;
22
+ margin-block-end: 24px;
23
23
  }
24
24
 
25
25
  .${prefixCls}-steps-icon {
@@ -47,11 +47,11 @@ const Inspector = memo<InspectorProps>(
47
47
  identifier = 'unknown',
48
48
  id,
49
49
  }) => {
50
- const { t } = useTranslation('plugin');
50
+ const { t } = useTranslation(['plugin', 'portal']);
51
51
  const { styles } = useStyles();
52
52
  const [open, setOpen] = useState(false);
53
53
  const [isMessageToolUIOpen, openToolUI, toggleInspector] = useChatStore((s) => [
54
- chatPortalSelectors.isMessageToolUIOpen(id)(s),
54
+ chatPortalSelectors.isArtifactMessageUIOpen(id)(s),
55
55
  s.openToolUI,
56
56
  s.toggleDock,
57
57
  ]);
@@ -105,7 +105,7 @@ const Inspector = memo<InspectorProps>(
105
105
  </Flexbox>
106
106
 
107
107
  <Flexbox horizontal>
108
- {showRightAction && false && (
108
+ {showRightAction && (
109
109
  <ActionIcon
110
110
  icon={InspectionPanel}
111
111
  onClick={() => {
@@ -115,7 +115,7 @@ const Inspector = memo<InspectorProps>(
115
115
  }
116
116
  }}
117
117
  size={DESKTOP_HEADER_ICON_SIZE}
118
- title={'inspector'}
118
+ title={t('title', { ns: 'portal' })}
119
119
  />
120
120
  )}
121
121
  <ActionIcon
@@ -5,7 +5,8 @@ export const useStyles = createStyles(({ css, token }) => ({
5
5
  cursor: pointer;
6
6
 
7
7
  width: fit-content;
8
- padding: 6px 8px;
8
+ padding-block: 6px;
9
+ padding-inline: 8px;
9
10
  padding-inline-end: 12px;
10
11
 
11
12
  color: ${token.colorText};
@@ -17,7 +17,7 @@ import Inspector from './Inspector';
17
17
  export const ToolMessage = memo<ChatMessage>(({ id, content, pluginState, plugin }) => {
18
18
  const [loading, isMessageToolUIOpen] = useChatStore((s) => [
19
19
  chatSelectors.isPluginApiInvoking(id)(s),
20
- chatPortalSelectors.isMessageToolUIOpen(id)(s),
20
+ chatPortalSelectors.isArtifactMessageUIOpen(id)(s),
21
21
  ]);
22
22
  const { direction } = useContext(ConfigProvider.ConfigContext);
23
23
  const { t } = useTranslation('plugin');
@@ -9,8 +9,8 @@ export const useStyles = createStyles(({ token, css, stylish, cx, responsive })
9
9
 
10
10
  position: absolute;
11
11
  z-index: 1000;
12
- right: 16px;
13
- bottom: 16px;
12
+ inset-block-end: 16px;
13
+ inset-inline-end: 16px;
14
14
  transform: translateY(16px);
15
15
 
16
16
  padding-inline: 12px !important;
@@ -21,10 +21,10 @@ export const useStyles = createStyles(({ token, css, stylish, cx, responsive })
21
21
  border-radius: 16px !important;
22
22
 
23
23
  ${responsive.mobile} {
24
- right: 0;
25
- border-right: none;
26
- border-top-right-radius: 0 !important;
27
- border-bottom-right-radius: 0 !important;
24
+ inset-inline-end: 0;
25
+ border-inline-end: none;
26
+ border-start-end-radius: 0 !important;
27
+ border-end-end-radius: 0 !important;
28
28
  }
29
29
  `,
30
30
  ),
@@ -17,7 +17,8 @@ const useStyles = createStyles(({ css, token, responsive }) => ({
17
17
  card: css`
18
18
  cursor: pointer;
19
19
 
20
- padding: 12px 24px;
20
+ padding-block: 12px;
21
+ padding-inline: 24px;
21
22
 
22
23
  color: ${token.colorText};
23
24
 
@@ -29,7 +30,8 @@ const useStyles = createStyles(({ css, token, responsive }) => ({
29
30
  }
30
31
 
31
32
  ${responsive.mobile} {
32
- padding: 8px 16px;
33
+ padding-block: 8px;
34
+ padding-inline: 16px;
33
35
  }
34
36
  `,
35
37
  icon: css`
@@ -23,13 +23,11 @@ const useStyles = createStyles(({ css, responsive }) => ({
23
23
  font-size: 14px;
24
24
  text-align: center;
25
25
  ${responsive.mobile} {
26
- text-align: left;
26
+ text-align: start;
27
27
  }
28
28
  `,
29
29
  title: css`
30
- margin-top: 0.2em;
31
- margin-bottom: 0;
32
-
30
+ margin-block: 0.2em 0;
33
31
  font-size: 32px;
34
32
  font-weight: bolder;
35
33
  line-height: 1;
@@ -56,12 +54,12 @@ const InboxWelcome = memo(() => {
56
54
  <Markdown className={styles.desc} variant={'chat'}>
57
55
  {t('guide.defaultMessage')}
58
56
  </Markdown>
59
- {
60
- showWelcomeSuggest && <>
57
+ {showWelcomeSuggest && (
58
+ <>
61
59
  <AgentsSuggest mobile={mobile} />
62
60
  <QuestionSuggest mobile={mobile} />
63
61
  </>
64
- }
62
+ )}
65
63
  </Flexbox>
66
64
  </Center>
67
65
  );
@@ -20,8 +20,8 @@ const useStyles = createStyles(
20
20
  content: '';
21
21
 
22
22
  position: absolute;
23
- top: 0;
24
- left: 0;
23
+ inset-block-start: 0;
24
+ inset-inline-start: 0;
25
25
 
26
26
  box-sizing: border-box;
27
27
  width: 40%;
@@ -34,12 +34,12 @@ const useStyles = createStyles(
34
34
 
35
35
  @keyframes animloader {
36
36
  0% {
37
- left: 0;
37
+ inset-inline-start: 0;
38
38
  transform: translateX(-100%);
39
39
  }
40
40
 
41
41
  100% {
42
- left: 100%;
42
+ inset-inline-start: 100%;
43
43
  transform: translateX(0%);
44
44
  }
45
45
  }
@@ -17,7 +17,8 @@ import { useServerConfigStore } from '@/store/serverConfig';
17
17
 
18
18
  const useStyles = createStyles(({ css, token }) => ({
19
19
  card: css`
20
- padding: 6px 8px;
20
+ padding-block: 6px;
21
+ padding-inline: 8px;
21
22
  background: ${token.colorFillTertiary};
22
23
  border-radius: ${token.borderRadius}px;
23
24
  `,
@@ -10,8 +10,8 @@ import { useNewVersion } from './useNewVersion';
10
10
 
11
11
  const useStyles = createStyles(({ css }) => ({
12
12
  popover: css`
13
- top: 8px !important;
14
- left: 8px !important;
13
+ inset-block-start: 8px !important;
14
+ inset-inline-start: 8px !important;
15
15
  `,
16
16
  }));
17
17
 
@@ -140,7 +140,7 @@ export default {
140
140
  modalDesc: '配置插件市场的地址后,可以使用自定义的插件市场',
141
141
  title: '设置插件市场',
142
142
  },
143
- showInPortal: '请在扩展窗中查看详情',
143
+ showInPortal: '请在工作区中查看详情',
144
144
  store: {
145
145
  actions: {
146
146
  confirmUninstall: '即将卸载该插件,卸载后将清除该插件配置,请确认你的操作',
@@ -1,4 +1,10 @@
1
1
  export default {
2
- aiSummary: '让助手总结',
3
- title: '扩展窗',
2
+ Artifacts: 'Artifacts',
3
+ actions: {
4
+ genAiMessage: '创建助手消息',
5
+ summary: '总结',
6
+ summaryTooltip: '总结当前内容',
7
+ },
8
+ emptyArtifactList: '当前 Artifacts 列表为空,请在会话中按需使用插件后再查看',
9
+ title: '工作区',
4
10
  };
@@ -640,7 +640,7 @@ export const chatMessage: StateCreator<
640
640
 
641
641
  const { internal_coreProcessMessage } = get();
642
642
 
643
- const latestMsg = contextMessages.filter((s) => s.role === 'user').at(-1);
643
+ const latestMsg = contextMessages.findLast((s) => s.role === 'user');
644
644
 
645
645
  if (!latestMsg) return;
646
646
 
@@ -12,7 +12,7 @@ import { CreateMessageParams, messageService } from '@/services/message';
12
12
  import { ChatStore } from '@/store/chat/store';
13
13
  import { useToolStore } from '@/store/tool';
14
14
  import { pluginSelectors } from '@/store/tool/selectors';
15
- import { ChatToolPayload, MessageToolCall } from '@/types/message';
15
+ import { ChatMessage, ChatToolPayload, MessageToolCall } from '@/types/message';
16
16
  import { merge } from '@/utils/merge';
17
17
  import { safeParseJSON } from '@/utils/safeParseJSON';
18
18
  import { setNamespace } from '@/utils/storeDebug';
@@ -37,6 +37,7 @@ export interface ChatPluginAction {
37
37
 
38
38
  reInvokeToolMessage: (id: string) => Promise<void>;
39
39
  triggerAIMessage: (params: { parentId?: string; traceId?: string }) => Promise<void>;
40
+ summaryPluginContent: (id: string) => Promise<void>;
40
41
 
41
42
  triggerToolCalls: (id: string) => Promise<void>;
42
43
  updatePluginState: (id: string, value: any) => Promise<void>;
@@ -167,6 +168,29 @@ export const chatPlugin: StateCreator<
167
168
  const chats = chatSelectors.currentChats(get());
168
169
  await internal_coreProcessMessage(chats, parentId ?? chats.at(-1)!.id, { traceId });
169
170
  },
171
+
172
+ summaryPluginContent: async (id) => {
173
+ const message = chatSelectors.getMessageById(id)(get());
174
+ if (!message || message.role !== 'tool') return;
175
+
176
+ await get().internal_coreProcessMessage(
177
+ [
178
+ {
179
+ role: 'assistant',
180
+ content: '作为一名总结专家,请结合以上系统提示词,将以下内容进行总结:',
181
+ },
182
+ {
183
+ ...message,
184
+ content: message.content,
185
+ role: 'assistant',
186
+ name: undefined,
187
+ tool_call_id: undefined,
188
+ },
189
+ ] as ChatMessage[],
190
+ message.id,
191
+ );
192
+ },
193
+
170
194
  triggerToolCalls: async (assistantId) => {
171
195
  const message = chatSelectors.getMessageById(assistantId)(get());
172
196
  if (!message || !message.tools) return;
@@ -14,7 +14,7 @@ describe('chatDockSlice', () => {
14
14
  result.current.openToolUI('test-id', 'test-identifier');
15
15
  });
16
16
 
17
- expect(result.current.dockToolMessage).toEqual({
17
+ expect(result.current.portalToolMessage).toEqual({
18
18
  id: 'test-id',
19
19
  identifier: 'test-identifier',
20
20
  });
@@ -23,7 +23,7 @@ describe('chatDockSlice', () => {
23
23
  result.current.closeToolUI();
24
24
  });
25
25
 
26
- expect(result.current.dockToolMessage).toBeUndefined();
26
+ expect(result.current.portalToolMessage).toBeUndefined();
27
27
  });
28
28
  });
29
29
 
@@ -31,17 +31,17 @@ describe('chatDockSlice', () => {
31
31
  it('should set dockToolMessage and open dock if it is closed', () => {
32
32
  const { result } = renderHook(() => useChatStore());
33
33
 
34
- expect(result.current.showDock).toBe(false);
34
+ expect(result.current.showPortal).toBe(false);
35
35
 
36
36
  act(() => {
37
37
  result.current.openToolUI('test-id', 'test-identifier');
38
38
  });
39
39
 
40
- expect(result.current.dockToolMessage).toEqual({
40
+ expect(result.current.portalToolMessage).toEqual({
41
41
  id: 'test-id',
42
42
  identifier: 'test-identifier',
43
43
  });
44
- expect(result.current.showDock).toBe(true);
44
+ expect(result.current.showPortal).toBe(true);
45
45
  });
46
46
 
47
47
  it('should not change dock state if it is already open', () => {
@@ -51,17 +51,17 @@ describe('chatDockSlice', () => {
51
51
  result.current.toggleDock(true);
52
52
  });
53
53
 
54
- expect(result.current.showDock).toBe(true);
54
+ expect(result.current.showPortal).toBe(true);
55
55
 
56
56
  act(() => {
57
57
  result.current.openToolUI('test-id', 'test-identifier');
58
58
  });
59
59
 
60
- expect(result.current.dockToolMessage).toEqual({
60
+ expect(result.current.portalToolMessage).toEqual({
61
61
  id: 'test-id',
62
62
  identifier: 'test-identifier',
63
63
  });
64
- expect(result.current.showDock).toBe(true);
64
+ expect(result.current.showPortal).toBe(true);
65
65
  });
66
66
  });
67
67
 
@@ -69,19 +69,19 @@ describe('chatDockSlice', () => {
69
69
  it('should toggle dock state when no argument is provided', () => {
70
70
  const { result } = renderHook(() => useChatStore());
71
71
 
72
- expect(result.current.showDock).toBe(false);
72
+ expect(result.current.showPortal).toBe(false);
73
73
 
74
74
  act(() => {
75
75
  result.current.toggleDock();
76
76
  });
77
77
 
78
- expect(result.current.showDock).toBe(true);
78
+ expect(result.current.showPortal).toBe(true);
79
79
 
80
80
  act(() => {
81
81
  result.current.toggleDock();
82
82
  });
83
83
 
84
- expect(result.current.showDock).toBe(false);
84
+ expect(result.current.showPortal).toBe(false);
85
85
  });
86
86
 
87
87
  it('should set dock state to the provided value', () => {
@@ -91,19 +91,19 @@ describe('chatDockSlice', () => {
91
91
  result.current.toggleDock(true);
92
92
  });
93
93
 
94
- expect(result.current.showDock).toBe(true);
94
+ expect(result.current.showPortal).toBe(true);
95
95
 
96
96
  act(() => {
97
97
  result.current.toggleDock(false);
98
98
  });
99
99
 
100
- expect(result.current.showDock).toBe(false);
100
+ expect(result.current.showPortal).toBe(false);
101
101
 
102
102
  act(() => {
103
103
  result.current.toggleDock(true);
104
104
  });
105
105
 
106
- expect(result.current.showDock).toBe(true);
106
+ expect(result.current.showPortal).toBe(true);
107
107
  });
108
108
  });
109
109
  });
@@ -15,17 +15,17 @@ export const chatPortalSlice: StateCreator<
15
15
  ChatPortalAction
16
16
  > = (set, get) => ({
17
17
  closeToolUI: () => {
18
- set({ dockToolMessage: undefined }, false, 'openToolUI');
18
+ set({ portalToolMessage: undefined }, false, 'openToolUI');
19
19
  },
20
20
  openToolUI: (id, identifier) => {
21
- if (!get().showDock) {
21
+ if (!get().showPortal) {
22
22
  get().toggleDock(true);
23
23
  }
24
24
 
25
- set({ dockToolMessage: { id, identifier } }, false, 'openToolUI');
25
+ set({ portalToolMessage: { id, identifier } }, false, 'openToolUI');
26
26
  },
27
27
  toggleDock: (open) => {
28
- const showInspector = open === undefined ? !get().showDock : open;
29
- set({ showDock: showInspector }, false, 'toggleInspector');
28
+ const showInspector = open === undefined ? !get().showPortal : open;
29
+ set({ showPortal: showInspector }, false, 'toggleInspector');
30
30
  },
31
31
  });
@@ -1,8 +1,8 @@
1
1
  export interface ChatPortalState {
2
- dockToolMessage?: { id: string; identifier: string };
3
- showDock: boolean;
2
+ portalToolMessage?: { id: string; identifier: string };
3
+ showPortal: boolean;
4
4
  }
5
5
 
6
6
  export const initialChatPortalState: ChatPortalState = {
7
- showDock: false,
7
+ showPortal: false,
8
8
  };
@@ -7,56 +7,56 @@ import { chatPortalSelectors } from './selectors';
7
7
  describe('chatDockSelectors', () => {
8
8
  const createState = (overrides?: Partial<ChatStoreState>) =>
9
9
  ({
10
- showDock: false,
11
- dockToolMessage: undefined,
10
+ showPortal: false,
11
+ portalToolMessage: undefined,
12
12
  ...overrides,
13
13
  }) as ChatStoreState;
14
14
 
15
15
  describe('showDock', () => {
16
16
  it('should return the showDock state', () => {
17
- expect(chatPortalSelectors.showDock(createState({ showDock: true }))).toBe(true);
18
- expect(chatPortalSelectors.showDock(createState({ showDock: false }))).toBe(false);
17
+ expect(chatPortalSelectors.showPortal(createState({ showPortal: true }))).toBe(true);
18
+ expect(chatPortalSelectors.showPortal(createState({ showPortal: false }))).toBe(false);
19
19
  });
20
20
  });
21
21
 
22
22
  describe('toolUIMessageId', () => {
23
23
  it('should return undefined when dockToolMessage is not set', () => {
24
- expect(chatPortalSelectors.toolUIMessageId(createState())).toBeUndefined();
24
+ expect(chatPortalSelectors.artifactMessageId(createState())).toBeUndefined();
25
25
  });
26
26
 
27
27
  it('should return the id when dockToolMessage is set', () => {
28
- const state = createState({ dockToolMessage: { id: 'test-id', identifier: 'test' } });
29
- expect(chatPortalSelectors.toolUIMessageId(state)).toBe('test-id');
28
+ const state = createState({ portalToolMessage: { id: 'test-id', identifier: 'test' } });
29
+ expect(chatPortalSelectors.artifactMessageId(state)).toBe('test-id');
30
30
  });
31
31
  });
32
32
 
33
33
  describe('isMessageToolUIOpen', () => {
34
34
  it('should return false when id does not match or showDock is false', () => {
35
35
  const state = createState({
36
- dockToolMessage: { id: 'test-id', identifier: 'test' },
37
- showDock: false,
36
+ portalToolMessage: { id: 'test-id', identifier: 'test' },
37
+ showPortal: false,
38
38
  });
39
- expect(chatPortalSelectors.isMessageToolUIOpen('test-id')(state)).toBe(false);
40
- expect(chatPortalSelectors.isMessageToolUIOpen('other-id')(state)).toBe(false);
39
+ expect(chatPortalSelectors.isArtifactMessageUIOpen('test-id')(state)).toBe(false);
40
+ expect(chatPortalSelectors.isArtifactMessageUIOpen('other-id')(state)).toBe(false);
41
41
  });
42
42
 
43
43
  it('should return true when id matches and showDock is true', () => {
44
44
  const state = createState({
45
- dockToolMessage: { id: 'test-id', identifier: 'test' },
46
- showDock: true,
45
+ portalToolMessage: { id: 'test-id', identifier: 'test' },
46
+ showPortal: true,
47
47
  });
48
- expect(chatPortalSelectors.isMessageToolUIOpen('test-id')(state)).toBe(true);
48
+ expect(chatPortalSelectors.isArtifactMessageUIOpen('test-id')(state)).toBe(true);
49
49
  });
50
50
  });
51
51
 
52
52
  describe('showToolUI', () => {
53
53
  it('should return false when dockToolMessage is not set', () => {
54
- expect(chatPortalSelectors.showToolUI(createState())).toBe(false);
54
+ expect(chatPortalSelectors.showArtifactUI(createState())).toBe(false);
55
55
  });
56
56
 
57
57
  it('should return true when dockToolMessage is set', () => {
58
- const state = createState({ dockToolMessage: { id: 'test-id', identifier: 'test' } });
59
- expect(chatPortalSelectors.showToolUI(state)).toBe(true);
58
+ const state = createState({ portalToolMessage: { id: 'test-id', identifier: 'test' } });
59
+ expect(chatPortalSelectors.showArtifactUI(state)).toBe(true);
60
60
  });
61
61
  });
62
62
 
@@ -66,7 +66,7 @@ describe('chatDockSelectors', () => {
66
66
  });
67
67
 
68
68
  it('should return the identifier when dockToolMessage is set', () => {
69
- const state = createState({ dockToolMessage: { id: 'test-id', identifier: 'test' } });
69
+ const state = createState({ portalToolMessage: { id: 'test-id', identifier: 'test' } });
70
70
  expect(chatPortalSelectors.toolUIIdentifier(state)).toBe('test');
71
71
  });
72
72
  });
@@ -1,15 +1,15 @@
1
1
  import type { ChatStoreState } from '@/store/chat';
2
2
 
3
- const toolUIMessageId = (s: ChatStoreState) => s.dockToolMessage?.id;
4
- const showDock = (s: ChatStoreState) => s.showDock;
3
+ const artifactMessageId = (s: ChatStoreState) => s.portalToolMessage?.id;
4
+ const showPortal = (s: ChatStoreState) => s.showPortal;
5
5
 
6
- const isMessageToolUIOpen = (id: string) => (s: ChatStoreState) =>
7
- toolUIMessageId(s) === id && showDock(s);
6
+ const isArtifactMessageUIOpen = (id: string) => (s: ChatStoreState) =>
7
+ artifactMessageId(s) === id && showPortal(s);
8
8
 
9
9
  export const chatPortalSelectors = {
10
- isMessageToolUIOpen,
11
- showDock,
12
- showToolUI: (state: ChatStoreState) => !!state.dockToolMessage,
13
- toolUIIdentifier: (state: ChatStoreState) => state.dockToolMessage?.identifier,
14
- toolUIMessageId,
10
+ artifactMessageId,
11
+ isArtifactMessageUIOpen,
12
+ showArtifactUI: (state: ChatStoreState) => !!state.portalToolMessage,
13
+ showPortal,
14
+ toolUIIdentifier: (state: ChatStoreState) => state.portalToolMessage?.identifier,
15
15
  };
@@ -18,8 +18,8 @@ const useStyles = createStyles(({ css, token, prefixCls }) => ({
18
18
  action: css`
19
19
  position: absolute;
20
20
  z-index: 100;
21
- top: 4px;
22
- right: 4px;
21
+ inset-block-start: 4px;
22
+ inset-inline-end: 4px;
23
23
  `,
24
24
  container: css`
25
25
  overflow: scroll;
@@ -1,39 +0,0 @@
1
- import { Skeleton } from 'antd';
2
- import isEqual from 'fast-deep-equal';
3
- import { Flexbox } from 'react-layout-kit';
4
-
5
- import { useChatStore } from '@/store/chat';
6
- import { chatSelectors } from '@/store/chat/selectors';
7
-
8
- import ToolItem from './Item';
9
-
10
- const ToolList = () => {
11
- const messages = useChatStore(chatSelectors.currentToolMessages, isEqual);
12
- const isCurrentChatLoaded = useChatStore(chatSelectors.isCurrentChatLoaded);
13
-
14
- return !isCurrentChatLoaded ? (
15
- <Flexbox gap={12} paddingInline={12}>
16
- {[1, 1, 1, 1, 1, 1].map((key, index) => (
17
- <Skeleton.Button
18
- active
19
- block
20
- key={`${key}-${index}`}
21
- style={{ borderRadius: 8, height: 68 }}
22
- />
23
- ))}
24
- </Flexbox>
25
- ) : (
26
- <Flexbox gap={12} paddingInline={12}>
27
- {messages.map((m) => (
28
- <ToolItem
29
- identifier={m.plugin?.identifier}
30
- key={m.id}
31
- messageId={m.id}
32
- payload={m.plugin}
33
- />
34
- ))}
35
- </Flexbox>
36
- );
37
- };
38
-
39
- export default ToolList;