🤯 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
💄 Polish goal creation experience (#18079)
Arvin Xu62adb7d593f5
diff --git a/locales/en-US/chat.json b/locales/en-US/chat.jsonindex 77d91a0947f..6824881ccca 100644--- a/locales/en-US/chat.json+++ b/locales/en-US/chat.json@@ -218,6 +218,7 @@"connectAgent.providerDesc.qoder": "Qoder coding agent CLI","createGoal.addCriterion": "Add criterion","createGoal.back": "Back",+ "createGoal.budgetTitle": "Budget","createGoal.contextHint": "Add constraints, source material, or anything the Agent should know","createGoal.contextLabel": "Context for the Agent","createGoal.costBudgetHint": "Stops once total spend reaches this amount; leave blank for no cap.",@@ -225,9 +226,10 @@"createGoal.costBudgetPlaceholder": "No cap","createGoal.createFailed": "Failed to create goal","createGoal.criteriaHint": "Review and edit these before the goal starts",- "createGoal.criteriaTitle": "What counts as done",+ "createGoal.criteriaTitle": "Acceptance criteria","createGoal.criterionPlaceholder": "Describe a result that can be clearly checked","createGoal.describeHint": "Describe the outcome first, then complete its execution plan.",+ "createGoal.describeTitle": "What outcome do you want?","createGoal.generateFailed": "Could not draft acceptance criteria. Try again.","createGoal.instructionPlaceholder": "Add any context the agent needs — scope, constraints, where to look…","createGoal.next": "Next",@@ -245,7 +247,7 @@"createGoal.roundBudgetUncappedHint": "It keeps going until the goal is reached — watch the cost.","createGoal.roundsUnit": "rounds","createGoal.submit": "Create goal",- "createGoal.titlePlaceholder": "The outcome you want",+ "createGoal.titlePlaceholder": "Goal title","createModal.createBlank": "Start Blank","createModal.groupPlaceholder": "Describe what this Group should do...","createModal.groupTitle": "What should this Group do?",diff --git a/locales/zh-CN/chat.json b/locales/zh-CN/chat.jsonindex 4751284f952..bdcd0523ee9 100644--- a/locales/zh-CN/chat.json+++ b/locales/zh-CN/chat.json@@ -218,6 +218,7 @@"connectAgent.providerDesc.qoder": "Qoder 编码助理 CLI","createGoal.addCriterion": "添加验收标准","createGoal.back": "返回",+ "createGoal.budgetTitle": "预算","createGoal.contextHint": "补充约束、参考资料或 Agent 开始前需要知道的信息","createGoal.contextLabel": "给 Agent 的补充背景","createGoal.costBudgetHint": "累计花费达到这个金额就停下,留空表示不限。",@@ -225,9 +226,10 @@"createGoal.costBudgetPlaceholder": "不限","createGoal.createFailed": "创建目标失败","createGoal.criteriaHint": "目标开始前,你可以逐条检查和修改",- "createGoal.criteriaTitle": "什么算做到了",+ "createGoal.criteriaTitle": "验收标准","createGoal.criterionPlaceholder": "描述一个能够明确检查的结果","createGoal.describeHint": "先描述想要的结果,下一步再完善完整执行计划。",+ "createGoal.describeTitle": "你想要的效果","createGoal.generateFailed": "没能起草验收标准,请重试。","createGoal.instructionPlaceholder": "补充 Agent 需要的背景 —— 范围、约束、从哪里入手……","createGoal.next": "下一步",@@ -245,7 +247,7 @@"createGoal.roundBudgetUncappedHint": "会一直跑到达成为止,注意花费。","createGoal.roundsUnit": "轮","createGoal.submit": "创建目标",- "createGoal.titlePlaceholder": "你想要的结果",+ "createGoal.titlePlaceholder": "目标标题","createModal.createBlank": "从空白开始","createModal.groupPlaceholder": "描述这个群组要完成什么…","createModal.groupTitle": "这个群组要做什么?",diff --git a/packages/builtin-tool-task/src/client/Intervention/CriterionEditModal.test.ts b/packages/builtin-tool-task/src/client/Intervention/CriterionEditModal.test.tsnew file mode 100644index 00000000000..73e373ffe8d--- /dev/null+++ b/packages/builtin-tool-task/src/client/Intervention/CriterionEditModal.test.ts@@ -0,0 +1,38 @@+import { describe, expect, it, vi } from 'vitest';++import { openCriterionEditModal } from './CriterionEditModal';++const mocks = vi.hoisted(() => ({ createModal: vi.fn((options) => options) }));++vi.mock('@lobehub/ui', () => ({+ Flexbox: () => null,+ Input: () => null,+ Text: () => null,+ TextArea: () => null,+}));++vi.mock('@lobehub/ui/base-ui', () => ({+ Button: () => null,+ Select: () => null,+ Switch: () => null,+ createModal: mocks.createModal,+ useModalContext: () => ({ close: vi.fn() }),+}));++vi.mock('react-i18next', () => ({+ useTranslation: () => ({ t: (key: string) => key }),+}));++describe('openCriterionEditModal', () => {+ it('renders the title through react-i18next so a lazily loaded namespace can update it', () => {+ openCriterionEditModal({+ criterion: { required: true, title: 'Check result', verifierType: 'agent' },+ onSubmit: vi.fn(),+ seq: 2,+ });++ const options = mocks.createModal.mock.calls[0][0];++ expect(typeof options.title).not.toBe('string');+ });+});diff --git a/packages/builtin-tool-task/src/client/Intervention/CriterionEditModal.tsx b/packages/builtin-tool-task/src/client/Intervention/CriterionEditModal.tsxindex ab232255b9d..9278a54c00f 100644--- a/packages/builtin-tool-task/src/client/Intervention/CriterionEditModal.tsx+++ b/packages/builtin-tool-task/src/client/Intervention/CriterionEditModal.tsx@@ -9,7 +9,6 @@ import {Switch,useModalContext,} from '@lobehub/ui/base-ui';-import { t } from 'i18next';import { memo, useState } from 'react';import { useTranslation } from 'react-i18next';@@ -23,6 +22,18 @@ interface CriterionEditContentProps {seq: number;}+const CriterionEditTitle = memo<Pick<CriterionEditContentProps, 'isNew' | 'seq'>>(+ ({ isNew, seq }) => {+ const { t } = useTranslation('plugin');++ return isNew+ ? t('builtins.lobe-task.goal.addCriterion')+ : t('builtins.lobe-task.goal.editCriterion', { seq });+ },+);++CriterionEditTitle.displayName = 'GoalCriterionEditTitle';+/*** A criterion's judge prompt is the thing the whole loop is scored against, so* it gets a real editing surface rather than a row that grows a textarea in@@ -118,8 +129,6 @@ export const openCriterionEditModal = (props: CriterionEditContentProps): ModalIcontent: <CriterionEditContent {...props} />,footer: null,maskClosable: true,- title: props.isNew- ? t('builtins.lobe-task.goal.addCriterion', { ns: 'plugin' })- : t('builtins.lobe-task.goal.editCriterion', { ns: 'plugin', seq: props.seq }),+ title: <CriterionEditTitle isNew={props.isNew} seq={props.seq} />,width: 'min(90vw, 560px)',});diff --git a/packages/builtin-tool-task/src/client/index.ts b/packages/builtin-tool-task/src/client/index.tsindex 22612e4c0f6..6d891db5a55 100644--- a/packages/builtin-tool-task/src/client/index.ts+++ b/packages/builtin-tool-task/src/client/index.ts@@ -16,6 +16,7 @@ export {ViewTaskInspector,} from './Inspector';export { TaskInterventions } from './Intervention';+export { openCriterionEditModal } from './Intervention/CriterionEditModal';// Render components (read-only snapshots)export {diff --git a/packages/locales/src/default/chat.ts b/packages/locales/src/default/chat.tsindex 5985f3df855..f125a62aca6 100644--- a/packages/locales/src/default/chat.ts+++ b/packages/locales/src/default/chat.ts@@ -1441,11 +1441,13 @@ export default {'createGoal.costBudgetPlaceholder': 'No cap','createGoal.createFailed': 'Failed to create goal','createGoal.back': 'Back',+ 'createGoal.budgetTitle': 'Budget','createGoal.contextLabel': 'Context for the Agent','createGoal.contextHint': 'Add constraints, source material, or anything the Agent should know','createGoal.criterionPlaceholder': 'Describe a result that can be clearly checked','createGoal.criteriaHint': 'Review and edit these before the goal starts',- 'createGoal.criteriaTitle': 'What counts as done',+ 'createGoal.criteriaTitle': 'Acceptance criteria',+ 'createGoal.describeTitle': 'What outcome do you want?','createGoal.describeHint': 'Describe the outcome first, then complete its execution plan.','createGoal.generateFailed': 'Could not draft acceptance criteria. Try again.','createGoal.instructionPlaceholder':@@ -1468,7 +1470,7 @@ export default {'createGoal.roundBudgetUncappedHint':'It keeps going until the goal is reached — watch the cost.','createGoal.submit': 'Create goal',- 'createGoal.titlePlaceholder': 'The outcome you want',+ 'createGoal.titlePlaceholder': 'Goal title','createTask.assignee': 'Assignee','createTask.collapse': 'Hide input','createTask.createFailed': 'Failed to create task',diff --git a/src/features/AgentGoals/CreateGoalModal/CreateGoalContent.tsx b/src/features/AgentGoals/CreateGoalModal/CreateGoalContent.tsxindex 34c8f1915aa..02b05fa9b7e 100644--- a/src/features/AgentGoals/CreateGoalModal/CreateGoalContent.tsx+++ b/src/features/AgentGoals/CreateGoalModal/CreateGoalContent.tsx@@ -1,19 +1,21 @@'use client';import type { CreateGoalParams, GoalCriterionDraft } from '@lobechat/builtin-tool-task';+import { openCriterionEditModal } from '@lobechat/builtin-tool-task/client';import { DEFAULT_GOAL_MAX_ROUNDS } from '@lobechat/const/verify';import { useEditor } from '@lobehub/editor/react';-import { ActionIcon, Flexbox, Icon, Input, Text } from '@lobehub/ui';+import { ActionIcon, Flexbox, Icon, Text } from '@lobehub/ui';import { Button, toast, useModalContext } from '@lobehub/ui/base-ui';import { InputNumber } from 'antd';import { createStaticStyles, cssVar } from 'antd-style';import {ArrowLeft,- CheckCircle2,- CircleDollarSign,+ CircleDashed,Paperclip,+ Pencil,+ PencilLine,Plus,- RotateCcw,+ ShieldCheck,Trash2,X,} from 'lucide-react';@@ -32,59 +34,58 @@ import { usePermission } from '@/hooks/usePermission';import { verifyService } from '@/services/verify';import { useTaskStore } from '@/store/task';-import { buildGoalTaskConfig } from './goalConfig';+import { buildGoalTaskConfig, deriveInitialGoalCriterionTitle } from './goalConfig';+import { deriveGoalTitle } from './goalTitle';const styles = createStaticStyles(({ css }) => ({- budgetCard: css`- min-width: 0;- padding: 16px;- border: 1px solid ${cssVar.colorBorderSecondary};- border-radius: ${cssVar.borderRadius};-- background: ${cssVar.colorFillQuaternary};- `,- budgetGrid: css`+ budgetField: css`display: grid;- grid-template-columns: repeat(2, minmax(0, 1fr));+ grid-template-columns: 96px 144px minmax(0, 1fr);gap: 12px;+ align-items: center;++ min-width: 0;@media (width <= 640px) {grid-template-columns: minmax(0, 1fr);+ gap: 6px;}`,body: css`overflow-y: auto;+min-height: 0;+ max-height: min(70vh, 680px);padding-block: 8px 24px;- padding-inline: 24px;+ padding-inline: 16px;+ `,+ close: css`+ position: absolute;+ inset-block-start: 14px;+ inset-inline-end: 14px;`,criteriaList: css`+ overflow: hidden;overflow-y: auto;- max-height: 240px;+ max-height: 320px;+ padding: 0;`,criterion: css`- padding-block: 8px;- padding-inline: 10px;- border: 1px solid ${cssVar.colorBorderSecondary};- border-radius: ${cssVar.borderRadius};+ cursor: pointer;+ padding-block: 10px;- background: ${cssVar.colorBgElevated};+ & + & {+ border-block-start: 1px solid ${cssVar.colorBorderSecondary};+ }++ &:hover {+ background: ${cssVar.colorFillQuaternary};+ }`,criterionIndex: css`- display: flex;flex: none;- align-items: center;- justify-content: center;-- width: 24px;- height: 24px;- border-radius: ${cssVar.borderRadiusSM};-- font-family: ${cssVar.fontFamilyCode};font-size: 12px;- color: ${cssVar.colorTextSecondary};-- background: ${cssVar.colorFillSecondary};+ color: ${cssVar.colorTextTertiary};`,footer: css`padding-block: 8px;@@ -92,26 +93,59 @@ const styles = createStaticStyles(({ css }) => ({border-block-start: 1px solid ${cssVar.colorBorderSecondary};`,head: css`+ position: relative;padding-block: 16px 8px;- padding-inline: 24px;+ padding-inline: 16px;`,inputShell: css`- padding: 1px;- border: 1px solid ${cssVar.colorBorderSecondary};- border-radius: ${cssVar.borderRadiusLG};+ position: relative;++ overflow: hidden;++ min-height: 208px;+ border-block: 1px solid ${cssVar.colorBorderSecondary};+ border-radius: 8px;+background: ${cssVar.colorBgElevated};`,inputShellLoading: css`border-color: transparent;- background: linear-gradient(- 90deg,- ${cssVar.colorPrimary},- ${cssVar.colorInfo},- ${cssVar.colorSuccess},- ${cssVar.colorPrimary}- );- background-size: 300% 100%;- animation: goal-input-flow 1.4s linear infinite;+ background: ${cssVar.colorBgElevated};++ &::after {+ pointer-events: none;+ content: '';++ position: absolute;+ z-index: 1;+ inset: 0;++ padding: 2px;+ border-radius: inherit;++ background: linear-gradient(+ 90deg,+ ${cssVar.colorBorderSecondary} 0%,+ ${cssVar.colorBorderSecondary} 16%,+ #ff3d8d 30%,+ #8b5cf6 40%,+ #00c8ff 50%,+ #22e6a8 60%,+ #ffd43b 70%,+ #ff6b35 80%,+ ${cssVar.colorBorderSecondary} 92%,+ ${cssVar.colorBorderSecondary} 100%+ );+ background-size: 300% 100%;++ mask:+ linear-gradient(#fff 0 0) content-box,+ linear-gradient(#fff 0 0);++ animation: goal-input-flow 1.2s linear infinite;++ mask-composite: exclude;+ }@keyframes goal-input-flow {from {@@ -124,22 +158,48 @@ const styles = createStaticStyles(({ css }) => ({}@media (prefers-reduced-motion: reduce) {- animation: none;+ &::after {+ animation: none;+ }}`,- section: css`- padding: 16px;- border: 1px solid ${cssVar.colorBorderSecondary};- border-radius: ${cssVar.borderRadiusLG};- background: ${cssVar.colorFillQuaternary};+ instructionEditor: css`+ min-height: 36px;+ padding-block: 0 4px;+ padding-inline: 12px;++ /* EditorCanvas reserves space for its document footer by default. The+ compact review summary has no footer, so keeping that space turns a+ one-line instruction into a conspicuous empty band. */+ & > div > div > div {+ padding-block-end: 0 !important;+ }+ `,+ optional: css`+ flex: none;+ color: ${cssVar.colorTextSecondary};+ background: ${cssVar.colorFillSecondary};`,- sectionIcon: css`+ required: css`flex: none;+ color: ${cssVar.colorInfo};+ background: ${cssVar.colorInfoBg};+ `,+ reviewSection: css`+ padding-block: 16px;++ &:first-child {+ padding-block: 0 4px;+ }+ `,+ sectionHint: css`color: ${cssVar.colorTextSecondary};`,title: css`+ box-sizing: border-box;width: 100%;- padding-block: 4px;+ padding-block: 4px 8px;+ padding-inline-end: 40px;border: none;font-family: inherit;@@ -151,11 +211,14 @@ const styles = createStaticStyles(({ css }) => ({background: transparent;outline: none;`,- titleDescribe: css`- padding-block: 10px;- padding-inline: 12px;- border-radius: ${cssVar.borderRadiusLG};- background: ${cssVar.colorBgElevated};+ titleStatic: css`+ padding-block: 4px 8px;+ padding-inline-end: 40px;++ font-size: 20px;+ font-weight: 600;+ line-height: 1.4;+ color: ${cssVar.colorText};`,}));@@ -236,8 +299,9 @@ const CreateGoalContent = memo<CreateGoalContentProps>((props) => {}, [editor]);const handleNext = useCallback(() => {- if (!canCreate || !plan.name.trim()) return;- const seededCriterion = initialRequirement?.trim();+ const instruction = instructionRef.current.trim() || plan.instruction.trim();+ if (!canCreate || !instruction) return;+ const criterionTitle = deriveInitialGoalCriterionTitle(instruction, initialRequirement);setPlan((current) => ({...current,criteria:@@ -247,22 +311,38 @@ const CreateGoalContent = memo<CreateGoalContentProps>((props) => {{onFail: 'auto_repair',required: true,- title: seededCriterion ?? '',+ title: criterionTitle,verifierType: 'agent',},],- instruction: current.instruction.trim() || current.name.trim(),+ instruction,+ name: current.name.trim() || deriveGoalTitle(instruction),}));- instructionRef.current = plan.instruction.trim() || plan.name.trim();+ instructionRef.current = instruction;setStep('preparing');- prepareTimerRef.current = setTimeout(() => setStep('review'), 700);- }, [canCreate, initialRequirement, plan.instruction, plan.name]);+ prepareTimerRef.current = setTimeout(() => setStep('review'), 1200);+ }, [canCreate, initialRequirement, plan.instruction]);++ const handleCreateBlank = useCallback(() => {+ if (!canCreate) return;+ const instruction = instructionRef.current.trim() || plan.instruction.trim();+ setPlan((current) => ({+ ...current,+ criteria:+ current.criteria.length > 0+ ? current.criteria+ : [{ onFail: 'auto_repair', required: true, title: '', verifierType: 'agent' }],+ instruction,+ }));+ instructionRef.current = instruction;+ setStep('review');+ }, [canCreate, plan.instruction]);- const updateCriterion = useCallback((index: number, value: string) => {+ const updateCriterion = useCallback((index: number, value: GoalCriterionDraft) => {setPlan((current) => ({...current,criteria: current.criteria.map((criterion, criterionIndex) =>- criterionIndex === index ? { ...criterion, title: value } : criterion,+ criterionIndex === index ? value : criterion,),}));}, []);@@ -275,14 +355,27 @@ const CreateGoalContent = memo<CreateGoalContentProps>((props) => {}, []);const addCriterion = useCallback(() => {- setPlan((current) => ({- ...current,- criteria: [- ...current.criteria,- { onFail: 'auto_repair', required: true, title: '', verifierType: 'agent' },- ],- }));- }, []);+ openCriterionEditModal({+ criterion: { onFail: 'auto_repair', required: true, title: '', verifierType: 'agent' },+ isNew: true,+ onSubmit: (criterion) =>+ setPlan((current) => ({ ...current, criteria: [...current.criteria, criterion] })),+ seq: plan.criteria.length + 1,+ });+ }, [plan.criteria.length]);++ const editCriterion = useCallback(+ (index: number) => {+ const criterion = plan.criteria[index];+ if (!criterion) return;+ openCriterionEditModal({+ criterion,+ onSubmit: (next) => updateCriterion(index, next),+ seq: index + 1,+ });+ },+ [plan.criteria, updateCriterion],+ );const handleSubmit = useCallback(async () => {if (!canCreate) return;@@ -354,7 +447,7 @@ const CreateGoalContent = memo<CreateGoalContentProps>((props) => {}, []);return (- <Flexbox height={step === 'review' ? 'min(86vh, 800px)' : undefined} onKeyDown={handleKeyDown}>+ <Flexbox onKeyDown={handleKeyDown}><Flexbox horizontal className={styles.head}><Flexbox flex={1} gap={6}>{step === 'review' && (@@ -371,72 +464,72 @@ const CreateGoalContent = memo<CreateGoalContentProps>((props) => {</Flexbox>)}{step === 'review' ? (- <Text fontSize={20} weight={600}>- {plan.name}- </Text>+ <input+ className={styles.title}+ disabled={!canCreate}+ placeholder={t('createGoal.titlePlaceholder')}+ value={plan.name}+ onChange={(e) => setPlan((current) => ({ ...current, name: e.target.value }))}+ />) : (- <div- className={`${styles.inputShell} ${step === 'preparing' ? styles.inputShellLoading : ''}`}- >- <input- autoFocus={canCreate}- className={`${styles.title} ${styles.titleDescribe}`}- disabled={!canCreate || step === 'preparing'}- placeholder={t('createGoal.titlePlaceholder')}- value={plan.name}- onChange={(e) => setPlan((current) => ({ ...current, name: e.target.value }))}- />- </div>+ <div className={styles.titleStatic}>{t('createGoal.describeTitle')}</div>+ )}+ {step !== 'review' && (+ <>+ <div+ className={`${styles.inputShell} ${step === 'preparing' ? styles.inputShellLoading : ''}`}+ >+ <EditorCanvas+ disabled={!canCreate || step === 'preparing'}+ editor={editor}+ editorData={{ content: plan.instruction }}+ entityId={'create-goal-description'}+ floatingToolbar={false}+ placeholder={t('createGoal.instructionPlaceholder')}+ style={{ fontSize: 14, minHeight: 206, padding: 16 }}+ onContentChange={handleContentChange}+ />+ </div>+ <Text type={'secondary'}>{t('createGoal.describeHint')}</Text>+ </>)}- {step !== 'review' && <Text type={'secondary'}>{t('createGoal.describeHint')}</Text>}</Flexbox>- <ActionIcon icon={X} style={{ flexShrink: 0 }} onClick={close} />+ <ActionIcon className={styles.close} icon={X} onClick={close} /></Flexbox>{step === 'review' && (- <Flexbox className={styles.body} flex={1} gap={12}>- <Flexbox className={styles.section} gap={12}>- <Flexbox horizontal align={'flex-start'} gap={10}>- <Icon className={styles.sectionIcon} icon={Paperclip} size={18} />- <Flexbox gap={2}>- <Text fontSize={14} weight={600}>- {t('createGoal.contextLabel')}- </Text>- <Text fontSize={12} type={'secondary'}>- {t('createGoal.contextHint')}- </Text>- </Flexbox>+ <Flexbox className={styles.body}>+ <Flexbox className={styles.reviewSection} gap={10}>+ <Flexbox className={styles.instructionEditor}>+ <EditorCanvas+ disabled={!canCreate}+ editor={editor}+ editorData={{ content: plan.instruction }}+ entityId={'create-goal-instruction'}+ floatingToolbar={false}+ placeholder={t('createGoal.instructionPlaceholder')}+ style={{ fontSize: 13, minHeight: 32 }}+ onContentChange={handleContentChange}+ /></Flexbox>- <EditorCanvas- disabled={!canCreate}- editor={editor}- editorData={{ content: plan.instruction }}- entityId={'create-goal-instruction'}- floatingToolbar={false}- placeholder={t('createGoal.instructionPlaceholder')}- style={{ fontSize: 14, minHeight: 120 }}- onContentChange={handleContentChange}- /></Flexbox>- <Flexbox className={styles.section} gap={12}>+ <Flexbox className={styles.reviewSection} gap={10}><Flexbox horizontal align={'center'} gap={8} justify={'space-between'}>- <Flexbox horizontal align={'flex-start'} gap={10}>- <Icon className={styles.sectionIcon} icon={CheckCircle2} size={18} />- <Flexbox gap={2}>- <Text fontSize={14} weight={600}>- {t('createGoal.criteriaTitle')}- </Text>- <Text fontSize={12} type={'secondary'}>- {t('createGoal.criteriaHint')}- </Text>- </Flexbox>+ <Flexbox horizontal align={'center'} gap={8}>+ <Icon color={cssVar.colorTextTertiary} icon={ShieldCheck} size={16} />+ <Text fontSize={13} weight={600}>+ {t('createGoal.criteriaTitle')}+ </Text>+ <Text className={styles.sectionHint} fontSize={12}>+ {t('createGoal.criteriaHint')}+ </Text></Flexbox><Button icon={Plus} size={'small'} type={'text'} onClick={addCriterion}>{t('createGoal.addCriterion')}</Button></Flexbox>- <Flexbox className={styles.criteriaList} gap={8}>+ <Flexbox className={styles.criteriaList}>{plan.criteria.map((criterion, index) => (<Flexboxhorizontal@@ -444,69 +537,97 @@ const CreateGoalContent = memo<CreateGoalContentProps>((props) => {className={styles.criterion}gap={8}key={index}+ onClick={() => editCriterion(index)}>+ <Icon color={cssVar.colorTextQuaternary} icon={CircleDashed} size={16} /><span className={styles.criterionIndex}>C{index + 1}</span>- <Input- disabled={!canCreate}- placeholder={t('createGoal.criterionPlaceholder')}- value={criterion.title}- variant={'borderless'}- onChange={(e) => updateCriterion(index, e.target.value)}+ <Text ellipsis style={{ flex: 1, minWidth: 0 }}>+ {criterion.title || t('createGoal.criterionPlaceholder')}+ </Text>+ <Button+ className={(criterion.required ?? true) ? styles.required : styles.optional}+ size={'small'}+ type={'text'}+ onClick={(event) => {+ event.stopPropagation();+ updateCriterion(index, {+ ...criterion,+ required: !(criterion.required ?? true),+ });+ }}+ >+ {(criterion.required ?? true)+ ? t('verifyConfig.required')+ : t('verifyConfig.optional')}+ </Button>+ <ActionIcon+ icon={Pencil}+ size={'small'}+ onClick={(event) => {+ event.stopPropagation();+ editCriterion(index);+ }}/><ActionIconicon={Trash2}size={'small'}title={t('createGoal.removeCriterion')}- onClick={() => removeCriterion(index)}+ onClick={(event) => {+ event.stopPropagation();+ removeCriterion(index);+ }}/></Flexbox>))}</Flexbox></Flexbox>- <div className={styles.budgetGrid}>- <Flexbox className={styles.budgetCard} gap={12}>- <Flexbox horizontal align={'center'} gap={8}>- <Icon className={styles.sectionIcon} icon={RotateCcw} size={16} />- <Text fontSize={14} weight={600}>+ <Flexbox className={styles.reviewSection} gap={10}>+ <Text fontSize={13} weight={600}>+ {t('createGoal.budgetTitle')}+ </Text>+ <Flexbox gap={12}>+ <div className={styles.budgetField}>+ <Text fontSize={12} type={'secondary'}>{t('createGoal.roundBudgetLabel')}</Text>- </Flexbox>- <InputNumber- disabled={!canCreate}- min={2}- suffix={t('createGoal.roundsUnit')}- value={plan.maxIterations ?? undefined}- variant={'filled'}- onChange={(value) => setPlan((current) => ({ ...current, maxIterations: value }))}- />- <Text fontSize={12} type={'secondary'}>- {t('createGoal.roundBudgetHint')}- </Text>- </Flexbox>+ <InputNumber+ disabled={!canCreate}+ min={2}+ size={'small'}+ style={{ width: '100%' }}+ suffix={t('createGoal.roundsUnit')}+ value={plan.maxIterations ?? undefined}+ variant={'filled'}+ onChange={(value) => setPlan((current) => ({ ...current, maxIterations: value }))}+ />+ <Text className={styles.sectionHint} fontSize={12}>+ {t('createGoal.roundBudgetHint')}+ </Text>+ </div>- <Flexbox className={styles.budgetCard} gap={12}>- <Flexbox horizontal align={'center'} gap={8}>- <Icon className={styles.sectionIcon} icon={CircleDollarSign} size={16} />- <Text fontSize={14} weight={600}>+ <div className={styles.budgetField}>+ <Text fontSize={12} type={'secondary'}>{t('createGoal.costBudgetLabel')}</Text>- </Flexbox>- <InputNumber- controls={false}- disabled={!canCreate}- min={0}- placeholder={t('createGoal.costBudgetPlaceholder')}- prefix={'$'}- value={plan.maxTotalCost}- variant={'filled'}- onChange={(value) => setPlan((current) => ({ ...current, maxTotalCost: value }))}- />- <Text fontSize={12} type={'secondary'}>- {t('createGoal.costBudgetHint')}- </Text>+ <InputNumber+ controls={false}+ disabled={!canCreate}+ min={0}+ placeholder={t('createGoal.costBudgetPlaceholder')}+ prefix={'$'}+ size={'small'}+ style={{ width: '100%' }}+ value={plan.maxTotalCost}+ variant={'filled'}+ onChange={(value) => setPlan((current) => ({ ...current, maxTotalCost: value }))}+ />+ <Text className={styles.sectionHint} fontSize={12}>+ {t('createGoal.costBudgetHint')}+ </Text>+ </div></Flexbox>- </div>+ </Flexbox></Flexbox>)}@@ -536,27 +657,43 @@ const CreateGoalContent = memo<CreateGoalContentProps>((props) => {)}</Flexbox>- <Button- loading={isCreating || step === 'preparing'}- shape={'round'}- size={'small'}- title={canCreate ? undefined : reason}- type={'primary'}- disabled={- !canCreate ||- isCreating ||- step === 'preparing' ||- !plan.name.trim() ||- (step === 'review' && plan.criteria.every((criterion) => !criterion.title.trim()))- }- onClick={step === 'describe' ? handleNext : handleSubmit}- >- {step === 'preparing'- ? t('createGoal.preparing')- : step === 'describe'- ? t('createGoal.next')- : t('createGoal.submit')}- </Button>+ <Flexbox horizontal align={'center'} gap={4}>+ {step === 'describe' && (+ <Button+ disabled={!canCreate || isCreating}+ icon={PencilLine}+ size={'small'}+ style={{ color: cssVar.colorTextTertiary }}+ title={canCreate ? undefined : reason}+ type={'text'}+ onClick={handleCreateBlank}+ >+ {t('createModal.createBlank')}+ </Button>+ )}+ <Button+ loading={isCreating || step === 'preparing'}+ shape={'round'}+ size={'small'}+ title={canCreate ? undefined : reason}+ type={'primary'}+ disabled={+ !canCreate ||+ isCreating ||+ step === 'preparing' ||+ (step === 'describe'+ ? !plan.instruction.trim()+ : !plan.name.trim() || plan.criteria.every((criterion) => !criterion.title.trim()))+ }+ onClick={step === 'describe' ? handleNext : handleSubmit}+ >+ {step === 'preparing'+ ? t('createGoal.preparing')+ : step === 'describe'+ ? t('createGoal.next')+ : t('createGoal.submit')}+ </Button>+ </Flexbox></Flexbox></Flexbox>);diff --git a/src/features/AgentGoals/CreateGoalModal/goalConfig.test.ts b/src/features/AgentGoals/CreateGoalModal/goalConfig.test.tsindex ebe8c5d6425..ce015778ec4 100644--- a/src/features/AgentGoals/CreateGoalModal/goalConfig.test.ts+++ b/src/features/AgentGoals/CreateGoalModal/goalConfig.test.ts@@ -1,7 +1,21 @@import { DEFAULT_GOAL_MAX_ROUNDS, DEFAULT_MAX_REPAIR_ROUNDS } from '@lobechat/const/verify';import { describe, expect, it } from 'vitest';-import { buildGoalTaskConfig } from './goalConfig';+import { buildGoalTaskConfig, deriveInitialGoalCriterionTitle } from './goalConfig';++describe('deriveInitialGoalCriterionTitle', () => {+ it('uses the instruction when a free-form goal has no dedicated requirement', () => {+ expect(deriveInitialGoalCriterionTitle(' ship the quarterly report ')).toBe(+ 'ship the quarterly report',+ );+ });++ it('prefers a seeded requirement when one is available', () => {+ expect(+ deriveInitialGoalCriterionTitle('ship the quarterly report', ' include all source links '),+ ).toBe('include all source links');+ });+});describe('buildGoalTaskConfig', () => {it('keeps the round budget and the repair budget independent', () => {diff --git a/src/features/AgentGoals/CreateGoalModal/goalConfig.ts b/src/features/AgentGoals/CreateGoalModal/goalConfig.tsindex 10843731696..3d02d25bf1a 100644--- a/src/features/AgentGoals/CreateGoalModal/goalConfig.ts+++ b/src/features/AgentGoals/CreateGoalModal/goalConfig.ts@@ -31,6 +31,15 @@ export interface BuildGoalTaskConfigParams {verifyCriteriaIds?: string[];}+/**+ * Seed the review step with a usable criterion even when the user started from+ * a free-form description instead of an example with a dedicated requirement.+ */+export const deriveInitialGoalCriterionTitle = (+ instruction: string,+ requirement?: string,+): string => requirement?.trim() || instruction.trim();+/*** Build the `tasks.config` payload that marks a task as a goal root.*diff --git a/src/features/AgentGoals/CreateGoalModal/goalTitle.test.ts b/src/features/AgentGoals/CreateGoalModal/goalTitle.test.tsnew file mode 100644index 00000000000..f84d1903e45--- /dev/null+++ b/src/features/AgentGoals/CreateGoalModal/goalTitle.test.ts@@ -0,0 +1,17 @@+import { describe, expect, it } from 'vitest';++import { deriveGoalTitle } from './goalTitle';++describe('deriveGoalTitle', () => {+ it('uses the first semantic clause instead of the entire instruction', () => {+ expect(+ deriveGoalTitle(+ '搜集 YC26 的所有公司清单,整理成一个 xlsx。需要包含公司名称、批次、官网与公开来源。',+ ),+ ).toBe('搜集 YC26 的所有公司清单');+ });++ it('caps an unpunctuated title', () => {+ expect(deriveGoalTitle('a'.repeat(80))).toHaveLength(48);+ });+});diff --git a/src/features/AgentGoals/CreateGoalModal/goalTitle.ts b/src/features/AgentGoals/CreateGoalModal/goalTitle.tsnew file mode 100644index 00000000000..2e1641228cf--- /dev/null+++ b/src/features/AgentGoals/CreateGoalModal/goalTitle.ts@@ -0,0 +1,6 @@+export const deriveGoalTitle = (instruction: string) => {+ const normalized = instruction.trim();+ const firstSentence = normalized.split(/[\n,。!?!?]/)[0].trim();++ return (firstSentence || normalized).slice(0, 48);+};diff --git a/src/features/AgentGoals/GoalEmptyState.tsx b/src/features/AgentGoals/GoalEmptyState.tsxindex fee732f86c7..ff715735b86 100644--- a/src/features/AgentGoals/GoalEmptyState.tsx+++ b/src/features/AgentGoals/GoalEmptyState.tsx@@ -4,19 +4,22 @@ import { Block, Flexbox, Icon, Text } from '@lobehub/ui';import { Button } from '@lobehub/ui/base-ui';import { createStaticStyles, cssVar } from 'antd-style';import {+ CalendarClockIcon,CheckIcon,CircleCheckBigIcon,InfinityIcon,+ Layers3Icon,PlayIcon,PlusIcon,RotateCcwIcon,+ TablePropertiesIcon,TargetIcon,XIcon,} from 'lucide-react';import { memo } from 'react';import { useTranslation } from 'react-i18next';-import type { GoalExampleSeed } from './goalExamples';+import type { GoalExampleKey, GoalExampleSeed } from './goalExamples';import { buildGoalExampleSeed, GOAL_EXAMPLE_KEYS } from './goalExamples';const styles = createStaticStyles(({ css }) => ({@@ -44,9 +47,19 @@ const styles = createStaticStyles(({ css }) => ({grid-template-columns: minmax(0, 1fr);}`,+ exampleIcon: css`+ flex: none;+ color: ${cssVar.colorTextTertiary};+ `,hero: css`+ isolation: isolate;+ position: relative;++ overflow: hidden;+padding-block: 40px 32px;padding-inline: 40px;+text-align: center;`,heroIcon: css`@@ -54,13 +67,14 @@ const styles = createStaticStyles(({ css }) => ({align-items: center;justify-content: center;- width: 48px;- height: 48px;- border-radius: 14px;-- color: ${cssVar.colorTextSecondary};+ width: 104px;+ height: 72px;- background: ${cssVar.colorFillTertiary};+ color: ${cssVar.colorTextTertiary};+ `,+ heroInner: css`+ position: relative;+ z-index: 1;`,heroLead: css`max-width: 560px;@@ -130,6 +144,12 @@ const styles = createStaticStyles(({ css }) => ({`,}));+const EXAMPLE_ICONS: Record<GoalExampleKey, typeof TargetIcon> = {+ backlog: TablePropertiesIcon,+ digest: CalendarClockIcon,+ metric: Layers3Icon,+};+interface StepProps {desc: string;icon: typeof TargetIcon;@@ -172,22 +192,24 @@ const GoalEmptyState = memo<GoalEmptyStateProps>(({ onCreate }) => {const { t } = useTranslation('chat');return (- <Block padding={0} variant={'outlined'}>- <Flexbox align={'center'} className={styles.hero} gap={16}>- <div className={styles.heroIcon}>- <Icon icon={InfinityIcon} size={24} />- </div>- <Flexbox align={'center'} gap={8}>- <Text fontSize={20} weight={600}>- {t('goalEmpty.title')}- </Text>- <Text className={styles.heroLead} fontSize={14} type={'secondary'}>- {t('goalEmpty.lead')}- </Text>+ <Block padding={0} variant={'borderless'}>+ <Flexbox align={'center'} className={styles.hero}>+ <Flexbox align={'center'} className={styles.heroInner} gap={16}>+ <div className={styles.heroIcon}>+ <InfinityIcon aria-hidden size={64} strokeWidth={1.75} />+ </div>+ <Flexbox align={'center'} gap={8}>+ <Text fontSize={20} weight={600}>+ {t('goalEmpty.title')}+ </Text>+ <Text className={styles.heroLead} fontSize={14} type={'secondary'}>+ {t('goalEmpty.lead')}+ </Text>+ </Flexbox>+ <Button icon={PlusIcon} type={'primary'} onClick={() => onCreate()}>+ {t('goalEmpty.create')}+ </Button></Flexbox>- <Button icon={PlusIcon} type={'primary'} onClick={() => onCreate()}>- {t('goalEmpty.create')}- </Button></Flexbox><Flexbox className={styles.section} gap={14}>@@ -249,9 +271,12 @@ const GoalEmptyState = memo<GoalEmptyStateProps>(({ onCreate }) => {onCreate(seed);}}>- <Text fontSize={11} type={'secondary'}>- {t(`goalEmpty.examples.${key}.tag` as never)}- </Text>+ <Flexbox horizontal align={'center'} justify={'space-between'}>+ <Text fontSize={11} type={'secondary'}>+ {t(`goalEmpty.examples.${key}.tag` as never)}+ </Text>+ <Icon className={styles.exampleIcon} icon={EXAMPLE_ICONS[key]} size={16} />+ </Flexbox><Text fontSize={13} weight={500}>{seed.title}</Text>