🤯 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.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
'use client';
import type { ReplaceTextArgs } from '@lobechat/editor-runtime';
import type { BuiltinInspectorProps } from '@lobechat/types';
import { Icon } from '@lobehub/ui';
import { Text } from '@lobehub/ui';
import { createStaticStyles, cx } from '@lobehub/ui';
import { ArrowRight } from 'lucide-react';
import { memo } from 'react';
import { useTranslation } from 'react-i18next';
import { highlightTextStyles, inspectorTextStyles, shinyTextStyles } from '@/styles';
import type { ReplaceTextState } from '../../../types';
const styles = createStaticStyles(({ css, cssVar }) => ({
arrow: css`
margin-inline: 4px;
color: ${cssVar.colorTextQuaternary};
`,
from: css`
color: ${cssVar.colorTextSecondary};
text-decoration: line-through;
`,
title: css`
margin-inline-end: 8px;
color: ${cssVar.colorText};
`,
}));
export const ReplaceTextInspector = memo<BuiltinInspectorProps<ReplaceTextArgs, ReplaceTextState>>(
({ args, partialArgs, isArgumentsStreaming, pluginState }) => {
const { t } = useTranslation('plugin');
const from = args?.searchText || partialArgs?.searchText;
const to = args?.newText ?? partialArgs?.newText;
// During streaming without searchText yet, show init message
if (isArgumentsStreaming && !from) {
return (
<div className={inspectorTextStyles.root}>
<span className={shinyTextStyles.shinyText}>
{t('builtins.lobe-page-agent.apiName.replaceText.init')}
</span>
</div>
);
}
const count = pluginState?.replacementCount ?? 0;
const hasResult = from && to !== undefined;
return (
<div className={inspectorTextStyles.root}>
<span className={cx(styles.title, isArgumentsStreaming && shinyTextStyles.shinyText)}>
{t('builtins.lobe-page-agent.apiName.replaceText')}
</span>
{hasResult && (
<>
<span className={styles.from}>{from}</span>
<Icon className={styles.arrow} icon={ArrowRight} size={12} />
<span className={highlightTextStyles.gold}>
{to || t('builtins.lobe-page-agent.apiName.replaceText.empty')}
</span>
{count > 0 && (
<Text code as={'span'} fontSize={12} type={'secondary'}>
{' '}
({t('builtins.lobe-page-agent.apiName.replaceText.count', { count })})
</Text>
)}
</>
)}
</div>
);
},
);
ReplaceTextInspector.displayName = 'ReplaceTextInspector';
export default ReplaceTextInspector;