🤯 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
✨ feat(memory): one Self-evolving page — my rules first, then what each agent learned (#20261)
Arvin Xue0d304f4a716
diff --git a/locales/en-US/electron.json b/locales/en-US/electron.jsonindex 776880b6f39..7bafd88e0a7 100644--- a/locales/en-US/electron.json+++ b/locales/en-US/electron.json@@ -34,7 +34,7 @@"navigation.memoryContexts": "Memory - Contexts","navigation.memoryIdentities": "Memory - Identities","navigation.memoryPreferences": "Memory - Preferences",- "navigation.memoryRules": "Memory - Rules",+ "navigation.memoryRules": "Memory - Self-evolving","navigation.newChat": "New Chat","navigation.noPages": "No pages yet","navigation.onboarding": "Onboarding",diff --git a/locales/en-US/labs.json b/locales/en-US/labs.jsonindex e0843fef9bf..8445b21c387 100644--- a/locales/en-US/labs.json+++ b/locales/en-US/labs.json@@ -32,15 +32,13 @@"features.inputMarkdown.title": "Input Markdown Rendering","features.integrations.desc": "Show the Integrations settings page: connect the GitHub App so merged pull requests accept deliveries and failing checks or reviews reach the agent that opened them. Hidden by default.","features.integrations.title": "Integrations",- "features.memoryRules.desc": "Adds \"My rules\" under Memory: the delivery rules distilled from the acceptance rounds you sent back, with ordering, grouping and block / remind controls.",- "features.memoryRules.title": "My rules","features.messageTextSelectionActions.desc": "Show a quick action when selecting text in chat messages so the selected text can be added to the next conversation context.","features.messageTextSelectionActions.title": "Message Text Selection Actions","features.oauthApps.desc": "Show OAuth app management in personal and workspace settings. This feature is hidden by default.","features.oauthApps.title": "OAuth Apps","features.projects.desc": "Organize long-running goals into dedicated workspaces with their own agents, knowledge bases, and tasks.","features.projects.title": "Project Workspaces",- "features.selfLearning.desc": "Show what each agent has learned from real practice — its rule base, which rules actually get used, and which layers are still blank.",+ "features.selfLearning.desc": "Learn from practice: the rounds you send back become rules, and each agent picks up lessons from its own runs — both go with the agent into every run. See them all under Memory → Self-evolving.","features.selfLearning.title": "Self-evolving","features.taskVerify.desc": "Add an Acceptance section to the task detail: describe acceptance in one sentence and let AI generate editable verify criteria.","features.taskVerify.title": "Acceptance",diff --git a/locales/en-US/memory.json b/locales/en-US/memory.jsonindex 3bfe54cfc9e..f670b9a033c 100644--- a/locales/en-US/memory.json+++ b/locales/en-US/memory.json@@ -103,7 +103,6 @@"rules.archived.byYou": "archived by you","rules.archived.group": "Archived ({{count}})","rules.archived.mergedInto": "merged into \"{{title}}\"",- "rules.backlog": "{{count}} rejected rounds have not been read yet","rules.columns.code": "No.","rules.columns.enforcement": "Effect","rules.columns.method": "Check",@@ -132,9 +131,6 @@"rules.compose.submit": "Save","rules.compose.titlePlaceholder": "The rule in one sentence","rules.compose.why": "Why it matters (optional)",- "rules.empty.description": "Rules grow out of the checks you send back — the reason you wrote, and the spot you circled.",- "rules.empty.title": "No rules yet",- "rules.empty.write": "Or write one first","rules.enforcement.block": "Block","rules.enforcement.blockDesc": "Will hold the delivery until you let it through. Not in effect yet: for now it only reminds","rules.enforcement.blockHint": "Block: will hold the delivery (not in effect yet, reminds for now). Click to switch to remind",@@ -174,9 +170,9 @@"rules.group.scope": "· applies to {{scopes}}","rules.group.submitCreate": "Create","rules.group.submitRename": "Save",- "rules.labOff.description": "Turn it on under Settings → Labs to see the delivery rules distilled from the rounds you sent back.",+ "rules.labOff.description": "Turn on Self-evolving under Settings → Labs to see your rules and what each agent has learned.","rules.labOff.open": "Open Labs",- "rules.labOff.title": "My rules is still in the lab",+ "rules.labOff.title": "Self-evolving is still in the lab","rules.merge.banner": "Click the rule to merge into — \"{{title}}\" will be archived and its sources and counts move over.","rules.merge.cancel": "Cancel","rules.meta.enforcement": "Effect",@@ -188,6 +184,19 @@"rules.method.compilable": "Program-assisted","rules.method.compiled": "By program","rules.method.not-compilable": "By judgement",+ "rules.onboarding.agents.action": "View",+ "rules.onboarding.agents.description": "{{name}} has learned {{count}} on its own",+ "rules.onboarding.agents.descriptionMany": "{{agents}} agents have learned {{count}} on their own",+ "rules.onboarding.agents.title": "What agents learned",+ "rules.onboarding.backlog": "{{count}} rounds not read yet",+ "rules.onboarding.description": "Say one thing you expect from a delivery, or paste a guideline you have; it becomes a checkable rule.",+ "rules.onboarding.descriptionGrow": "Reasons you write when sending an acceptance back grow into rules here too.",+ "rules.onboarding.listTitle": "Rules also come from",+ "rules.onboarding.reject.action": "Open",+ "rules.onboarding.reject.description": "Reject a check and say why; it is distilled when the next round lands",+ "rules.onboarding.reject.title": "Send back an acceptance",+ "rules.onboarding.title": "Write your first rule",+ "rules.onboarding.write": "Write a rule","rules.origin.authored": "You wrote it","rules.origin.distilled": "You sent {{hits}} rounds back over this","rules.origin.distilledAndObserved": "You sent {{rejections}} rounds back over this; it also came up {{conversations}} times in conversations",@@ -197,6 +206,9 @@"rules.origin.observed": "Learned from conversations, where it came up {{hits}} times","rules.origin.oneOff": "Looks like a request about that one delivery; it becomes a standing rule once another delivery is sent back for it","rules.origin.overSpecific": "Looks tied to one page; may belong in a broader rule",+ "rules.origin.taught": "You taught it to this agent",+ "rules.owner.mine": "My rules",+ "rules.owner.untitledAgent": "Untitled agent","rules.reason.inferred": "inferred, you never said it","rules.reason.mechanism": "Has a reason","rules.reason.reviewer": "in your words",@@ -232,17 +244,20 @@"rules.sources.rejected": "you said it learned this wrong","rules.sources.retry": "Try again","rules.sources.round": "round {{index}}",+ "rules.sources.taughtEmpty": "You taught this to the agent; no feedback on record yet.","rules.sources.title": "Where it came from",- "rules.subtitle": "{{count}} in use · the agent checks every delivery against them · what you say when sending a round back lands here",+ "rules.subtitle": "{{rules}} rules of yours · {{lessons}} lessons your agents learned on their own · all of them go with the agent into every run",+ "rules.subtitleAgentsOnly": "{{lessons}} lessons your agents learned on their own · all of them go with the agent into every run","rules.tag.authored": "yours","rules.tag.oneOff": "one-off",- "rules.title": "My rules",+ "rules.tag.taught": "taught",+ "rules.title": "Self-evolving","tab.activities": "Activities","tab.contexts": "Contexts","tab.home": "Home","tab.identities": "Identities","tab.preferences": "Preferences",- "tab.rules": "Rules",+ "tab.rules": "Self-evolving","tab.search": "Search","viewMode.masonry": "Masonry","viewMode.timeline": "Timeline"diff --git a/locales/zh-CN/electron.json b/locales/zh-CN/electron.jsonindex 57d2e17c2ff..34adc1e7e19 100644--- a/locales/zh-CN/electron.json+++ b/locales/zh-CN/electron.json@@ -34,7 +34,7 @@"navigation.memoryContexts": "记忆 - 上下文","navigation.memoryIdentities": "记忆 - 身份","navigation.memoryPreferences": "记忆 - 偏好",- "navigation.memoryRules": "记忆 - 规矩",+ "navigation.memoryRules": "记忆 - 自进化","navigation.newChat": "新建对话","navigation.noPages": "暂无页面","navigation.onboarding": "引导",diff --git a/locales/zh-CN/labs.json b/locales/zh-CN/labs.jsonindex ad3b3d728f5..b3cb1f9712b 100644--- a/locales/zh-CN/labs.json+++ b/locales/zh-CN/labs.json@@ -32,15 +32,13 @@"features.inputMarkdown.title": "输入框 Markdown 渲染","features.integrations.desc": "显示「集成」设置页:连接 GitHub App 后,合并 PR 自动验收通过,CI 失败或评审意见会送到开这个 PR 的智能体。默认隐藏。","features.integrations.title": "集成",- "features.memoryRules.desc": "在「记忆」下增加「我的规矩」:从你打回的验收轮次里沉淀出来的交付规矩,可以排序、分组,并设置拦下或提醒。",- "features.memoryRules.title": "我的规矩","features.messageTextSelectionActions.desc": "在聊天消息中选中文本时显示快捷操作,可将选中的文本加入下一次对话上下文。","features.messageTextSelectionActions.title": "消息文本选择操作","features.oauthApps.desc": "在个人和工作区设置中显示 OAuth 应用管理入口。此功能默认隐藏。","features.oauthApps.title": "OAuth 应用","features.projects.desc": "将长期目标组织到独立工作空间中,并集中管理相关智能体、资料库与任务。","features.projects.title": "项目工作空间",- "features.selfLearning.desc": "看见每个 agent 从真实实践里学到了什么 —— 它的规则库、哪些规则真的用得上、哪几层还是空的。",+ "features.selfLearning.desc": "从实践中学习:你打回的验收会沉淀成规矩,每个 Agent 也会从自己的运行里学到经验,运行时都会带给 Agent。在「记忆 → 自进化」里统一查看。","features.selfLearning.title": "自进化","features.taskVerify.desc": "在任务详情里增加「交付验收」模块:一句话描述验收要求,AI 自动生成可编辑的验收项。","features.taskVerify.title": "任务交付验收",diff --git a/locales/zh-CN/memory.json b/locales/zh-CN/memory.jsonindex f4485f50ea1..58441b36a6a 100644--- a/locales/zh-CN/memory.json+++ b/locales/zh-CN/memory.json@@ -103,7 +103,6 @@"rules.archived.byYou": "你归档的","rules.archived.group": "已归档({{count}})","rules.archived.mergedInto": "并入了「{{title}}」",- "rules.backlog": "还有 {{count}} 轮打回没被读过","rules.columns.code": "编号","rules.columns.enforcement": "效力","rules.columns.method": "验法",@@ -132,9 +131,6 @@"rules.compose.submit": "记下","rules.compose.titlePlaceholder": "一句话说清这条规矩","rules.compose.why": "为什么这样要求(可不填)",- "rules.empty.description": "规矩是从你打回的检查项里长出来的——你写下的理由,和你圈出的那一处。",- "rules.empty.title": "还没有规矩",- "rules.empty.write": "也可以先写一条","rules.enforcement.block": "拦","rules.enforcement.blockDesc": "将拦下交付,直到你放行。尚未生效,目前仍只提醒","rules.enforcement.blockHint": "拦:将拦下交付(尚未生效,目前仍只提醒)。点一下改成提醒",@@ -174,9 +170,9 @@"rules.group.scope": "· 生效于 {{scopes}}","rules.group.submitCreate": "建组","rules.group.submitRename": "保存",- "rules.labOff.description": "到「设置 → 实验室」里打开它,就能看到从你打回的那些轮里沉淀出来的交付规矩。",+ "rules.labOff.description": "到「设置 → 实验室」打开「自进化」,就能看到你的规矩和每个 Agent 自己学到的经验。","rules.labOff.open": "打开实验室",- "rules.labOff.title": "「我的规矩」还在实验室里",+ "rules.labOff.title": "「自进化」还在实验室里","rules.merge.banner": "点一条要并进去的规矩——「{{title}}」会归档,它的来源和次数记到目标上。","rules.merge.cancel": "取消","rules.meta.enforcement": "效力",@@ -188,6 +184,19 @@"rules.method.compilable": "可程序验","rules.method.compiled": "程序验","rules.method.not-compilable": "靠判断",+ "rules.onboarding.agents.action": "查看",+ "rules.onboarding.agents.description": "{{name}} 已经自己学到 {{count}} 条",+ "rules.onboarding.agents.descriptionMany": "{{agents}} 个 Agent 已经自己学到 {{count}} 条",+ "rules.onboarding.agents.title": "Agent 学到的",+ "rules.onboarding.backlog": "{{count}} 轮还没读",+ "rules.onboarding.description": "说一句你的交付要求,或贴一段现成规范,整理成可检查的规矩。",+ "rules.onboarding.descriptionGrow": "你打回验收时写下的理由,也会自动长到这里。",+ "rules.onboarding.listTitle": "规矩还会从这些地方来",+ "rules.onboarding.reject.action": "去验收",+ "rules.onboarding.reject.description": "在验收里打回一项并写下理由,下一轮交付后沉淀成规矩",+ "rules.onboarding.reject.title": "打回验收",+ "rules.onboarding.title": "写下你的第一条规矩",+ "rules.onboarding.write": "写一条","rules.origin.authored": "你自己写的","rules.origin.distilled": "你为这事打回过 {{hits}} 次","rules.origin.distilledAndObserved": "你为这事打回过 {{rejections}} 次,对话里另出现过 {{conversations}} 次",@@ -197,6 +206,9 @@"rules.origin.observed": "从对话里学到的,出现过 {{hits}} 次","rules.origin.oneOff": "看起来是针对那一次交付的具体意见,再有一次交付因它被打回,才算通用规矩","rules.origin.overSpecific": "看起来只对某个页面成立,可能该并进更通用的那条",+ "rules.origin.taught": "你教给它的",+ "rules.owner.mine": "我的规矩",+ "rules.owner.untitledAgent": "未命名 Agent","rules.reason.inferred": "推断出来的,你没说过","rules.reason.mechanism": "有依据","rules.reason.reviewer": "你说过的",@@ -232,17 +244,20 @@"rules.sources.rejected": "你说这条学错了","rules.sources.retry": "重试","rules.sources.round": "第 {{index}} 轮",+ "rules.sources.taughtEmpty": "你亲手教给它的,还没有反馈记录。","rules.sources.title": "它从哪来",- "rules.subtitle": "{{count}} 条在用 · 交付前 Agent 会逐条对照 · 打回验收时说的话会记到这里",+ "rules.subtitle": "{{rules}} 条我的规矩 · Agent 自己学到 {{lessons}} 条 · 每次运行都会带给 Agent",+ "rules.subtitleAgentsOnly": "Agent 自己学到 {{lessons}} 条 · 每次运行都会带给 Agent","rules.tag.authored": "你写的","rules.tag.oneOff": "一次性",- "rules.title": "我的规矩",+ "rules.tag.taught": "你教的",+ "rules.title": "自进化","tab.activities": "活动","tab.contexts": "情境","tab.home": "首页","tab.identities": "身份","tab.preferences": "偏好",- "tab.rules": "规矩",+ "tab.rules": "自进化","tab.search": "搜索","viewMode.masonry": "瀑布流","viewMode.timeline": "时间线"diff --git a/packages/database/src/models/__tests__/expertise.test.ts b/packages/database/src/models/__tests__/expertise.test.tsindex e617851ad10..8980892341e 100644--- a/packages/database/src/models/__tests__/expertise.test.ts+++ b/packages/database/src/models/__tests__/expertise.test.ts@@ -1,5 +1,5 @@// @vitest-environment node-import { eq } from 'drizzle-orm';+import { eq, inArray } from 'drizzle-orm';import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';import { getTestDB } from '../../core/getTestDB';@@ -482,9 +482,11 @@ describe('ExpertiseModel', () => {expect(group.rules[2].enforcement).toBe('remind');});- it('lists groups distilled from a project, but not agent self-learning domains', async () => {+ it("lists project groups as the reviewer's, and agent self-learning after them", async () => {await seedRuleGroup();- await serverDB.insert(agents).values({ id: 'rules-agent', userId });+ await serverDB+ .insert(agents)+ .values({ avatar: '🦊', id: 'rules-agent', title: '狐狸', userId });await serverDB.insert(projects).values({coordinatorAgentId: 'rules-agent',id: 'rules-project',@@ -517,11 +519,52 @@ describe('ExpertiseModel', () => {const groups = await new ExpertiseModel(serverDB, userId).listRules();- expect(groups.map((g) => g.domain.title)).toContain('lobehub 的规矩');- expect(groups.map((g) => g.domain.title)).not.toContain('智能体专长');+ expect(groups.find((g) => g.domain.id === 'project-domain')?.owner).toEqual({ kind: 'mine' });expect(groups.find((g) => g.domain.id === 'project-domain')?.scopes).toEqual([{ id: 'rules-project', kind: 'project', title: 'lobehub' },]);+ // Agent self-learning is listed too, owned by its agent, after every group of the reviewer's.+ expect(groups.at(-1)?.domain.id).toBe('agent-domain');+ expect(groups.at(-1)?.owner).toEqual({+ agent: { avatar: '🦊', backgroundColor: null, id: 'rules-agent', title: '狐狸' },+ kind: 'agent',+ });+ expect(groups.slice(0, -1).every((g) => g.owner.kind === 'mine')).toBe(true);+ });++ it("leaves out what a teammate's private agent learned", async () => {+ const teammate = 'expertise-rules-private-learner';+ const workspaceId = 'rules-private-learner-workspace';+ await serverDB.insert(users).values({ id: teammate });+ await serverDB.insert(workspaces).values({+ id: workspaceId,+ name: 'Team',+ primaryOwnerId: userId,+ slug: 'rules-private-learner',+ });+ await serverDB.insert(agents).values({+ id: 'private-learner',+ title: '队友的私有助手',+ userId: teammate,+ visibility: 'private',+ workspaceId,+ });+ await serverDB.insert(expertiseDomains).values({+ anchorChosenAt: new Date(),+ domainFilter: '私有专长',+ id: 'private-learned-domain',+ slug: 'private-learned-domain',+ title: '私有专长',+ userId: teammate,+ workspaceId,+ });+ await serverDB+ .insert(expertiseBindings)+ .values({ agentId: 'private-learner', domainId: 'private-learned-domain' });++ const groups = await new ExpertiseModel(serverDB, userId, workspaceId).listRules();++ expect(groups.map((g) => g.domain.id)).not.toContain('private-learned-domain');});it('files a hand-written rule at the top of its group with the next code', async () => {@@ -767,6 +810,60 @@ describe('ExpertiseModel', () => {});};+ const seedAgentLesson = async () => {+ await serverDB.insert(agents).values({ id: 'reach-agent', title: '狐狸', userId });+ await serverDB.insert(expertiseDomains).values({+ anchorChosenAt: new Date(),+ domainFilter: '智能体专长',+ id: 'reach-agent-domain',+ slug: 'reach-agent-domain',+ title: '狐狸学到的',+ userId,+ });+ await serverDB+ .insert(expertiseBindings)+ .values({ agentId: 'reach-agent', domainId: 'reach-agent-domain' });+ const id = '0d3e1a5c-6f52-4c2e-8f2a-9f2d3f26b1a1';+ await serverDB.insert(expertiseLessons).values({+ code: 'P-01',+ domainId: 'reach-agent-domain',+ id,+ polarity: 'rule',+ sections: [{ body: '空状态给出下一步', key: 'rule' }],+ title: '空状态给出下一步',+ });+ return id;+ };++ it("refuses to move the reviewer's rule into an agent's lessons", async () => {+ const { first } = await seedRuleGroup();+ await seedAgentLesson();+ const model = new ExpertiseModel(serverDB, userId);++ expect(await model.moveRule(first, 'reach-agent-domain')).toBeNull();++ const [row] = await serverDB+ .select({ domainId: expertiseLessons.domainId, status: expertiseLessons.status })+ .from(expertiseLessons)+ .where(eq(expertiseLessons.id, first));+ expect(row).toEqual({ domainId: 'rules-domain', status: 'active' });+ });++ it("refuses to merge across the reviewer's rules and an agent's lessons", async () => {+ const { first } = await seedRuleGroup();+ const agentLesson = await seedAgentLesson();+ const repository = new ExpertiseRuleRepository(serverDB, userId);++ expect(await repository.mergeRules(first, agentLesson)).toBeNull();+ expect(await repository.mergeRules(agentLesson, first)).toBeNull();++ const rows = await serverDB+ .select({ id: expertiseLessons.id, status: expertiseLessons.status })+ .from(expertiseLessons)+ .where(inArray(expertiseLessons.id, [first, agentLesson]));+ expect(rows.every((row) => row.status === 'active')).toBe(true);+ });+it('moves an unencumbered rule in place with a fresh code', async () => {const { first } = await seedRuleGroup();const model = new ExpertiseModel(serverDB, userId);diff --git a/packages/database/src/models/expertise.ts b/packages/database/src/models/expertise.tsindex 225606da57e..4318bb766c2 100644--- a/packages/database/src/models/expertise.ts+++ b/packages/database/src/models/expertise.ts@@ -40,6 +40,19 @@ export type ExpertiseTier = 'core' | 'niche' | 'unused';export type ExpertiseCarrier ={ id: string; type: 'agent' } | { id: string; type: 'project' } | { type: 'user' };+/** Whose a listed group is: the reviewer's own rules, or one agent's self-learning. */+export type ExpertiseGroupOwner =+ | { kind: 'mine' }+ | {+ agent: {+ avatar: string | null;+ backgroundColor: string | null;+ id: string;+ title: string | null;+ };+ kind: 'agent';+ };+/*** The single carrier column a binding sets. `user` resolves to the workspace when one is in* scope, so a workspace member's always-on standards reach their teammates rather than only@@ -189,18 +202,24 @@ export class ExpertiseModel {};/**- * The reviewer's rules — every always-on domain as a group, with the rules filed in it and- * where the group takes effect.+ * Everything the self-evolving page lists — the reviewer's rules first, then what each agent+ * learned on its own — as groups with the lessons filed in them and where each takes effect.** Reads the same binding arm the distillation writes through, so what this returns is exactly* what an acceptance without a project would add to. Rules come back in the reviewer's own* order (`sortOrder`, then creation) because they told us the order matters; the page does not* re-rank them by hit count.+ *+ * Each group carries an `owner`: `mine` when the reviewer, their workspace or a project holds+ * it (it reaches every run in that scope), otherwise the one agent it was learned by. A group+ * mounted on both is the reviewer's — that is the wider of the two reaches.*/listRules = async () => {- // The reviewer's own groups plus the ones distilled from a project's acceptances, which are- // bound to that project only. Agent-bound domains are self-learning, not rules, and stay out.- const bound = await this.listDomainsBoundTo(isNotNull(expertiseBindings.projectId));+ // The reviewer's own groups, the ones distilled from a project's acceptances, and every+ // agent's self-learning domains — the same set the run context injects from.+ const bound = await this.listDomainsBoundTo(+ or(isNotNull(expertiseBindings.projectId), isNotNull(expertiseBindings.agentId)),+ );const domainIds = bound.map(({ domain }) => domain.id);if (domainIds.length === 0) return [];@@ -250,8 +269,12 @@ export class ExpertiseModel {),this.db.select({+ agentAvatar: agents.avatar,+ agentBackgroundColor: agents.backgroundColor,agentId: expertiseBindings.agentId,agentTitle: agents.title,+ // Null when the agent exists but the viewer may not see it.+ visibleAgentId: agents.id,boundUserId: expertiseBindings.boundUserId,boundWorkspaceId: expertiseBindings.boundWorkspaceId,domainId: expertiseBindings.domainId,@@ -281,15 +304,62 @@ export class ExpertiseModel {const bySource = await this.countHitsBySource(lessons.map((lesson) => lesson.id));- return bound.map(({ domain }) => ({+ // Bucket once by domain: the page now spans every agent's domains, so filtering the full+ // lesson and binding lists per group would grow with groups × rows.+ const byDomain = <T extends { domainId: string }>(rows: T[]) => {+ const map = new Map<string, T[]>();+ for (const row of rows) {+ const bucket = map.get(row.domainId);+ if (bucket) bucket.push(row);+ else map.set(row.domainId, [row]);+ }+ return map;+ };+ const lessonsByDomain = byDomain(lessons);+ const bindingsByDomain = byDomain(bindings);++ const ownerOf = (domainId: string): ExpertiseGroupOwner | null => {+ const mounts = bindingsByDomain.get(domainId) ?? [];+ if (mounts.some((binding) => !binding.agentId)) return { kind: 'mine' };+ const agent = mounts.find((binding) => binding.visibleAgentId);+ // Only mounted on agents the viewer cannot see: nothing of it belongs on their page.+ if (!agent?.agentId) return null;+ return {+ agent: {+ avatar: agent.agentAvatar,+ backgroundColor: agent.agentBackgroundColor,+ id: agent.agentId,+ title: agent.agentTitle,+ },+ kind: 'agent',+ };+ };++ const owned = bound.flatMap(({ domain }) => {+ const owner = ownerOf(domain.id);+ return owner ? [{ domain, owner }] : [];+ });+ // The reviewer's groups lead in their own order; each agent's follow together, agents in the+ // order their first group was mounted.+ const agentOrder = [+ ...new Set(owned.flatMap(({ owner }) => (owner.kind === 'agent' ? [owner.agent.id] : []))),+ ];+ const rank = ({ owner }: (typeof owned)[number]) =>+ owner.kind === 'mine' ? -1 : agentOrder.indexOf(owner.agent.id);+ const ordered = owned+ .map((entry, index) => ({ entry, index }))+ .sort((a, b) => rank(a.entry) - rank(b.entry) || a.index - b.index)+ .map(({ entry }) => entry);++ return ordered.map(({ domain, owner }) => ({+ owner,domain: {domainFilter: domain.domainFilter,id: domain.id,outOfScope: domain.outOfScope,title: domain.title,},- rules: lessons- .filter((lesson) => lesson.domainId === domain.id)+ rules: (lessonsByDomain.get(domain.id) ?? [])// Written by the reviewer rather than distilled from a run. Hit counts grow as a rule is// applied, so provenance is read from where the row came from — same test the lesson// reader uses for `taughtByUser`.@@ -298,19 +368,17 @@ export class ExpertiseModel {...(bySource.get(lesson.id) ?? { conversationHitCount: 0, rejectionHitCount: 0 }),authored: lesson.createdByUserId != null && originRunId == null,})),- scopes: bindings- .filter((binding) => binding.domainId === domain.id)- .map((binding) => {- if (binding.projectId) {- return { id: binding.projectId, kind: 'project' as const, title: binding.projectName };- }- if (binding.agentId) {- return { id: binding.agentId, kind: 'agent' as const, title: binding.agentTitle };- }- return binding.boundWorkspaceId- ? { id: binding.boundWorkspaceId, kind: 'workspace' as const, title: null }- : { id: binding.boundUserId!, kind: 'user' as const, title: null };- }),+ scopes: (bindingsByDomain.get(domain.id) ?? []).map((binding) => {+ if (binding.projectId) {+ return { id: binding.projectId, kind: 'project' as const, title: binding.projectName };+ }+ if (binding.agentId) {+ return { id: binding.agentId, kind: 'agent' as const, title: binding.agentTitle };+ }+ return binding.boundWorkspaceId+ ? { id: binding.boundWorkspaceId, kind: 'workspace' as const, title: null }+ : { id: binding.boundUserId!, kind: 'user' as const, title: null };+ }),}));};@@ -613,6 +681,29 @@ export class ExpertiseModel {.where(and(inArray(expertiseRuns.domainId, domainIds), eq(expertiseRuns.actorType, 'agent')));};+ /**+ * Who a domain reaches, as one comparable key — the same rule `listRules` uses for its+ * `owner`: `mine` when any enabled binding is not an agent's (the reviewer, workspace or a+ * project), otherwise the agents it is mounted on. A rule moved or merged across reaches would+ * silently change which runs receive it, so both mutations refuse that.+ */+ private reachOf = async (domainId: string) => {+ const mounts = await this.db+ .select({ agentId: expertiseBindings.agentId })+ .from(expertiseBindings)+ .where(and(eq(expertiseBindings.domainId, domainId), eq(expertiseBindings.enabled, true)));+ if (mounts.some((mount) => !mount.agentId)) return 'mine';+ const agentIds = [...new Set(mounts.map((mount) => mount.agentId!))].sort();+ return agentIds.length > 0 ? `agent:${agentIds.join(',')}` : 'unbound';+ };++ /** Whether two domains reach the same runs; see {@link reachOf}. */+ sameReach = async (domainA: string, domainB: string) => {+ if (domainA === domainB) return true;+ const [a, b] = await Promise.all([this.reachOf(domainA), this.reachOf(domainB)]);+ return a === b;+ };+// L1: domain detailfindDomain = async (domainId: string) => {@@ -1160,6 +1251,8 @@ export class ExpertiseModel {]);if (!lesson || !domain) return null;if (lesson.domainId === domainId) return { domainId, id: lessonId };+ // Older clients list every group in the move menu; the boundary has to hold here too.+ if (!(await this.sameReach(lesson.domainId, domainId))) return null;return this.db.transaction(async (tx) => {// Re-read under a row lock and copy from that: a merge committed since the read above hasdiff --git a/packages/database/src/repositories/expertiseRules/index.ts b/packages/database/src/repositories/expertiseRules/index.tsindex dcfb3beb520..6888c7d6c07 100644--- a/packages/database/src/repositories/expertiseRules/index.ts+++ b/packages/database/src/repositories/expertiseRules/index.ts@@ -117,6 +117,9 @@ export class ExpertiseRuleRepository {if (!from || !into) return null;// Folding into an archived rule would leave neither rule in force.if (from.status !== 'active' || into.status !== 'active') return null;+ // Folding across reaches (the reviewer's rules vs an agent's lessons, or two agents) would+ // change which runs receive it; only newer clients hide those targets, so refuse it here.+ if (!(await model.sameReach(from.domainId, into.domainId))) return null;const revision = into.currentRevision + 1;// The evidence stays where it is; `generalizedFromIds` is how the target reads it.diff --git a/packages/locales/src/default/electron.ts b/packages/locales/src/default/electron.tsindex 5eb6c8a4d36..161991a5975 100644--- a/packages/locales/src/default/electron.ts+++ b/packages/locales/src/default/electron.ts@@ -21,7 +21,7 @@ export default {'navigation.memoryIdentities': 'Memory - Identities','navigation.document': 'Document','navigation.memoryPreferences': 'Memory - Preferences',- 'navigation.memoryRules': 'Memory - Rules',+ 'navigation.memoryRules': 'Memory - Self-evolving','navigation.newChat': 'New Chat','navigation.noPages': 'No pages yet','navigation.onboarding': 'Onboarding',diff --git a/packages/locales/src/default/labs.ts b/packages/locales/src/default/labs.tsindex 2673873575f..cf18a7a3cb1 100644--- a/packages/locales/src/default/labs.ts+++ b/packages/locales/src/default/labs.ts@@ -48,9 +48,6 @@ export default {'Show the Integrations settings page: connect the GitHub App so merged pull requests accept deliveries and failing checks or reviews reach the agent that opened them. Hidden by default.','features.integrations.title': 'Integrations','features.inputMarkdown.title': 'Input Markdown Rendering',- 'features.memoryRules.desc':- 'Adds "My rules" under Memory: the delivery rules distilled from the acceptance rounds you sent back, with ordering, grouping and block / remind controls.',- 'features.memoryRules.title': 'My rules','features.messageTextSelectionActions.desc':'Show a quick action when selecting text in chat messages so the selected text can be added to the next conversation context.','features.messageTextSelectionActions.title': 'Message Text Selection Actions',@@ -64,7 +61,7 @@ export default {'Add an Acceptance section to the task detail: describe acceptance in one sentence and let AI generate editable verify criteria.','features.taskVerify.title': 'Acceptance','features.selfLearning.desc':- 'Show what each agent has learned from real practice — its rule base, which rules actually get used, and which layers are still blank.',+ 'Learn from practice: the rounds you send back become rules, and each agent picks up lessons from its own runs — both go with the agent into every run. See them all under Memory → Self-evolving.','features.selfLearning.title': 'Self-evolving','group.desktop': 'Desktop','group.general': 'General',diff --git a/packages/locales/src/default/memory.ts b/packages/locales/src/default/memory.tsindex d780e018f4c..9ba9804655b 100644--- a/packages/locales/src/default/memory.ts+++ b/packages/locales/src/default/memory.ts@@ -112,7 +112,6 @@ export default {'rules.archived.byYou': 'archived by you','rules.archived.group': 'Archived ({{count}})','rules.archived.mergedInto': 'merged into "{{title}}"',- 'rules.backlog': '{{count}} rejected rounds have not been read yet','rules.columns.code': 'No.','rules.columns.enforcement': 'Effect','rules.columns.method': 'Check',@@ -143,10 +142,6 @@ export default {'rules.compose.submit': 'Save','rules.compose.titlePlaceholder': 'The rule in one sentence','rules.compose.why': 'Why it matters (optional)',- 'rules.empty.description':- 'Rules grow out of the checks you send back — the reason you wrote, and the spot you circled.',- 'rules.empty.title': 'No rules yet',- 'rules.empty.write': 'Or write one first','rules.enforcement.block': 'Block','rules.enforcement.blockDesc':'Will hold the delivery until you let it through. Not in effect yet: for now it only reminds',@@ -195,9 +190,9 @@ export default {'rules.group.submitCreate': 'Create','rules.group.submitRename': 'Save','rules.labOff.description':- 'Turn it on under Settings → Labs to see the delivery rules distilled from the rounds you sent back.',+ 'Turn on Self-evolving under Settings → Labs to see your rules and what each agent has learned.','rules.labOff.open': 'Open Labs',- 'rules.labOff.title': 'My rules is still in the lab',+ 'rules.labOff.title': 'Self-evolving is still in the lab','rules.merge.banner':'Click the rule to merge into — "{{title}}" will be archived and its sources and counts move over.','rules.merge.cancel': 'Cancel',@@ -210,6 +205,23 @@ export default {'rules.method.compilable': 'Program-assisted','rules.method.compiled': 'By program','rules.method.not-compilable': 'By judgement',+ 'rules.onboarding.agents.action': 'View',+ 'rules.onboarding.agents.description': '{{name}} has learned {{count}} on its own',+ 'rules.onboarding.agents.descriptionMany':+ '{{agents}} agents have learned {{count}} on their own',+ 'rules.onboarding.agents.title': 'What agents learned',+ 'rules.onboarding.backlog': '{{count}} rounds not read yet',+ 'rules.onboarding.description':+ 'Say one thing you expect from a delivery, or paste a guideline you have; it becomes a checkable rule.',+ 'rules.onboarding.descriptionGrow':+ 'Reasons you write when sending an acceptance back grow into rules here too.',+ 'rules.onboarding.listTitle': 'Rules also come from',+ 'rules.onboarding.reject.action': 'Open',+ 'rules.onboarding.reject.description':+ 'Reject a check and say why; it is distilled when the next round lands',+ 'rules.onboarding.reject.title': 'Send back an acceptance',+ 'rules.onboarding.title': 'Write your first rule',+ 'rules.onboarding.write': 'Write a rule','rules.origin.authored': 'You wrote it','rules.origin.distilled': 'You sent {{hits}} rounds back over this','rules.origin.distilledAndObserved':@@ -221,6 +233,9 @@ export default {'rules.origin.oneOff':'Looks like a request about that one delivery; it becomes a standing rule once another delivery is sent back for it','rules.origin.overSpecific': 'Looks tied to one page; may belong in a broader rule',+ 'rules.origin.taught': 'You taught it to this agent',+ 'rules.owner.mine': 'My rules',+ 'rules.owner.untitledAgent': 'Untitled agent','rules.reason.inferred': 'inferred, you never said it','rules.reason.mechanism': 'Has a reason','rules.reason.reviewer': 'in your words',@@ -256,18 +271,22 @@ export default {'rules.sources.rejected': 'you said it learned this wrong','rules.sources.retry': 'Try again','rules.sources.round': 'round {{index}}',+ 'rules.sources.taughtEmpty': 'You taught this to the agent; no feedback on record yet.','rules.sources.title': 'Where it came from','rules.subtitle':- '{{count}} in use · the agent checks every delivery against them · what you say when sending a round back lands here',+ '{{rules}} rules of yours · {{lessons}} lessons your agents learned on their own · all of them go with the agent into every run',+ 'rules.subtitleAgentsOnly':+ '{{lessons}} lessons your agents learned on their own · all of them go with the agent into every run','rules.tag.authored': 'yours','rules.tag.oneOff': 'one-off',- 'rules.title': 'My rules',+ 'rules.tag.taught': 'taught',+ 'rules.title': 'Self-evolving','tab.activities': 'Activities','tab.contexts': 'Contexts','tab.home': 'Home','tab.identities': 'Identities','tab.preferences': 'Preferences',- 'tab.rules': 'Rules',+ 'tab.rules': 'Self-evolving','tab.search': 'Search','viewMode.masonry': 'Masonry','viewMode.timeline': 'Timeline',diff --git a/packages/types/src/user/preference.ts b/packages/types/src/user/preference.tsindex 77dd2e30370..17118efd317 100644--- a/packages/types/src/user/preference.ts+++ b/packages/types/src/user/preference.ts@@ -207,12 +207,9 @@ export const UserLabSchema = z.object({*/enableProjects: z.boolean().optional(),/**- * show the "my rules" page under memory: the delivery rules distilled from rejected- * acceptance rounds, with ordering, grouping and enforcement controls- */- enableMemoryRules: z.boolean().optional(),- /**- * show the per-agent self-learning (expertise) page and its sidebar entry+ * self-evolving: inject what was learned (the user's rules and each agent's own lessons) into+ * runs, and show it under memory and on each agent's self-learning page. The former separate+ * "my rules" switch (`enableMemoryRules`) is folded into this one.*/enableSelfLearning: z.boolean().optional(),/**diff --git a/src/features/MemoryRules/ComposeModal.tsx b/src/features/MemoryRules/ComposeModal.tsxindex 834797d2697..33eff187343 100644--- a/src/features/MemoryRules/ComposeModal.tsx+++ b/src/features/MemoryRules/ComposeModal.tsx@@ -71,6 +71,11 @@ interface GroupChoice {}interface ComposeContentProps {+ /**+ * Whether a new group may be opened from here. A new group always mounts on the reviewer, so+ * writing into an agent's part must stay within that agent's existing groups.+ */+ canOpenGroup?: boolean;defaultGroupId?: string;groups: RuleGroup[];onCreated: (id: string) => void;@@ -82,6 +87,7 @@ interface ComposeContentProps {* myself" skips the draft and lands on the same review form.*/const ComposeContent = ({+ canOpenGroup = true,defaultGroupId,groups: initialGroups,onCreated,@@ -142,7 +148,7 @@ const ComposeContent = ({if (drafted.groupId) {setGroupId(drafted.groupId);setNewGroup(null);- } else if (drafted.newGroup) {+ } else if (drafted.newGroup && canOpenGroup) {setGroupId(undefined);setNewGroup(drafted.newGroup);}@@ -318,7 +324,7 @@ const ComposeContent = ({setNewGroup(null);},})),- ...(newGroup+ ...(newGroup && canOpenGroup? [{key: 'proposed',@@ -327,13 +333,17 @@ const ComposeContent = ({},]: []),- { type: 'divider' as const },- {- icon: <Icon icon={FolderPlusIcon} />,- key: 'new',- label: t('rules.actions.newGroup'),- onClick: addGroup,- },+ ...(canOpenGroup+ ? [+ { type: 'divider' as const },+ {+ icon: <Icon icon={FolderPlusIcon} />,+ key: 'new',+ label: t('rules.actions.newGroup'),+ onClick: addGroup,+ },+ ]+ : []),]}><span className={styles.chip}>diff --git a/src/features/MemoryRules/DetailPanel.tsx b/src/features/MemoryRules/DetailPanel.tsxindex c7a6bf1df84..2a35ca1a3e3 100644--- a/src/features/MemoryRules/DetailPanel.tsx+++ b/src/features/MemoryRules/DetailPanel.tsx@@ -190,8 +190,8 @@ interface PropertyProps {/*** One property line, in the shape the task detail uses: a label, an icon, the current value, and- * a menu behind the click when it can be changed. Read-only lines drop the fill so the eye finds- * the switches first.+ * a menu behind the click when it can be changed. Every line sits on the same plain ground; the+ * ones that open a menu only light up on hover, so the block does not read as a highlight.*/const Property = ({ children, icon, label, menu }: PropertyProps) => {const row = (@@ -201,7 +201,7 @@ const Property = ({ children, icon, label, menu }: PropertyProps) => {className={cx(styles.property, !menu && styles.propertyStatic)}clickable={Boolean(menu)}gap={8}- variant={menu ? 'filled' : 'borderless'}+ variant={'borderless'}><span className={styles.propertyLabel}>{label}</span><Icon color={cssVar.colorTextSecondary} icon={icon} size={14} />@@ -266,6 +266,8 @@ const RuleDocument = ({const titleOf = (id: string) => all.find((r) => r.id === id)?.title ?? id;const mergedInto = mergedIntoId(rule);const origin = ruleOrigin(rule);+ // What the reviewer wrote into an agent's lessons was taught to that agent, not a rule of theirs.+ const taught = authored && group?.owner.kind === 'agent';const save = async (patch: UpdateRuleInput) => {if (busy) return false;@@ -433,7 +435,9 @@ const RuleDocument = ({</Property><Property icon={HistoryIcon} label={t('rules.meta.origin')}><span>- {t(`rules.origin.${origin.key}`, 'params' in origin ? origin.params : undefined)}+ {taught+ ? t('rules.origin.taught')+ : t(`rules.origin.${origin.key}`, 'params' in origin ? origin.params : undefined)}{!authored && rule.lastHitAt? t('rules.origin.lastHit', { time: dayjs(rule.lastHitAt).fromNow() }): ''}@@ -570,7 +574,13 @@ const RuleDocument = ({))) : (<p className={styles.muted}>- {t(authored ? 'rules.sources.authoredEmpty' : 'rules.sources.empty')}+ {t(+ taught+ ? 'rules.sources.taughtEmpty'+ : authored+ ? 'rules.sources.authoredEmpty'+ : 'rules.sources.empty',+ )}</p>)}diff --git a/src/features/MemoryRules/GroupSection.tsx b/src/features/MemoryRules/GroupSection.tsxindex b89e0e1bad4..6bf1df5c556 100644--- a/src/features/MemoryRules/GroupSection.tsx+++ b/src/features/MemoryRules/GroupSection.tsx@@ -27,6 +27,10 @@ interface GroupSectionProps {const GroupSection = ({ collapsed, count, group, menu, onToggle, onWrite }: GroupSectionProps) => {const { t } = useTranslation('memory');const scopeLabel = useScopeLabel();+ const owner = group.owner;+ const onlyItsAgent =+ owner.kind === 'agent' &&+ group.scopes.every((scope) => scope.kind === 'agent' && scope.id === owner.agent.id);return (<div className={cx(styles.section, collapsed && styles.sectionCollapsed)} onClick={onToggle}>@@ -35,9 +39,12 @@ const GroupSection = ({ collapsed, count, group, menu, onToggle, onWrite }: Grou</span><span className={styles.sectionTitle}>{group.domain.title}</span><span className={styles.sectionCount}>{count}</span>- <span className={styles.sectionScope}>- {t('rules.group.scope', { scopes: scopeLabel(group.scopes) })}- </span>+ {/* Under an agent's heading, "applies to that agent" only repeats the heading. */}+ {!onlyItsAgent && (+ <span className={styles.sectionScope}>+ {t('rules.group.scope', { scopes: scopeLabel(group.scopes) })}+ </span>+ )}{!collapsed && <span data-line className={styles.sectionLine} />}<spandata-hoverdiff --git a/src/features/MemoryRules/OwnerLabel.tsx b/src/features/MemoryRules/OwnerLabel.tsxnew file mode 100644index 00000000000..869bc56e8a9--- /dev/null+++ b/src/features/MemoryRules/OwnerLabel.tsx@@ -0,0 +1,47 @@+'use client';++import { DEFAULT_AVATAR } from '@lobechat/const';+import { Flexbox } from '@lobehub/ui';+import { Avatar } from '@lobehub/ui/base-ui';+import { cssVar } from 'antd-style';+import { useTranslation } from 'react-i18next';++import type { OwnerSection } from './labels';+import { styles } from './styles';++interface OwnerLabelProps {+ count: number;+ owner: OwnerSection['owner'];+}++/**+ * One option of the switcher above the sheet: "My rules", or the agent's avatar and name, each+ * with how many are in force.+ */+const OwnerLabel = ({ count, owner }: OwnerLabelProps) => {+ const { t } = useTranslation('memory');++ return (+ <Flexbox horizontal align={'center'} gap={6}>+ {/* Decorative: the name follows, so screen readers should not hear it twice. */}+ {owner.kind === 'agent' && (+ <span aria-hidden style={{ display: 'inline-flex' }}>+ <Avatar+ avatar={owner.agent.avatar || DEFAULT_AVATAR}+ background={owner.agent.backgroundColor || cssVar.colorBgContainer}+ shape={'circle'}+ size={16}+ />+ </span>+ )}+ <span>+ {owner.kind === 'mine'+ ? t('rules.owner.mine')+ : owner.agent.title || t('rules.owner.untitledAgent')}+ </span>+ <span className={styles.ownerCount}>{count}</span>+ </Flexbox>+ );+};++export default OwnerLabel;diff --git a/src/features/MemoryRules/RuleRow.tsx b/src/features/MemoryRules/RuleRow.tsxindex 07195c84101..778a4d370dc 100644--- a/src/features/MemoryRules/RuleRow.tsx+++ b/src/features/MemoryRules/RuleRow.tsx@@ -22,6 +22,8 @@ interface RuleRowProps {onEnforcement: (next: ExpertiseEnforcement) => void;onSelect: () => void;rule: RuleItem;+ /** Whether the row sits in an agent's part, where what the reviewer wrote was taught to it. */+ taughtToAgent?: boolean;}/**@@ -37,6 +39,7 @@ const RuleRow = ({onEnforcement,onSelect,rule,+ taughtToAgent,}: RuleRowProps) => {const { t } = useTranslation('memory');const archived = rule.status === 'retired';@@ -65,7 +68,11 @@ const RuleRow = ({<div style={{ minWidth: 0 }}><Flexbox horizontal align={'baseline'} gap={6} wrap={'wrap'}><span className={styles.title}>{rule.title}</span>- {authored && <Tag size={'small'}>{t('rules.tag.authored')}</Tag>}+ {authored && (+ <Tag size={'small'}>+ {t(taughtToAgent ? 'rules.tag.taught' : 'rules.tag.authored')}+ </Tag>+ )}{rule.specificity === 'one-off' && !archived && (<Tooltip title={t('rules.origin.oneOff')}><Tag size={'small'}>{t('rules.tag.oneOff')}</Tag>diff --git a/src/features/MemoryRules/RulesOnboarding.tsx b/src/features/MemoryRules/RulesOnboarding.tsxnew file mode 100644index 00000000000..cf4e8abb422--- /dev/null+++ b/src/features/MemoryRules/RulesOnboarding.tsx@@ -0,0 +1,242 @@+'use client';++import { Icon } from '@lobehub/ui';+import { Button } from '@lobehub/ui/base-ui';+import { createStaticStyles, cssVar, cx } from 'antd-style';+import { BotIcon, ClipboardCheckIcon, PlusIcon, ScaleIcon } from 'lucide-react';+import type { ReactNode } from 'react';+import { useTranslation } from 'react-i18next';++import { useWorkspaceAwareNavigate } from '@/features/Workspace/useWorkspaceAwareNavigate';++const styles = createStaticStyles(({ css }) => ({+ actions: css`+ margin-block: 24px 32px;+ `,+ description: css`+ margin: 0;+ line-height: 1.7;+ color: ${cssVar.colorTextSecondary};+ `,+ hero: css`+ display: flex;+ flex-direction: column;+ align-items: center;++ max-inline-size: 460px;++ text-align: center;+ `,+ heroIcon: css`+ display: flex;+ align-items: center;+ justify-content: center;++ inline-size: 56px;+ block-size: 56px;+ margin-block-end: 24px;+ border: 1px solid ${cssVar.colorBorderSecondary};+ border-radius: 14px;++ color: ${cssVar.colorText};++ background: ${cssVar.colorFillQuaternary};+ `,+ inline: css`+ padding-block: 40px;+ `,+ list: css`+ inline-size: 100%;+ max-inline-size: 640px;+ border: 1px solid ${cssVar.colorBorderSecondary};+ border-radius: ${cssVar.borderRadiusLG};+ `,+ listTitle: css`+ inline-size: 100%;+ max-inline-size: 640px;+ margin-block-end: 8px;++ font-size: ${cssVar.fontSizeSM};+ color: ${cssVar.colorTextSecondary};+ `,+ row: css`+ display: flex;+ gap: 14px;+ align-items: center;++ padding-block: 16px;+ padding-inline: 20px;++ & + & {+ border-block-start: 1px solid ${cssVar.colorBorderSecondary};+ }+ `,+ rowAction: css`+ flex: none;++ > * {+ min-inline-size: 72px;+ }+ `,+ rowCopy: css`+ display: flex;+ flex: 1;+ flex-direction: column;+ gap: 2px;++ min-inline-size: 0;+ `,+ rowDescription: css`+ overflow: hidden;++ font-size: ${cssVar.fontSizeSM};+ color: ${cssVar.colorTextSecondary};+ text-overflow: ellipsis;+ white-space: nowrap;+ `,+ rowIcon: css`+ display: flex;+ flex: none;+ align-items: center;+ justify-content: center;++ inline-size: 36px;+ block-size: 36px;+ border-radius: ${cssVar.borderRadius};++ color: ${cssVar.colorTextSecondary};++ background: ${cssVar.colorFillTertiary};+ `,+ rowMeta: css`+ flex: none;+ font-size: ${cssVar.fontSizeSM};+ color: ${cssVar.colorTextTertiary};+ `,+ rowTitle: css`+ font-weight: 500;+ color: ${cssVar.colorText};+ `,+ shell: css`+ display: flex;+ flex-direction: column;+ align-items: center;+ padding-block: 72px 48px;+ `,+ title: css`+ margin-block: 0 8px;+ margin-inline: 0;++ font-size: 18px;+ font-weight: 600;+ color: ${cssVar.colorText};+ `,+}));++interface RowProps {+ action?: ReactNode;+ description: ReactNode;+ icon: typeof ScaleIcon;+ meta?: ReactNode;+ title: string;+}++const Row = ({ action, description, icon, meta, title }: RowProps) => (+ <div className={styles.row}>+ <span className={styles.rowIcon}>+ <Icon icon={icon} size={18} />+ </span>+ <span className={styles.rowCopy}>+ <span className={styles.rowTitle}>{title}</span>+ <span className={styles.rowDescription}>{description}</span>+ </span>+ {meta && <span className={styles.rowMeta}>{meta}</span>}+ {action && <span className={styles.rowAction}>{action}</span>}+ </div>+);++export interface RulesOnboardingAgents {+ /** How many agents have learned something, and how many lessons in force across them. */+ agentCount: number;+ lessonCount: number;+ /** The first agent's name, used when there is only one. */+ name: string;+ onOpen: () => void;+}++interface RulesOnboardingProps {+ /** Present when agents have learned on their own, so there is something to look at already. */+ agents?: RulesOnboardingAgents;+ /** Rejected rounds no rule has been distilled from yet. */+ backlogRounds?: number;+ /** Inside the page under the part switcher, rather than as the whole page. */+ inline?: boolean;+ onWrite: () => void;+}++/**+ * The first screen of "My rules" while the reviewer has none: one centred column whose hero is+ * the one thing that can be done right here (write a rule — a sentence or a pasted guideline),+ * then the other places rules come from, each with the single action that gets there.+ */+const RulesOnboarding = ({ agents, backlogRounds, inline, onWrite }: RulesOnboardingProps) => {+ const { t } = useTranslation('memory');+ const navigate = useWorkspaceAwareNavigate();++ return (+ <div className={cx(styles.shell, inline && styles.inline)}>+ <div className={styles.hero}>+ <div className={styles.heroIcon}>+ <Icon icon={ScaleIcon} size={24} />+ </div>+ <h2 className={styles.title}>{t('rules.onboarding.title')}</h2>+ <p className={styles.description}>+ {t('rules.onboarding.description')}+ <br />+ {t('rules.onboarding.descriptionGrow')}+ </p>+ </div>++ <div className={styles.actions}>+ <Button icon={<Icon icon={PlusIcon} />} type={'primary'} onClick={onWrite}>+ {t('rules.onboarding.write')}+ </Button>+ </div>++ <div className={styles.listTitle}>{t('rules.onboarding.listTitle')}</div>+ <div className={styles.list}>+ <Row+ description={t('rules.onboarding.reject.description')}+ icon={ClipboardCheckIcon}+ meta={backlogRounds ? t('rules.onboarding.backlog', { count: backlogRounds }) : undefined}+ title={t('rules.onboarding.reject.title')}+ action={+ <Button onClick={() => navigate('/acceptance')}>+ {t('rules.onboarding.reject.action')}+ </Button>+ }+ />+ {agents && (+ <Row+ action={<Button onClick={agents.onOpen}>{t('rules.onboarding.agents.action')}</Button>}+ icon={BotIcon}+ title={t('rules.onboarding.agents.title')}+ description={+ agents.agentCount > 1+ ? t('rules.onboarding.agents.descriptionMany', {+ agents: agents.agentCount,+ count: agents.lessonCount,+ })+ : t('rules.onboarding.agents.description', {+ count: agents.lessonCount,+ name: agents.name,+ })+ }+ />+ )}+ </div>+ </div>+ );+};++export default RulesOnboarding;diff --git a/src/features/MemoryRules/index.tsx b/src/features/MemoryRules/index.tsxindex dc2720b3e1c..d3cdd867b11 100644--- a/src/features/MemoryRules/index.tsx+++ b/src/features/MemoryRules/index.tsx@@ -1,9 +1,9 @@'use client';import { Block, Empty, Flexbox, Icon, SortableList } from '@lobehub/ui';-import { Button, Text, toast } from '@lobehub/ui/base-ui';+import { Button, Segmented, Text, toast } from '@lobehub/ui/base-ui';import { cx } from 'antd-style';-import { FlaskConicalIcon, PencilIcon, PlusIcon, ScaleIcon } from 'lucide-react';+import { FlaskConicalIcon, PencilIcon, PlusIcon } from 'lucide-react';import { useMemo, useState } from 'react';import { useTranslation } from 'react-i18next';@@ -21,9 +21,11 @@ import DetailPanel from './DetailPanel';import { createGroupModal } from './GroupModal';import GroupSection from './GroupSection';import { useRules } from './hooks';-import { findMove, mergedIntoId } from './labels';+import { findMove, mergedIntoId, sectionsByOwner } from './labels';+import OwnerLabel from './OwnerLabel';import { buildRuleMenu } from './ruleMenu';import RuleRow from './RuleRow';+import RulesOnboarding, { type RulesOnboardingAgents } from './RulesOnboarding';import { styles } from './styles';const LabOff = () => {@@ -45,36 +47,85 @@ const LabOff = () => {};/**- * The reviewer's rules as one sheet: groups as full-width section rows, rules as draggable lines- * under them, the archive at the foot, and the selected rule opened as a document on the right.+ * Self-evolving, as one sheet per part: a switcher above it picks the reviewer's own rules (the+ * default) or what one agent learned by itself. Within the part, groups are full-width section+ * rows and lessons draggable lines under them; the archive sits at the foot and the selected one+ * opens as a document on the right.+ *+ * Both parts are the same thing underneath — lessons in expertise domains, injected into runs —+ * so they share every control. What differs is reach: a rule of the reviewer's reaches every run,+ * an agent's lesson only that agent's, so a lesson can only be moved or merged within its part.** Every write goes through the service and then re-reads the list; only the drag reorder and the* effect switch are applied optimistically, because both would visibly snap back otherwise.*/const MemoryRules = () => {const { t } = useTranslation('memory');- const enabled = useUserStore(labPreferSelectors.enableMemoryRules);+ const enabled = useUserStore(labPreferSelectors.enableSelfLearning);const { data, error, isLoading, mutate } = useRules();const [selectedId, setSelectedId] = useState<string>();const [titleEditing, setTitleEditing] = useState(false);const [mergeFrom, setMergeFrom] = useState<string>();const [collapsed, setCollapsed] = useState<Record<string, boolean>>({});+ const [partKey, setPartKey] = useState('mine');const groups = useMemo(() => data?.groups ?? [], [data]);+ const sections = useMemo(() => sectionsByOwner(groups), [groups]);+ // The part on screen: the switcher above the sheet picks one, "My rules" by default.+ const part = sections.find((section) => section.key === partKey) ?? sections[0];+ // Which part each group belongs to, so moves and merges never cross from one reach to another.+ const sectionOf = useMemo(+ () =>+ new Map(+ sections.flatMap((section) => section.groups.map((g) => [g.domain.id, section] as const)),+ ),+ [sections],+ );+ const sameSection = (domainId: string) => sectionOf.get(domainId)?.groups ?? [];const all = useMemo(() => groups.flatMap((group) => group.rules), [groups]);const live = useMemo(() => all.filter((rule) => rule.status === 'active'), [all]);- const archived = useMemo(() => all.filter((rule) => rule.status === 'retired'), [all]);const selected = all.find((rule) => rule.id === selectedId);+ const partRules = useMemo(() => part.groups.flatMap((group) => group.rules), [part]);+ const partLive = useMemo(() => partRules.filter((rule) => rule.status === 'active'), [partRules]);+ const partArchived = useMemo(+ () => partRules.filter((rule) => rule.status === 'retired'),+ [partRules],+ );const isEmpty = !isLoading && !error && all.length === 0;- // Display numbers follow the sheet order, not the per-group `P-nn` codes, which restart in- // every group and would repeat down the page.+ // Display numbers follow the sheet order of the part on screen, not the per-group `P-nn` codes,+ // which restart in every group and would repeat down the page.const codes = useMemo(() => {const map = new Map<string, string>();let n = 0;- for (const rule of [...live, ...archived]) map.set(rule.id, `R${String(++n).padStart(2, '0')}`);+ for (const rule of [...partLive, ...partArchived])+ map.set(rule.id, `R${String(++n).padStart(2, '0')}`);return map;- }, [live, archived]);+ }, [partLive, partArchived]);++ const ruleCount = live.filter((rule) => sectionOf.get(rule.domainId)?.key === 'mine').length;+ const lessonCount = live.length - ruleCount;+ // "My rules" with nothing in it is the reviewer's first screen there, not an empty table.+ const mineOnboarding = !isLoading && !error && part.key === 'mine' && part.groups.length === 0;+ const agentSections = sections.filter((section) => section.owner.kind === 'agent');+ const onboardingAgents: RulesOnboardingAgents | undefined =+ agentSections.length > 0 && agentSections[0].owner.kind === 'agent'+ ? {+ agentCount: agentSections.length,+ lessonCount,+ name: agentSections[0].owner.agent.title || t('rules.owner.untitledAgent'),+ onOpen: () => switchPart(agentSections[0].key),+ }+ : undefined;++ // A selection or a merge in progress belongs to the part it started in; switching drops both,+ // so a merge can only ever pick a target within its own part.+ const switchPart = (key: string) => {+ setPartKey(key);+ setSelectedId(undefined);+ setTitleEditing(false);+ setMergeFrom(undefined);+ };const refresh = () => mutate();@@ -169,8 +220,12 @@ const MemoryRules = () => {const select = (id: string) => {setTitleEditing(false);if (mergeFrom && mergeFrom !== id) {- // Only a rule still in force can absorb another; archived rows are not targets.- if (all.find((rule) => rule.id === id)?.status !== 'active') return;+ // Only a rule still in force can absorb another; archived rows are not targets, and a+ // lesson cannot be folded into one with a different reach.+ const into = all.find((rule) => rule.id === id);+ const from = all.find((rule) => rule.id === mergeFrom);+ if (into?.status !== 'active') return;+ if (!from || sectionOf.get(into.domainId) !== sectionOf.get(from.domainId)) return;const target = id;const source = mergeFrom;// Leave merge mode whatever the outcome, so a failure does not strand the page in it.@@ -184,10 +239,12 @@ const MemoryRules = () => {setSelectedId(selectedId === id ? undefined : id);};+ // Writing files into the part on screen: the header offers its groups, a group's `+` that group.const compose = (defaultGroupId?: string) =>createComposeRuleModal({+ canOpenGroup: part.key === 'mine',defaultGroupId,- groups,+ groups: part.groups,onCreated: (id) => {setSelectedId(id);void refresh();@@ -201,8 +258,9 @@ const MemoryRules = () => {<RuleRowactive={rule.id === selectedId}code={codes.get(rule.id) ?? ''}- menu={buildRuleMenu(t, rule, groups, handlers)}+ menu={buildRuleMenu(t, rule, sameSection(rule.domainId), handlers)}rule={rule}+ taughtToAgent={part.owner.kind === 'agent'}archivedInto={(() => {const into = mergedIntoId(rule);return into ? (all.find((r) => r.id === into)?.title ?? into) : null;@@ -212,6 +270,52 @@ const MemoryRules = () => {/>);+ const renderGroup = (group: (typeof groups)[number]) => {+ const items = group.rules.filter((rule) => rule.status === 'active');+ const isCollapsed = Boolean(collapsed[group.domain.id]);+ return (+ <div key={group.domain.id}>+ <GroupSection+ collapsed={isCollapsed}+ count={items.length}+ group={group}+ menu={[+ {+ disabled: true,+ key: 'gate',+ label: (+ <span className={styles.muted} style={{ display: 'block', maxWidth: 280 }}>+ {t('rules.group.gate', { gate: group.domain.domainFilter })}+ </span>+ ),+ },+ { type: 'divider' },+ {+ icon: <Icon icon={PencilIcon} />,+ key: 'rename',+ label: t('rules.actions.renameGroup'),+ onClick: () => openGroupModal(group),+ },+ ]}+ onToggle={() => setCollapsed((c) => ({ ...c, [group.domain.id]: !c[group.domain.id] }))}+ onWrite={() => compose(group.domain.id)}+ />+ {isCollapsed ? null : items.length === 0 ? (+ <div className={styles.muted} style={{ padding: '10px 8px' }}>+ {t('rules.group.empty')}+ </div>+ ) : (+ <SortableList+ gap={0}+ items={items}+ renderItem={renderRow}+ onChange={(next) => void reorder(group.domain.id, next)}+ />+ )}+ </div>+ );+ };+if (!enabled) {return (<Flexbox height={'100%'} width={'100%'}>@@ -238,13 +342,22 @@ const MemoryRules = () => {<Text fontSize={26} weight={700}>{t('rules.title')}</Text>- <Text type={'secondary'}>{t('rules.subtitle', { count: live.length })}</Text>+ {/* A count of zero says nothing; with no rules yet, only what agents learned. */}+ {!isEmpty && (+ <Text type={'secondary'}>+ {ruleCount > 0+ ? t('rules.subtitle', { lessons: lessonCount, rules: ruleCount })+ : t('rules.subtitleAgentsOnly', { lessons: lessonCount })}+ </Text>+ )}</Flexbox>{/* One primary action. Writing a rule also opens the group when the reviewer hasnone, so a separate "new group" button would be a second way to start. */}- <Button icon={<Icon icon={PlusIcon} />} type={'primary'} onClick={() => compose()}>- {t('rules.actions.write')}- </Button>+ {!mineOnboarding && (+ <Button icon={<Icon icon={PlusIcon} />} type={'primary'} onClick={() => compose()}>+ {t('rules.actions.write')}+ </Button>+ )}</Flexbox>{mergeFrom && (@@ -270,92 +383,65 @@ const MemoryRules = () => {isLoading={isLoading}loading={<Loading debugId={'MemoryRules'} />}empty={- <Empty- icon={ScaleIcon}- title={t('rules.empty.title')}- description={- <Flexbox align={'center'} gap={8}>- <span>{t('rules.empty.description')}</span>- {Boolean(data?.backlogRounds) && (- <Text fontSize={13} type={'secondary'}>- {t('rules.backlog', { count: data!.backlogRounds })}- </Text>- )}- <Button onClick={() => compose()}>{t('rules.empty.write')}</Button>- </Flexbox>- }- />+ <RulesOnboarding backlogRounds={data?.backlogRounds} onWrite={() => compose()} />}onRetry={() => void refresh()}><div>- <div className={cx(styles.grid, styles.thead)}>- <span />- <span>{t('rules.columns.code')}</span>- <span>{t('rules.columns.rule')}</span>- <span>{t('rules.columns.enforcement')}</span>- <span>{t('rules.columns.method')}</span>- <span>{t('rules.columns.runs')}</span>- <span />- </div>- {groups.map((group) => {- const items = group.rules.filter((rule) => rule.status === 'active');- const isCollapsed = Boolean(collapsed[group.domain.id]);- return (- <div key={group.domain.id}>- <GroupSection- collapsed={isCollapsed}- count={items.length}- group={group}- menu={[- {- disabled: true,- key: 'gate',- label: (- <span- className={styles.muted}- style={{ display: 'block', maxWidth: 280 }}- >- {t('rules.group.gate', { gate: group.domain.domainFilter })}- </span>- ),- },- { type: 'divider' },- {- icon: <Icon icon={PencilIcon} />,- key: 'rename',- label: t('rules.actions.renameGroup'),- onClick: () => openGroupModal(group),- },- ]}- onWrite={() => compose(group.domain.id)}- onToggle={() =>- setCollapsed((c) => ({ ...c, [group.domain.id]: !c[group.domain.id] }))- }- />- {isCollapsed ? null : items.length === 0 ? (- <div className={styles.muted} style={{ padding: '10px 8px' }}>- {t('rules.group.empty')}- </div>- ) : (- <SortableList- gap={0}- items={items}- renderItem={renderRow}- onChange={(next) => void reorder(group.domain.id, next)}- />- )}- </div>- );- })}- {archived.length > 0 && (+ {/* Whose sheet this is: the reviewer's own rules, or one agent's lessons. Only+ shown once some agent has learned something, so there is a choice to make. */}+ {sections.length > 1 && (+ <Flexbox horizontal paddingBlock={'0 12px'} paddingInline={8}>+ <Segmented+ value={part.key}+ options={sections.map((section) => ({+ label: (+ <OwnerLabel+ owner={section.owner}+ count={+ section.groups+ .flatMap((group) => group.rules)+ .filter((rule) => rule.status === 'active').length+ }+ />+ ),+ value: section.key,+ }))}+ onChange={(value) => switchPart(String(value))}+ />+ </Flexbox>+ )}+ {!mineOnboarding && (+ <div className={cx(styles.grid, styles.thead)}>+ <span />+ <span>{t('rules.columns.code')}</span>+ <span>{t('rules.columns.rule')}</span>+ <span>{t('rules.columns.enforcement')}</span>+ <span>{t('rules.columns.method')}</span>+ <span>{t('rules.columns.runs')}</span>+ <span />+ </div>+ )}+ {/* The reviewer's part shows even before it holds anything: it is where they+ learn that their rejections become rules. */}+ {mineOnboarding ? (+ <RulesOnboarding+ inline+ agents={onboardingAgents}+ backlogRounds={data?.backlogRounds}+ onWrite={() => compose()}+ />+ ) : (+ part.groups.map(renderGroup)+ )}+ {partArchived.length > 0 && (<><div className={styles.divider}>- {t('rules.archived.group', { count: archived.length })}+ {t('rules.archived.group', { count: partArchived.length })}</div><SortableListgap={0}- items={archived}+ items={partArchived}renderItem={renderRow}onChange={() => {}}/>@@ -370,9 +456,11 @@ const MemoryRules = () => {code={selected ? codes.get(selected.id) : undefined}group={groups.find((group) => group.domain.id === selected?.domainId)}groups={groups}- menu={selected ? buildRuleMenu(t, selected, groups, handlers) : []}rule={selected}titleEditing={titleEditing}+ menu={+ selected ? buildRuleMenu(t, selected, sameSection(selected.domainId), handlers) : []+ }onTitleEditing={setTitleEditing}onClose={() => {setSelectedId(undefined);diff --git a/src/features/MemoryRules/labels.test.ts b/src/features/MemoryRules/labels.test.tsindex c6660883065..380e2d058cf 100644--- a/src/features/MemoryRules/labels.test.ts+++ b/src/features/MemoryRules/labels.test.ts@@ -1,6 +1,15 @@import { describe, expect, it } from 'vitest';-import { appendException, findMove, revisionAuthorKey, ruleOrigin, sectionBody } from './labels';+import type { RuleGroup } from '@/services/expertise';++import {+ appendException,+ findMove,+ revisionAuthorKey,+ ruleOrigin,+ sectionBody,+ sectionsByOwner,+} from './labels';describe('appendException', () => {it('keeps the exceptions already written and adds the new one below', () => {@@ -86,3 +95,30 @@ describe('sectionBody', () => {expect(sectionBody({ sections }, 'limits')).toBeUndefined();});});++describe('sectionsByOwner', () => {+ const agent = (id: string) => ({+ agent: { avatar: null, backgroundColor: null, id, title: id },+ kind: 'agent' as const,+ });+ const group = (id: string, owner: RuleGroup['owner']) =>+ ({ domain: { id }, owner, rules: [], scopes: [] }) as unknown as RuleGroup;++ it("puts the reviewer's rules first and gathers each agent's groups together", () => {+ const sections = sectionsByOwner([+ group('mine-1', { kind: 'mine' }),+ group('fox-1', agent('fox')),+ group('owl-1', agent('owl')),+ group('fox-2', agent('fox')),+ ]);++ expect(sections.map((s) => s.key)).toEqual(['mine', 'agent:fox', 'agent:owl']);+ expect(sections[1].groups.map((g) => g.domain.id)).toEqual(['fox-1', 'fox-2']);+ });++ it("keeps the reviewer's part even when only agents have learned anything", () => {+ const sections = sectionsByOwner([group('fox-1', agent('fox'))]);++ expect(sections[0]).toMatchObject({ groups: [], key: 'mine' });+ });+});diff --git a/src/features/MemoryRules/labels.ts b/src/features/MemoryRules/labels.tsindex 75dc2fc98fe..2bebd59a377 100644--- a/src/features/MemoryRules/labels.ts+++ b/src/features/MemoryRules/labels.ts@@ -1,6 +1,6 @@import { useTranslation } from 'react-i18next';-import type { RuleItem, RuleRevision, RuleScope } from '@/services/expertise';+import type { RuleGroup, RuleItem, RuleRevision, RuleScope } from '@/services/expertise';export type RuleSectionKey = 'rule' | 'why' | 'how' | 'limits';@@ -47,6 +47,34 @@ export const ruleOrigin = (return { key: 'learned' } as const;};+/** One part of the page: the reviewer's own rules, or everything one agent learned. */+export interface OwnerSection {+ groups: RuleGroup[];+ key: string;+ owner: RuleGroup['owner'];+}++/**+ * Splits the server's groups into the page's parts, keeping the server's order: the reviewer's+ * rules always come first (and always appear, so writing a first rule has a place to land),+ * then one part per agent.+ */+export const sectionsByOwner = (groups: RuleGroup[]): OwnerSection[] => {+ const mine: OwnerSection = { groups: [], key: 'mine', owner: { kind: 'mine' } };+ const agents = new Map<string, OwnerSection>();+ for (const group of groups) {+ if (group.owner.kind === 'mine') {+ mine.groups.push(group);+ continue;+ }+ const key = `agent:${group.owner.agent.id}`;+ const section = agents.get(key) ?? { groups: [], key, owner: group.owner };+ section.groups.push(group);+ agents.set(key, section);+ }+ return [mine, ...agents.values()];+};+/** Where a rule went when it was archived by a merge, or null for a plain archive. */export const mergedIntoId = (rule: Pick<RuleItem, 'rejectedReason'>) =>rule.rejectedReason?.startsWith('merged-into:')diff --git a/src/features/MemoryRules/styles.ts b/src/features/MemoryRules/styles.tsindex 1f7d498da66..56a359764d2 100644--- a/src/features/MemoryRules/styles.ts+++ b/src/features/MemoryRules/styles.ts@@ -72,6 +72,11 @@ export const styles = createStaticStyles(({ css }) => ({line-height: 1.6;color: ${cssVar.colorTextSecondary};`,+ ownerCount: css`+ font-size: 12px;+ font-weight: 400;+ color: ${cssVar.colorTextTertiary};+ `,row: css`cursor: pointer;diff --git a/src/features/Settings/labs/features.ts b/src/features/Settings/labs/features.tsindex 116826e3694..8b698f10e95 100644--- a/src/features/Settings/labs/features.ts+++ b/src/features/Settings/labs/features.ts@@ -24,7 +24,6 @@ type LabFeatureI18nKey =| 'imessage'| 'inputMarkdown'| 'integrations'- | 'memoryRules'| 'messageTextSelectionActions'| 'oauthApps'| 'projects'@@ -67,16 +66,18 @@ export const LAB_FEATURES: LabFeatureItem[] = [searchKeywords: ['text selection', 'quote'],stage: 'alpha',},- {- flag: 'enableMemoryRules',- i18nKey: 'memoryRules',- searchKeywords: ['rules', 'memory rules', 'delivery rules', 'verifier'],- stage: 'alpha',- },{flag: 'enableSelfLearning',i18nKey: 'selfLearning',- searchKeywords: ['self-evolving', 'self learning', 'rule base'],+ searchKeywords: [+ 'self-evolving',+ 'self learning',+ 'rule base',+ 'rules',+ 'memory rules',+ 'delivery rules',+ 'verifier',+ ],stage: 'alpha',},{diff --git a/src/routes/(main)/memory/_layout/Sidebar/Header/Nav.tsx b/src/routes/(main)/memory/_layout/Sidebar/Header/Nav.tsxindex 691dec4be7f..f623025fd5d 100644--- a/src/routes/(main)/memory/_layout/Sidebar/Header/Nav.tsx+++ b/src/routes/(main)/memory/_layout/Sidebar/Header/Nav.tsx@@ -51,7 +51,7 @@ const Nav = memo(() => {const navigate = useWorkspaceAwareNavigate();const { t } = useTranslation('memory');const toggleCommandMenu = useGlobalStore((s) => s.toggleCommandMenu);- const enableRules = useUserStore(labPreferSelectors.enableMemoryRules);+ const enableSelfLearning = useUserStore(labPreferSelectors.enableSelfLearning);/*** Four groups, separated by space rather than rules: what the whole section is (home), what it@@ -79,9 +79,9 @@ const Nav = memo(() => {url: '/memory',},],- // Rules are still an alpha lab: the group disappears with the flag rather than sitting- // there disabled, so the sidebar of everyone else reads exactly as before.- ...(enableRules+ // Self-evolving is still an alpha lab: the group disappears with the flag rather than+ // sitting there disabled, so the sidebar of everyone else reads exactly as before.+ ...(enableSelfLearning? [[{@@ -122,7 +122,7 @@ const Nav = memo(() => {},],],- [t, toggleCommandMenu, enableRules],+ [t, toggleCommandMenu, enableSelfLearning],);return (diff --git a/src/store/user/slices/preference/selectors/labPrefer.ts b/src/store/user/slices/preference/selectors/labPrefer.tsindex 20a0113b129..40c972d249c 100644--- a/src/store/user/slices/preference/selectors/labPrefer.ts+++ b/src/store/user/slices/preference/selectors/labPrefer.ts@@ -21,7 +21,6 @@ export const labPreferSelectors = {enableIntegrations: (s: UserState): boolean => s.preference.lab?.enableIntegrations ?? false,enableInputMarkdown: (s: UserState): boolean =>s.preference.lab?.enableInputMarkdown ?? DEFAULT_PREFERENCE.lab?.enableInputMarkdown ?? true,- enableMemoryRules: (s: UserState): boolean => s.preference.lab?.enableMemoryRules ?? false,enableMessageTextSelectionActions: (s: UserState): boolean =>s.preference.lab?.enableMessageTextSelectionActions ??DEFAULT_PREFERENCE.lab?.enableMessageTextSelectionActions ??