Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

style: update tools style

canisminor199079274f6dee0a
diff --git a/src/app/[variants]/(main)/community/(detail)/assistant/features/Details/Overview/index.tsx b/src/app/[variants]/(main)/community/(detail)/assistant/features/Details/Overview/index.tsx
index 9723a5443e1..ec23fc32859 100644
--- a/src/app/[variants]/(main)/community/(detail)/assistant/features/Details/Overview/index.tsx
+++ b/src/app/[variants]/(main)/community/(detail)/assistant/features/Details/Overview/index.tsx
@@ -66,7 +66,7 @@ const Overview = memo(() => {
<Flexbox gap={16}>
<Collapse
defaultActiveKey={['summary']}
- expandIconPosition={'end'}
+ expandIconPlacement={'end'}
items={[
{
children: summary || description,
diff --git a/src/app/[variants]/(main)/community/(detail)/assistant/features/Sidebar/Summary/index.tsx b/src/app/[variants]/(main)/community/(detail)/assistant/features/Sidebar/Summary/index.tsx
index 47f7b1c8f1f..2bf60ce5702 100644
--- a/src/app/[variants]/(main)/community/(detail)/assistant/features/Sidebar/Summary/index.tsx
+++ b/src/app/[variants]/(main)/community/(detail)/assistant/features/Sidebar/Summary/index.tsx
@@ -12,7 +12,7 @@ const Summary = memo(() => {
return (
<Collapse
defaultActiveKey={['summary']}
- expandIconPosition={'end'}
+ expandIconPlacement={'end'}
items={[
{
children: (
diff --git a/src/app/[variants]/(main)/community/(detail)/model/features/Details/Parameter/index.tsx b/src/app/[variants]/(main)/community/(detail)/model/features/Details/Parameter/index.tsx
index 150037ab713..a71965131da 100644
--- a/src/app/[variants]/(main)/community/(detail)/model/features/Details/Parameter/index.tsx
+++ b/src/app/[variants]/(main)/community/(detail)/model/features/Details/Parameter/index.tsx
@@ -98,7 +98,7 @@ const ParameterList = memo(() => {
<Title>{t('models.parameterList.title')}</Title>
<Collapse
defaultActiveKey={items.map((item) => item.key)}
- expandIconPosition={'end'}
+ expandIconPlacement={'end'}
gap={16}
items={items.map((item) => ({
children: <ParameterItem {...item} key={item.key} />,
diff --git a/src/app/[variants]/(main)/settings/usage/features/UsageCards/ActiveModels/ModelTable.tsx b/src/app/[variants]/(main)/settings/usage/features/UsageCards/ActiveModels/ModelTable.tsx
index fa348c34938..dcc4583a12b 100644
--- a/src/app/[variants]/(main)/settings/usage/features/UsageCards/ActiveModels/ModelTable.tsx
+++ b/src/app/[variants]/(main)/settings/usage/features/UsageCards/ActiveModels/ModelTable.tsx
@@ -1,6 +1,6 @@
import { CategoryBar, useThemeColorRange } from '@lobehub/charts';
import { ModelIcon, ProviderIcon } from '@lobehub/icons';
-import { Collapse, Tag , Skeleton } from '@lobehub/ui';
+import { Collapse, Skeleton, Tag } from '@lobehub/ui';
import { useTheme } from 'antd-style';
import { memo, useMemo } from 'react';
import { useTranslation } from 'react-i18next';
@@ -86,7 +86,7 @@ const ModelTable = memo<UsageChartProps>(({ data, isLoading, groupBy }) => {
) : (
<Collapse
defaultActiveKey={formattedData.map((item) => item.id)}
- expandIconPosition={'end'}
+ expandIconPlacement={'end'}
gap={16}
items={formattedData.map((item) => {
const key = item.id;
diff --git a/src/app/[variants]/(mobile)/(home)/features/SessionListContent/CollapseGroup/index.tsx b/src/app/[variants]/(mobile)/(home)/features/SessionListContent/CollapseGroup/index.tsx
index c091b293d55..73a7557983b 100644
--- a/src/app/[variants]/(mobile)/(home)/features/SessionListContent/CollapseGroup/index.tsx
+++ b/src/app/[variants]/(mobile)/(home)/features/SessionListContent/CollapseGroup/index.tsx
@@ -52,7 +52,7 @@ const CollapseGroup = memo<CollapseProps>((props) => {
style={isActive ? {} : { rotate: '-90deg' }}
/>
)}
- expandIconPosition={'end'}
+ expandIconPlacement={'end'}
ghost
size={'small'}
{...props}
diff --git a/src/components/ChangelogModal/index.tsx b/src/components/ChangelogModal/index.tsx
index 90052d82956..779a7d377b4 100644
--- a/src/components/ChangelogModal/index.tsx
+++ b/src/components/ChangelogModal/index.tsx
@@ -55,7 +55,7 @@ const ChangelogModal = memo<ChangelogModalProps>(({ open, onClose, shouldLoad })
<Flexbox align={'center'} gap={8}>
<Button
icon={<ArrowUpRightIcon size={16} />}
- iconPosition="end"
+ iconPlacement="end"
onClick={onClose}
type="text"
>
diff --git a/src/components/ChatGroupWizard/ChatGroupWizard.tsx b/src/components/ChatGroupWizard/ChatGroupWizard.tsx
index d9ad0ecbab8..72d52346ca4 100644
--- a/src/components/ChatGroupWizard/ChatGroupWizard.tsx
+++ b/src/components/ChatGroupWizard/ChatGroupWizard.tsx
@@ -598,7 +598,7 @@ const ChatGroupWizard = memo<ChatGroupWizardProps>(
accordion
activeKey={activePanel}
collapsible
- expandIconPosition="end"
+ expandIconPlacement="end"
gap={12}
items={[
{
diff --git a/src/components/TodoList.tsx b/src/components/TodoList.tsx
index 5d132ecc448..646f877fc11 100644
--- a/src/components/TodoList.tsx
+++ b/src/components/TodoList.tsx
@@ -130,7 +130,7 @@ const TodoList = memo<TodoListProps>(({ todos, resolveAssigneeName }) => {
return (
<Collapse
className={styles.collapse}
- expandIconPosition="end"
+ expandIconPlacement="end"
items={[
{
children: todoItems,
diff --git a/src/features/AgentSetting/AgentMeta/index.tsx b/src/features/AgentSetting/AgentMeta/index.tsx
index 410c4ccfb7c..6cbc20011b1 100644
--- a/src/features/AgentSetting/AgentMeta/index.tsx
+++ b/src/features/AgentSetting/AgentMeta/index.tsx
@@ -113,7 +113,7 @@ const AgentMeta = memo(() => {
<Button
disabled={!hasSystemRole}
icon={Wand2}
- iconPosition={'end'}
+ iconPlacement={'end'}
iconProps={{
size: 12,
}}
diff --git a/src/features/AgentSetting/AgentPrompt/index.tsx b/src/features/AgentSetting/AgentPrompt/index.tsx
index 2cb8dd0f245..c3499495387 100644
--- a/src/features/AgentSetting/AgentPrompt/index.tsx
+++ b/src/features/AgentSetting/AgentPrompt/index.tsx
@@ -22,7 +22,7 @@ const AgentPrompt = memo(() => {
const editButton = !editing && !!systemRole && (
<Button
icon={PenLineIcon}
- iconPosition={'end'}
+ iconPlacement={'end'}
iconProps={{
size: 12,
}}
diff --git a/src/features/Conversation/Messages/AssistantGroup/Tool/Render/Intervention/ModeSelector.tsx b/src/features/Conversation/Messages/AssistantGroup/Tool/Render/Intervention/ModeSelector.tsx
index 77897cf04f1..b53bc1bda54 100644
--- a/src/features/Conversation/Messages/AssistantGroup/Tool/Render/Intervention/ModeSelector.tsx
+++ b/src/features/Conversation/Messages/AssistantGroup/Tool/Render/Intervention/ModeSelector.tsx
@@ -120,7 +120,7 @@ const ModeSelector = memo(() => {
className={styles.modeButton}
color={'default'}
icon={ChevronDown}
- iconPosition="end"
+ iconPlacement="end"
size="small"
variant={'text'}
>
diff --git a/src/features/Conversation/Messages/AssistantGroup/Tools.tsx b/src/features/Conversation/Messages/AssistantGroup/Tools.tsx
index 1c69c0cf75f..8dfa247df61 100644
--- a/src/features/Conversation/Messages/AssistantGroup/Tools.tsx
+++ b/src/features/Conversation/Messages/AssistantGroup/Tools.tsx
@@ -1,5 +1,4 @@
import { ChatToolPayloadWithResult } from '@lobechat/types';
-import { Block } from '@lobehub/ui';
import { memo } from 'react';
import Tool from './Tool';
@@ -12,29 +11,19 @@ interface ToolsRendererProps {
export const Tools = memo<ToolsRendererProps>(({ messageId, tools }) => {
if (!tools || tools.length === 0) return null;
- return (
- <Block
- className={'tool-blocks'}
- gap={8}
- paddingBlock={6}
- paddingInline={12}
- variant={'outlined'}
- >
- {tools.map((tool, index) => (
- <Tool
- apiName={tool.apiName}
- arguments={tool.arguments}
- assistantMessageId={messageId}
- id={tool.id}
- identifier={tool.identifier}
- index={index}
- intervention={tool.intervention}
- key={tool.id}
- result={tool.result}
- toolMessageId={tool.result_msg_id}
- type={tool.type}
- />
- ))}
- </Block>
- );
+ return tools.map((tool, index) => (
+ <Tool
+ apiName={tool.apiName}
+ arguments={tool.arguments}
+ assistantMessageId={messageId}
+ id={tool.id}
+ identifier={tool.identifier}
+ index={index}
+ intervention={tool.intervention}
+ key={tool.id}
+ result={tool.result}
+ toolMessageId={tool.result_msg_id}
+ type={tool.type}
+ />
+ ));
});
diff --git a/src/features/Conversation/Messages/Tool/Inspector/BuiltinPluginTitle.tsx b/src/features/Conversation/Messages/Tool/Inspector/BuiltinPluginTitle.tsx
deleted file mode 100644
index 7c49458c728..00000000000
--- a/src/features/Conversation/Messages/Tool/Inspector/BuiltinPluginTitle.tsx
+++ /dev/null
@@ -1,54 +0,0 @@
-import { Icon } from '@lobehub/ui';
-import { createStyles } from 'antd-style';
-import { ChevronRight } from 'lucide-react';
-import { ReactNode, memo } from 'react';
-import { Flexbox } from 'react-layout-kit';
-
-import { shinyTextStylish } from '@/styles/loading';
-
-import { messageStateSelectors, useConversationStore } from '../../../store';
-
-export const useStyles = createStyles(({ css, token }) => ({
- apiName: css`
- overflow: hidden;
- display: -webkit-box;
- -webkit-box-orient: vertical;
- -webkit-line-clamp: 1;
-
- font-family: ${token.fontFamilyCode};
- font-size: 12px;
- text-overflow: ellipsis;
- `,
-
- shinyText: shinyTextStylish(token),
-}));
-
-interface BuiltinPluginTitleProps {
- apiName: string;
- icon?: ReactNode;
- identifier: string;
- index: number;
- messageId: string;
- title: string;
- toolCallId: string;
-}
-
-const BuiltinPluginTitle = memo<BuiltinPluginTitleProps>(
- ({ messageId, index, apiName, title, toolCallId }) => {
- const { styles } = useStyles();
-
- const isLoading = useConversationStore(
- messageStateSelectors.isToolApiNameShining(messageId, index, toolCallId),
- );
-
- return (
- <Flexbox align={'center'} className={isLoading ? styles.shinyText : ''} gap={4} horizontal>
- <div>{title}</div>
- <Icon icon={ChevronRight} />
- <span className={styles.apiName}>{apiName}</span>
- </Flexbox>
- );
- },
-);
-
-export default BuiltinPluginTitle;
diff --git a/src/features/Conversation/Messages/Tool/Inspector/Debug.tsx b/src/features/Conversation/Messages/Tool/Inspector/Debug.tsx
deleted file mode 100644
index d89f4473817..00000000000
--- a/src/features/Conversation/Messages/Tool/Inspector/Debug.tsx
+++ /dev/null
@@ -1,52 +0,0 @@
-import { Highlighter } from '@lobehub/ui';
-import { Tabs } from 'antd';
-import { memo } from 'react';
-import { useTranslation } from 'react-i18next';
-
-import PluginResult from './PluginResult';
-import PluginState from './PluginState';
-
-interface DebugProps {
- payload: object;
- requestArgs?: string;
- toolCallId: string;
-}
-
-const Debug = memo<DebugProps>(({ payload, requestArgs, toolCallId }) => {
- const { t } = useTranslation('plugin');
- let params;
- try {
- params = JSON.stringify(JSON.parse(requestArgs || ''), null, 2);
- } catch {
- params = '';
- }
-
- return (
- <Tabs
- items={[
- {
- children: <Highlighter language={'json'}>{params}</Highlighter>,
- key: 'arguments',
- label: t('debug.arguments'),
- },
- {
- children: <PluginResult toolCallId={toolCallId} />,
- key: 'response',
- label: t('debug.response'),
- },
- {
- children: <Highlighter language={'json'}>{JSON.stringify(payload, null, 2)}</Highlighter>,
- key: 'function_call',
- label: t('debug.function_call'),
- },
- {
- children: <PluginState toolCallId={toolCallId} />,
- key: 'pluginState',
- label: t('debug.pluginState'),
- },
- ]}
- style={{ display: 'grid', maxWidth: 800 }}
- />
- );
-});
-export default Debug;
diff --git a/src/features/Conversation/Messages/Tool/Inspector/PluginResult.tsx b/src/features/Conversation/Messages/Tool/Inspector/PluginResult.tsx
deleted file mode 100644
index 816384b4233..00000000000
--- a/src/features/Conversation/Messages/Tool/Inspector/PluginResult.tsx
+++ /dev/null
@@ -1,38 +0,0 @@
-import { Highlighter } from '@lobehub/ui';
-import { memo, useMemo } from 'react';
-
-import { dataSelectors, useConversationStore } from '../../../store';
-
-export interface FunctionMessageProps {
- toolCallId: string;
- variant?: 'filled' | 'outlined' | 'borderless';
-}
-
-const PluginResult = memo<FunctionMessageProps>(({ toolCallId, variant }) => {
- const toolMessage = useConversationStore(dataSelectors.getDbMessageByToolCallId(toolCallId));
-
- const { data, language } = useMemo(() => {
- try {
- const parsed = JSON.parse(toolMessage?.content || '');
- // Special case: if the parsed result is a string, it means the original content was a stringified string
- if (typeof parsed === 'string') {
- return { data: parsed, language: 'plaintext' }; // Return the parsed string directly, do not re-serialize
- }
- return { data: JSON.stringify(parsed, null, 2), language: 'json' };
- } catch {
- return { data: toolMessage?.content || '', language: 'plaintext' };
- }
- }, [toolMessage?.content]);
-
- return (
- <Highlighter
- language={language}
- style={{ maxHeight: 200, overflow: 'scroll', width: '100%' }}
- variant={variant}
- >
- {data}
- </Highlighter>
- );
-});
-
-export default PluginResult;
diff --git a/src/features/Conversation/Messages/Tool/Inspector/PluginState.tsx b/src/features/Conversation/Messages/Tool/Inspector/PluginState.tsx
deleted file mode 100644
index 8c18e34324a..00000000000
--- a/src/features/Conversation/Messages/Tool/Inspector/PluginState.tsx
+++ /dev/null
@@ -1,22 +0,0 @@
-import { Highlighter } from '@lobehub/ui';
-import { memo } from 'react';
-
-import { dataSelectors, useConversationStore } from '../../../store';
-
-export interface FunctionMessageProps {
- toolCallId: string;
-}
-
-const PluginState = memo<FunctionMessageProps>(({ toolCallId }) => {
- const toolMessage = useConversationStore(dataSelectors.getDbMessageByToolCallId(toolCallId));
-
- return (
- toolMessage?.pluginState && (
- <Highlighter language={'json'} style={{ maxHeight: 200, maxWidth: 800, overflow: 'scroll' }}>
- {JSON.stringify(toolMessage?.pluginState, null, 2)}
- </Highlighter>
- )
- );
-});
-
-export default PluginState;
diff --git a/src/features/Conversation/Messages/Tool/Inspector/Settings.tsx b/src/features/Conversation/Messages/Tool/Inspector/Settings.tsx
deleted file mode 100644
index 181345723d9..00000000000
--- a/src/features/Conversation/Messages/Tool/Inspector/Settings.tsx
+++ /dev/null
@@ -1,40 +0,0 @@
-import { ActionIcon } from '@lobehub/ui';
-import { LucideSettings } from 'lucide-react';
-import { memo, useState } from 'react';
-import { useTranslation } from 'react-i18next';
-
-import PluginDetailModal from '@/features/PluginDetailModal';
-import { pluginHelpers, useToolStore } from '@/store/tool';
-import { pluginSelectors } from '@/store/tool/selectors';
-
-const Settings = memo<{ id: string }>(({ id }) => {
- const item = useToolStore(pluginSelectors.getToolManifestById(id));
- const [open, setOpen] = useState(false);
- const { t } = useTranslation('plugin');
- const hasSettings = pluginHelpers.isSettingSchemaNonEmpty(item?.settings);
-
- return (
- hasSettings && (
- <>
- <ActionIcon
- icon={LucideSettings}
- onClick={() => {
- setOpen(true);
- }}
- size={'small'}
- title={t('setting')}
- />
- <PluginDetailModal
- id={id}
- onClose={() => {
- setOpen(false);
- }}
- open={open}
- schema={item?.settings}
- />
- </>
- )
- );
-});
-
-export default Settings;
diff --git a/src/features/Conversation/Messages/Tool/Inspector/ToolTitle.tsx b/src/features/Conversation/Messages/Tool/Inspector/ToolTitle.tsx
deleted file mode 100644
index f82c758e615..00000000000
--- a/src/features/Conversation/Messages/Tool/Inspector/ToolTitle.tsx
+++ /dev/null
@@ -1,68 +0,0 @@
-import { Icon } from '@lobehub/ui';
-import { createStyles } from 'antd-style';
-import isEqual from 'fast-deep-equal';
-import { ChevronRight } from 'lucide-react';
-import { memo } from 'react';
-import { useTranslation } from 'react-i18next';
-import { Flexbox } from 'react-layout-kit';
-
-import { pluginHelpers, useToolStore } from '@/store/tool';
-import { toolSelectors } from '@/store/tool/selectors';
-import { shinyTextStylish } from '@/styles/loading';
-import { builtinToolIdentifiers } from '@/tools/identifiers';
-
-import BuiltinPluginTitle from './BuiltinPluginTitle';
-
-export const useStyles = createStyles(({ css, token }) => ({
- apiName: css`
- overflow: hidden;
- display: -webkit-box;
- -webkit-box-orient: vertical;
- -webkit-line-clamp: 1;
-
- font-family: ${token.fontFamilyCode};
- font-size: 12px;
- text-overflow: ellipsis;
- `,
-
- shinyText: shinyTextStylish(token),
-}));
-
-interface ToolTitleProps {
- apiName: string;
- identifier: string;
- index: number;
- messageId: string;
- toolCallId: string;
-}
-
-const ToolTitle = memo<ToolTitleProps>(({ identifier, messageId, index, apiName, toolCallId }) => {
- const { t } = useTranslation('plugin');
- const { styles } = useStyles();
-
- const pluginMeta = useToolStore(toolSelectors.getMetaById(identifier), isEqual);
-
- if (builtinToolIdentifiers.includes(identifier)) {
- return (
- <BuiltinPluginTitle
- apiName={t(`builtins.${identifier}.apiName.${apiName}`, apiName)}
- identifier={identifier}
- index={index}
- messageId={messageId}
- title={t(`builtins.${identifier}.title`, identifier)}
- toolCallId={toolCallId}
- />
- );
- }
-
- const pluginTitle = pluginHelpers.getPluginTitle(pluginMeta) ?? t('unknownPlugin');
-
- return (
- <Flexbox align={'center'} gap={6} horizontal>
- <div>{pluginTitle}</div> <Icon icon={ChevronRight} />
- <span className={styles.apiName}>{apiName}</span>
- </Flexbox>
- );
-});
-
-export default ToolTitle;
diff --git a/src/features/Conversation/Messages/Tool/Inspector/index.tsx b/src/features/Conversation/Messages/Tool/Inspector/index.tsx
deleted file mode 100644
index 068400c1195..00000000000
--- a/src/features/Conversation/Messages/Tool/Inspector/index.tsx
+++ /dev/null
@@ -1,134 +0,0 @@
-import { ActionIcon } from '@lobehub/ui';
-import { createStyles } from 'antd-style';
-import { LayoutPanelTop, LogsIcon, LucideBug, LucideBugOff } from 'lucide-react';
-import { CSSProperties, memo, useState } from 'react';
-import { useTranslation } from 'react-i18next';
-import { Flexbox } from 'react-layout-kit';
-
-import { shinyTextStylish } from '@/styles/loading';
-
-import Debug from './Debug';
-import Settings from './Settings';
-import ToolTitle from './ToolTitle';
-
-export const useStyles = createStyles(({ css, token, cx }) => ({
- actions: cx(
- 'inspector-container',
- css`
- opacity: 0;
- transition: opacity 300ms ease-in-out;
- `,
- ),
- apiName: css`
- overflow: hidden;
- display: -webkit-box;
- -webkit-box-orient: vertical;
- -webkit-line-clamp: 1;
-
- font-family: ${token.fontFamilyCode};
- font-size: 12px;
- text-overflow: ellipsis;
- `,
- container: css`
- :hover {
- .inspector-container {
- opacity: 1;
- }
- }
- `,
- plugin: css`
- display: flex;
- gap: 4px;
- align-items: center;
- width: fit-content;
- `,
- shinyText: shinyTextStylish(token),
- tool: css`
- cursor: pointer;
-
- width: fit-content;
- padding-block: 2px;
- border-radius: 6px;
-
- color: ${token.colorTextTertiary};
-
- &:hover {
- background: ${token.colorFillTertiary};
- }
- `,
-}));
-
-interface InspectorProps {
- apiName: string;
- arguments?: string;
- hidePluginUI?: boolean;
- id: string;
- identifier: string;
- index: number;
- messageId: string;
- payload: object;
- setShowPluginRender: (show: boolean) => void;
- showPluginRender: boolean;
- showPortal?: boolean;
- style?: CSSProperties;
-}
-
-const Inspectors = memo<InspectorProps>(
- ({
- messageId,
- index,
- identifier,
- apiName,
- id,
- arguments: requestArgs,
- payload,
- showPluginRender,
- setShowPluginRender,
- hidePluginUI = false,
- }) => {
- const { t } = useTranslation('plugin');
- const { styles } = useStyles();
-
- const [showDebug, setShowDebug] = useState(false);
-
- return (
- <Flexbox className={styles.container} gap={4}>
- <Flexbox align={'center'} distribution={'space-between'} gap={8} horizontal>
- <Flexbox align={'center'} className={styles.tool} gap={8} horizontal paddingInline={4}>
- <ToolTitle
- apiName={apiName}
- identifier={identifier}
- index={index}
- messageId={messageId}
- toolCallId={id}
- />
- </Flexbox>
- <Flexbox className={styles.actions} horizontal>
- {!hidePluginUI && (
- <ActionIcon
- icon={showPluginRender ? LogsIcon : LayoutPanelTop}
- onClick={() => {
- setShowPluginRender(!showPluginRender);
- }}
- size={'small'}
- title={showPluginRender ? t('inspector.args') : t('inspector.pluginRender')}
- />
- )}
- <ActionIcon
- icon={showDebug ? LucideBugOff : LucideBug}
- onClick={() => {
- setShowDebug(!showDebug);
- }}
- size={'small'}
- title={t(showDebug ? 'debug.off' : 'debug.on')}
- />
- <Settings id={identifier} />
- </Flexbox>
- </Flexbox>
- {showDebug && <Debug payload={payload} requestArgs={requestArgs} toolCallId={id} />}
- </Flexbox>
- );
- },
-);
-
-export default Inspectors;
diff --git a/src/features/Conversation/Messages/Tool/Render/Arguments/ObjectEntity.tsx b/src/features/Conversation/Messages/Tool/Render/Arguments/ObjectEntity.tsx
deleted file mode 100644
index 37406123e94..00000000000
--- a/src/features/Conversation/Messages/Tool/Render/Arguments/ObjectEntity.tsx
+++ /dev/null
@@ -1,76 +0,0 @@
-import { createStyles } from 'antd-style';
-import { memo } from 'react';
-
-import { shinyTextStylish } from '@/styles/loading';
-
-import ValueCell from './ValueCell';
-
-const useStyles = createStyles(({ css, token }) => ({
- arrayRow: css`
- &:not(:first-child) {
- border-block-start: 1px dotted ${token.colorBorderSecondary};
- }
- `,
- colon: css`
- color: ${token.colorTextTertiary};
- `,
- key: css`
- color: ${token.colorTextTertiary};
- `,
- row: css`
- display: flex;
- align-items: baseline;
-
- &:not(:first-child) {
- border-block-start: 1px dotted ${token.colorBorderSecondary};
- }
- `,
- shineText: shinyTextStylish(token),
- value: css`
- color: ${token.colorTextSecondary};
- `,
-}));
-
-const formatValue = (value: any): string | string[] => {
- if (Array.isArray(value)) {
- return value.map((v) => (typeof v === 'object' ? JSON.stringify(v) : v));
- }
-
- if (typeof value === 'object' && value !== null) {
- return Object.entries(value)
- .map(([k, v]) => `${k}: ${typeof v === 'object' ? JSON.stringify(v) : v}`)
- .join(', ');
- }
- return String(value);
-};
-
-interface ObjectEntityProps {
- editable?: boolean;
- hasMinWidth: boolean;
- objectKey: string;
- shine?: boolean;
- value: any;
-}
-
-const ObjectEntity = memo<ObjectEntityProps>(({ hasMinWidth, shine, value, objectKey }) => {
- const { styles, cx } = useStyles();
- const formatedValue = formatValue(value);
-
- return (
- <div className={styles.row}>
- <span className={styles.key} style={{ minWidth: hasMinWidth ? 140 : undefined }}>
- {objectKey}
- </span>
- <span className={styles.colon}>:</span>
- <div className={cx(shine ? styles.shineText : styles.value)} style={{ width: '100%' }}>
- {typeof formatedValue === 'string' ? (
- <ValueCell value={formatedValue} />
- ) : (
- formatedValue.map((v, i) => <ValueCell key={i + v} value={v} />)
- )}
- </div>
- </div>
- );
-});
-
-export default ObjectEntity;
diff --git a/src/features/Conversation/Messages/Tool/Render/Arguments/ValueCell.tsx b/src/features/Conversation/Messages/Tool/Render/Arguments/ValueCell.tsx
deleted file mode 100644
index 38d35f48522..00000000000
--- a/src/features/Conversation/Messages/Tool/Render/Arguments/ValueCell.tsx
+++ /dev/null
@@ -1,43 +0,0 @@
-import { copyToClipboard } from '@lobehub/ui';
-import { App } from 'antd';
-import { createStyles } from 'antd-style';
-import { memo } from 'react';
-import { useTranslation } from 'react-i18next';
-
-const useStyles = createStyles(({ css, token }) => ({
- copyable: css`
- cursor: pointer;
- width: 100%;
- margin-block: 2px;
- padding: 4px;
-
- &:hover {
- border-radius: 6px;
- background: ${token.colorFillTertiary};
- }
- `,
-}));
-
-interface ValueCellProps {
- value: string;
-}
-
-const ValueCell = memo<ValueCellProps>(({ value }) => {
- const { message } = App.useApp();
- const { t } = useTranslation('common');
- const { styles } = useStyles();
-
- return (
- <div
- className={styles.copyable}
- onClick={async () => {
- await copyToClipboard(value);
- message.success(t('copySuccess'));
- }}
- >
- {value}
- </div>
- );
-});
-
-export default ValueCell;
diff --git a/src/features/Conversation/Messages/Tool/Render/Arguments/index.tsx b/src/features/Conversation/Messages/Tool/Render/Arguments/index.tsx
deleted file mode 100644
index 5aa94ab746e..00000000000
--- a/src/features/Conversation/Messages/Tool/Render/Arguments/index.tsx
+++ /dev/null
@@ -1,134 +0,0 @@
-import { Highlighter } from '@lobehub/ui';
-import { createStyles } from 'antd-style';
-import { parse } from 'partial-json';
-import { ReactNode, memo, useMemo } from 'react';
-import { Flexbox } from 'react-layout-kit';
-
-import { useYamlArguments } from '@/hooks/useYamlArguments';
-
-import ObjectEntity from './ObjectEntity';
-
-const useStyles = createStyles(({ css, token, cx }) => ({
- button: css`
- color: ${token.colorTextSecondary};
-
- &:hover {
- color: ${token.colorText};
- }
- `,
- codeContainer: css`
- border-radius: ${token.borderRadiusLG}px;
- `,
- container: css`
- position: relative;
-
- overflow: auto;
-
- max-height: 200px;
- padding-block: 4px;
- padding-inline: 12px 64px;
- border-radius: ${token.borderRadiusLG}px;
-
- font-family: ${token.fontFamilyCode};
- font-size: 13px;
- line-height: 1.5;
-
- background: ${token.colorFillQuaternary};
-
- pre {
- margin: 0 !important;
- background: none !important;
- }
-
- &:hover {
- .actions {
- opacity: 1;
- }
- }
- `,
- editButton: cx(
- 'actions',
- css`
- position: absolute;
- z-index: 10;
- inset-block-start: 4px;
- inset-inline-end: 4px;
-
- opacity: 0;
-
- transition: opacity 0.2s ${token.motionEaseInOut};
- `,
- ),
-}));
-
-export interface ArgumentsProps {
- actions?: ReactNode;
- arguments?: string;
- shine?: boolean;
-}
-
-const Arguments = memo<ArgumentsProps>(({ arguments: args = '', shine, actions }) => {
- const { styles } = useStyles();
-
- const displayArgs = useMemo(() => {
- try {
- const obj = parse(args);
- if (Object.keys(obj).length === 0) return {};
- return obj;
- } catch {
- return args;
- }
- }, [args]);
-
- const yaml = useYamlArguments(args);
-
- const showActions = !!actions;
-
- if (typeof displayArgs === 'string') {
- return (
- !!yaml && (
- <div className={styles.container}>
- <Highlighter language={'yaml'} showLanguage={false}>
- {yaml}
- </Highlighter>
- </div>
- )
- );
- }
-
- // if (args.length > 100) {
- // return (
- // <Highlighter language={'json'} showLanguage={false} variant={'filled'}>
- // {JSON.stringify(displayArgs, null, 2)}
- // </Highlighter>
- // );
- // }
-
- const hasMinWidth = Object.keys(displayArgs).length > 1;
-
- if (Object.keys(displayArgs).length === 0) return null;
-
- return (
- <div className={styles.container}>
- {showActions && (
- <Flexbox className={styles.editButton} gap={4} horizontal>
- {actions}
- </Flexbox>
- )}
- {Object.entries(displayArgs).map(([key, value]) => {
- return (
- <ObjectEntity
- editable={false}
- hasMinWidth={hasMinWidth}
- key={key}
- objectKey={key}
- shine={shine}
- value={value}
- />
- );
- })}
- </div>
- );
-});
-
-export default Arguments;
diff --git a/src/features/Conversation/Messages/Tool/Render/CustomRender.tsx b/src/features/Conversation/Messages/Tool/Render/CustomRender.tsx
deleted file mode 100644
index f1836431b90..00000000000
--- a/src/features/Conversation/Messages/Tool/Render/CustomRender.tsx
+++ /dev/null
@@ -1,146 +0,0 @@
-import { UIChatMessage } from '@lobechat/types';
-import { ActionIcon } from '@lobehub/ui';
-import { App } from 'antd';
-import { Edit3Icon, PlayCircleIcon } from 'lucide-react';
-import { parse } from 'partial-json';
-import { memo, useCallback, useEffect, useState } from 'react';
-import { useTranslation } from 'react-i18next';
-import { Flexbox } from 'react-layout-kit';
-
-import PluginRender from '@/features/PluginsUI/Render';
-
-import { messageStateSelectors, useConversationStore } from '../../../store';
-import PluginResult from '../Inspector/PluginResult';
-import Arguments from './Arguments';
-import KeyValueEditor from './KeyValueEditor';
-
-const safeParseJson = (str: string): Record<string, any> => {
- try {
- const obj = parse(str);
- return typeof obj === 'object' && obj !== null ? obj : {};
- } catch {
- return {};
- }
-};
-
-interface CustomRenderProps extends UIChatMessage {
- requestArgs?: string;
- setShowPluginRender: (value: boolean) => void;
- showPluginRender: boolean;
-}
-
-const CustomRender = memo<CustomRenderProps>(
- ({
- id,
- content,
- pluginState,
- plugin,
- requestArgs,
- showPluginRender,
- setShowPluginRender,
- pluginError,
- tool_call_id,
- }) => {
- const { t } = useTranslation(['tool', 'common']);
- // Use ConversationStore for state selectors
- const loading = useConversationStore(messageStateSelectors.isPluginApiInvoking(id));
- const [isEditing, setIsEditing] = useState(false);
- const { message } = App.useApp();
- // Get actions from ConversationStore
- const [updatePluginArguments, reInvokeToolMessage] = useConversationStore((s) => [
- s.updatePluginArguments,
- s.reInvokeToolMessage,
- ]);
- const handleCancel = useCallback(() => {
- setIsEditing(false);
- }, []);
-
- const handleFinish = useCallback(
- async (editedObject: Record<string, any>) => {
- if (!tool_call_id) return;
-
- try {
- const newArgsString = JSON.stringify(editedObject, null, 2);
-
- if (newArgsString !== requestArgs) {
- await updatePluginArguments(tool_call_id, editedObject, true);
- await reInvokeToolMessage(id);
- }
- setIsEditing(false);
- } catch (error) {
- console.error('Error stringifying arguments:', error);
- message.error(t('updateArgs.stringifyError'));
- }
- },
- [requestArgs, id, tool_call_id, updatePluginArguments, reInvokeToolMessage, message, t],
- );
-
- useEffect(() => {
- if (!plugin?.type || loading) return;
-
- setShowPluginRender(!['default', 'mcp'].includes(plugin?.type));
- }, [plugin?.type, loading]);
-
- if (loading) return <Arguments arguments={requestArgs} shine />;
-
- if (showPluginRender)
- return (
- <Flexbox gap={12} id={id} width={'100%'}>
- <PluginRender
- arguments={plugin?.arguments}
- content={content}
- identifier={plugin?.identifier}
- loading={loading}
- messageId={id}
- payload={plugin}
- pluginError={pluginError}
- pluginState={pluginState}
- toolCallId={tool_call_id}
- type={plugin?.type}
- />
- </Flexbox>
- );
-
- if (isEditing)
- return (
- <KeyValueEditor
- initialValue={safeParseJson(requestArgs || '')}
- onCancel={handleCancel}
- onFinish={handleFinish}
- />
- );
-
- return (
- <Flexbox gap={12} id={id} width={'100%'}>
- <Arguments
- actions={
- <>
- <ActionIcon
- icon={Edit3Icon}
- onClick={() => {
- setIsEditing(true);
- }}
- size={'small'}
- title={t('edit', { ns: 'common' })}
- />
- <ActionIcon
- icon={PlayCircleIcon}
- onClick={async () => {
- await reInvokeToolMessage(id);
- }}
- size={'small'}
- title={t('run', { ns: 'common' })}
- />
- </>
- }
- arguments={requestArgs}
- />
- {tool_call_id && <PluginResult toolCallId={tool_call_id} variant={'outlined'} />}
- </Flexbox>
- );
- },
-);
-
-CustomRender.displayName = 'CustomRender';
-
-export default CustomRender;
diff --git a/src/features/Conversation/Messages/Tool/Render/ErrorResponse.tsx b/src/features/Conversation/Messages/Tool/Render/ErrorResponse.tsx
deleted file mode 100644
index 207f1126ff5..00000000000
--- a/src/features/Conversation/Messages/Tool/Render/ErrorResponse.tsx
+++ /dev/null
@@ -1,35 +0,0 @@
-import { ChatMessageError, ChatPluginPayload } from '@lobechat/types';
-import { Alert, Highlighter } from '@lobehub/ui';
-import { memo } from 'react';
-import { useTranslation } from 'react-i18next';
-import { Flexbox } from 'react-layout-kit';
-
-import PluginSettings from './PluginSettings';
-
-interface ErrorResponseProps extends ChatMessageError {
- id: string;
- plugin?: ChatPluginPayload;
-}
-
-const ErrorResponse = memo<ErrorResponseProps>(({ id, type, body, message, plugin }) => {
- const { t } = useTranslation('error');
- if (type === 'PluginSettingsInvalid') {
- return <PluginSettings id={id} plugin={plugin} />;
- }
-
- return (
- <Alert
- extra={
- <Flexbox>
- <Highlighter actionIconSize={'small'} language={'json'} variant={'borderless'}>
- {JSON.stringify(body || { message, type }, null, 2)}
- </Highlighter>
- </Flexbox>
- }
- message={t(`response.${type}` as any)}
- showIcon
- type={'secondary'}
- />
- );
-});
-export default ErrorResponse;
diff --git a/src/features/Conversation/Messages/Tool/Render/KeyValueEditor.tsx b/src/features/Conversation/Messages/Tool/Render/KeyValueEditor.tsx
deleted file mode 100644
index bc06cb5f27d..00000000000
--- a/src/features/Conversation/Messages/Tool/Render/KeyValueEditor.tsx
+++ /dev/null
@@ -1,214 +0,0 @@
-import { ActionIcon, Button, Icon, Input } from '@lobehub/ui';
-import { App, Form, FormInstance } from 'antd';
-import { createStyles } from 'antd-style';
-import { LucidePlus, LucideTrash } from 'lucide-react';
-import { memo, useEffect, useRef, useState } from 'react';
-import { useTranslation } from 'react-i18next';
-import { Flexbox } from 'react-layout-kit';
-
-const useStyles = createStyles(({ css, token }) => ({
- form: css`
- position: relative;
-
- width: 100%;
- min-width: 600px;
- padding-block: 8px;
- padding-inline: 12px;
- border: 1px solid ${token.colorBorder};
- border-radius: ${token.borderRadiusLG}px;
- `,
- formItem: css`
- margin-block-end: 4px !important;
- `,
- input: css`
- font-family: ${token.fontFamilyCode};
- font-size: 12px;
- `,
- row: css`
- position: relative;
- `,
- title: css`
- color: ${token.colorTextTertiary};
- `,
-}));
-
-interface KeyValueItem {
- id: string;
- key?: string;
- value?: string;
-}
-
-interface KeyValueEditorProps {
- initialValue?: Record<string, any>;
- onCancel?: () => void;
- onFinish?: (value: Record<string, any>) => Promise<void>;
-}
-
-const recordToFormList = (record: Record<string, any>): KeyValueItem[] =>
- Object.entries(record)
- .map(([key, val], index) => ({
- id: `${key}-${index}`,
- key,
- value: typeof val === 'string' ? val : JSON.stringify(val),
- }))
- .filter((item) => item.key);
-
-const formListToRecord = (list: KeyValueItem[]): Record<string, any> => {
- const record: Record<string, any> = {};
- list.forEach((item) => {
- if (item.key) {
- try {
- record[item.key] = JSON.parse(item.value || '""');
- } catch {
- record[item.key] = item.value || '';
- }
- }
- });
- return record;
-};
-
-const KeyValueEditor = memo<KeyValueEditorProps>(({ initialValue = {}, onFinish, onCancel }) => {
- const { styles } = useStyles();
- const { t } = useTranslation(['tool', 'common']);
- const [form] = Form.useForm();
- const { message } = App.useApp();
- const formRef = useRef<FormInstance>(null);
-
- useEffect(() => {
- form.setFieldsValue({ items: recordToFormList(initialValue) });
- }, [initialValue, form]);
-
- const [updating, setUpdating] = useState(false);
- const handleFinish = async () => {
- setUpdating(true);
- try {
- await form.validateFields();
- const values = form.getFieldsValue();
- const record = formListToRecord(values.items || []);
- await onFinish?.(record);
- } catch (errorInfo) {
- console.error('Validation Failed:', errorInfo);
- message.error(t('updateArgs.formValidationFailed') || 'Please check the form for errors.');
- }
- setUpdating(false);
- };
-
- const handleCancel = () => {
- onCancel?.();
- };
-
- const validateKeys = (_: any, item: KeyValueItem, items: KeyValueItem[]) => {
- if (!item?.key) {
- return Promise.resolve();
- }
- const keys = items.map((i) => i?.key).filter(Boolean);
- if (keys.filter((k) => k === item.key).length > 1) {
- return Promise.reject(new Error(t('updateArgs.duplicateKeyError')));
- }
-
- return Promise.resolve();
- };
-
- return (
- <Form
- autoComplete="off"
- className={styles.form}
- form={form}
- initialValues={{ items: recordToFormList(initialValue) }}
- ref={formRef}
- >
- <Flexbox className={styles.title} gap={8} horizontal>
- <Flexbox flex={1}>key</Flexbox>
- <Flexbox flex={4}>value</Flexbox>
- </Flexbox>
- <Form.List name="items">
- {(fields, { add, remove }) => (
- <Flexbox width={'100%'}>
- {fields.map(({ key, name, ...restField }, index) => (
- <Flexbox
- align="center"
- className={styles.row}
- gap={8}
- horizontal
- key={key}
- width={'100%'}
- >
- <Form.Item
- {...restField}
- className={styles.formItem}
- name={[name, 'key']}
- rules={[
- { message: t('updateArgs.keyRequired'), required: true },
- {
- validator: (rule) =>
- validateKeys(
- rule,
- form.getFieldValue(['items', index]),
- form.getFieldValue('items'),
- ),
- },
- ]}
- style={{ flex: 1 }}
- validateTrigger={['onChange', 'onBlur']}
- >
- <Input
- allowClear
- className={styles.input}
- placeholder={t('updateArgs.form.key')}
- variant={'filled'}
- />
- </Form.Item>
- <Form.Item
- {...restField}
- className={styles.formItem}
- name={[name, 'value']}
- style={{ flex: 4 }}
- >
- <Input
- allowClear
- className={styles.input}
- placeholder={t('updateArgs.form.value')}
- variant={'filled'}
- />
- </Form.Item>
- <ActionIcon
- icon={LucideTrash}
- onClick={() => remove(name)}
- size={'small'}
- style={{
- marginBottom: 6,
- }}
- title={t('delete', { ns: 'common' })}
- />
- </Flexbox>
- ))}
- <Form.Item style={{ marginBottom: 0, marginTop: 8 }}>
- <Flexbox gap={8} horizontal justify={'space-between'}>
- <Button
- color={'default'}
- icon={<Icon icon={LucidePlus} />}
- onClick={() => add({ id: `new-${Date.now()}`, key: '', value: '' })}
- size={'small'}
- variant="filled"
- >
- {t('updateArgs.form.add')}
- </Button>
-
- <Flexbox gap={8} horizontal>
- <Button onClick={handleCancel} size={'small'}>
- {t('cancel', { ns: 'common' })}
- </Button>
- <Button loading={updating} onClick={handleFinish} size={'small'} type={'primary'}>
- {t('save', { ns: 'common' })}
- </Button>
- </Flexbox>
- </Flexbox>
- </Form.Item>
- </Flexbox>
- )}
- </Form.List>
- </Form>
- );
-});
-
-export default KeyValueEditor;
diff --git a/src/features/Conversation/Messages/Tool/Render/PluginSettings.tsx b/src/features/Conversation/Messages/Tool/Render/PluginSettings.tsx
deleted file mode 100644
index 6b37a13c20a..00000000000
--- a/src/features/Conversation/Messages/Tool/Render/PluginSettings.tsx
+++ /dev/null
@@ -1,71 +0,0 @@
-import { Avatar, Button } from '@lobehub/ui';
-import { Divider } from 'antd';
-import { useTheme } from 'antd-style';
-import isEqual from 'fast-deep-equal';
-import { memo } from 'react';
-import { useTranslation } from 'react-i18next';
-import { Center, Flexbox } from 'react-layout-kit';
-
-import PluginSettingsConfig from '@/features/PluginSettings';
-import { pluginHelpers, useToolStore } from '@/store/tool';
-import { pluginSelectors } from '@/store/tool/selectors';
-import { ChatPluginPayload } from '@/types/index';
-
-import { ErrorActionContainer, useStyles } from '../../../Error/style';
-import { useConversationStore } from '../../../store';
-
-interface PluginSettingsProps {
- id: string;
- plugin?: ChatPluginPayload;
-}
-
-const PluginSettings = memo<PluginSettingsProps>(({ id, plugin }) => {
- const { styles } = useStyles();
- const { t } = useTranslation('error');
- const theme = useTheme();
- // Get actions from ConversationStore
- const [deleteMessage, resend] = useConversationStore((s) => [
- s.deleteMessage,
- s.regenerateAssistantMessage,
- ]);
- const pluginIdentifier = plugin?.identifier as string;
- const pluginMeta = useToolStore(pluginSelectors.getPluginMetaById(pluginIdentifier), isEqual);
- const manifest = useToolStore(pluginSelectors.getToolManifestById(pluginIdentifier), isEqual);
-
- return (
- !!manifest && (
- <ErrorActionContainer>
- <Center gap={16} style={{ maxWidth: 400 }}>
- <Avatar
- avatar={pluginHelpers.getPluginAvatar(pluginMeta) || '⚙️'}
- background={theme.colorFillContent}
- gap={12}
- shape={'square'}
- size={80}
- />
- <Flexbox style={{ fontSize: 20 }}>
- {t('pluginSettings.title', { name: pluginHelpers.getPluginTitle(pluginMeta) })}
- </Flexbox>
- <Flexbox className={styles.desc}>{t('pluginSettings.desc')}</Flexbox>
- <Divider style={{ margin: '0 16px' }} />
- {manifest.settings && (
- <PluginSettingsConfig id={manifest.identifier} schema={manifest.settings} />
- )}
- <Button
- block
- onClick={() => {
- resend(id);
- deleteMessage(id);
- }}
- style={{ marginTop: 8 }}
- type={'primary'}
- >
- {t('unlock.confirm')}
- </Button>
- </Center>
- </ErrorActionContainer>
- )
- );
-});
-
-export default PluginSettings;
diff --git a/src/features/Conversation/Messages/Tool/Render/index.tsx b/src/features/Conversation/Messages/Tool/Render/index.tsx
deleted file mode 100644
index 32bdaedda2a..00000000000
--- a/src/features/Conversation/Messages/Tool/Render/index.tsx
+++ /dev/null
@@ -1,46 +0,0 @@
-import { Suspense, memo } from 'react';
-
-import { dataSelectors, messageStateSelectors, useConversationStore } from '../../../store';
-import CustomRender from './CustomRender';
-import ErrorResponse from './ErrorResponse';
-
-interface RenderProps {
- messageId: string;
- requestArgs?: string;
- setShowPluginRender: (show: boolean) => void;
- showPluginRender: boolean;
- toolCallId: string;
- toolIndex: number;
-}
-
-const Render = memo<RenderProps>(
- ({ toolCallId, toolIndex, messageId, requestArgs, showPluginRender, setShowPluginRender }) => {
- const loading = useConversationStore(
- messageStateSelectors.isToolCallStreaming(messageId, toolIndex),
- );
- const toolMessage = useConversationStore(dataSelectors.getDbMessageByToolCallId(toolCallId));
-
- if (loading || !toolMessage) return null;
-
- if (!!toolMessage) {
- if (toolMessage.error) {
- return <ErrorResponse {...toolMessage.error} id={messageId} plugin={toolMessage.plugin} />;
- }
-
- return (
- <Suspense>
- <CustomRender
- {...toolMessage}
- requestArgs={requestArgs}
- setShowPluginRender={setShowPluginRender}
- showPluginRender={showPluginRender}
- />
- </Suspense>
- );
- }
- },
-);
-
-Render.displayName = 'ToolRender';
-
-export default Render;
diff --git a/src/features/Conversation/Messages/Tool/ToolItem.tsx b/src/features/Conversation/Messages/Tool/ToolItem.tsx
index 24b5d5f9cd4..d5b3b5a48cd 100644
--- a/src/features/Conversation/Messages/Tool/ToolItem.tsx
+++ b/src/features/Conversation/Messages/Tool/ToolItem.tsx
@@ -1,8 +1,9 @@
import { CSSProperties, memo, useState } from 'react';
import { Flexbox } from 'react-layout-kit';
-import Inspectors from './Inspector';
-import Render from './Render';
+import { dataSelectors, messageStateSelectors, useConversationStore } from '../../store';
+import Inspectors from '../AssistantGroup/Tool/Inspector';
+import Render from '../AssistantGroup/Tool/Render';
export interface InspectorProps {
apiName: string;
@@ -10,36 +11,66 @@ export interface InspectorProps {
identifier: string;
index: number;
messageId: string;
- payload: object;
style?: CSSProperties;
toolCallId: string;
type?: string;
}
+/**
+ * Tool message component - adapts Tool message data to use AssistantGroup/Tool components
+ */
const Tool = memo<InspectorProps>(
- ({ arguments: requestArgs, apiName, messageId, toolCallId, index, identifier, payload }) => {
+ ({ arguments: requestArgs, apiName, messageId, toolCallId, index, identifier, type }) => {
const [showPluginRender, setShowPluginRender] = useState(false);
+ const [showRender, setShowRender] = useState(false);
+
+ // Fetch tool message from store
+ const toolMessage = useConversationStore(dataSelectors.getDbMessageByToolCallId(toolCallId));
+
+ // Check if tool is still loading
+ const loading = useConversationStore(
+ messageStateSelectors.isToolCallStreaming(messageId, index),
+ );
+
+ // Adapt tool message data to AssistantGroup/Tool format
+ const result = toolMessage
+ ? {
+ content: toolMessage.content,
+ error: toolMessage.error,
+ id: toolCallId,
+ state: toolMessage.pluginState,
+ }
+ : undefined;
+
+ // Don't render if still loading and no message yet
+ if (loading && !toolMessage) return null;
return (
<Flexbox gap={8} style={{ paddingBottom: 12 }}>
<Inspectors
apiName={apiName}
arguments={requestArgs}
+ assistantMessageId={messageId}
id={toolCallId}
identifier={identifier}
index={index}
- messageId={messageId}
- payload={payload}
+ result={result}
setShowPluginRender={setShowPluginRender}
+ setShowRender={setShowRender}
showPluginRender={showPluginRender}
+ showRender={showRender}
+ type={type}
/>
<Render
+ apiName={apiName}
+ arguments={requestArgs}
+ identifier={identifier}
messageId={messageId}
- requestArgs={requestArgs}
+ result={result}
setShowPluginRender={setShowPluginRender}
showPluginRender={showPluginRender}
toolCallId={toolCallId}
- toolIndex={index}
+ type={type}
/>
</Flexbox>
);
diff --git a/src/features/Conversation/Messages/Tool/index.tsx b/src/features/Conversation/Messages/Tool/index.tsx
index 2a664e55a14..16f0dc4d8c0 100644
--- a/src/features/Conversation/Messages/Tool/index.tsx
+++ b/src/features/Conversation/Messages/Tool/index.tsx
@@ -42,13 +42,7 @@ const Tool = memo<ToolMessageProps>(({ id, index }) => {
variant={'borderless'}
/>
{item.plugin && (
- <ToolItem
- {...item.plugin}
- index={index}
- messageId={id}
- payload={item.plugin || {}}
- toolCallId={item.tool_call_id!}
- />
+ <ToolItem {...item.plugin} index={index} messageId={id} toolCallId={item.tool_call_id!} />
)}
</Flexbox>
);
diff --git a/src/features/MCPPluginDetail/Deployment/index.tsx b/src/features/MCPPluginDetail/Deployment/index.tsx
index 6e814b18a61..d7679b28f8c 100644
--- a/src/features/MCPPluginDetail/Deployment/index.tsx
+++ b/src/features/MCPPluginDetail/Deployment/index.tsx
@@ -88,7 +88,7 @@ const Deployment = memo<{ mobile?: boolean }>(({ mobile }) => {
return (
<Collapse
activeKey={activeKey}
- expandIconPosition={'end'}
+ expandIconPlacement={'end'}
gap={24}
items={deploymentOptions.map((item, index) => {
let properties: {
diff --git a/src/features/MCPPluginDetail/Overview/index.tsx b/src/features/MCPPluginDetail/Overview/index.tsx
index 41d00f50f0b..62e733bebe3 100644
--- a/src/features/MCPPluginDetail/Overview/index.tsx
+++ b/src/features/MCPPluginDetail/Overview/index.tsx
@@ -20,7 +20,7 @@ const Overview = memo<{ inModal?: boolean }>(({ inModal }) => {
<Flexbox gap={48}>
<Collapse
defaultActiveKey={['summary']}
- expandIconPosition={'end'}
+ expandIconPlacement={'end'}
items={[
{
children: !!summary ? <Markdown>{summary}</Markdown> : summary,
diff --git a/src/features/MCPPluginDetail/Schema/Prompts.tsx b/src/features/MCPPluginDetail/Schema/Prompts.tsx
index 51f8ec24db1..d83f278a01b 100644
--- a/src/features/MCPPluginDetail/Schema/Prompts.tsx
+++ b/src/features/MCPPluginDetail/Schema/Prompts.tsx
@@ -39,7 +39,7 @@ const Prompts = memo<PromptsProps>(({ mode, activeKey = [], setActiveKey }) => {
return (
<Collapse
activeKey={activeKey}
- expandIconPosition={'end'}
+ expandIconPlacement={'end'}
gap={8}
items={prompts.map((item) => {
return {
diff --git a/src/features/MCPPluginDetail/Schema/Tools.tsx b/src/features/MCPPluginDetail/Schema/Tools.tsx
index c40c61c3445..84767e7788c 100644
--- a/src/features/MCPPluginDetail/Schema/Tools.tsx
+++ b/src/features/MCPPluginDetail/Schema/Tools.tsx
@@ -39,7 +39,7 @@ const Tools = memo<ToolsProps>(({ mode, activeKey = [], setActiveKey }) => {
return (
<Collapse
activeKey={activeKey}
- expandIconPosition={'end'}
+ expandIconPlacement={'end'}
gap={8}
items={tools.map((item) => {
let properties: {
diff --git a/src/features/PluginStore/PluginList/Detail/Header.tsx b/src/features/PluginStore/PluginList/Detail/Header.tsx
index ad6a33ebb54..db51dda85d2 100644
--- a/src/features/PluginStore/PluginList/Detail/Header.tsx
+++ b/src/features/PluginStore/PluginList/Detail/Header.tsx
@@ -115,7 +115,7 @@ const Header = memo<{ inModal?: boolean; mobile?: boolean }>(({ mobile: isMobile
<Collapse
defaultActiveKey={['summary']}
- expandIconPosition={'end'}
+ expandIconPlacement={'end'}
items={[
{
children: description,
diff --git a/src/features/PluginStore/PluginList/Detail/InstallDetail/Tools.tsx b/src/features/PluginStore/PluginList/Detail/InstallDetail/Tools.tsx
index 98b4e6c2929..e1d1d407140 100644
--- a/src/features/PluginStore/PluginList/Detail/InstallDetail/Tools.tsx
+++ b/src/features/PluginStore/PluginList/Detail/InstallDetail/Tools.tsx
@@ -40,7 +40,7 @@ const Tools = memo<ToolProps>(({ mode }) => {
return (
<Collapse
activeKey={activeKey}
- expandIconPosition={'end'}
+ expandIconPlacement={'end'}
gap={8}
items={manifest.api.map((item) => {
const parameters = Object.entries(item.parameters?.properties || {}).map(