๐คฏ 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
๐ fix: store onboarding interests as keys (#14624)
YuTengjing58318e97df06
diff --git a/packages/builtin-agents/src/agents/web-onboarding/systemRole.ts b/packages/builtin-agents/src/agents/web-onboarding/systemRole.tsindex c5e69cafa1a..4f0318d3742 100644--- a/packages/builtin-agents/src/agents/web-onboarding/systemRole.ts+++ b/packages/builtin-agents/src/agents/web-onboarding/systemRole.ts@@ -79,7 +79,7 @@ Guidelines:- If the user is not comfortable typing, acknowledge alternatives like photos or voice when relevant.- Discover their interests naturally. The preferred reply language is already configured before onboarding starts and injected into your system prompt โ do not ask about it or save it via saveUserQuestion.- Do NOT call saveUserQuestion with interests until you have covered at least 1โ2 different dimensions above. As soon as you have a workable read, save it and move on.-- Call saveUserQuestion for interests as soon as you have enough signal โ do not stall for more.+- Call saveUserQuestion for interests as soon as you have enough signal โ use the predefined interests enum when it fits, and customInterests for specific freeform interests.- **Persist each new fact on the turn you learn it.** Do NOT accumulate unwritten facts in memory waiting to do one big write at the end โ that pattern is forbidden. If Persona is empty, call writeDocument(type="persona") this turn to seed it. On every subsequent turn where you learn something new (role, pain point, goal, preference, interest), call updateDocument(type="persona") to record it.- **One call per document per turn โ batch your hunks.** \`updateDocument\` accepts an array of hunks; if you have multiple changes to record this turn, put ALL of them into a single call's \`hunks\` array. Calling \`updateDocument(type="persona")\` two or more times in immediate succession is forbidden โ each call costs a full LLM round-trip. The same rule applies to \`updateDocument(type="soul")\`. Reword-then-add loops (where each call adds a slightly rephrased version of the same fact) are an explicit anti-pattern; once a fact is in the document, do not re-record it.- This phase should feel like a good first conversation, not an interview.diff --git a/packages/builtin-tool-web-onboarding/package.json b/packages/builtin-tool-web-onboarding/package.jsonindex 02d4ca4a515..6663f3ac2be 100644--- a/packages/builtin-tool-web-onboarding/package.json+++ b/packages/builtin-tool-web-onboarding/package.json@@ -14,6 +14,7 @@},"main": "./src/index.ts","dependencies": {+ "@lobechat/const": "workspace:*","@lobechat/markdown-patch": "workspace:*","@lobechat/prompts": "workspace:*","zod": "^3.25.76"diff --git a/packages/builtin-tool-web-onboarding/src/ExecutionRuntime/utils.ts b/packages/builtin-tool-web-onboarding/src/ExecutionRuntime/utils.tsindex b77251d9da8..8d7aeb8a7dd 100644--- a/packages/builtin-tool-web-onboarding/src/ExecutionRuntime/utils.ts+++ b/packages/builtin-tool-web-onboarding/src/ExecutionRuntime/utils.ts@@ -15,6 +15,7 @@ interface WebOnboardingToolActionResult {const FIELD_LABELS: Record<SaveUserQuestionField, string> = {agentEmoji: 'agent emoji',agentName: 'agent name',+ customInterests: 'custom interests',fullName: 'full name',interests: 'interests',};diff --git a/packages/builtin-tool-web-onboarding/src/client/Inspector/SaveUserQuestion/index.tsx b/packages/builtin-tool-web-onboarding/src/client/Inspector/SaveUserQuestion/index.tsxindex 0a8a3db5c29..c06032c8c4b 100644--- a/packages/builtin-tool-web-onboarding/src/client/Inspector/SaveUserQuestion/index.tsx+++ b/packages/builtin-tool-web-onboarding/src/client/Inspector/SaveUserQuestion/index.tsx@@ -19,7 +19,9 @@ export const SaveUserQuestionInspector = memo<const agentName = data.agentName?.trim();const agentEmoji = data.agentEmoji?.trim();const fullName = data.fullName?.trim();- const interestsCount = Array.isArray(data.interests) ? data.interests.length : 0;+ const interestsCount =+ (Array.isArray(data.interests) ? data.interests.length : 0) ++ (Array.isArray(data.customInterests) ? data.customInterests.length : 0);const hasAnyField = Boolean(agentName || agentEmoji || fullName || interestsCount > 0);if (isArgumentsStreaming && !hasAnyField) {diff --git a/packages/builtin-tool-web-onboarding/src/manifest.ts b/packages/builtin-tool-web-onboarding/src/manifest.tsindex 63057d08138..64de632ebca 100644--- a/packages/builtin-tool-web-onboarding/src/manifest.ts+++ b/packages/builtin-tool-web-onboarding/src/manifest.ts@@ -1,10 +1,11 @@+import { INTEREST_AREA_KEYS } from '@lobechat/const';import type { BuiltinToolManifest, HumanInterventionRule } from '@lobechat/types';import { toolSystemPrompt } from './toolSystemRole';import { WebOnboardingApiName, WebOnboardingIdentifier } from './types';// Agent identity (name/emoji) surface a confirmation card;-// user profile fields (fullName) and interests saves bypass intervention.+// user profile fields (fullName) and interest saves bypass intervention.const saveUserQuestionConfirmationRules: HumanInterventionRule[] = [{match: {@@ -25,7 +26,7 @@ export const WebOnboardingManifest: BuiltinToolManifest = {api: [{description:- 'Persist structured onboarding fields. agentName and agentEmoji (updates inbox agent title/avatar) require user confirmation; interests-only saves run without confirmation.',+ 'Persist structured onboarding fields. agentName and agentEmoji (updates inbox agent title/avatar) require user confirmation; interests/customInterests saves run without confirmation.',humanIntervention: saveUserQuestionConfirmationRules,name: WebOnboardingApiName.saveUserQuestion,parameters: {@@ -42,8 +43,18 @@ export const WebOnboardingManifest: BuiltinToolManifest = {fullName: {type: 'string',},+ customInterests: {+ description:+ 'Specific freeform user interests that do not fit the predefined interest keys.',+ items: {+ type: 'string',+ },+ type: 'array',+ },interests: {+ description: 'Predefined interest keys selected from the supported enum values.',items: {+ enum: [...INTEREST_AREA_KEYS],type: 'string',},type: 'array',diff --git a/packages/builtin-tool-web-onboarding/src/toolSystemRole.ts b/packages/builtin-tool-web-onboarding/src/toolSystemRole.tsindex a57261f0d1c..db356b01140 100644--- a/packages/builtin-tool-web-onboarding/src/toolSystemRole.ts+++ b/packages/builtin-tool-web-onboarding/src/toolSystemRole.ts@@ -12,7 +12,7 @@ Turn protocol:8. **CRITICAL: You MUST call persistence tools (saveUserQuestion, writeDocument, updateDocument) throughout the entire conversation, not just at the beginning. Every time you learn new information about the user, persist it promptly. On a normal completion, the wrap-up sequence is: persist any unsaved fields โ call \`showAgentMarketplace\` exactly once for the assistant handoff (skip only if the user explicitly refuses recommendations) โ on the NEXT turn, send a brief warm closing and call \`finishOnboarding\`. The user's text reply on that next turn is the resolution signal even if the picker is still pending โ do not stall.**Persistence rules:-1. Use saveUserQuestion only for these structured onboarding fields: agentName, agentEmoji, fullName, and interests. Use it only when that information emerges naturally in conversation. The user's preferred reply language is configured before onboarding starts and is injected into your system role automatically โ do not ask about it or save it via saveUserQuestion.+1. Use saveUserQuestion only for these structured onboarding fields: agentName, agentEmoji, fullName, interests, and customInterests. Use interests for predefined enum keys and customInterests for specific freeform interests. Use it only when that information emerges naturally in conversation. The user's preferred reply language is configured before onboarding starts and is injected into your system role automatically โ do not ask about it or save it via saveUserQuestion.2. saveUserQuestion updates lightweight onboarding state; it never writes markdown content.3. Use writeDocument **only for the very first write** when the document is empty (or for a rare full structural rewrite). For every subsequent edit โ even adding a single line โ use **updateDocument**. updateDocument is cheaper, safer, and less error-prone than rewriting the full document. The current contents of SOUL.md and User Persona are automatically injected into your context (in <current_soul_document> and <current_user_persona> tags, each line prefixed with its 1-based line number and a \`โ\` separator), so you do not need to call readDocument to read them. Use readDocument only if you suspect the injected content may be stale.4. updateDocument takes an ordered list of structured hunks. Pick the hunk mode that best fits the edit:@@ -28,7 +28,7 @@ Persistence rules:8. User Persona (type: "persona") is for user identity, role, work style, current context, interests, pain points, communication comfort level, and preferred input style.9. Do not put user information into SOUL.md. Do not put agent identity into the persona document.10. Document tools (readDocument, writeDocument, updateDocument) must ONLY be used for SOUL.md and User Persona documents. Never use them to create arbitrary content such as guides, tutorials, checklists, or reference materials. Present such content directly in your reply text instead.-11. Do not call saveUserQuestion with interests until you have spent at least 5-6 exchanges exploring the user's world in the discovery phase across multiple dimensions (workflow, pain points, goals, interests, AI expectations). The server enforces a minimum discovery exchange count โ early field saves will not advance the phase but will reduce conversation quality.+11. Do not call saveUserQuestion with interests or customInterests until you have spent at least 5-6 exchanges exploring the user's world in the discovery phase across multiple dimensions (workflow, pain points, goals, interests, AI expectations). The server enforces a minimum discovery exchange count โ early field saves will not advance the phase but will reduce conversation quality.Workspace setup rules:1. Do not create or modify workspace agents or agent groups unless the user explicitly asks for that setup.diff --git a/packages/const/src/index.ts b/packages/const/src/index.tsindex 8db7a206748..c81bc55ed75 100644--- a/packages/const/src/index.ts+++ b/packages/const/src/index.ts@@ -6,6 +6,7 @@ export * from './discover';export * from './editor';export * from './fetch';export * from './file';+export * from './interests';export * from './klavis';export * from './layoutTokens';export * from './lobehubSkill';diff --git a/packages/const/src/interests.test.ts b/packages/const/src/interests.test.tsnew file mode 100644index 00000000000..1eba170298d--- /dev/null+++ b/packages/const/src/interests.test.ts@@ -0,0 +1,19 @@+import { describe, expect, it } from 'vitest';++import { normalizeInterestsForStorage, resolveInterestAreaKey } from './interests';++describe('interests', () => {+ it('resolves canonical keys only', () => {+ expect(resolveInterestAreaKey('coding')).toBe('coding');+ expect(resolveInterestAreaKey(' coding ')).toBe('coding');+ expect(resolveInterestAreaKey('็ผ็จไธๅผๅ')).toBeUndefined();+ expect(resolveInterestAreaKey('interests.area.personal')).toBeUndefined();+ });++ it('dedupes predefined keys while preserving freeform values', () => {+ expect(normalizeInterestsForStorage([' coding ', '้่', 'coding', ' ้่ '])).toEqual([+ 'coding',+ '้่',+ ]);+ });+});diff --git a/packages/const/src/interests.ts b/packages/const/src/interests.tsnew file mode 100644index 00000000000..2df0501f725--- /dev/null+++ b/packages/const/src/interests.ts@@ -0,0 +1,53 @@+export const INTEREST_AREA_KEYS = [+ 'writing',+ 'coding',+ 'design',+ 'education',+ 'business',+ 'marketing',+ 'product',+ 'sales',+ 'operations',+ 'hr',+ 'finance-legal',+ 'creator',+ 'investing',+ 'parenting',+ 'health',+ 'hobbies',+ 'personal',+] as const;++export type InterestAreaKey = (typeof INTEREST_AREA_KEYS)[number];++const interestAreaKeySet = new Set<string>(INTEREST_AREA_KEYS);++export const isInterestAreaKey = (value: string): value is InterestAreaKey =>+ interestAreaKeySet.has(value);++export const resolveInterestAreaKey = (value: string): InterestAreaKey | undefined => {+ const normalized = value.trim();++ return isInterestAreaKey(normalized) ? normalized : undefined;+};++export const normalizeInterestsForStorage = (interests: readonly string[]): string[] => {+ const result: string[] = [];+ const seen = new Set<string>();++ for (const interest of interests) {+ const trimmed = interest.trim();+ if (!trimmed) continue;++ const areaKey = resolveInterestAreaKey(trimmed);+ const normalized = areaKey ?? trimmed;+ const dedupeKey = areaKey ? `area:${areaKey}` : `raw:${trimmed}`;++ if (seen.has(dedupeKey)) continue;++ seen.add(dedupeKey);+ result.push(normalized);+ }++ return result;+};diff --git a/packages/const/src/taskTemplate.test.ts b/packages/const/src/taskTemplate.test.tsindex 2bc91551f79..2501f384f46 100644--- a/packages/const/src/taskTemplate.test.ts+++ b/packages/const/src/taskTemplate.test.ts@@ -1,30 +1,11 @@import { parseCronPattern } from '@lobechat/utils/cron';import { describe, expect, it } from 'vitest';+import { INTEREST_AREA_KEYS } from './interests';import { TASK_TEMPLATE_FALLBACK_CATEGORIES, taskTemplates } from './taskTemplate';const CRON_FIELDS = 5;-// Keep in sync with INTEREST_AREAS in lobehub/src/routes/onboarding/config.ts โ-// those are the only values `users.interests` can hold.-const VALID_INTEREST_KEYS = new Set([- 'writing',- 'coding',- 'design',- 'education',- 'business',- 'marketing',- 'product',- 'sales',- 'operations',- 'hr',- 'finance-legal',- 'creator',- 'investing',- 'parenting',- 'health',- 'hobbies',- 'personal',-]);+const VALID_INTEREST_KEYS = new Set(INTEREST_AREA_KEYS);describe('taskTemplates', () => {it('has the expected number of templates', () => {diff --git a/packages/const/src/taskTemplate.ts b/packages/const/src/taskTemplate.tsindex b08cc8351a5..ddb4096e8ef 100644--- a/packages/const/src/taskTemplate.ts+++ b/packages/const/src/taskTemplate.ts@@ -1,9 +1,11 @@+import type { InterestAreaKey } from './interests';+/*** Task Template catalog used by home "Try following tasks" recommendation.* I18n keys: `taskTemplate:${id}.title|description|prompt`.*- * `interests` values must be keys from `INTEREST_AREAS` in- * `src/routes/onboarding/config.ts` โ that's what `users.interests` stores.+ * `interests` values must be canonical interest area keys โ that's what+ * predefined `users.interests` entries store.*//**@@ -21,7 +23,7 @@ export interface TaskTemplate {/** Optional icon identifier; consumers resolve it to a component. */icon?: TaskTemplateIcon;id: string;- interests: string[];+ interests: InterestAreaKey[];/** Skills that enrich the brief but are not required to run it. */optionalSkills?: TaskTemplateSkillRequirement[];/** Skill dependencies. The `source` field routes the connection flow. */diff --git a/packages/context-engine/src/providers/OnboardingActionHintInjector.ts b/packages/context-engine/src/providers/OnboardingActionHintInjector.tsindex f931d8963bc..2f30f8e907a 100644--- a/packages/context-engine/src/providers/OnboardingActionHintInjector.ts+++ b/packages/context-engine/src/providers/OnboardingActionHintInjector.ts@@ -95,7 +95,7 @@ export class OnboardingActionHintInjector extends BaseVirtualLastUserContentProv);} else if (phase.includes('Discovery')) {hints.push(- 'Each turn where you learn a new fact (pain point, goal, preference, workflow detail, interest), call updateDocument(type="persona") BEFORE replying. Preferred shape: `{ mode: "insertAt", line: <line shown in <current_user_persona>>, content: "- new fact" }`. This is the default every turn โ not an end-of-phase action. Do NOT save facts only in memory waiting for a final full write. After sufficient discovery (5-6 exchanges), also call saveUserQuestion with interests. The preferred reply language is configured before onboarding starts and is already injected into your system prompt โ do not ask about it or pass a responseLanguage field to saveUserQuestion. Use writeDocument(type="persona") only if the document is still empty.',+ 'Each turn where you learn a new fact (pain point, goal, preference, workflow detail, interest), call updateDocument(type="persona") BEFORE replying. Preferred shape: `{ mode: "insertAt", line: <line shown in <current_user_persona>>, content: "- new fact" }`. This is the default every turn โ not an end-of-phase action. Do NOT save facts only in memory waiting for a final full write. After sufficient discovery (5-6 exchanges), also call saveUserQuestion with interests and/or customInterests. The preferred reply language is configured before onboarding starts and is already injected into your system prompt โ do not ask about it or pass a responseLanguage field to saveUserQuestion. Use writeDocument(type="persona") only if the document is still empty.',);hints.push('EARLY EXIT: A true early-exit signal is the user explicitly wanting to END onboarding (e.g., "ๆ็ดฏไบ", "ๆๅ ่ตฐ", "ไธๆฌกๅ่", "ๆฒก็ฉบ", "ๆๆถไธๅผไบ", "็ปๆๅง", "Thanks, that\'s enough", "I have to go"). Short affirmations like "ๅฅฝ็" / "่ก" / "ๅฏ" / "ok" are NOT early-exit signals โ they confirm what you just said and you should keep exploring or move toward summary normally. When you see a real exit signal: stop exploring, save whatever fields you have (call saveUserQuestion with interests even if partial), present a brief summary, then call `showAgentMarketplace` and only after it resolves call `finishOnboarding`. Do NOT skip the marketplace step unless the user explicitly cancels/skips the picker.',diff --git a/packages/types/src/user/agentOnboarding.test.ts b/packages/types/src/user/agentOnboarding.test.tsindex 589de236ec7..4bb02f01a5e 100644--- a/packages/types/src/user/agentOnboarding.test.ts+++ b/packages/types/src/user/agentOnboarding.test.ts@@ -6,12 +6,14 @@ describe('SaveUserQuestionInputSchema', () => {it('accepts the flat structured payload', () => {const parsed = SaveUserQuestionInputSchema.parse({fullName: 'Ada Lovelace',- interests: ['AI tooling'],+ customInterests: ['AI tooling'],+ interests: ['coding'],});expect(parsed).toEqual({+ customInterests: ['AI tooling'],fullName: 'Ada Lovelace',- interests: ['AI tooling'],+ interests: ['coding'],});});@@ -31,11 +33,13 @@ describe('SaveUserQuestionInputSchema', () => {it('drops empty interests entries and an all-empty array', () => {const partial = SaveUserQuestionInputSchema.parse({- interests: ['AI tooling', '', ' '],+ customInterests: ['AI tooling', '', ' '],+ interests: ['coding', '', ' '],});- expect(partial).toEqual({ interests: ['AI tooling'] });+ expect(partial).toEqual({ customInterests: ['AI tooling'], interests: ['coding'] });const allEmpty = SaveUserQuestionInputSchema.parse({+ customInterests: ['', ' '],fullName: 'Ada',interests: ['', ' '],});diff --git a/packages/types/src/user/agentOnboarding.ts b/packages/types/src/user/agentOnboarding.tsindex b674c733d3a..e3db4110735 100644--- a/packages/types/src/user/agentOnboarding.ts+++ b/packages/types/src/user/agentOnboarding.ts@@ -5,12 +5,18 @@ export const SAVE_USER_QUESTION_FIELDS = ['agentName','fullName','interests',+ 'customInterests',] as const;-export const AGENT_ONBOARDING_STRUCTURED_FIELDS = SAVE_USER_QUESTION_FIELDS;+export const AGENT_ONBOARDING_STRUCTURED_FIELDS = [+ 'agentEmoji',+ 'agentName',+ 'fullName',+ 'interests',+] as const;export type SaveUserQuestionField = (typeof SAVE_USER_QUESTION_FIELDS)[number];-export type AgentOnboardingStructuredField = SaveUserQuestionField;+export type AgentOnboardingStructuredField = (typeof AGENT_ONBOARDING_STRUCTURED_FIELDS)[number];export const AGENT_ONBOARDING_NODES = ['agentIdentity',@@ -26,6 +32,7 @@ export type UserAgentOnboardingNode = (typeof AGENT_ONBOARDING_NODES)[number];export interface SaveUserQuestionInput {agentEmoji?: string;agentName?: string;+ customInterests?: string[];fullName?: string;interests?: string[];}@@ -139,7 +146,7 @@ export type OnboardingPhase = (typeof ONBOARDING_PHASES)[number];export interface UserAgentOnboardingContext {discoveryUserMessageCount?: number;finished: boolean;- missingStructuredFields: SaveUserQuestionField[];+ missingStructuredFields: AgentOnboardingStructuredField[];phase: OnboardingPhase;remainingDiscoveryExchanges?: number;topicId?: string;@@ -187,13 +194,14 @@ const OptionalTrimmedNonEmptyStringArraySchema = z.optional();export const SaveUserQuestionFieldSchema = z.enum(SAVE_USER_QUESTION_FIELDS);-export const AgentOnboardingStructuredFieldSchema = SaveUserQuestionFieldSchema;+export const AgentOnboardingStructuredFieldSchema = z.enum(AGENT_ONBOARDING_STRUCTURED_FIELDS);export const UserAgentOnboardingNodeSchema = z.enum(AGENT_ONBOARDING_NODES);export const SaveUserQuestionInputSchema = z.object({agentEmoji: OptionalTrimmedNonEmptyStringSchema,agentName: OptionalTrimmedNonEmptyStringSchema,+ customInterests: OptionalTrimmedNonEmptyStringArraySchema,fullName: OptionalTrimmedNonEmptyStringSchema,interests: OptionalTrimmedNonEmptyStringArraySchema,})@@ -205,7 +213,7 @@ export const UserAgentOnboardingContextSchema = z.object({discoveryUserMessageCount: z.number().optional(),finished: z.boolean(),- missingStructuredFields: z.array(SaveUserQuestionFieldSchema),+ missingStructuredFields: z.array(AgentOnboardingStructuredFieldSchema),phase: OnboardingPhaseSchema,remainingDiscoveryExchanges: z.number().optional(),topicId: z.string().optional(),diff --git a/src/features/Onboarding/Common/index.test.tsx b/src/features/Onboarding/Common/index.test.tsxindex a0440be3cef..20a1ec455da 100644--- a/src/features/Onboarding/Common/index.test.tsx+++ b/src/features/Onboarding/Common/index.test.tsx@@ -32,6 +32,9 @@ const renderCommon = async ({AGENT_ONBOARDING_ENABLED,}));vi.doMock('@lobechat/const', () => ({ isDesktop: desktop }));+ vi.doMock('@lobehub/ui', () => ({+ Flexbox: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,+ }));vi.doMock('@/components/Loading/BrandTextLoading', () => ({default: ({ debugId }: { debugId: string }) => <div>Loading:{debugId}</div>,}));@@ -91,6 +94,7 @@ afterEach(() => {cleanup();vi.doUnmock('@lobechat/business-const');vi.doUnmock('@lobechat/const');+ vi.doUnmock('@lobehub/ui');vi.doUnmock('@/components/Loading/BrandTextLoading');vi.doUnmock('@/routes/onboarding/_layout');vi.doUnmock('@/routes/onboarding/features/TelemetryStep');diff --git a/src/features/Onboarding/Common/index.tsx b/src/features/Onboarding/Common/index.tsxindex 3fb1ea169dc..c49073dd8a1 100644--- a/src/features/Onboarding/Common/index.tsx+++ b/src/features/Onboarding/Common/index.tsx@@ -8,7 +8,7 @@ import { Navigate, useSearchParams } from 'react-router-dom';import Loading from '@/components/Loading/BrandTextLoading';import OnboardingContainer from '@/routes/onboarding/_layout';-import { deriveOnboardingBranchPath } from '@/routes/onboarding/config';+import { deriveOnboardingBranchPath } from '@/routes/onboarding/branch';import ResponseLanguageStep from '@/routes/onboarding/features/ResponseLanguageStep';import TelemetryStep from '@/routes/onboarding/features/TelemetryStep';import { useServerConfigStore } from '@/store/serverConfig';diff --git a/src/features/RecommendTaskTemplates/useResolvedInterestKeys.ts b/src/features/RecommendTaskTemplates/useResolvedInterestKeys.tsindex 810eb8dd669..9fbcbcd5c3d 100644--- a/src/features/RecommendTaskTemplates/useResolvedInterestKeys.ts+++ b/src/features/RecommendTaskTemplates/useResolvedInterestKeys.ts@@ -1,45 +1,26 @@import { useMemo } from 'react';-import { useTranslation } from 'react-i18next';-import { INTEREST_AREAS } from '@/routes/onboarding/config';import { useUserStore } from '@/store/user';import { userProfileSelectors } from '@/store/user/selectors';import { authSelectors } from '@/store/user/slices/auth/selectors';/**- * onboarding stores localized labels in `user.interests` (e.g. "ๅ ๅฎนๅไฝ",- * "Content Creation") plus occasional freeform text. Resolve each entry back- * to an INTEREST_AREAS key via the current-locale onboarding translations so- * the server can intersection-match against template.interests (which hold- * canonical keys). Unresolved entries are lowercased passthroughs โ server- * treats them as non-matching.+ * Predefined interests are stored as canonical INTEREST_AREAS keys. Freeform+ * entries are lowercased passthroughs โ the server treats them as non-matching.*- * Returns `null` while either:- * - the user store hasn't finished hydrating (`interests` is `[]` until then,- * which would fire an SWR request with empty keys and immediately re-fire- * once the real interests land โ wasted round trip), or- * - the onboarding namespace is still loading (lazy-loaded, not in startup- * bundle; without this gate localized labels resolve to passthrough strings- * on first render and re-resolve correctly after the namespace lands).+ * Returns `null` while the user store hasn't finished hydrating (`interests`+ * is `[]` until then, which would fire an SWR request with empty keys and+ * immediately re-fire once the real interests land โ wasted round trip).** Callers should keep SWR disabled while null.*/export const useResolvedInterestKeys = (): string[] | null => {const isUserLoaded = useUserStore(authSelectors.isLoaded);const userInterests = useUserStore(userProfileSelectors.interests);- const { t, ready } = useTranslation('onboarding');return useMemo(() => {- if (!isUserLoaded || !ready) return null;- const labelToKey = new Map<string, string>();- for (const area of INTEREST_AREAS) {- labelToKey.set(area.key, area.key);- const translated = t(`interests.area.${area.key}`, { defaultValue: '' });- if (translated) labelToKey.set(translated.trim().toLowerCase(), area.key);- }- return userInterests.map((raw) => {- const k = raw.trim().toLowerCase();- return labelToKey.get(k) ?? k;- });- }, [isUserLoaded, userInterests, t, ready]);+ if (!isUserLoaded) return null;++ return userInterests.map((raw) => raw.trim().toLocaleLowerCase()).filter(Boolean);+ }, [isUserLoaded, userInterests]);};diff --git a/src/routes/(main)/settings/profile/features/InterestsRow.test.tsx b/src/routes/(main)/settings/profile/features/InterestsRow.test.tsxnew file mode 100644index 00000000000..108091b830b--- /dev/null+++ b/src/routes/(main)/settings/profile/features/InterestsRow.test.tsx@@ -0,0 +1,112 @@+import { cleanup, render, screen, waitFor } from '@testing-library/react';+import userEvent from '@testing-library/user-event';+import type { MouseEventHandler, ReactNode } from 'react';+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';++import InterestsRow from './InterestsRow';++const mocks = vi.hoisted(() => ({+ interests: [] as string[],+ updateInterests: vi.fn(),+}));++vi.mock('@lobehub/ui', () => ({+ Block: ({+ children,+ onClick,+ }: {+ children: ReactNode;+ onClick?: MouseEventHandler<HTMLButtonElement>;+ }) => (+ <button type="button" onClick={onClick}>+ {children}+ </button>+ ),+ Flexbox: ({ children }: { children: ReactNode }) => <div>{children}</div>,+ Icon: () => null,+ Input: () => null,+ Text: ({ children }: { children: ReactNode }) => <span>{children}</span>,+}));++vi.mock('react-i18next', () => ({+ useTranslation: (namespace: string) => ({+ t: (key: string) => {+ if (namespace === 'auth') {+ return ({ 'profile.interests': 'Interests' } as Record<string, string>)[key] ?? key;+ }++ return (+ (+ {+ 'interests.area.coding': '็ผ็จไธๅผๅ',+ 'interests.area.other': 'ๅ ถไป้ขๅ',+ 'interests.area.writing': 'ๅ ๅฎนๅไฝ',+ } as Record<string, string>+ )[key] ?? key+ );+ },+ }),+}));++vi.mock('@/components/Error/fetchErrorNotification', () => ({+ fetchErrorNotification: {+ error: vi.fn(),+ },+}));++vi.mock('@/store/user', () => ({+ useUserStore: (selector: (state: Record<string, unknown>) => unknown) =>+ selector({+ updateInterests: mocks.updateInterests,+ user: { interests: mocks.interests },+ }),+}));++vi.mock('@/store/user/selectors', () => ({+ userProfileSelectors: {+ interests: (state: { user?: { interests?: string[] } }) => state.user?.interests ?? [],+ },+}));++vi.mock('./ProfileRow', () => ({+ default: ({ children, label }: { children: ReactNode; label: string }) => (+ <section aria-label={label}>{children}</section>+ ),+}));++beforeEach(() => {+ mocks.interests = [];+ mocks.updateInterests.mockReset();+ mocks.updateInterests.mockResolvedValue(undefined);+});++afterEach(() => {+ cleanup();+});++describe('InterestsRow', () => {+ it('stores predefined interests as canonical keys', async () => {+ const user = userEvent.setup();++ render(<InterestsRow />);++ await user.click(screen.getByRole('button', { name: '็ผ็จไธๅผๅ' }));++ await waitFor(() => {+ expect(mocks.updateInterests).toHaveBeenCalledWith(['coding']);+ });+ });++ it('removes predefined interests by canonical key', async () => {+ const user = userEvent.setup();+ mocks.interests = ['coding', '่ชๅฎไน'];++ render(<InterestsRow />);++ await user.click(screen.getByRole('button', { name: '็ผ็จไธๅผๅ' }));++ await waitFor(() => {+ expect(mocks.updateInterests).toHaveBeenCalledWith(['่ชๅฎไน']);+ });+ });+});diff --git a/src/routes/(main)/settings/profile/features/InterestsRow.tsx b/src/routes/(main)/settings/profile/features/InterestsRow.tsxindex 23a0e3cdb57..b65094f2032 100644--- a/src/routes/(main)/settings/profile/features/InterestsRow.tsx+++ b/src/routes/(main)/settings/profile/features/InterestsRow.tsx@@ -1,5 +1,7 @@'use client';+import type { InterestAreaKey } from '@lobechat/const';+import { normalizeInterestsForStorage, resolveInterestAreaKey } from '@lobechat/const';import { Block, Flexbox, Icon, Input, Text } from '@lobehub/ui';import { cssVar } from 'antd-style';import { BriefcaseIcon } from 'lucide-react';@@ -21,22 +23,10 @@ const InterestsRow = () => {const [customInput, setCustomInput] = useState('');const [showCustomInput, setShowCustomInput] = useState(false);const [saving, setSaving] = useState(false);+ const normalizedInterests = useMemo(() => normalizeInterestsForStorage(interests), [interests]);- const areas = useMemo(- () =>- INTEREST_AREAS.map((area) => ({- ...area,- label: tOnboarding(`interests.area.${area.key}`),- })),- [tOnboarding],- );-- const toggleInterest = useCallback(- async (label: string) => {- const updated = interests.includes(label)- ? interests.filter((i) => i !== label)- : [...interests, label];-+ const saveInterests = useCallback(+ async (updated: string[]) => {try {setSaving(true);await updateInterests(updated);@@ -50,36 +40,54 @@ const InterestsRow = () => {setSaving(false);}},- [interests, updateInterests],+ [updateInterests],+ );++ const areas = useMemo(+ () =>+ INTEREST_AREAS.map((area) => ({+ ...area,+ label: tOnboarding(`interests.area.${area.key}`),+ })),+ [tOnboarding],+ );++ const toggleInterest = useCallback(+ async (key: InterestAreaKey) => {+ const updated = normalizedInterests.includes(key)+ ? normalizedInterests.filter((i) => i !== key)+ : [...normalizedInterests, key];++ await saveInterests(updated);+ },+ [normalizedInterests, saveInterests],+ );++ const removeCustomInterest = useCallback(+ async (interest: string) => {+ const updated = normalizedInterests.filter((i) => i !== interest);++ await saveInterests(updated);+ },+ [normalizedInterests, saveInterests],);const handleAddCustom = useCallback(async () => {const trimmed = customInput.trim();- if (!trimmed || interests.includes(trimmed)) return;+ if (!trimmed || normalizedInterests.includes(trimmed)) return;- const updated = [...interests, trimmed];+ const updated = [...normalizedInterests, trimmed];setCustomInput('');- try {- setSaving(true);- await updateInterests(updated);- } catch (error) {- console.error('Failed to update interests:', error);- fetchErrorNotification.error({- errorMessage: error instanceof Error ? error.message : String(error),- status: 500,- });- } finally {- setSaving(false);- }- }, [customInput, interests, updateInterests]);+ await saveInterests(updated);+ }, [customInput, normalizedInterests, saveInterests]);return (<ProfileRow label={t('profile.interests')}><Flexbox gap={12}><Flexbox horizontal align="center" gap={8} wrap="wrap">{areas.map((item) => {- const isSelected = interests.includes(item.label);+ const isSelected = normalizedInterests.includes(item.key);return (<Blockclickable@@ -97,7 +105,7 @@ const InterestsRow = () => {}: { opacity: saving ? 0.6 : 1 }}- onClick={() => !saving && toggleInterest(item.label)}+ onClick={() => !saving && toggleInterest(item.key)}><Icon color={cssVar.colorTextSecondary} icon={item.icon} size={14} /><Text fontSize={13} weight={500}>@@ -106,8 +114,8 @@ const InterestsRow = () => {</Block>);})}- {interests- .filter((i) => !areas.some((a) => a.label === i))+ {normalizedInterests+ .filter((i) => !resolveInterestAreaKey(i)).map((interest) => (<Blockclickable@@ -119,7 +127,7 @@ const InterestsRow = () => {borderColor: cssVar.colorFillSecondary,opacity: saving ? 0.6 : 1,}}- onClick={() => !saving && toggleInterest(interest)}+ onClick={() => !saving && removeCustomInterest(interest)}><Text fontSize={13} weight={500}>{interest}diff --git a/src/routes/onboarding/branch.ts b/src/routes/onboarding/branch.tsnew file mode 100644index 00000000000..41a0ff633d7--- /dev/null+++ b/src/routes/onboarding/branch.ts@@ -0,0 +1,26 @@+import { AGENT_ONBOARDING_ENABLED } from '@lobechat/business-const';++export const ONBOARDING_AGENT_PATH = '/onboarding/agent';+export const ONBOARDING_CLASSIC_PATH = '/onboarding/classic';++export type OnboardingBranchPath = typeof ONBOARDING_AGENT_PATH | typeof ONBOARDING_CLASSIC_PATH;++interface DeriveOnboardingBranchInput {+ enableAgentOnboarding: boolean;+ isDesktop: boolean;+}++/**+ * Decide which branch the user enters after the shared-prefix steps complete.+ * `AGENT_ONBOARDING_ENABLED` is the build-time master switch, so the agent+ * flow stays unreachable when it is disabled regardless of runtime flags.+ */+export const deriveOnboardingBranchPath = ({+ enableAgentOnboarding,+ isDesktop,+}: DeriveOnboardingBranchInput): OnboardingBranchPath => {+ if (!AGENT_ONBOARDING_ENABLED || isDesktop || !enableAgentOnboarding) {+ return ONBOARDING_CLASSIC_PATH;+ }+ return ONBOARDING_AGENT_PATH;+};diff --git a/src/routes/onboarding/config.ts b/src/routes/onboarding/config.tsindex a44d01f90d5..68073a2fba4 100644--- a/src/routes/onboarding/config.ts+++ b/src/routes/onboarding/config.ts@@ -1,4 +1,6 @@-import { AGENT_ONBOARDING_ENABLED } from '@lobechat/business-const';+import type { InterestAreaKey } from '@lobechat/const';+import { INTEREST_AREA_KEYS } from '@lobechat/const';+import type { LucideIcon } from 'lucide-react';import {BabyIcon,CameraIcon,@@ -19,55 +21,40 @@ import {UsersIcon,} from 'lucide-react';-export const ONBOARDING_AGENT_PATH = '/onboarding/agent';-export const ONBOARDING_CLASSIC_PATH = '/onboarding/classic';--export type OnboardingBranchPath = typeof ONBOARDING_AGENT_PATH | typeof ONBOARDING_CLASSIC_PATH;--interface DeriveOnboardingBranchInput {- enableAgentOnboarding: boolean;- isDesktop: boolean;-}--/**- * Decide which branch the user enters after the shared-prefix steps complete.- * `AGENT_ONBOARDING_ENABLED` is the build-time master switch โ when it is off,- * the agent flow is unreachable regardless of the runtime feature flag.- * Desktop and disabled-flag users also land on the classic flow; otherwise- * the agent conversational flow is the default.- */-export const deriveOnboardingBranchPath = ({- enableAgentOnboarding,- isDesktop,-}: DeriveOnboardingBranchInput): OnboardingBranchPath => {- if (!AGENT_ONBOARDING_ENABLED || isDesktop || !enableAgentOnboarding) {- return ONBOARDING_CLASSIC_PATH;- }- return ONBOARDING_AGENT_PATH;-};+export type { OnboardingBranchPath } from './branch';+export {+ deriveOnboardingBranchPath,+ ONBOARDING_AGENT_PATH,+ ONBOARDING_CLASSIC_PATH,+} from './branch';/*** Predefined interest areas with icons and translation keys.* Use with `t('interests.area.${key}')` from 'onboarding' namespace.*/-export const INTEREST_AREAS = [- { icon: PenIcon, key: 'writing' },- { icon: CodeXmlIcon, key: 'coding' },- { icon: PaintBucketIcon, key: 'design' },- { icon: GraduationCapIcon, key: 'education' },- { icon: ChartNetworkIcon, key: 'business' },- { icon: PercentIcon, key: 'marketing' },- { icon: TargetIcon, key: 'product' },- { icon: HandCoinsIcon, key: 'sales' },- { icon: SettingsIcon, key: 'operations' },- { icon: UsersIcon, key: 'hr' },- { icon: ScaleIcon, key: 'finance-legal' },- { icon: CameraIcon, key: 'creator' },- { icon: LineChartIcon, key: 'investing' },- { icon: BabyIcon, key: 'parenting' },- { icon: HeartIcon, key: 'health' },- { icon: CompassIcon, key: 'hobbies' },- { icon: HomeIcon, key: 'personal' },-] as const;+const INTEREST_AREA_ICONS: Record<InterestAreaKey, LucideIcon> = {+ 'business': ChartNetworkIcon,+ 'coding': CodeXmlIcon,+ 'creator': CameraIcon,+ 'design': PaintBucketIcon,+ 'education': GraduationCapIcon,+ 'finance-legal': ScaleIcon,+ 'health': HeartIcon,+ 'hobbies': CompassIcon,+ 'hr': UsersIcon,+ 'investing': LineChartIcon,+ 'marketing': PercentIcon,+ 'operations': SettingsIcon,+ 'parenting': BabyIcon,+ 'personal': HomeIcon,+ 'product': TargetIcon,+ 'sales': HandCoinsIcon,+ 'writing': PenIcon,+};++export const INTEREST_AREAS = INTEREST_AREA_KEYS.map((key) => ({+ icon: INTEREST_AREA_ICONS[key],+ key,+}));-export type InterestAreaKey = (typeof INTEREST_AREAS)[number]['key'];+export type { InterestAreaKey } from '@lobechat/const';diff --git a/src/routes/onboarding/features/InterestsStep.test.tsx b/src/routes/onboarding/features/InterestsStep.test.tsxnew file mode 100644index 00000000000..64c106d23ad--- /dev/null+++ b/src/routes/onboarding/features/InterestsStep.test.tsx@@ -0,0 +1,102 @@+import { cleanup, render, screen } from '@testing-library/react';+import userEvent from '@testing-library/user-event';+import type { MouseEventHandler, ReactNode } from 'react';+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';++import InterestsStep from './InterestsStep';++const mocks = vi.hoisted(() => ({+ interests: [] as string[],+ updateInterests: vi.fn(),+}));++vi.mock('@lobehub/ui', () => ({+ Block: ({+ children,+ onClick,+ }: {+ children: ReactNode;+ onClick?: MouseEventHandler<HTMLButtonElement>;+ }) => (+ <button type="button" onClick={onClick}>+ {children}+ </button>+ ),+ Button: ({+ children,+ disabled,+ onClick,+ }: {+ children: ReactNode;+ disabled?: boolean;+ onClick?: MouseEventHandler<HTMLButtonElement>;+ }) => (+ <button disabled={disabled} type="button" onClick={onClick}>+ {children}+ </button>+ ),+ Flexbox: ({ children }: { children: ReactNode }) => <div>{children}</div>,+ Icon: () => null,+ Input: () => null,+ Text: ({ children }: { children: ReactNode }) => <span>{children}</span>,+}));++vi.mock('react-i18next', () => ({+ useTranslation: () => ({+ t: (key: string) =>+ (+ ({+ 'back': 'Back',+ 'interests.area.coding': '็ผ็จไธๅผๅ',+ 'interests.area.other': 'ๅ ถไป้ขๅ',+ 'interests.area.writing': 'ๅ ๅฎนๅไฝ',+ 'interests.title': 'Title',+ 'interests.title2': 'Title 2',+ 'interests.title3': 'Title 3',+ 'next': 'Next',+ }) as Record<string, string>+ )[key] ?? key,+ }),+}));++vi.mock('@/store/user', () => ({+ useUserStore: (selector: (state: Record<string, unknown>) => unknown) =>+ selector({+ updateInterests: mocks.updateInterests,+ user: { interests: mocks.interests },+ }),+}));++vi.mock('@/store/user/selectors', () => ({+ userProfileSelectors: {+ interests: (state: { user?: { interests?: string[] } }) => state.user?.interests ?? [],+ },+}));++vi.mock('../components/LobeMessage', () => ({+ default: () => <div>Lobe Message</div>,+}));++beforeEach(() => {+ mocks.interests = [];+ mocks.updateInterests.mockReset();+});++afterEach(() => {+ cleanup();+});++describe('InterestsStep', () => {+ it('stores predefined interests as canonical keys', async () => {+ const user = userEvent.setup();+ const onNext = vi.fn();++ render(<InterestsStep onBack={vi.fn()} onNext={onNext} />);++ await user.click(screen.getByRole('button', { name: 'ๅ ๅฎนๅไฝ' }));+ await user.click(screen.getByRole('button', { name: 'Next' }));++ expect(mocks.updateInterests).toHaveBeenCalledWith(['writing']);+ expect(onNext).toHaveBeenCalled();+ });+});diff --git a/src/routes/onboarding/features/InterestsStep.tsx b/src/routes/onboarding/features/InterestsStep.tsxindex c98fb21ef97..9a18438b7af 100644--- a/src/routes/onboarding/features/InterestsStep.tsx+++ b/src/routes/onboarding/features/InterestsStep.tsx@@ -1,5 +1,6 @@'use client';+import { normalizeInterestsForStorage } from '@lobechat/const';import { Block, Button, Flexbox, Icon, Input, Text } from '@lobehub/ui';import { cssVar } from 'antd-style';import { BriefcaseIcon, Undo2Icon } from 'lucide-react';@@ -10,6 +11,7 @@ import { useUserStore } from '@/store/user';import { userProfileSelectors } from '@/store/user/selectors';import LobeMessage from '../components/LobeMessage';+import type { InterestAreaKey } from '../config';import { INTEREST_AREAS } from '../config';interface InterestsStepProps {@@ -22,7 +24,9 @@ const InterestsStep = memo<InterestsStepProps>(({ onBack, onNext }) => {const existingInterests = useUserStore(userProfileSelectors.interests);const updateInterests = useUserStore((s) => s.updateInterests);- const [selectedInterests, setSelectedInterests] = useState<string[]>(existingInterests);+ const [selectedInterests, setSelectedInterests] = useState<string[]>(() =>+ normalizeInterestsForStorage(existingInterests),+ );const [customInput, setCustomInput] = useState('');const [showCustomInput, setShowCustomInput] = useState(false);const [isNavigating, setIsNavigating] = useState(false);@@ -37,9 +41,9 @@ const InterestsStep = memo<InterestsStepProps>(({ onBack, onNext }) => {[t],);- const toggleInterest = useCallback((label: string) => {+ const toggleInterest = useCallback((key: InterestAreaKey) => {setSelectedInterests((prev) =>- prev.includes(label) ? prev.filter((i) => i !== label) : [...prev, label],+ prev.includes(key) ? prev.filter((i) => i !== key) : [...prev, key],);}, []);@@ -63,8 +67,7 @@ const InterestsStep = memo<InterestsStepProps>(({ onBack, onNext }) => {finalInterests.push(trimmedCustom);}- // Deduplicate- const uniqueInterests = [...new Set(finalInterests)];+ const uniqueInterests = normalizeInterestsForStorage(finalInterests);updateInterests(uniqueInterests);onNext();@@ -84,7 +87,7 @@ const InterestsStep = memo<InterestsStepProps>(({ onBack, onNext }) => {/><Flexbox horizontal align={'center'} gap={12} wrap={'wrap'}>{areas.map((item) => {- const isSelected = selectedInterests.includes(item.label);+ const isSelected = selectedInterests.includes(item.key);return (<Blockclickable@@ -101,7 +104,7 @@ const InterestsStep = memo<InterestsStepProps>(({ onBack, onNext }) => {}: {}}- onClick={() => toggleInterest(item.label)}+ onClick={() => toggleInterest(item.key)}><Icon color={cssVar.colorTextSecondary} icon={item.icon} size={16} /><Text fontSize={15} weight={500}>diff --git a/src/server/services/onboarding/index.test.ts b/src/server/services/onboarding/index.test.tsindex 64324c316ab..ad3312cc381 100644--- a/src/server/services/onboarding/index.test.ts+++ b/src/server/services/onboarding/index.test.ts@@ -211,8 +211,9 @@ describe('OnboardingService', () => {it('persists fullName and interests through saveUserQuestion', async () => {const service = new OnboardingService(mockDb, userId);const result = await service.saveUserQuestion({+ customInterests: ['AI tooling'],fullName: 'Ada Lovelace',- interests: ['AI tooling'],+ interests: ['coding'],});expect(result).toEqual({@@ -223,7 +224,7 @@ describe('OnboardingService', () => {unchangedFields: [],});expect(persistedUserState.fullName).toBe('Ada Lovelace');- expect(persistedUserState.interests).toEqual(['AI tooling']);+ expect(persistedUserState.interests).toEqual(['coding', 'AI tooling']);});it('ignores responseLanguage if the agent still tries to send it', async () => {diff --git a/src/server/services/onboarding/index.ts b/src/server/services/onboarding/index.tsindex a70439e31a8..dd017b8341a 100644--- a/src/server/services/onboarding/index.ts+++ b/src/server/services/onboarding/index.ts@@ -3,6 +3,7 @@ import { BUILTIN_AGENT_SLUGS } from '@lobechat/builtin-agents';import { CURRENT_ONBOARDING_VERSION } from '@lobechat/const';import type { OnboardingUserInfo } from '@lobechat/context-engine';import type {+ AgentOnboardingStructuredField,ChatTopicMetadata,MessagePluginItem,OnboardingPhase,@@ -40,6 +41,7 @@ import { AgentDocumentsService } from '@/server/services/agentDocuments';const STRUCTURED_FIELD_LABELS: Record<SaveUserQuestionField, string> = {agentEmoji: 'agent emoji',agentName: 'agent name',+ customInterests: 'custom interests',fullName: 'full name',interests: 'interests',};@@ -80,6 +82,14 @@ const normalizeUserInfoField = (value: unknown) => {return trimmed || undefined;};+const normalizeStringArray = (value: unknown) =>+ Array.isArray(value)+ ? value+ .filter((item): item is string => typeof item === 'string')+ .map((item) => item.trim())+ .filter(Boolean)+ : undefined;+const parseToolArguments = (value?: string) => {if (!value) return undefined;@@ -293,9 +303,9 @@ export class OnboardingService {return { created: true, topicId: topic.id };};- private getMissingStructuredFields = async (): Promise<SaveUserQuestionField[]> => {+ private getMissingStructuredFields = async (): Promise<AgentOnboardingStructuredField[]> => {const userState = await this.getUserState();- const missingFields: SaveUserQuestionField[] = [];+ const missingFields: AgentOnboardingStructuredField[] = [];// Agent identity fields โ stored on inbox agentconst inboxAgent = await this.agentModel.getBuiltinAgent(BUILTIN_AGENT_SLUGS.inbox);@@ -447,7 +457,7 @@ export class OnboardingService {};private derivePhase = async (- missingStructuredFields: SaveUserQuestionField[],+ missingStructuredFields: AgentOnboardingStructuredField[],discoveryContext?: { currentUserMessageCount: number; startUserMessageCount: number },): Promise<OnboardingPhase> => {if (missingStructuredFields.includes('agentName')) return 'agent_identity';@@ -598,11 +608,11 @@ export class OnboardingService {}}- const interests = Array.isArray(parsed.interests)- ? parsed.interests- .filter((item): item is string => typeof item === 'string')- .map((item) => item.trim())- .filter(Boolean)+ const interestKeys = normalizeStringArray(parsed.interests);+ const customInterests = normalizeStringArray(parsed.customInterests);+ const hasInterestInput = Boolean(interestKeys || customInterests);+ const interests = hasInterestInput+ ? [...new Set([...(interestKeys ?? []), ...(customInterests ?? [])])]: undefined;if (interests?.length) {if (JSON.stringify(interests) === JSON.stringify(userState.interests ?? [])) {diff --git a/src/server/services/taskTemplate/index.ts b/src/server/services/taskTemplate/index.tsindex 8e020589392..8a81c962561 100644--- a/src/server/services/taskTemplate/index.ts+++ b/src/server/services/taskTemplate/index.ts@@ -88,10 +88,6 @@ export const isTemplateSkillSourceEligible = (export class TaskTemplateService {constructor(private userId: string) {}- /**- * Client resolves user.interests (localized labels or raw values) to- * INTEREST_AREAS keys before calling โ see useResolvedInterestKeys in the UI.- */async listDailyRecommend(interestKeys: string[],options: {diff --git a/src/store/tool/slices/builtin/executors/lobe-web-onboarding.test.ts b/src/store/tool/slices/builtin/executors/lobe-web-onboarding.test.tsindex 0b281230733..c0813e7394f 100644--- a/src/store/tool/slices/builtin/executors/lobe-web-onboarding.test.ts+++ b/src/store/tool/slices/builtin/executors/lobe-web-onboarding.test.ts@@ -68,9 +68,18 @@ describe('webOnboardingExecutor', () => {properties: {agentEmoji: { description: expect.any(String), type: 'string' },agentName: { description: expect.any(String), type: 'string' },+ customInterests: {+ description: expect.any(String),+ items: { type: 'string' },+ type: 'array',+ },fullName: { type: 'string' },interests: {- items: { type: 'string' },+ description: expect.any(String),+ items: {+ enum: expect.arrayContaining(['coding', 'writing']),+ type: 'string',+ },type: 'array',},},