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: fix some style issues

canisminor1990b65ffdcc15d3
diff --git a/src/app/[variants]/(main)/home/_layout/Body/Agent/AllAgentsDrawer/Content.tsx b/src/app/[variants]/(main)/home/_layout/Body/Agent/AllAgentsDrawer/Content.tsx
index aa203398b79..a9174e279d9 100644
--- a/src/app/[variants]/(main)/home/_layout/Body/Agent/AllAgentsDrawer/Content.tsx
+++ b/src/app/[variants]/(main)/home/_layout/Body/Agent/AllAgentsDrawer/Content.tsx
@@ -57,7 +57,7 @@ const Content = memo<ContentProps>(({ searchKeyword }) => {
style={{ height: '100%' }}
>
{displayItems.map((item) => (
- <Flexbox gap={1} key={item.id} padding={'4px 8px'}>
+ <Flexbox key={item.id} paddingBlock={1} paddingInline={4}>
{item.type === 'group' ? <GroupItem item={item} /> : <AgentItem item={item} />}
</Flexbox>
))}
diff --git a/src/features/Conversation/Messages/AssistantGroup/Tool/Debug/index.tsx b/src/features/Conversation/Messages/AssistantGroup/Tool/Debug/index.tsx
index 6a02c024137..6500b39e479 100644
--- a/src/features/Conversation/Messages/AssistantGroup/Tool/Debug/index.tsx
+++ b/src/features/Conversation/Messages/AssistantGroup/Tool/Debug/index.tsx
@@ -1,7 +1,9 @@
+import { ToolIntervention } from '@lobechat/types';
import { Block, Highlighter, Icon, Tabs, TabsProps } from '@lobehub/ui';
import {
BracesIcon,
FunctionSquareIcon,
+ HandIcon,
MessageSquareCodeIcon,
SquareArrowDownIcon,
} from 'lucide-react';
@@ -11,113 +13,130 @@ import { useTranslation } from 'react-i18next';
interface DebugProps {
apiName: string;
identifier: string;
+ intervention?: ToolIntervention;
requestArgs?: string;
result?: { content: string | null; error?: any; state?: any };
toolCallId: string;
type?: string;
}
-const Debug = memo<DebugProps>(({ result, requestArgs, toolCallId, apiName, identifier, type }) => {
- const { t } = useTranslation('plugin');
+const Debug = memo<DebugProps>(
+ ({ result, requestArgs, toolCallId, apiName, identifier, type, intervention }) => {
+ const { t } = useTranslation('plugin');
- const params = useMemo(() => {
- try {
- return JSON.stringify(JSON.parse(requestArgs || ''), null, 2);
- } catch {
- return '';
- }
- }, [requestArgs]);
+ const params = useMemo(() => {
+ try {
+ return JSON.stringify(JSON.parse(requestArgs || ''), null, 2);
+ } catch {
+ return '';
+ }
+ }, [requestArgs]);
- const functionCall = useMemo(() => {
- return {
- apiName,
- arguments: requestArgs,
- id: toolCallId,
- identifier,
- type,
- };
- }, [requestArgs, toolCallId, apiName, identifier, type]);
+ const functionCall = useMemo(() => {
+ return {
+ apiName,
+ arguments: requestArgs,
+ id: toolCallId,
+ identifier,
+ type,
+ };
+ }, [requestArgs, toolCallId, apiName, identifier, type]);
- const isJsonResult =
- result?.content?.trim().startsWith('{') || result?.content?.trim().startsWith('[');
+ const isJsonResult =
+ result?.content?.trim().startsWith('{') || result?.content?.trim().startsWith('[');
- const items: TabsProps['items'] = useMemo(
- () => [
- {
- children: (
- <Highlighter
- language={'json'}
- style={{ background: 'transparent', borderRadius: 0, height: '100%' }}
- variant={'filled'}
- >
- {params}
- </Highlighter>
- ),
- icon: <Icon icon={MessageSquareCodeIcon} />,
- key: 'arguments',
- label: t('debug.arguments'),
- },
- {
- children: (
- <Highlighter
- language={isJsonResult ? 'json' : 'plaintext'}
- style={{ background: 'transparent', borderRadius: 0, height: '100%' }}
- variant={'filled'}
- >
- {isJsonResult ? JSON.stringify(result?.content, null, 2) : result?.content || ''}
- </Highlighter>
- ),
- icon: <Icon icon={SquareArrowDownIcon} />,
- key: 'response',
- label: t('debug.response'),
- },
- {
- children: (
- <Highlighter
- language={'json'}
- style={{ background: 'transparent', borderRadius: 0, height: '100%' }}
- variant={'filled'}
- >
- {JSON.stringify(functionCall, null, 2)}
- </Highlighter>
- ),
- icon: <Icon icon={FunctionSquareIcon} />,
- key: 'function_call',
- label: t('debug.function_call'),
- },
- {
- children: (
- <Highlighter
- language={'json'}
- style={{ background: 'transparent', borderRadius: 0, height: '100%' }}
- variant={'filled'}
- >
- {JSON.stringify(result?.state, null, 2)}
- </Highlighter>
- ),
- icon: <Icon icon={BracesIcon} />,
- key: 'pluginState',
- label: t('debug.pluginState'),
- },
- ],
- [functionCall, isJsonResult, params, result?.content, result?.state, t],
- );
+ const items: TabsProps['items'] = useMemo(
+ () => [
+ {
+ children: (
+ <Highlighter
+ language={'json'}
+ style={{ background: 'transparent', borderRadius: 0, height: '100%' }}
+ variant={'filled'}
+ >
+ {params}
+ </Highlighter>
+ ),
+ icon: <Icon icon={MessageSquareCodeIcon} />,
+ key: 'arguments',
+ label: t('debug.arguments'),
+ },
+ {
+ children: (
+ <Highlighter
+ language={isJsonResult ? 'json' : 'plaintext'}
+ style={{ background: 'transparent', borderRadius: 0, height: '100%' }}
+ variant={'filled'}
+ >
+ {isJsonResult ? JSON.stringify(result?.content, null, 2) : result?.content || ''}
+ </Highlighter>
+ ),
+ icon: <Icon icon={SquareArrowDownIcon} />,
+ key: 'response',
+ label: t('debug.response'),
+ },
+ {
+ children: (
+ <Highlighter
+ language={'json'}
+ style={{ background: 'transparent', borderRadius: 0, height: '100%' }}
+ variant={'filled'}
+ >
+ {JSON.stringify(functionCall, null, 2)}
+ </Highlighter>
+ ),
+ icon: <Icon icon={FunctionSquareIcon} />,
+ key: 'function_call',
+ label: t('debug.function_call'),
+ },
+ {
+ children: (
+ <Highlighter
+ language={'json'}
+ style={{ background: 'transparent', borderRadius: 0, height: '100%' }}
+ variant={'filled'}
+ >
+ {JSON.stringify(result?.state, null, 2)}
+ </Highlighter>
+ ),
+ icon: <Icon icon={BracesIcon} />,
+ key: 'pluginState',
+ label: t('debug.pluginState'),
+ },
+ {
+ children: (
+ <Highlighter
+ language={'json'}
+ style={{ background: 'transparent', borderRadius: 0, height: '100%' }}
+ variant={'filled'}
+ >
+ {JSON.stringify(intervention, null, 2)}
+ </Highlighter>
+ ),
+ icon: <Icon icon={HandIcon} />,
+ key: 'intervention',
+ label: t('debug.pluginState'),
+ },
+ ],
+ [functionCall, isJsonResult, params, result?.content, result?.state, intervention, t],
+ );
- return (
- <Block variant={'outlined'}>
- <Tabs
- compact
- items={items}
- styles={{
- content: {
- height: 300,
- padding: 0,
- },
- }}
- tabPlacement={'start'}
- />
- </Block>
- );
-});
+ return (
+ <Block variant={'outlined'}>
+ <Tabs
+ compact
+ items={items}
+ styles={{
+ content: {
+ height: 300,
+ padding: 0,
+ },
+ }}
+ tabPlacement={'start'}
+ />
+ </Block>
+ );
+ },
+);
export default Debug;
diff --git a/src/features/Conversation/Messages/AssistantGroup/Tool/Inspector/StatusIndicator.tsx b/src/features/Conversation/Messages/AssistantGroup/Tool/Inspector/StatusIndicator.tsx
index 16978e8ae46..e7b86b2ead8 100644
--- a/src/features/Conversation/Messages/AssistantGroup/Tool/Inspector/StatusIndicator.tsx
+++ b/src/features/Conversation/Messages/AssistantGroup/Tool/Inspector/StatusIndicator.tsx
@@ -1,7 +1,14 @@
import { ToolIntervention } from '@lobechat/types';
import { Block, Icon, Tooltip } from '@lobehub/ui';
import { useTheme } from 'antd-style';
-import { Ban, Check, CircleStop, Loader2Icon, X } from 'lucide-react';
+import {
+ Ban,
+ Check,
+ HandIcon,
+ Loader2Icon,
+ PauseIcon,
+ X,
+} from 'lucide-react';
import { memo } from 'react';
import { useTranslation } from 'react-i18next';
@@ -19,29 +26,30 @@ const StatusIndicator = memo<StatusIndicatorProps>(({ intervention, result }) =>
const hasError = !!result?.error;
const hasSuccessResult = !!result?.content && result.content !== LOADING_FLAT;
const hasResult = hasSuccessResult || hasError;
+ const isPending = intervention?.status === 'pending';
const isReject = intervention?.status === 'rejected';
const isAbort = intervention?.status === 'aborted';
let icon;
- if (hasResult) {
- if (isAbort) {
- icon = (
- <Tooltip title={t('tool.intervention.toolAbort')}>
- <Icon color={theme.colorTextTertiary} icon={CircleStop} />
- </Tooltip>
- );
- } else if (isReject) {
- icon = (
- <Tooltip title={t('tool.intervention.toolRejected')}>
- <Icon color={theme.colorTextTertiary} icon={Ban} />
- </Tooltip>
- );
- } else if (hasError) {
- icon = <Icon color={theme.colorError} icon={X} />;
- } else {
- icon = <Icon color={theme.colorSuccess} icon={Check} />;
- }
+ if (isAbort) {
+ icon = (
+ <Tooltip title={t('tool.intervention.toolAbort')}>
+ <Icon color={theme.colorTextTertiary} icon={PauseIcon} />
+ </Tooltip>
+ );
+ } else if (isReject) {
+ icon = (
+ <Tooltip title={t('tool.intervention.toolRejected')}>
+ <Icon color={theme.colorTextTertiary} icon={Ban} />
+ </Tooltip>
+ );
+ } else if (hasError) {
+ icon = <Icon color={theme.colorError} icon={X} />;
+ } else if (isPending) {
+ icon = <Icon color={theme.colorInfo} icon={HandIcon} />;
+ } else if (hasResult) {
+ icon = <Icon color={theme.colorSuccess} icon={Check} />;
} else {
icon = <Icon color={theme.colorTextDescription} icon={Loader2Icon} spin />;
}
diff --git a/src/features/Conversation/Messages/AssistantGroup/Tool/Inspector/ToolTitle.tsx b/src/features/Conversation/Messages/AssistantGroup/Tool/Inspector/ToolTitle.tsx
index ef0d14c5cd8..2622cb2f22d 100644
--- a/src/features/Conversation/Messages/AssistantGroup/Tool/Inspector/ToolTitle.tsx
+++ b/src/features/Conversation/Messages/AssistantGroup/Tool/Inspector/ToolTitle.tsx
@@ -11,6 +11,9 @@ import { shinyTextStylish } from '@/styles/loading';
import { builtinToolIdentifiers } from '@/tools/identifiers';
export const useStyles = createStyles(({ css, token }) => ({
+ aborted: css`
+ color: ${token.colorTextQuaternary};
+ `,
root: css`
overflow: hidden;
display: -webkit-box;
@@ -25,10 +28,11 @@ export const useStyles = createStyles(({ css, token }) => ({
interface ToolTitleProps {
apiName: string;
identifier: string;
+ isAborted?: boolean;
isLoading?: boolean;
}
-const ToolTitle = memo<ToolTitleProps>(({ identifier, apiName, isLoading }) => {
+const ToolTitle = memo<ToolTitleProps>(({ identifier, apiName, isLoading, isAborted }) => {
const { t } = useTranslation('plugin');
const { styles, cx } = useStyles();
@@ -37,7 +41,7 @@ const ToolTitle = memo<ToolTitleProps>(({ identifier, apiName, isLoading }) => {
const pluginTitle = pluginHelpers.getPluginTitle(pluginMeta) ?? t('unknownPlugin');
return (
- <div className={cx(styles.root, isLoading && styles.shinyText)}>
+ <div className={cx(styles.root, isLoading && styles.shinyText, isAborted && styles.aborted)}>
<span>
{isBuiltinPlugin
? t(`builtins.${identifier}.title`, {
diff --git a/src/features/Conversation/Messages/AssistantGroup/Tool/Inspector/index.tsx b/src/features/Conversation/Messages/AssistantGroup/Tool/Inspector/index.tsx
index fcb238fc7bb..08cc0889078 100644
--- a/src/features/Conversation/Messages/AssistantGroup/Tool/Inspector/index.tsx
+++ b/src/features/Conversation/Messages/AssistantGroup/Tool/Inspector/index.tsx
@@ -20,12 +20,18 @@ const Inspectors = memo<InspectorProps>(({ identifier, apiName, result, interven
const hasResult = hasSuccessResult || hasError;
const isPending = intervention?.status === 'pending';
- const isTitleLoading = !hasResult && !isPending;
+ const isAborted = intervention?.status === 'aborted';
+ const isTitleLoading = !hasResult && !isPending && !isAborted;
return (
<Flexbox align={'center'} gap={6} horizontal>
<StatusIndicator intervention={intervention} result={result} />
- <ToolTitle apiName={apiName} identifier={identifier} isLoading={isTitleLoading} />
+ <ToolTitle
+ apiName={apiName}
+ identifier={identifier}
+ isAborted={isAborted}
+ isLoading={isTitleLoading}
+ />
</Flexbox>
);
});
diff --git a/src/features/Conversation/Messages/AssistantGroup/Tool/Render/AbortResponse.tsx b/src/features/Conversation/Messages/AssistantGroup/Tool/Render/AbortResponse.tsx
index 2bfa866c079..09bf46a1e0e 100644
--- a/src/features/Conversation/Messages/AssistantGroup/Tool/Render/AbortResponse.tsx
+++ b/src/features/Conversation/Messages/AssistantGroup/Tool/Render/AbortResponse.tsx
@@ -1,36 +1,11 @@
-import { Flexbox, Icon } from '@lobehub/ui';
-import { createStyles } from 'antd-style';
-import { BanIcon } from 'lucide-react';
+import { Alert } from '@lobehub/ui';
import { memo } from 'react';
import { useTranslation } from 'react-i18next';
-const useStyles = createStyles(({ css, token }) => ({
- container: css`
- padding-block: 8px;
- padding-inline: 6px;
- `,
- reason: css`
- font-size: 12px;
- color: ${token.colorTextTertiary};
- `,
- title: css`
- font-size: 14px;
- color: ${token.colorTextSecondary};
- `,
-}));
-
const AbortResponse = memo(() => {
const { t } = useTranslation('chat');
- const { styles, theme } = useStyles();
- return (
- <Flexbox className={styles.container} gap={8}>
- <Flexbox align={'center'} gap={8} horizontal>
- <Icon color={theme.colorTextTertiary} icon={BanIcon} size={16} />
- <div className={styles.title}>{t('tool.intervention.toolAbort')}</div>
- </Flexbox>
- </Flexbox>
- );
+ return <Alert title={t('tool.intervention.toolAbort')} type={'secondary'} />;
});
export default AbortResponse;
diff --git a/src/features/Conversation/Messages/AssistantGroup/Tool/index.tsx b/src/features/Conversation/Messages/AssistantGroup/Tool/index.tsx
index 34833bb8c3a..4cd4115a3f1 100644
--- a/src/features/Conversation/Messages/AssistantGroup/Tool/index.tsx
+++ b/src/features/Conversation/Messages/AssistantGroup/Tool/index.tsx
@@ -57,14 +57,15 @@ const Tool = memo<GroupToolProps>(
const isPending = intervention?.status === 'pending';
const isReject = intervention?.status === 'rejected';
const isAbort = intervention?.status === 'aborted';
+ const needExpand = renderDisplayControl !== 'collapsed' || isPending;
const showCustomPluginRender = !isPending && !isReject && !isAbort;
useEffect(() => {
- if (renderDisplayControl !== 'collapsed') {
+ if (needExpand) {
handleExpand?.(true);
}
- }, [renderDisplayControl]);
+ }, [needExpand]);
return (
<AccordionItem
@@ -97,6 +98,7 @@ const Tool = memo<GroupToolProps>(
<Debug
apiName={apiName}
identifier={identifier}
+ intervention={intervention}
requestArgs={requestArgs}
result={result}
toolCallId={id}
diff --git a/src/features/Conversation/Messages/AssistantGroup/Tools.tsx b/src/features/Conversation/Messages/AssistantGroup/Tools.tsx
index 815af576845..09b0359fbb6 100644
--- a/src/features/Conversation/Messages/AssistantGroup/Tools.tsx
+++ b/src/features/Conversation/Messages/AssistantGroup/Tools.tsx
@@ -1,6 +1,6 @@
import { ChatToolPayloadWithResult } from '@lobechat/types';
import { Accordion } from '@lobehub/ui';
-import { type Key, memo, useCallback, useState } from 'react';
+import { type Key, memo, useState } from 'react';
import Tool from './Tool';
@@ -12,19 +12,6 @@ interface ToolsRendererProps {
export const Tools = memo<ToolsRendererProps>(({ messageId, tools }) => {
const [showToolContents, setShowToolDetails] = useState<Key[]>([]);
- const handleExpand = useCallback(
- (id: string) => (expand?: boolean) => {
- if (expand) {
- if (!showToolContents.includes(id)) {
- setShowToolDetails([...showToolContents, id]);
- }
- } else {
- setShowToolDetails(showToolContents.filter((key) => key !== id));
- }
- },
- [showToolContents],
- );
-
if (!tools || tools.length === 0) return null;
return (
@@ -40,7 +27,19 @@ export const Tools = memo<ToolsRendererProps>(({ messageId, tools }) => {
arguments={tool.arguments}
assistantMessageId={messageId}
expand={showToolContents.includes(tool.id)}
- handleExpand={handleExpand(tool.id)}
+ handleExpand={(expand?: boolean) => {
+ setShowToolDetails((prev = []) => {
+ if (expand) {
+ if (!prev.includes(tool.id)) {
+ return [...prev, tool.id];
+ } else {
+ return prev;
+ }
+ } else {
+ return prev.filter((key) => key !== tool.id);
+ }
+ });
+ }}
id={tool.id}
identifier={tool.identifier}
intervention={tool.intervention}
diff --git a/src/features/NavPanel/SideBarDrawer.tsx b/src/features/NavPanel/SideBarDrawer.tsx
index 3ef71a807a9..720b3924477 100644
--- a/src/features/NavPanel/SideBarDrawer.tsx
+++ b/src/features/NavPanel/SideBarDrawer.tsx
@@ -44,6 +44,7 @@ const SideBarDrawer = memo<SideBarDrawerProps>(
padding: 0,
},
header: {
+ background: theme.colorBgLayout,
borderBottom: 'none',
padding: 0,
},
diff --git a/src/locales/default/plugin.ts b/src/locales/default/plugin.ts
index 6e3076fab48..fbe2c83d9b3 100644
--- a/src/locales/default/plugin.ts
+++ b/src/locales/default/plugin.ts
@@ -107,6 +107,7 @@ export default {
'confirm': '确认',
'debug.arguments': '调用参数',
'debug.function_call': '函数调用',
+ 'debug.intervention': '技能干涉',
'debug.off': '关闭调试',
'debug.on': '查看技能调用信息',
'debug.payload': '技能载荷',