Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

✨ feat(self-learning): make the domain anchor rationale editable (#18517)

Arvin Xu63a2778092ce
diff --git a/locales/en-US/selfLearning.json b/locales/en-US/selfLearning.json
index dca540f0853..443819f46e4 100644
--- a/locales/en-US/selfLearning.json
+++ b/locales/en-US/selfLearning.json
@@ -26,6 +26,7 @@
"create.adjust.placeholder.domainFilter": "e.g. Include delegated scheduling and information triage, but only for a named principal…",
"create.adjust.placeholder.layers": "e.g. Make these a true progression of proficiency, rather than stages in a workflow…",
"create.adjust.placeholder.outOfScope": "e.g. Exclude general project management and decisions made on behalf of the principal…",
+ "create.adjust.placeholder.rationale": "e.g. Say plainly what I will get better at, without listing the layers again…",
"create.adjust.title": "Adjust with AI",
"create.anchor.addCanon": "Add",
"create.anchor.addLayer": "Add",
@@ -51,6 +52,7 @@
"create.field.domainFilter": "What counts as practice",
"create.field.outOfScope": "What does not count",
"create.field.outOfScopePlaceholder": "e.g. design discussions, general Q&A…",
+ "create.field.rationalePlaceholder": "How it reads this direction, and where it will improve…",
"create.field.title": "Name",
"create.generate": "Generate with AI",
"create.generating": "Reading your brief…",
diff --git a/locales/zh-CN/selfLearning.json b/locales/zh-CN/selfLearning.json
index 7fcdafffbb4..140d8535784 100644
--- a/locales/zh-CN/selfLearning.json
+++ b/locales/zh-CN/selfLearning.json
@@ -26,6 +26,7 @@
"create.adjust.placeholder.domainFilter": "例如:包含日程协调和信息筛选,但必须服务于一位明确的主体人…",
"create.adjust.placeholder.layers": "例如:把分层改成真正的能力递进,不要使用工作流程阶段…",
"create.adjust.placeholder.outOfScope": "例如:排除通用项目管理,以及代替主体人做决策…",
+ "create.adjust.placeholder.rationale": "例:把这段说得更直白些,别再重复分层的名字…",
"create.adjust.title": "让 AI 调整",
"create.anchor.addCanon": "添加",
"create.anchor.addLayer": "添加",
@@ -51,6 +52,7 @@
"create.field.domainFilter": "什么算实践",
"create.field.outOfScope": "什么不算",
"create.field.outOfScopePlaceholder": "例:方案讨论、通用问答…",
+ "create.field.rationalePlaceholder": "它如何理解这个方向,以及打算在哪里进步…",
"create.field.title": "名称",
"create.generate": "一键生成",
"create.generating": "正在读你的描述…",
diff --git a/packages/locales/src/default/selfLearning.ts b/packages/locales/src/default/selfLearning.ts
index b3093abe8ab..e4c14fcc128 100644
--- a/packages/locales/src/default/selfLearning.ts
+++ b/packages/locales/src/default/selfLearning.ts
@@ -46,6 +46,8 @@ export default {
'e.g. Make these a true progression of proficiency, rather than stages in a workflow…',
'create.adjust.placeholder.outOfScope':
'e.g. Exclude general project management and decisions made on behalf of the principal…',
+ 'create.adjust.placeholder.rationale':
+ 'e.g. Say plainly what I will get better at, without listing the layers again…',
'create.adjust.title': 'Adjust with AI',
'create.back': 'Back',
'create.briefHelp':
@@ -59,6 +61,7 @@ export default {
'create.field.domainFilter': 'What counts as practice',
'create.field.outOfScope': 'What does not count',
'create.field.outOfScopePlaceholder': 'e.g. design discussions, general Q&A…',
+ 'create.field.rationalePlaceholder': 'How it reads this direction, and where it will improve…',
'create.field.title': 'Name',
'create.generate': 'Generate with AI',
'create.generating': 'Reading your brief…',
diff --git a/src/features/SelfLearning/CreateDomainPage.tsx b/src/features/SelfLearning/CreateDomainPage.tsx
index 79df8d542c4..da667f632dc 100644
--- a/src/features/SelfLearning/CreateDomainPage.tsx
+++ b/src/features/SelfLearning/CreateDomainPage.tsx
@@ -39,6 +39,7 @@ const emptyAdjustments: Record<AdjustmentTarget, string> = {
domainFilter: '',
layers: '',
outOfScope: '',
+ rationale: '',
};
const styles = createStaticStyles(({ css }) => ({
@@ -200,6 +201,8 @@ const styles = createStaticStyles(({ css }) => ({
`,
rationale: css`
margin: 0;
+ padding-inline: 0;
+
font-size: 16px;
line-height: 1.75;
color: ${cssVar.colorText};
@@ -348,6 +351,7 @@ const CreateDomainPage = memo(() => {
domainFilter: draft.domainFilter.trim(),
layers: draft.layers.filter((l) => l.title.trim()),
outOfScope: draft.outOfScope?.trim() || null,
+ rationale: draft.rationale?.trim() || null,
title: draft.title.trim(),
});
if (storageKey) localStorage.removeItem(storageKey);
@@ -597,10 +601,24 @@ const CreateDomainPage = memo(() => {
</Flexbox>
<Divider style={{ margin: 0 }} />
<Flexbox className={styles.reviewSection} gap={12}>
- <Text fontSize={14} type={'secondary'}>
- {t('create.reviewHelp')}
- </Text>
- {draft.rationale && <div className={styles.rationale}>{draft.rationale}</div>}
+ <Flexbox horizontal align={'flex-start'} gap={8} justify={'space-between'}>
+ <Text fontSize={14} type={'secondary'}>
+ {t('create.reviewHelp')}
+ </Text>
+ <Flexbox flex={'none'}>{renderAdjustmentButton('rationale')}</Flexbox>
+ </Flexbox>
+ <TextArea
+ autoSize={{ maxRows: 8, minRows: 2 }}
+ className={styles.rationale}
+ // An in-flight adjustment answers from the draft as it was when the
+ // request left, so edits made meanwhile would be silently overwritten
+ // when the response merges back.
+ disabled={refiningTarget === 'rationale'}
+ placeholder={t('create.field.rationalePlaceholder')}
+ value={draft.rationale ?? ''}
+ variant={'borderless'}
+ onChange={(e) => patch({ rationale: e.target.value })}
+ />
</Flexbox>
<Flexbox className={styles.reviewSection} gap={10}>
diff --git a/src/features/SelfLearning/createDomainAdjustment.test.ts b/src/features/SelfLearning/createDomainAdjustment.test.ts
index d5e743606d6..30c672a6c47 100644
--- a/src/features/SelfLearning/createDomainAdjustment.test.ts
+++ b/src/features/SelfLearning/createDomainAdjustment.test.ts
@@ -30,6 +30,7 @@ describe('mergeAdjustedBlock', () => {
it.each([
['domainFilter', 'New filter'],
['outOfScope', 'New exclusion'],
+ ['rationale', 'New rationale'],
['canonEntries', adjusted.canonEntries],
['layers', adjusted.layers],
] as const)('only replaces the requested %s block', (target, expected) => {
diff --git a/src/features/SelfLearning/createDomainAdjustment.ts b/src/features/SelfLearning/createDomainAdjustment.ts
index 8a112754477..7351fe5cf6f 100644
--- a/src/features/SelfLearning/createDomainAdjustment.ts
+++ b/src/features/SelfLearning/createDomainAdjustment.ts
@@ -1,6 +1,7 @@
import type { ExpertiseDomainDraft } from '@/services/expertise';
-export type AdjustmentTarget = 'canonEntries' | 'domainFilter' | 'layers' | 'outOfScope';
+export type AdjustmentTarget =
+ 'canonEntries' | 'domainFilter' | 'layers' | 'outOfScope' | 'rationale';
export const mergeAdjustedBlock = (
current: ExpertiseDomainDraft,