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(web-onboarding): add Render for saveUserQuestion & showAgentMarketplace (#14667)

Arvin Xuf591f7ac342a
diff --git a/locales/zh-CN/plugin.json b/locales/zh-CN/plugin.json
index 0564908d0a7..4c63e5722d7 100644
--- a/locales/zh-CN/plugin.json
+++ b/locales/zh-CN/plugin.json
@@ -326,6 +326,9 @@
"builtins.lobe-web-onboarding.inspector.hunkCount_other": "{{count}} 处修改",
"builtins.lobe-web-onboarding.inspector.interests_one": "{{count}} 个兴趣",
"builtins.lobe-web-onboarding.inspector.interests_other": "{{count}} 个兴趣",
+ "builtins.lobe-web-onboarding.render.agent": "Agent",
+ "builtins.lobe-web-onboarding.render.fullName": "姓名",
+ "builtins.lobe-web-onboarding.render.interests": "兴趣领域",
"builtins.lobe-web-onboarding.title": "用户入门",
"builtins.lobe-web-onboarding.updateDocument.hunkMode.delete": "删除",
"builtins.lobe-web-onboarding.updateDocument.hunkMode.deleteLines": "删除行",
diff --git a/packages/builtin-tool-web-onboarding/src/agentMarketplace/client/Render/index.ts b/packages/builtin-tool-web-onboarding/src/agentMarketplace/client/Render/index.ts
index fd43d025f79..bff894c23d1 100644
--- a/packages/builtin-tool-web-onboarding/src/agentMarketplace/client/Render/index.ts
+++ b/packages/builtin-tool-web-onboarding/src/agentMarketplace/client/Render/index.ts
@@ -1,7 +1,12 @@
import { AgentMarketplaceApiName } from '../../types';
import SubmitAgentPick from './SubmitAgentPick';
+// `showAgentMarketplace` is rewritten in place after the user submits — its
+// `pluginState` ends up with the same `{ summaries, installedAgentIds, ... }`
+// shape that `SubmitAgentPick` consumes (see `customInteractionHandlers.ts`),
+// so both APIs reuse the same Render.
export const AgentMarketplaceRenders = {
+ [AgentMarketplaceApiName.showAgentMarketplace]: SubmitAgentPick,
[AgentMarketplaceApiName.submitAgentPick]: SubmitAgentPick,
};
diff --git a/packages/builtin-tool-web-onboarding/src/client/Render/SaveUserQuestion/index.tsx b/packages/builtin-tool-web-onboarding/src/client/Render/SaveUserQuestion/index.tsx
new file mode 100644
index 00000000000..513ba12575d
--- /dev/null
+++ b/packages/builtin-tool-web-onboarding/src/client/Render/SaveUserQuestion/index.tsx
@@ -0,0 +1,146 @@
+'use client';
+
+import type { InterestAreaKey } from '@lobechat/const';
+import type { BuiltinRenderProps, SaveUserQuestionInput } from '@lobechat/types';
+import { Flexbox, Text } from '@lobehub/ui';
+import { createStaticStyles } from 'antd-style';
+import { memo, useMemo } from 'react';
+import { useTranslation } from 'react-i18next';
+
+const styles = createStaticStyles(({ css, cssVar }) => ({
+ avatar: css`
+ display: inline-flex;
+ flex-shrink: 0;
+ align-items: center;
+ justify-content: center;
+
+ box-sizing: border-box;
+ width: 48px;
+ height: 48px;
+ border-radius: 16px;
+
+ font-size: 28px;
+ line-height: 1;
+
+ background: ${cssVar.colorFillQuaternary};
+ `,
+ chip: css`
+ display: inline-flex;
+ align-items: center;
+
+ padding-block: 4px;
+ padding-inline: 10px;
+ border-radius: 999px;
+
+ font-size: 12px;
+ color: ${cssVar.colorText};
+
+ background: ${cssVar.colorFillQuaternary};
+ `,
+ detailCard: css`
+ padding: 16px;
+ border: 1px solid ${cssVar.colorBorderSecondary};
+ border-radius: 12px;
+ background: ${cssVar.colorFillTertiary};
+ `,
+ name: css`
+ overflow: hidden;
+ display: -webkit-box;
+ -webkit-box-orient: vertical;
+ -webkit-line-clamp: 1;
+
+ font-size: 16px;
+ font-weight: 600;
+ color: ${cssVar.colorText};
+ `,
+ sectionLabel: css`
+ font-size: 12px;
+ font-weight: 600;
+ color: ${cssVar.colorTextSecondary};
+ `,
+ value: css`
+ padding-block: 10px;
+ padding-inline: 12px;
+ border-radius: 10px;
+
+ font-size: 14px;
+ font-weight: 500;
+ color: ${cssVar.colorText};
+
+ background: ${cssVar.colorFillQuaternary};
+ `,
+}));
+
+const SaveUserQuestion = memo<BuiltinRenderProps<SaveUserQuestionInput, unknown, unknown>>(
+ ({ args }) => {
+ const { t } = useTranslation('plugin');
+ const { t: tOnboarding } = useTranslation('onboarding');
+
+ const agentName = args?.agentName?.trim();
+ const agentEmoji = args?.agentEmoji?.trim();
+ const fullName = args?.fullName?.trim();
+ const interestLabels = useMemo(() => {
+ const predefined = (args?.interests ?? []).map((key) =>
+ tOnboarding(`interests.area.${key as InterestAreaKey}`),
+ );
+ const custom = (args?.customInterests ?? [])
+ .map((item) => item.trim())
+ .filter((item) => item.length > 0);
+ return [...predefined, ...custom];
+ }, [args?.interests, args?.customInterests, tOnboarding]);
+
+ const hasAgentIdentity = Boolean(agentName || agentEmoji);
+ const hasUserProfile = Boolean(fullName);
+ const hasInterests = interestLabels.length > 0;
+
+ if (!hasAgentIdentity && !hasUserProfile && !hasInterests) return null;
+
+ return (
+ <Flexbox gap={16}>
+ {hasAgentIdentity && (
+ <Flexbox gap={8}>
+ <Text className={styles.sectionLabel}>
+ {t('builtins.lobe-web-onboarding.render.agent')}
+ </Text>
+ <div className={styles.detailCard}>
+ <Flexbox horizontal align="center" gap={12}>
+ <div className={styles.avatar}>{agentEmoji || '🤖'}</div>
+ {agentName && <div className={styles.name}>{agentName}</div>}
+ </Flexbox>
+ </div>
+ </Flexbox>
+ )}
+
+ {hasUserProfile && (
+ <Flexbox gap={8}>
+ <Text className={styles.sectionLabel}>
+ {t('builtins.lobe-web-onboarding.render.fullName')}
+ </Text>
+ <div className={styles.detailCard}>
+ <div className={styles.value}>{fullName}</div>
+ </div>
+ </Flexbox>
+ )}
+
+ {hasInterests && (
+ <Flexbox gap={8}>
+ <Text className={styles.sectionLabel}>
+ {t('builtins.lobe-web-onboarding.render.interests')}
+ </Text>
+ <Flexbox horizontal style={{ flexWrap: 'wrap', gap: 8 }}>
+ {interestLabels.map((label) => (
+ <span className={styles.chip} key={label}>
+ {label}
+ </span>
+ ))}
+ </Flexbox>
+ </Flexbox>
+ )}
+ </Flexbox>
+ );
+ },
+);
+
+SaveUserQuestion.displayName = 'WebOnboardingSaveUserQuestion';
+
+export default SaveUserQuestion;
diff --git a/packages/builtin-tool-web-onboarding/src/client/Render/index.ts b/packages/builtin-tool-web-onboarding/src/client/Render/index.ts
index f01214c9810..ab421d5ed89 100644
--- a/packages/builtin-tool-web-onboarding/src/client/Render/index.ts
+++ b/packages/builtin-tool-web-onboarding/src/client/Render/index.ts
@@ -1,11 +1,14 @@
import { WebOnboardingApiName } from '../../types';
+import SaveUserQuestion from './SaveUserQuestion';
import UpdateDocument from './UpdateDocument';
import WriteDocument from './WriteDocument';
export const WebOnboardingRenders = {
+ [WebOnboardingApiName.saveUserQuestion]: SaveUserQuestion,
[WebOnboardingApiName.updateDocument]: UpdateDocument,
[WebOnboardingApiName.writeDocument]: WriteDocument,
};
+export { default as SaveUserQuestionRender } from './SaveUserQuestion';
export { default as UpdateDocumentRender } from './UpdateDocument';
export { default as WriteDocumentRender } from './WriteDocument';
diff --git a/src/locales/default/plugin.ts b/src/locales/default/plugin.ts
index 6101c23886f..7251cdc45a3 100644
--- a/src/locales/default/plugin.ts
+++ b/src/locales/default/plugin.ts
@@ -332,6 +332,9 @@ export default {
'builtins.lobe-web-onboarding.updateDocument.hunkMode.replaceLines': 'Replace lines',
'builtins.lobe-web-onboarding.inspector.interests_one': '{{count}} interest',
'builtins.lobe-web-onboarding.inspector.interests_other': '{{count}} interests',
+ 'builtins.lobe-web-onboarding.render.agent': 'Agent',
+ 'builtins.lobe-web-onboarding.render.fullName': 'Full name',
+ 'builtins.lobe-web-onboarding.render.interests': 'Interests',
'builtins.lobe-web-onboarding.title': 'User Onboarding',
'builtins.lobe-topic-reference.apiName.getTopicContext': 'Get Topic Context',
'builtins.lobe-topic-reference.title': 'Topic Reference',