@lobehub/chat 1.2.2 → 1.2.4
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/.stylelintrc.js +1 -0
- package/CHANGELOG.md +50 -0
- package/README.md +1 -1
- package/locales/ar/plugin.json +1 -1
- package/locales/ar/portal.json +7 -1
- package/locales/bg-BG/plugin.json +1 -1
- package/locales/bg-BG/portal.json +7 -1
- package/locales/de-DE/plugin.json +1 -1
- package/locales/de-DE/portal.json +7 -1
- package/locales/en-US/plugin.json +1 -1
- package/locales/en-US/portal.json +8 -2
- package/locales/es-ES/plugin.json +1 -1
- package/locales/es-ES/portal.json +7 -1
- package/locales/fr-FR/plugin.json +1 -1
- package/locales/fr-FR/portal.json +7 -1
- package/locales/it-IT/plugin.json +1 -1
- package/locales/it-IT/portal.json +7 -1
- package/locales/ja-JP/plugin.json +1 -1
- package/locales/ja-JP/portal.json +7 -1
- package/locales/ko-KR/plugin.json +1 -1
- package/locales/ko-KR/portal.json +7 -1
- package/locales/nl-NL/plugin.json +1 -1
- package/locales/nl-NL/portal.json +7 -1
- package/locales/pl-PL/plugin.json +1 -1
- package/locales/pl-PL/portal.json +7 -1
- package/locales/pt-BR/plugin.json +1 -1
- package/locales/pt-BR/portal.json +7 -1
- package/locales/ru-RU/plugin.json +1 -1
- package/locales/ru-RU/portal.json +7 -1
- package/locales/tr-TR/plugin.json +1 -1
- package/locales/tr-TR/portal.json +7 -1
- package/locales/vi-VN/plugin.json +1 -1
- package/locales/vi-VN/portal.json +7 -1
- package/locales/zh-CN/plugin.json +1 -1
- package/locales/zh-CN/portal.json +8 -2
- package/locales/zh-TW/portal.json +7 -1
- package/package.json +9 -6
- package/src/app/(main)/@nav/_layout/Mobile.tsx +2 -3
- package/src/app/(main)/chat/(workspace)/@conversation/features/ChatInput/Desktop/Footer/DragUpload.tsx +1 -1
- package/src/app/(main)/chat/(workspace)/@conversation/features/ChatInput/Desktop/TextArea.tsx +2 -1
- package/src/app/(main)/chat/(workspace)/@portal/features/{Tools/ToolUI → ArtifactUI}/Footer.tsx +18 -7
- package/src/app/(main)/chat/(workspace)/@portal/features/{Tools/ToolUI → ArtifactUI}/ToolRender.tsx +4 -3
- package/src/app/(main)/chat/(workspace)/@portal/features/{Tools/ToolUI → ArtifactUI}/index.tsx +2 -2
- package/src/app/(main)/chat/(workspace)/@portal/features/{Tools/ToolList → Artifacts/ArtifactList}/Item/index.tsx +3 -3
- package/src/app/(main)/chat/(workspace)/@portal/features/{Tools/ToolList → Artifacts/ArtifactList}/Item/style.ts +3 -2
- package/src/app/(main)/chat/(workspace)/@portal/features/Artifacts/ArtifactList/index.tsx +61 -0
- package/src/app/(main)/chat/(workspace)/@portal/features/Artifacts/index.tsx +21 -0
- package/src/app/(main)/chat/(workspace)/@portal/features/Header.tsx +1 -1
- package/src/app/(main)/chat/(workspace)/@portal/index.tsx +12 -6
- package/src/app/(main)/chat/(workspace)/@topic/features/SystemRole/style.ts +8 -4
- package/src/app/(main)/chat/(workspace)/@topic/features/TopicListContent/TopicItem.tsx +1 -1
- package/src/app/(main)/chat/(workspace)/_layout/Desktop/Portal.tsx +7 -7
- package/src/app/(main)/chat/(workspace)/_layout/Desktop/TopicPanel.tsx +3 -3
- package/src/app/(main)/chat/(workspace)/_layout/Desktop/index.tsx +2 -2
- package/src/app/(main)/chat/(workspace)/features/ShareButton/style.ts +6 -6
- package/src/app/(main)/chat/@session/_layout/Desktop/PanelBody.tsx +3 -1
- package/src/app/(main)/chat/@session/_layout/Desktop/SessionHeader.tsx +1 -1
- package/src/app/(main)/chat/@session/features/SessionListContent/ListItem/index.tsx +2 -5
- package/src/app/(main)/chat/@session/features/SkeletonList.tsx +2 -3
- package/src/app/(main)/chat/features/Migration/Start.tsx +1 -1
- package/src/app/(main)/chat/settings/features/SubmitAgentButton/style.ts +4 -3
- package/src/app/(main)/market/@detail/features/TokenTag.tsx +2 -1
- package/src/app/(main)/market/@detail/features/style.ts +4 -3
- package/src/app/(main)/market/_layout/Desktop/DetailSidebar.tsx +1 -1
- package/src/app/(main)/market/_layout/Desktop/Hero.tsx +3 -2
- package/src/app/(main)/market/features/AgentCard/AgentCardBanner.tsx +1 -1
- package/src/app/(main)/market/features/AgentCard/index.tsx +2 -2
- package/src/app/(main)/market/features/AgentList.tsx +1 -1
- package/src/app/(main)/profile/[[...slugs]]/Client.tsx +4 -3
- package/src/app/(main)/settings/_layout/Desktop/SideBar.tsx +4 -2
- package/src/app/(main)/settings/about/features/ItemCard.tsx +2 -1
- package/src/app/(main)/settings/llm/components/ProviderModelList/ModelFetcher.tsx +5 -1
- package/src/app/(main)/settings/llm/components/ProviderModelList/index.tsx +1 -1
- package/src/app/(main)/welcome/features/Hero.tsx +1 -1
- package/src/components/Menu/index.tsx +4 -3
- package/src/components/Notification/index.tsx +4 -4
- package/src/database/client/models/message.ts +1 -1
- package/src/features/AgentSetting/AgentPlugin/LoadingList.tsx +1 -1
- package/src/features/AgentSetting/AgentPlugin/index.tsx +1 -1
- package/src/features/Conversation/Error/APIKeyForm/ProviderAvatar.tsx +10 -0
- package/src/features/Conversation/Error/OllamaBizError/SetupGuide.tsx +3 -3
- package/src/features/Conversation/Messages/Tool/Inspector/index.tsx +4 -4
- package/src/features/Conversation/Messages/Tool/Inspector/style.ts +2 -1
- package/src/features/Conversation/Messages/Tool/index.tsx +1 -1
- package/src/features/Conversation/components/BackBottom/style.ts +6 -6
- package/src/features/Conversation/components/InboxWelcome/QuestionSuggest.tsx +4 -2
- package/src/features/Conversation/components/InboxWelcome/index.tsx +5 -7
- package/src/features/PluginsUI/Render/Loading.tsx +4 -4
- package/src/features/User/DataStatistics.tsx +2 -1
- package/src/features/User/UserPanel/index.tsx +2 -2
- package/src/locales/default/plugin.ts +1 -1
- package/src/locales/default/portal.ts +8 -2
- package/src/store/chat/slices/message/action.ts +1 -1
- package/src/store/chat/slices/plugin/action.ts +25 -1
- package/src/store/chat/slices/portal/action.test.ts +14 -14
- package/src/store/chat/slices/portal/action.ts +5 -5
- package/src/store/chat/slices/portal/initialState.ts +3 -3
- package/src/store/chat/slices/portal/selectors.test.ts +18 -18
- package/src/store/chat/slices/portal/selectors.ts +9 -9
- package/src/tools/dalle/Render/Item/index.tsx +2 -2
- package/src/app/(main)/chat/(workspace)/@portal/features/Tools/ToolList/index.tsx +0 -39
|
@@ -11,13 +11,13 @@ const useStyles = createStyles(({ css, token, isDarkMode }) => ({
|
|
|
11
11
|
cancelIcon: css`
|
|
12
12
|
position: absolute;
|
|
13
13
|
z-index: 100;
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
inset-block-start: 8px;
|
|
15
|
+
inset-inline-end: 8px;
|
|
16
16
|
`,
|
|
17
17
|
container: css`
|
|
18
18
|
position: absolute;
|
|
19
19
|
z-index: 1100;
|
|
20
|
-
|
|
20
|
+
inset-block-end: 16px;
|
|
21
21
|
inset-inline-end: 20px;
|
|
22
22
|
|
|
23
23
|
overflow: hidden;
|
|
@@ -28,7 +28,7 @@ const useStyles = createStyles(({ css, token, isDarkMode }) => ({
|
|
|
28
28
|
box-shadow: ${token.boxShadowSecondary};
|
|
29
29
|
`,
|
|
30
30
|
mobileContainer: css`
|
|
31
|
-
|
|
31
|
+
inset-block-end: 8px;
|
|
32
32
|
inset-inline-start: 8px;
|
|
33
33
|
`,
|
|
34
34
|
wrapper: css`
|
|
@@ -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.
|
|
58
|
+
const isExist = finalList.some((i) => item.id === i.id);
|
|
59
59
|
if (!isExist) {
|
|
60
60
|
finalList.push(item);
|
|
61
61
|
}
|
|
@@ -66,7 +66,7 @@ const AgentPlugin = memo(() => {
|
|
|
66
66
|
|
|
67
67
|
// 检查出不在 installedPlugins 中的插件
|
|
68
68
|
const deprecatedList = userEnabledPlugins
|
|
69
|
-
.filter((pluginId) => installedPlugins.
|
|
69
|
+
.filter((pluginId) => !installedPlugins.some((p) => p.identifier === pluginId))
|
|
70
70
|
.map((id) => ({
|
|
71
71
|
avatar: <Avatar avatar={'♻️'} />,
|
|
72
72
|
children: (
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Anthropic,
|
|
3
|
+
Baichuan,
|
|
3
4
|
DeepSeek,
|
|
4
5
|
Google,
|
|
5
6
|
Groq,
|
|
@@ -9,6 +10,7 @@ import {
|
|
|
9
10
|
OpenAI,
|
|
10
11
|
OpenRouter,
|
|
11
12
|
Perplexity,
|
|
13
|
+
Stepfun,
|
|
12
14
|
Together,
|
|
13
15
|
Tongyi,
|
|
14
16
|
ZeroOne,
|
|
@@ -55,6 +57,10 @@ const ProviderAvatar = memo<ProviderAvatarProps>(({ provider }) => {
|
|
|
55
57
|
return <Anthropic color={Anthropic.colorPrimary} size={52} />;
|
|
56
58
|
}
|
|
57
59
|
|
|
60
|
+
case ModelProvider.Baichuan: {
|
|
61
|
+
return <Baichuan color={Baichuan.colorPrimary} size={56} />;
|
|
62
|
+
}
|
|
63
|
+
|
|
58
64
|
case ModelProvider.DeepSeek: {
|
|
59
65
|
return <DeepSeek color={DeepSeek.colorPrimary} size={56} />;
|
|
60
66
|
}
|
|
@@ -71,6 +77,10 @@ const ProviderAvatar = memo<ProviderAvatarProps>(({ provider }) => {
|
|
|
71
77
|
return <Tongyi color={Tongyi.colorPrimary} size={56} />;
|
|
72
78
|
}
|
|
73
79
|
|
|
80
|
+
case ModelProvider.Stepfun: {
|
|
81
|
+
return <Stepfun color={Stepfun.colorPrimary} size={56} />;
|
|
82
|
+
}
|
|
83
|
+
|
|
74
84
|
case ModelProvider.TogetherAI: {
|
|
75
85
|
return <Together color={Together.colorPrimary} size={56} />;
|
|
76
86
|
}
|
|
@@ -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-
|
|
14
|
+
margin-block-start: 32px;
|
|
15
15
|
&.${prefixCls}-steps-small .${prefixCls}-steps-item-title {
|
|
16
|
-
margin-
|
|
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-
|
|
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.
|
|
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 &&
|
|
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={'
|
|
118
|
+
title={t('title', { ns: 'portal' })}
|
|
119
119
|
/>
|
|
120
120
|
)}
|
|
121
121
|
<ActionIcon
|
|
@@ -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.
|
|
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
|
-
|
|
13
|
-
|
|
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
|
-
|
|
25
|
-
border-
|
|
26
|
-
border-
|
|
27
|
-
border-
|
|
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
|
|
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
|
|
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:
|
|
26
|
+
text-align: start;
|
|
27
27
|
}
|
|
28
28
|
`,
|
|
29
29
|
title: css`
|
|
30
|
-
margin-
|
|
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
|
-
|
|
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
|
-
|
|
24
|
-
|
|
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
|
-
|
|
37
|
+
inset-inline-start: 0;
|
|
38
38
|
transform: translateX(-100%);
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
100% {
|
|
42
|
-
|
|
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
|
|
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
|
-
|
|
14
|
-
|
|
13
|
+
inset-block-start: 8px !important;
|
|
14
|
+
inset-inline-start: 8px !important;
|
|
15
15
|
`,
|
|
16
16
|
}));
|
|
17
17
|
|
|
@@ -640,7 +640,7 @@ export const chatMessage: StateCreator<
|
|
|
640
640
|
|
|
641
641
|
const { internal_coreProcessMessage } = get();
|
|
642
642
|
|
|
643
|
-
const latestMsg = contextMessages.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
40
|
+
expect(result.current.portalToolMessage).toEqual({
|
|
41
41
|
id: 'test-id',
|
|
42
42
|
identifier: 'test-identifier',
|
|
43
43
|
});
|
|
44
|
-
expect(result.current.
|
|
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.
|
|
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.
|
|
60
|
+
expect(result.current.portalToolMessage).toEqual({
|
|
61
61
|
id: 'test-id',
|
|
62
62
|
identifier: 'test-identifier',
|
|
63
63
|
});
|
|
64
|
-
expect(result.current.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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({
|
|
18
|
+
set({ portalToolMessage: undefined }, false, 'openToolUI');
|
|
19
19
|
},
|
|
20
20
|
openToolUI: (id, identifier) => {
|
|
21
|
-
if (!get().
|
|
21
|
+
if (!get().showPortal) {
|
|
22
22
|
get().toggleDock(true);
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
set({
|
|
25
|
+
set({ portalToolMessage: { id, identifier } }, false, 'openToolUI');
|
|
26
26
|
},
|
|
27
27
|
toggleDock: (open) => {
|
|
28
|
-
const showInspector = open === undefined ? !get().
|
|
29
|
-
set({
|
|
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
|
-
|
|
3
|
-
|
|
2
|
+
portalToolMessage?: { id: string; identifier: string };
|
|
3
|
+
showPortal: boolean;
|
|
4
4
|
}
|
|
5
5
|
|
|
6
6
|
export const initialChatPortalState: ChatPortalState = {
|
|
7
|
-
|
|
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
|
-
|
|
11
|
-
|
|
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.
|
|
18
|
-
expect(chatPortalSelectors.
|
|
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.
|
|
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({
|
|
29
|
-
expect(chatPortalSelectors.
|
|
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
|
-
|
|
37
|
-
|
|
36
|
+
portalToolMessage: { id: 'test-id', identifier: 'test' },
|
|
37
|
+
showPortal: false,
|
|
38
38
|
});
|
|
39
|
-
expect(chatPortalSelectors.
|
|
40
|
-
expect(chatPortalSelectors.
|
|
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
|
-
|
|
46
|
-
|
|
45
|
+
portalToolMessage: { id: 'test-id', identifier: 'test' },
|
|
46
|
+
showPortal: true,
|
|
47
47
|
});
|
|
48
|
-
expect(chatPortalSelectors.
|
|
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.
|
|
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({
|
|
59
|
-
expect(chatPortalSelectors.
|
|
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({
|
|
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
|
|
4
|
-
const
|
|
3
|
+
const artifactMessageId = (s: ChatStoreState) => s.portalToolMessage?.id;
|
|
4
|
+
const showPortal = (s: ChatStoreState) => s.showPortal;
|
|
5
5
|
|
|
6
|
-
const
|
|
7
|
-
|
|
6
|
+
const isArtifactMessageUIOpen = (id: string) => (s: ChatStoreState) =>
|
|
7
|
+
artifactMessageId(s) === id && showPortal(s);
|
|
8
8
|
|
|
9
9
|
export const chatPortalSelectors = {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
artifactMessageId,
|
|
11
|
+
isArtifactMessageUIOpen,
|
|
12
|
+
showArtifactUI: (state: ChatStoreState) => !!state.portalToolMessage,
|
|
13
|
+
showPortal,
|
|
14
|
+
toolUIIdentifier: (state: ChatStoreState) => state.portalToolMessage?.identifier,
|
|
15
15
|
};
|