🤯 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(goal): non-blocking creation, dependency-aware decomposition & detail-page polish (#18979)
Arvin Xubaf49ab511dd
diff --git a/.agents/acceptance/common-mistakes.md b/.agents/acceptance/common-mistakes.mdindex d6c2bf50671..73f20773457 100644--- a/.agents/acceptance/common-mistakes.md+++ b/.agents/acceptance/common-mistakes.md@@ -504,6 +504,26 @@ supposed to have — a dialog opens, a request fires, a store field changes. Treclosed and nothing happened" as the expected failure signature, not as a missed click. Whenthe entry is nested, verify the child's own dispatch wiring, not the parent's.+### L-D13 — Picking `cssVar` color-scale steps by antd-palette intuition++**Wrong approach:** choose antd-style palette steps (`cssVar.blue1` for a tint,+`cssVar.blue6` for the primary line) from the standard antd 10-step palette in+your head, and judge the result from the code alone.++**Why it fails:** LobeHub's theme overrides the color scales with an 11-step+palette whose primary-strength band sits at x9–x10 — light-mode `blue-6`+resolves to `#acd4ff` and `blue-7` to `#93c8ff`, both near-pastel, nothing like+antd's `blue-6` `#1677ff`. The UI then renders washed out while every token+name in the code reads correct, and a one-step "fix" (x1→x2, x6→x7) changes+almost nothing.++**Correct approach:** never pick a scale step without reading the resolved+value in the running app (`getComputedStyle` on the element, or resolve+`--ant-<color>-<n>` from the element's scope — the variables are scoped, not on+`:root`). For a tinted-tile + line pairing, the working band is around x3 for+the tint and x9–x10 for the line, verified in both themes: the scale flips in+dark mode, so a step that is a tint in light is a deep fill in dark.+## Environment safety### L-S0 — Concluding a dependency moved from the root manifest alonediff --git a/apps/server/src/routers/lambda/goal.ts b/apps/server/src/routers/lambda/goal.tsindex 33b772b456a..865799f30da 100644--- a/apps/server/src/routers/lambda/goal.ts+++ b/apps/server/src/routers/lambda/goal.ts@@ -305,4 +305,14 @@ export const goalRouter = router({mapGoalError(error, 'tick');}}),++ updateRequirement: goalWriteProcedure+ .input(idInput.extend({ requirement: z.string().min(1) }))+ .mutation(async ({ ctx, input: { id, requirement } }) => {+ try {+ return { data: await ctx.goalService.updateRequirement(id, requirement), success: true };+ } catch (error) {+ mapGoalError(error, 'updateRequirement');+ }+ }),});diff --git a/apps/server/src/services/goal/criteriaGenerator.ts b/apps/server/src/services/goal/criteriaGenerator.tsindex b0e5b24205b..90f98f5ec58 100644--- a/apps/server/src/services/goal/criteriaGenerator.ts+++ b/apps/server/src/services/goal/criteriaGenerator.ts@@ -70,7 +70,14 @@ export interface GoalPlanDraft {const decompositionSchema = z.object({problemStatement: z.string().min(1),works: z- .array(z.object({ instruction: z.string().min(1), title: z.string().min(1).max(80) }))+ .array(+ z.object({+ /** 0-based indices of earlier works this one consumes; drives `depends_on` edges. */+ dependsOn: z.array(z.number().int().nonnegative()).optional(),+ instruction: z.string().min(1),+ title: z.string().min(1).max(80),+ }),+ ).min(1).max(5),});diff --git a/apps/server/src/services/goal/index.test.ts b/apps/server/src/services/goal/index.test.tsindex b699d9d1b17..75f6350972f 100644--- a/apps/server/src/services/goal/index.test.ts+++ b/apps/server/src/services/goal/index.test.ts@@ -184,6 +184,17 @@ describe('GoalService', () => {expect(raised?.status).not.toBe('paused');});+ it('edits the standing requirement in place', async () => {+ const service = new GoalService(serverDB, userId);+ const graph = await service.create({ requirement: '初版验收', title: 'Editable', work: ['A'] });++ const updated = await service.updateRequirement(graph.goal.id, '改过的验收标准');++ expect(updated.requirement).toBe('改过的验收标准');+ expect((await service.graph(graph.goal.id)).goal.requirement).toBe('改过的验收标准');+ await expect(service.updateRequirement('goal_missing', 'x')).rejects.toThrow();+ });+it('leaves a deliberately paused goal paused when its budget changes', async () => {// Nothing distinguishes a user pause from a budget pause on the row, so the// reopen is limited to goals whose budget was actually binding.@@ -220,8 +231,10 @@ describe('GoalService', () => {vi.spyOn(GoalCriteriaGeneratorService.prototype, 'decompose').mockResolvedValue({problemStatement: '核心问题的一句话陈述',works: [- { instruction: '收集原始材料', title: '方向A:收集' },- { instruction: '分析并综合结论', title: '方向B:分析' },+ { dependsOn: [], instruction: '收集原始材料', title: '方向A:收集' },+ { dependsOn: [0], instruction: '分析并综合结论', title: '方向B:分析' },+ // Self and forward references are planner hallucinations — dropped.+ { dependsOn: [1, 2, 9], instruction: '汇编最终报告', title: '方向C:汇编' },],});const service = new GoalService(serverDB, userId);@@ -241,9 +254,62 @@ describe('GoalService', () => {expect(after.nodes.filter((n) => n.kind === 'task').map((n) => n.title)).toEqual(['方向A:收集','方向B:分析',+ '方向C:汇编',]);expect(after.nodes.find((n) => n.kind === 'problem')?.description).toBe('核心问题的一句话陈述');- expect(after.edges.filter((e) => e.kind === 'decomposes')).toHaveLength(2);+ expect(after.edges.filter((e) => e.kind === 'decomposes')).toHaveLength(3);++ // The planner's dependsOn indices become depends_on edges, dependent →+ // prerequisite; the self and forward references were dropped.+ const byTitle = new Map(after.nodes.map((n) => [n.title, n.id]));+ const deps = after.edges+ .filter((e) => e.kind === 'depends_on')+ .map((e) => [e.sourceNodeId, e.targetNodeId]);+ expect(deps).toHaveLength(2);+ expect(deps).toEqual(+ expect.arrayContaining([+ [byTitle.get('方向B:分析'), byTitle.get('方向A:收集')],+ [byTitle.get('方向C:汇编'), byTitle.get('方向B:分析')],+ ]),+ );+ });++ it('plans the decomposition once when two advances race through the planner', async () => {+ // The queued kickoff and the client's fire-and-forget fallback can both+ // reach plan_decomposition together; the atomic planning claim must stop+ // the loser BEFORE the planner call, so nothing double-plans or double-pays.+ let release!: () => void;+ const gate = new Promise<void>((resolve) => {+ release = resolve;+ });+ let plannerCalls = 0;+ vi.spyOn(GoalCriteriaGeneratorService.prototype, 'decompose').mockImplementation(async () => {+ plannerCalls += 1;+ await gate;+ return {+ problemStatement: '并发规划',+ works: [+ { dependsOn: [], instruction: '收集', title: '方向A' },+ { dependsOn: [0], instruction: '分析', title: '方向B' },+ ],+ };+ });+ const service = new GoalService(serverDB, userId);+ const graph = await service.create({ problemDescription: '原话', title: 'Raced planning' });++ const ticks = Promise.all([service.tick(graph.goal.id), service.tick(graph.goal.id)]);+ // The winner holds the planner open; the loser must lose the claim and+ // return without ever entering it.+ await vi.waitFor(() => expect(plannerCalls).toBe(1));+ release();+ const results = await ticks;++ expect(plannerCalls).toBe(1);+ expect(results.filter((r) => r.outcome === 'advanced')).toHaveLength(1);+ expect(results.filter((r) => r.outcome === 'waiting_external')).toHaveLength(1);+ const after = await service.graph(graph.goal.id);+ expect(after.nodes.filter((n) => n.kind === 'task')).toHaveLength(2);+ expect(after.edges.filter((e) => e.kind === 'depends_on')).toHaveLength(1);});it('falls back to a single work when the planner fails, instead of stalling', async () => {diff --git a/apps/server/src/services/goal/index.ts b/apps/server/src/services/goal/index.tsindex ac562202190..30fdcac9205 100644--- a/apps/server/src/services/goal/index.ts+++ b/apps/server/src/services/goal/index.ts@@ -30,7 +30,7 @@ import { AgentRuntimeCoordinator } from '@/server/modules/AgentRuntime/AgentRuntimport { TaskService } from '../task';import { TaskRunnerService } from '../taskRunner';import { AcceptanceService } from '../verify/acceptanceService';-import { GoalCriteriaGeneratorService } from './criteriaGenerator';+import { GoalCriteriaGeneratorService, type GoalDecompositionDraft } from './criteriaGenerator';import {decideNextMove,frontierNeedsBudget,@@ -324,6 +324,17 @@ export class GoalService {};};+ /**+ * Edit the goal's standing acceptance requirement in place. The next+ * coordinator move and every later dispatched Work read the updated text;+ * already-running Work keeps the contract it was dispatched with.+ */+ updateRequirement = async (goalId: string, requirement: string) => {+ const goal = await this.goalModel.update(goalId, { requirement });+ if (!goal) throw new TRPCError({ code: 'NOT_FOUND', message: 'Goal not found' });+ return goal;+ };+setBudget = async (goalId: string,budget: {@@ -1080,10 +1091,43 @@ export class GoalService {const problem = graph.nodes.find((node) => node.kind === 'problem');const requirement = graph.goal.requirement ?? problem?.description ?? graph.goal.title;+ // Two advances can reach this branch together — the queued kickoff and the+ // client's fire-and-forget fallback both see zero Works. The conditional+ // `planning → running` write is the claim: the loser stops before even+ // calling the planner, so nothing double-plans and nothing double-pays.+ // `waiting_external` ends its advance loop — the winner carries the goal.+ if (graph.goal.status === 'planning') {+ const claimed = await this.goalModel.claimPlanning(goalId);+ if (!claimed) {+ return {+ goalId,+ message: 'Another advance is already planning this goal',+ outcome: 'waiting_external' as const,+ };+ }+ await this.coordinatorGraph+ .recordGoalStatus(goalId, 'planning', 'running', 'decomposition claimed')+ .catch((error) => console.error('[GoalService] failed to record goal status:', error));+ }+const generator = new GoalCriteriaGeneratorService(this.db, this.userId, this.workspaceId);const plan = await generator.decompose({ requirement }).catch(() => undefined);- const works = plan?.works ?? [+ // Rare shape: a goal already past `planning` whose Works were all removed.+ // There is no status edge to claim on that path, so shrink the duplicate+ // window to the instant before the inserts with a re-read instead.+ if (graph.goal.status !== 'planning') {+ const fresh = await this.graphModel.getGraph(goalId);+ if (fresh?.nodes.some((node) => node.kind === 'task')) {+ return {+ goalId,+ message: 'Decomposition already planned by a concurrent advance',+ outcome: 'advanced' as const,+ };+ }+ }++ const works: GoalDecompositionDraft['works'] = plan?.works ?? [{ instruction: problem?.description ?? requirement, title: graph.goal.title },];@@ -1093,18 +1137,34 @@ export class GoalService {await this.coordinatorGraph.updateNodeDescription(goalId, problem.id, plan.problemStatement);}+ const createdIds: (string | undefined)[] = [];for (const work of works) {const node = await this.coordinatorGraph.createNode(goalId, {description: work.instruction,kind: 'task',title: work.title,});+ createdIds.push(node?.id);if (!node) continue;if (problem)await this.coordinatorGraph.createEdge(goalId, problem.id, node.id, 'decomposes');effects.push({ nodeId: node.id, type: 'created_node', detail: work.title });}+ // The planner's `dependsOn` indices become `depends_on` edges, drawn+ // dependent → prerequisite the way `decideNextMove` reads a blocker. Only+ // earlier indices are honoured, so a hallucinated forward or self reference+ // can never form a cycle that deadlocks the frontier.+ for (const [index, work] of works.entries()) {+ const nodeId = createdIds[index];+ if (!nodeId) continue;+ for (const dep of new Set(work.dependsOn ?? [])) {+ const prerequisiteId = dep < index ? createdIds[dep] : undefined;+ if (!prerequisiteId) continue;+ await this.coordinatorGraph.createEdge(goalId, nodeId, prerequisiteId, 'depends_on');+ }+ }+return {goalId,message: plandiff --git a/locales/en-US/chat.json b/locales/en-US/chat.jsonindex 3f913a4f9fa..2e725aaa1a3 100644--- a/locales/en-US/chat.json+++ b/locales/en-US/chat.json@@ -489,6 +489,11 @@"goalProcess.actor.agent": "Agent","goalProcess.actor.system": "System","goalProcess.actor.user": "You",+ "goalProcess.addTask.descriptionLabel": "Instruction (optional)",+ "goalProcess.addTask.descriptionPlaceholder": "Deliverable, constraints, and how the result will be judged",+ "goalProcess.addTask.failed": "Failed to add the task — please try again",+ "goalProcess.addTask.titleLabel": "Task title",+ "goalProcess.addTask.titlePlaceholder": "What should this task deliver?","goalProcess.attempts.failed": "Did not pass","goalProcess.attempts.nth": "Attempt {{index}}","goalProcess.attempts.passed": "Passed",@@ -574,6 +579,7 @@"goalProcess.node.description": "Description","goalProcess.node.detailTitle": "Node detail","goalProcess.node.done": "Done",+ "goalProcess.node.generating": "Generating…","goalProcess.node.humanTouched": "You took part in this task","goalProcess.node.instruction": "Expected output","goalProcess.node.openTask": "Open task detail",@@ -582,7 +588,6 @@"goalProcess.node.running": "Running","goalProcess.node.unanswered": "Unanswered","goalProcess.node.unassigned": "Not dispatched",- "goalProcess.node.verifier": "verifier","goalProcess.node.verifierTooltip": "This task has its own acceptance contract — a verifier judges the delivery.","goalProcess.node.waiting": "Waiting","goalProcess.nodeStatus.active": "Running",@@ -593,7 +598,10 @@"goalProcess.nodeStatus.waiting": "Waiting","goalProcess.pause": "Pause","goalProcess.paused": "Paused — no new work will start",- "goalProcess.requirement": "What counts as done",+ "goalProcess.planning.description": "The coordinator is breaking the goal into executable tasks — they will appear here shortly.",+ "goalProcess.planning.title": "Planning the exploration",+ "goalProcess.requirementPlaceholder": "Describe what counts as done…",+ "goalProcess.requirementSaveFailed": "Failed to save the requirement — it will retry on your next edit","goalProcess.resume": "Resume","goalProcess.running.elapsed": "Running {{duration}}","goalProcess.stale.description": "No heartbeat for {{duration}}. The next advance marks this attempt lost and starts a fresh one — it does not count as a failure.",diff --git a/locales/zh-CN/chat.json b/locales/zh-CN/chat.jsonindex 48589a6aa98..a06a4a9f80f 100644--- a/locales/zh-CN/chat.json+++ b/locales/zh-CN/chat.json@@ -489,6 +489,11 @@"goalProcess.actor.agent": "Agent","goalProcess.actor.system": "系统","goalProcess.actor.user": "你",+ "goalProcess.addTask.descriptionLabel": "任务说明(选填)",+ "goalProcess.addTask.descriptionPlaceholder": "要交付什么、有哪些约束、怎样判定完成",+ "goalProcess.addTask.failed": "添加任务失败,请重试",+ "goalProcess.addTask.titleLabel": "任务标题",+ "goalProcess.addTask.titlePlaceholder": "这个任务要交付什么?","goalProcess.attempts.failed": "未通过","goalProcess.attempts.nth": "第 {{index}} 次","goalProcess.attempts.passed": "通过",@@ -574,6 +579,7 @@"goalProcess.node.description": "说明","goalProcess.node.detailTitle": "节点详情","goalProcess.node.done": "完成",+ "goalProcess.node.generating": "生成中…","goalProcess.node.humanTouched": "你参与过这项任务","goalProcess.node.instruction": "要求产出","goalProcess.node.openTask": "打开任务详情",@@ -582,7 +588,6 @@"goalProcess.node.running": "进行中","goalProcess.node.unanswered": "待回答","goalProcess.node.unassigned": "未派发",- "goalProcess.node.verifier": "verifier","goalProcess.node.verifierTooltip": "这项任务有自己的验收合约,由 verifier 判定交付","goalProcess.node.waiting": "等待中","goalProcess.nodeStatus.active": "进行中",@@ -593,7 +598,10 @@"goalProcess.nodeStatus.waiting": "等待中","goalProcess.pause": "暂停","goalProcess.paused": "已暂停,不会再开始新的任务",- "goalProcess.requirement": "什么算完成",+ "goalProcess.planning.description": "协调器正在把目标拆解为可执行任务,节点稍后会陆续出现",+ "goalProcess.planning.title": "正在规划探索方向",+ "goalProcess.requirementPlaceholder": "描述怎样才算达成这个目标…",+ "goalProcess.requirementSaveFailed": "验收要求保存失败,下次编辑时会自动重试","goalProcess.resume": "继续","goalProcess.running.elapsed": "已运行 {{duration}}","goalProcess.stale.description": "已 {{duration}} 没有心跳。下一次推进会把这次尝试标为失联并重开一次,不计失败次数。",diff --git a/packages/database/src/models/goal.ts b/packages/database/src/models/goal.tsindex 4eba347d847..b230fccda98 100644--- a/packages/database/src/models/goal.ts+++ b/packages/database/src/models/goal.ts@@ -88,6 +88,25 @@ export class GoalModel {return row as GoalItem | undefined;};+ /**+ * Atomically take `planning → running` as the decomposition claim: several+ * concurrent advances can all see an unplanned goal, and only the one this+ * conditional write succeeds for may seed the graph. `startedAt` is stamped+ * here because the later dispatch transition becomes a same-status no-op.+ */+ claimPlanning = async (id: string) => {+ const [row] = await this.db+ .update(goals)+ .set({+ startedAt: sql`coalesce(${goals.startedAt}, now())`,+ status: 'running',+ updatedAt: new Date(),+ })+ .where(and(eq(goals.id, id), eq(goals.status, 'planning'), this.ownership()))+ .returning();+ return row as GoalItem | undefined;+ };+/*** Advance the lifecycle state, stamping the boundary timestamps as a side* effect: first entry into `running` records `startedAt`, any terminal statediff --git a/packages/locales/src/default/chat.ts b/packages/locales/src/default/chat.tsindex 2d12cc27d62..720fa252f26 100644--- a/packages/locales/src/default/chat.ts+++ b/packages/locales/src/default/chat.ts@@ -1826,6 +1826,18 @@ export default {'Every task is either waiting on a dependency or already finished.','goalProcess.frontier.achievedTitle': 'Nothing left to advance — this goal is achieved','goalProcess.frontier.achievedDescription': 'The findings are in the map below.',+ 'goalProcess.addTask.failed': 'Failed to add the task — please try again',+ 'goalProcess.addTask.titleLabel': 'Task title',+ 'goalProcess.addTask.titlePlaceholder': 'What should this task deliver?',+ 'goalProcess.addTask.descriptionLabel': 'Instruction (optional)',+ 'goalProcess.addTask.descriptionPlaceholder':+ 'Deliverable, constraints, and how the result will be judged',+ 'goalProcess.requirementPlaceholder': 'Describe what counts as done…',+ 'goalProcess.requirementSaveFailed':+ 'Failed to save the requirement — it will retry on your next edit',+ 'goalProcess.planning.title': 'Planning the exploration',+ 'goalProcess.planning.description':+ 'The coordinator is breaking the goal into executable tasks — they will appear here shortly.','goalProcess.tag.needsDecision': 'Needs your decision','goalProcess.tag.lost': 'Lost','goalProcess.tag.done': 'Done',@@ -1918,13 +1930,12 @@ export default {'goalProcess.nodeStatus.waiting': 'Waiting','goalProcess.metrics.tasks': 'Tasks','goalProcess.metrics.findings': 'Findings',- 'goalProcess.requirement': 'What counts as done','goalProcess.node.answered': 'Answered by a finding',+ 'goalProcess.node.generating': 'Generating…','goalProcess.node.unassigned': 'Not dispatched','goalProcess.node.decidedByYou': 'You decided','goalProcess.node.decidedByAgent': 'Agent decided','goalProcess.node.attemptsTooltip': '{{count}} attempts so far',- 'goalProcess.node.verifier': 'verifier','goalProcess.node.verifierTooltip':'This task has its own acceptance contract — a verifier judges the delivery.','goalProcess.node.artifactsTooltip':diff --git a/packages/prompts/src/chains/goal.ts b/packages/prompts/src/chains/goal.tsindex 300dc2cafab..b14e5930da6 100644--- a/packages/prompts/src/chains/goal.ts+++ b/packages/prompts/src/chains/goal.ts@@ -65,7 +65,7 @@ export const GOAL_CRITERIA_DRAFT_JSON_SCHEMA = {};/** Bump when the goal decomposition planning prompt meaningfully changes. */-export const GOAL_DECOMPOSE_PROMPT_VERSION = 'v1';+export const GOAL_DECOMPOSE_PROMPT_VERSION = 'v2';export const GOAL_DECOMPOSE_JSON_SCHEMA = {name: 'goal_decomposition',@@ -77,10 +77,11 @@ export const GOAL_DECOMPOSE_JSON_SCHEMA = {items: {additionalProperties: false,properties: {+ dependsOn: { items: { minimum: 0, type: 'integer' }, type: 'array' },instruction: { minLength: 1, type: 'string' },title: { maxLength: 80, minLength: 1, type: 'string' },},- required: ['title', 'instruction'],+ required: ['title', 'instruction', 'dependsOn'],type: 'object',},maxItems: 5,@@ -119,6 +120,7 @@ export const chainGoalDecompose = ({'- Each work.instruction is a complete, self-contained brief for an autonomous agent working on that direction only: what to do, the concrete deliverable, and how that deliverable will be judged. Include only the requirements relevant to this direction — never paste the full goal acceptance list into every work.','- Preserve every concrete URL, scope, constraint, and numeric threshold from the goal in whichever work it belongs to.','- Order works so that earlier ones produce what later ones consume.',+ '- For each work, set dependsOn to the 0-based indices of the earlier works whose outputs it consumes; use [] for a work that can start immediately. A pipeline-shaped goal (gather → analyze → synthesize) must express those edges — do not mark every work independent — but never invent a dependency the work does not actually need.','- Write all fields in the language used by the goal.',].join('\n'),role: 'system',diff --git a/src/features/AgentGoals/AddTaskModal/AddTaskContent.tsx b/src/features/AgentGoals/AddTaskModal/AddTaskContent.tsxnew file mode 100644index 00000000000..337f5e86132--- /dev/null+++ b/src/features/AgentGoals/AddTaskModal/AddTaskContent.tsx@@ -0,0 +1,84 @@+'use client';++import { Flexbox, Input, TextArea } from '@lobehub/ui';+import { Button, Text, toast, useModalContext } from '@lobehub/ui/base-ui';+import { memo, useState } from 'react';+import { useTranslation } from 'react-i18next';++/**+ * Add a Work to a running goal. A task the coordinator will spend rounds on+ * deserves a titled brief, not a one-line inline input — the modal gives the+ * instruction room and keeps the frontier list itself read-focused.+ */++export interface AddTaskContentProps {+ onAdd: (title: string, description?: string) => Promise<void>;+}++const AddTaskContent = memo<AddTaskContentProps>(({ onAdd }) => {+ const { t } = useTranslation('chat');+ const { close } = useModalContext();+ const [title, setTitle] = useState('');+ const [description, setDescription] = useState('');+ const [busy, setBusy] = useState(false);++ const submit = async () => {+ const trimmed = title.trim();+ if (!trimmed || busy) return;+ setBusy(true);+ try {+ await onAdd(trimmed, description.trim() || undefined);+ close();+ } catch (error) {+ // Keep the form (and the user's input) open — a silent close would be+ // indistinguishable from success.+ console.error('[AddGoalTask] Failed to add task:', error);+ toast.error(t('goalProcess.addTask.failed'));+ } finally {+ setBusy(false);+ }+ };++ return (+ <Flexbox gap={16} paddingBlock={'4px 8px'}>+ <Flexbox gap={6}>+ <Text fontSize={13} weight={500}>+ {t('goalProcess.addTask.titleLabel')}+ </Text>+ <Input+ autoFocus+ placeholder={t('goalProcess.addTask.titlePlaceholder')}+ value={title}+ onChange={(e) => setTitle(e.target.value)}+ onPressEnter={() => void submit()}+ />+ </Flexbox>+ <Flexbox gap={6}>+ <Text fontSize={13} weight={500}>+ {t('goalProcess.addTask.descriptionLabel')}+ </Text>+ <TextArea+ autoSize={{ maxRows: 8, minRows: 3 }}+ placeholder={t('goalProcess.addTask.descriptionPlaceholder')}+ value={description}+ onChange={(e) => setDescription(e.target.value)}+ />+ </Flexbox>+ <Flexbox horizontal gap={8} justify={'flex-end'}>+ <Button onClick={() => close()}>{t('cancel', { ns: 'common' })}</Button>+ <Button+ disabled={!title.trim()}+ loading={busy}+ type={'primary'}+ onClick={() => void submit()}+ >+ {t('goalProcess.frontier.add')}+ </Button>+ </Flexbox>+ </Flexbox>+ );+});++AddTaskContent.displayName = 'AddGoalTaskContent';++export default AddTaskContent;diff --git a/src/features/AgentGoals/AddTaskModal/index.tsx b/src/features/AgentGoals/AddTaskModal/index.tsxnew file mode 100644index 00000000000..de4105740a5--- /dev/null+++ b/src/features/AgentGoals/AddTaskModal/index.tsx@@ -0,0 +1,17 @@+'use client';++import { createModal, type ModalInstance } from '@lobehub/ui/base-ui';+import { t } from 'i18next';++import AddTaskContent, { type AddTaskContentProps } from './AddTaskContent';++export type { AddTaskContentProps };++export const openAddGoalTaskModal = (props: AddTaskContentProps): ModalInstance =>+ createModal({+ content: <AddTaskContent {...props} />,+ footer: null,+ maskClosable: true,+ title: t('goalProcess.frontier.add', { ns: 'chat' }),+ width: 'min(90%, 560px)',+ });diff --git a/src/features/AgentGoals/AgentGoalsPage.tsx b/src/features/AgentGoals/AgentGoalsPage.tsxindex 13dbe19a1b7..63c03cceac0 100644--- a/src/features/AgentGoals/AgentGoalsPage.tsx+++ b/src/features/AgentGoals/AgentGoalsPage.tsx@@ -12,6 +12,7 @@ import GoalSkeleton from '@/components/Skeleton/Goal';import AgentBreadcrumb from '@/features/AgentBreadcrumb';import NavHeader from '@/features/NavHeader';import WideScreenContainer from '@/features/WideScreenContainer';+import { useWorkspaceAwareNavigate } from '@/features/Workspace/useWorkspaceAwareNavigate';import { goalSelectors, useGoalStore } from '@/store/goal';import { createGoalModal } from './CreateGoalModal';@@ -72,6 +73,7 @@ interface AgentGoalsPageProps {const AgentGoalsPage = memo<AgentGoalsPageProps>(({ agentId, projectId }) => {const { t } = useTranslation('chat');+ const navigate = useWorkspaceAwareNavigate();const scopeId = projectId ? `project:${projectId}` : agentId!;const useFetchGoals = useGoalStore((s) => s.useFetchGoals);const refreshGoals = useGoalStore((s) => s.refreshGoals);@@ -103,7 +105,14 @@ const AgentGoalsPage = memo<AgentGoalsPageProps>(({ agentId, projectId }) => {initialRoundBudget: seed?.roundBudget,initialTitle: seed?.title,projectId,- onCreated: () => void refreshGoals(scopeId),+ // Land the user inside the goal right away: the detail page polls while+ // the goal is still planning, so the exploration graph grows in place+ // instead of the modal blocking on it.+ onCreated: (goal) => {+ void refreshGoals(scopeId);+ const ownerId = goal.agentId ?? agentId;+ navigate(ownerId ? `/agent/${ownerId}/goal/${goal.goalId}` : `/goal/${goal.goalId}`);+ },});};diff --git a/src/features/AgentGoals/CreateGoalModal/CreateGoalContent.tsx b/src/features/AgentGoals/CreateGoalModal/CreateGoalContent.tsxindex 4125293b30a..ea75e01d7f7 100644--- a/src/features/AgentGoals/CreateGoalModal/CreateGoalContent.tsx+++ b/src/features/AgentGoals/CreateGoalModal/CreateGoalContent.tsx@@ -449,13 +449,12 @@ const CreateGoalContent = memo<CreateGoalContentProps>((props) => {requirement: buildGoalRequirement(title, reviewedCriteria, budget.requirement),title,});- // `goal.create` already queued an advance; this runs the same driver so- // the goal is visibly moving by the time the modal closes even where the- // queue is unavailable. It must be `advance`, not a single tick: whichever- // driver claims the Work has to carry it past binding the task into- // actually starting it, and the loser stops at `waiting_external`.- await goalService.advance(graph.goal.id);-+ // `goal.create` already queued the first advance server-side, but on a+ // queue-less serverless deployment that kickoff is an in-process timer+ // the host may freeze before firing. This request-bound advance is the+ // durable fallback — fired and forgotten so the modal still closes+ // immediately; the server dedupes a raced decomposition.+ void goalService.advance(graph.goal.id).catch(() => {});close();onCreated?.({ agentId: graph.goal.agentId ?? undefined, goalId: graph.goal.id });} catch (error) {diff --git a/src/features/AgentGoals/GoalDetailPage.tsx b/src/features/AgentGoals/GoalDetailPage.tsxindex 1421f7d2dda..7503f8f1d3c 100644--- a/src/features/AgentGoals/GoalDetailPage.tsx+++ b/src/features/AgentGoals/GoalDetailPage.tsx@@ -1,22 +1,22 @@'use client';import { Flexbox } from '@lobehub/ui';-import { Text } from '@lobehub/ui/base-ui';+import { Button, Text } from '@lobehub/ui/base-ui';import { createStaticStyles, cssVar } from 'antd-style';+import { PauseIcon, PlayIcon } from 'lucide-react';import { memo, type ReactNode, useEffect, useMemo } from 'react';import { useTranslation } from 'react-i18next';import NotFound from '@/components/404';import AsyncError from '@/components/AsyncError';-import CollapsibleContent from '@/components/CollapsibleContent';import GoalDetailSkeleton from '@/components/Skeleton/GoalDetail';import AgentBreadcrumb from '@/features/AgentBreadcrumb';-import RunningGlyph from '@/features/Home/components/RunningGlyph';import NavHeader from '@/features/NavHeader';import { PortalContent } from '@/features/Portal/router';import RightPanel from '@/features/RightPanel';import WideScreenContainer from '@/features/WideScreenContainer';import { useActivityTime } from '@/hooks/useActivityTime';+import { usePermission } from '@/hooks/usePermission';import { useChatStore } from '@/store/chat';import { chatPortalSelectors } from '@/store/chat/selectors';import { type GoalMetricKind } from '@/store/chat/slices/portal/initialState';@@ -24,6 +24,7 @@ import { goalSelectors, useGoalStore } from '@/store/goal';import GoalDetailActions from './GoalDetailActions';import { formatSpan, goalStatusKey } from './goalPresentation';+import GoalRequirement from './GoalRequirement';import GoalStatusGlyph from './GoalStatusGlyph';import ProcessControl from './ProcessControl';@@ -79,16 +80,15 @@ const Metric = memo<{Metric.displayName = 'GoalHeaderMetric';-/** Relative "last activity" readout; isolated so its refresh never re-renders the page. */-const LivenessValue = memo<{ active: boolean; latest?: Date }>(({ active, latest }) => {+/** Relative "last activity" readout; isolated so its refresh never re-renders the page.+ * Plain text on purpose: the status control already carries the "running"+ * animation, and a second spinner here said the same thing twice. */+const LivenessValue = memo<{ latest?: Date }>(({ latest }) => {const { text } = useActivityTime(latest);return (- <>- {active && <RunningGlyph size={14} />}- <Text fontSize={16} weight={600}>- {text || '—'}- </Text>- </>+ <Text fontSize={16} weight={600}>+ {text || '—'}+ </Text>);});@@ -102,9 +102,12 @@ interface GoalDetailPageProps {const GoalDetailPage = memo<GoalDetailPageProps>(({ agentId, goalId }) => {const { t } = useTranslation('chat');+ const { allowed: canEdit } = usePermission('create_content');const useFetchGoalGraph = useGoalStore((s) => s.useFetchGoalGraph);const { error, isLoading, mutate } = useFetchGoalGraph(goalId);const snapshot = useGoalStore(goalSelectors.goalGraph(goalId));+ const pauseGoal = useGoalStore((s) => s.pauseGoal);+ const resumeGoal = useGoalStore((s) => s.resumeGoal);const showPortal = useChatStore(chatPortalSelectors.showPortal);const openGoalMetric = useChatStore((s) => s.openGoalMetric);@@ -115,14 +118,12 @@ const GoalDetailPage = memo<GoalDetailPageProps>(({ agentId, goalId }) => {useEffect(() => () => clearPortalStack(), [clearPortalStack, goalId]);const liveness = useMemo(() => {- if (!snapshot) return { active: false, latest: undefined };+ if (!snapshot) return { latest: undefined };let latest: Date | undefined;- let active = false;for (const node of snapshot.nodes) {if (!latest || node.updatedAt > latest) latest = node.updatedAt;- if (node.kind === 'task' && node.status === 'active') active = true;}- return { active, latest };+ return { latest };}, [snapshot]);if (error && !snapshot) return <AsyncError error={error} variant={'page'} onRetry={mutate} />;@@ -138,6 +139,15 @@ const GoalDetailPage = memo<GoalDetailPageProps>(({ agentId, goalId }) => {const findings = nodes.filter((node) => node.kind === 'finding').length;const open = (metric: GoalMetricKind) => () => openGoalMetric(goalId, metric);+ const paused = goal.status === 'paused';+ // Pace control exists only while the coordinator loop is actually moving (or+ // explicitly paused). A goal in review awaits the human, and a closed goal+ // cannot move — pausing either would be a dead or misleading button.+ const canPause =+ canEdit &&+ nodes.length > 0 &&+ ['paused', 'planning', 'running', 'verifying'].includes(goal.status);+const durationText = goal.startedAt? formatSpan((goal.completedAt ?? new Date()).getTime() - goal.startedAt.getTime()): '—';@@ -228,24 +238,32 @@ const GoalDetailPage = memo<GoalDetailPageProps>(({ agentId, goalId }) => {/><Metriclabel={t('goalProcess.metrics.liveness')}- value={<LivenessValue active={liveness.active} latest={liveness.latest} />}+ value={<LivenessValue latest={liveness.latest} />}onClick={open('liveness')}/></Flexbox>- {goal.requirement && (- <Flexbox gap={4} paddingBlock={'8px 0'}>- <Text fontSize={12} type={'secondary'} weight={500}>- {t('goalProcess.requirement')}- </Text>- {/* Generated acceptance criteria run long — clamp like the task- instruction does, with the shared show-more affordance. */}- <CollapsibleContent maxHeight={160}>- <Text fontSize={14} style={{ lineHeight: 1.65, whiteSpace: 'pre-wrap' }}>- {goal.requirement}+ {/* Pause/resume above the requirement document — its reviewed+ home. The status glyph keeps the "running" animation; this+ button is only the control. */}+ {canPause && (+ <Flexbox horizontal align={'center'} gap={10} paddingBlock={'8px 0'}>+ <Button+ icon={paused ? PlayIcon : PauseIcon}+ type={paused ? 'primary' : 'default'}+ onClick={() => void (paused ? resumeGoal(goal.id) : pauseGoal(goal.id))}+ >+ {paused ? t('goalProcess.resume') : t('goalProcess.pause')}+ </Button>+ {paused && (+ <Text fontSize={12} type={'secondary'}>+ {t('goalProcess.paused')}</Text>- </CollapsibleContent>+ )}</Flexbox>)}+ {goal.requirement && (+ <GoalRequirement goalId={goal.id} requirement={goal.requirement} />+ )}</Flexbox><ProcessControl goalId={goal.id} />diff --git a/src/features/AgentGoals/GoalRequirement.tsx b/src/features/AgentGoals/GoalRequirement.tsxnew file mode 100644index 00000000000..82d5d0bd6e9--- /dev/null+++ b/src/features/AgentGoals/GoalRequirement.tsx@@ -0,0 +1,139 @@+'use client';++import { useEditor } from '@lobehub/editor/react';+import { Flexbox } from '@lobehub/ui';+import { toast } from '@lobehub/ui/base-ui';+import { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react';+import { useTranslation } from 'react-i18next';++import CollapsibleContent from '@/components/CollapsibleContent';+import { EditorCanvas } from '@/features/EditorCanvas';+import { usePermission } from '@/hooks/usePermission';+import { useGoalStore } from '@/store/goal';++/**+ * "What counts as done" as a live document, in the TaskInstruction shape: an+ * always-mounted editor that clamps when long and autosaves on a debounce.+ * Goals carry no collaborative lock and persist markdown only, so this is the+ * instruction pattern minus the lock/attachment machinery.+ */++const REQUIREMENT_MAX_HEIGHT = 320;+const SAVE_DEBOUNCE_MS = 600;++interface GoalRequirementProps {+ goalId: string;+ requirement: string;+}++const GoalRequirement = memo<GoalRequirementProps>(({ goalId, requirement }) => {+ const { t } = useTranslation('chat');+ const { allowed: canEdit } = usePermission('create_content');+ const updateGoalRequirement = useGoalStore((s) => s.updateGoalRequirement);+ const editor = useEditor();++ const [expanded, setExpanded] = useState(false);++ // The graph polls while the goal runs; reloading the mounted editor from+ // every snapshot would eat live input. Freeze the document at the first+ // value seen per goal — the editor itself is the source of truth afterwards.+ const initialRef = useRef({ goalId, requirement });+ if (initialRef.current.goalId !== goalId) {+ initialRef.current = { goalId, requirement };+ setExpanded(false);+ }+ // eslint-disable-next-line react-hooks/exhaustive-deps+ const editorData = useMemo(() => ({ content: initialRef.current.requirement }), [goalId]);++ const debounceRef = useRef<ReturnType<typeof setTimeout>>(undefined);+ const lastSavedRef = useRef(requirement);++ const saveNow = useCallback(() => {+ if (!canEdit || !editor) return;+ let markdown: string;+ try {+ // On the unmount flush the child editor may already be disposed; a dead+ // instance means nothing newer than the last change event to save.+ markdown = String(editor.getDocument('markdown') ?? '').trim();+ } catch {+ return;+ }+ // An emptied requirement is far more likely a half-finished edit than an+ // intent to drop the acceptance bar; keep the last saved text until the+ // user writes a replacement.+ if (!markdown || markdown === lastSavedRef.current) return;+ // The marker advances only on success: a transiently failed save stays+ // different from `lastSavedRef`, so the next edit (or the unmount flush)+ // retries the same content instead of silently considering it saved.+ updateGoalRequirement(goalId, markdown)+ .then(() => {+ lastSavedRef.current = markdown;+ })+ .catch((error) => {+ console.error('[GoalRequirement] Failed to save:', error);+ toast.error(t('goalProcess.requirementSaveFailed'));+ });+ }, [canEdit, editor, goalId, t, updateGoalRequirement]);++ // The unmount cleanup runs with the closure of a stale render; the ref keeps+ // it flushing the *current* document instead of an early one.+ const saveNowRef = useRef(saveNow);+ saveNowRef.current = saveNow;+ useEffect(+ () => () => {+ // Leaving the page inside the debounce window must not discard the edit —+ // flush it now instead of only cancelling the timer.+ if (debounceRef.current) clearTimeout(debounceRef.current);+ saveNowRef.current();+ },+ [],+ );++ const handleContentChange = useCallback(() => {+ if (!canEdit || !editor) return;+ if (debounceRef.current) clearTimeout(debounceRef.current);+ debounceRef.current = setTimeout(() => {+ debounceRef.current = undefined;+ saveNow();+ }, SAVE_DEBOUNCE_MS);+ }, [canEdit, editor, saveNow]);++ // One click both expands the clamped text and lands the caret where it aimed.+ const handleFocus = useCallback(() => setExpanded(true), []);++ const handleCollapsedChange = useCallback(+ (collapsed: boolean) => {+ // Collapsing while the editor holds the caret would let Lexical restore+ // focus and immediately re-expand.+ if (collapsed) editor?.blur();+ setExpanded(!collapsed);+ },+ [editor],+ );++ return (+ <Flexbox gap={4} paddingBlock={'8px 0'}>+ <CollapsibleContent+ collapsed={!expanded}+ maxHeight={REQUIREMENT_MAX_HEIGHT}+ onCollapsedChange={handleCollapsedChange}+ >+ <div onFocus={handleFocus}>+ <EditorCanvas+ disabled={!canEdit}+ editor={editor}+ editorData={editorData}+ entityId={goalId}+ placeholder={t('goalProcess.requirementPlaceholder')}+ style={{ fontSize: 14 }}+ onContentChange={handleContentChange}+ />+ </div>+ </CollapsibleContent>+ </Flexbox>+ );+});++GoalRequirement.displayName = 'GoalRequirement';++export default GoalRequirement;diff --git a/src/features/AgentGoals/ProcessControl/Frontier.tsx b/src/features/AgentGoals/ProcessControl/Frontier.tsxindex 5e8ccadb6ad..c5f55e4f9d5 100644--- a/src/features/AgentGoals/ProcessControl/Frontier.tsx+++ b/src/features/AgentGoals/ProcessControl/Frontier.tsx@@ -10,6 +10,7 @@ import { Fragment, memo, useState } from 'react';import { useTranslation } from 'react-i18next';import { TASK_STATUS_VISUALS } from '@/components/ExecutionStatus';+import { openAddGoalTaskModal } from '@/features/AgentGoals/AddTaskModal';import RunningGlyph from '@/features/Home/components/RunningGlyph';import { useActivityTime } from '@/hooks/useActivityTime';@@ -102,7 +103,7 @@ const styles = createStaticStyles(({ css }) => ({}));export interface FrontierActions {- addTask: (title: string) => Promise<void>;+ addTask: (title: string, description?: string) => Promise<void>;decide: (decisionId: string, optionId: string, resolution?: string) => void;}@@ -111,6 +112,8 @@ interface FrontierProps {canEdit: boolean;graph: GoalGraphView;onSelect: (nodeId: string) => void;+ /** The coordinator is still decomposing — the empty list is a promise, not a lull. */+ planning?: boolean;}/** Server option ids are stable; their labels are English strings from the coordinator. */@@ -390,66 +393,24 @@ const FrontierRow = memo<{FrontierRow.displayName = 'GoalFrontierRow';-const AddTaskRow = memo<{ onAdd: (title: string) => Promise<void> }>(({ onAdd }) => {+/** Opening a modal keeps the frontier header quiet — the brief gets a real form. */+const AddTaskButton = memo<{ onAdd: FrontierActions['addTask'] }>(({ onAdd }) => {const { t } = useTranslation('chat');- const [open, setOpen] = useState(false);- const [title, setTitle] = useState('');- const [busy, setBusy] = useState(false);-- const submit = async () => {- if (!title.trim() || busy) return;- setBusy(true);- try {- await onAdd(title.trim());- setTitle('');- setOpen(false);- } finally {- setBusy(false);- }- };-- if (!open)- return (- <Button- icon={<Icon icon={Plus} />}- size={'small'}- type={'text'}- onClick={() => setOpen(true)}- >- {t('goalProcess.frontier.add')}- </Button>- );-return (- <Flexbox horizontal align={'center'} gap={8}>- <TextArea- autoFocus- autoSize={{ maxRows: 2, minRows: 1 }}- placeholder={t('goalProcess.frontier.add')}- style={{ width: 260 }}- value={title}- onChange={(event) => setTitle(event.target.value)}- onPressEnter={(event) => {- event.preventDefault();- void submit();- }}- />- <Button- disabled={!title.trim()}- loading={busy}- size={'small'}- type={'primary'}- onClick={submit}- >- {t('goalProcess.frontier.add')}- </Button>- </Flexbox>+ <Button+ icon={<Icon icon={Plus} />}+ size={'small'}+ type={'text'}+ onClick={() => openAddGoalTaskModal({ onAdd })}+ >+ {t('goalProcess.frontier.add')}+ </Button>);});-AddTaskRow.displayName = 'GoalAddTaskRow';+AddTaskButton.displayName = 'GoalAddTaskButton';-const Frontier = memo<FrontierProps>(({ actions, canEdit, graph, onSelect }) => {+const Frontier = memo<FrontierProps>(({ actions, canEdit, graph, onSelect, planning }) => {const { t } = useTranslation('chat');const [showBlocked, setShowBlocked] = useState(false);@@ -474,25 +435,36 @@ const Frontier = memo<FrontierProps>(({ actions, canEdit, graph, onSelect }) =></Text>)}</Flexbox>- {canEdit && <AddTaskRow onAdd={actions.addTask} />}+ {canEdit && <AddTaskButton onAdd={actions.addTask} />}</Flexbox><div className={styles.list}><Block gap={0} padding={2} variant={'borderless'}>- {graph.frontier.length === 0 && (- <Flexbox gap={2} padding={12}>- <Text weight={500}>- {achieved- ? t('goalProcess.frontier.achievedTitle')- : t('goalProcess.frontier.emptyTitle')}- </Text>- <Text fontSize={12} type={'secondary'}>- {achieved- ? t('goalProcess.frontier.achievedDescription')- : t('goalProcess.frontier.emptyDescription')}- </Text>- </Flexbox>- )}+ {graph.frontier.length === 0 &&+ (planning ? (+ <Flexbox horizontal align={'center'} gap={10} padding={12}>+ <RunningGlyph size={16} />+ <Flexbox gap={2}>+ <Text weight={500}>{t('goalProcess.planning.title')}</Text>+ <Text fontSize={12} type={'secondary'}>+ {t('goalProcess.planning.description')}+ </Text>+ </Flexbox>+ </Flexbox>+ ) : (+ <Flexbox gap={2} padding={12}>+ <Text weight={500}>+ {achieved+ ? t('goalProcess.frontier.achievedTitle')+ : t('goalProcess.frontier.emptyTitle')}+ </Text>+ <Text fontSize={12} type={'secondary'}>+ {achieved+ ? t('goalProcess.frontier.achievedDescription')+ : t('goalProcess.frontier.emptyDescription')}+ </Text>+ </Flexbox>+ ))}{graph.frontier.map((item, index) => (<Fragment key={item.key}>{index > 0 && <Divider dashed style={{ margin: 0 }} />}diff --git a/src/features/AgentGoals/ProcessControl/Graph/GraphNode.tsx b/src/features/AgentGoals/ProcessControl/Graph/GraphNode.tsxindex 4d88f29bf79..40078d31465 100644--- a/src/features/AgentGoals/ProcessControl/Graph/GraphNode.tsx+++ b/src/features/AgentGoals/ProcessControl/Graph/GraphNode.tsx@@ -9,6 +9,7 @@ import { useTranslation } from 'react-i18next';import { TASK_STATUS_VISUALS } from '@/components/ExecutionStatus';import RunningGlyph from '@/features/Home/components/RunningGlyph';+import { shinyTextStyles } from '@/styles';import type { GoalNodeView } from '../goalGraphViewModel';import { KIND_COLOR, KIND_ICON } from '../shared';@@ -72,6 +73,30 @@ const styles = createStaticStyles(({ css }) => ({border-color: ${cssVar.colorWarningBorder};background: ${cssVar.colorWarningBg};`,+ ghost: css`+ border-style: dashed;+ `,+ ghostBar: css`+ height: 8px;+ border-radius: 4px;+ background: ${cssVar.colorFillSecondary};+ animation: goal-ghost-pulse 1.6s ease-in-out infinite;++ @keyframes goal-ghost-pulse {+ 0%,+ 100% {+ opacity: 1;+ }++ 50% {+ opacity: 0.4;+ }+ }++ @media (prefers-reduced-motion: reduce) {+ animation: none;+ }+ `,glyph: css`display: flex;flex: none;@@ -218,8 +243,9 @@ const useStateChip = (data: GraphNodeData): StateChip | null => {const RunningClock = memo<{ startedAt?: Date }>(({ startedAt }) => {const elapsed = useElapsed(startedAt);if (!elapsed) return null;- // Sits right behind the state chip in the status row — no auto margin.- return <span style={{ fontSize: 11 }}>{elapsed}</span>;+ // Sits right behind the state chip in the status row — no auto margin. The+ // clock is ambient context, so it reads in a light tint, not body color.+ return <span style={{ color: cssVar.colorTextTertiary, fontSize: 11 }}>{elapsed}</span>;});RunningClock.displayName = 'GoalGraphRunningClock';@@ -273,6 +299,15 @@ const GraphNodeView = memo<NodeProps>(({ data }) => {<span className={styles.human}>@</span></Tooltip>)}+ {/* Top-right corner: this Work carries its own verifier. Icon only —+ the word added nothing the hover hint doesn't say better. */}+ {isTask && node.taskId && (+ <Tooltip title={t('goalProcess.node.verifierTooltip')}>+ <span style={{ display: 'inline-flex', marginInlineStart: 'auto' }}>+ <Icon color={cssVar.colorTextTertiary} icon={ShieldCheck} size={13} />+ </span>+ </Tooltip>+ )}</div>)}<div className={styles.head}>@@ -286,16 +321,6 @@ const GraphNodeView = memo<NodeProps>(({ data }) => {</div>{isTask && (<div className={styles.metrics}>- {/* "Not dispatched" moved to the status row with every other- state; an unassigned task simply has no verifier metric yet. */}- {node.taskId && (- <Tooltip title={t('goalProcess.node.verifierTooltip')}>- <span className={styles.metric}>- <Icon icon={ShieldCheck} size={13} />- {t('goalProcess.node.verifier')}- </span>- </Tooltip>- )}<Tooltip title={t('goalProcess.node.attemptsTooltip', { count: attempts })}><span className={styles.metric}><Icon icon={Repeat2} size={13} />@@ -327,4 +352,42 @@ const GraphNodeView = memo<NodeProps>(({ data }) => {GraphNodeView.displayName = 'GoalGraphNodeView';+/**+ * A placeholder card shown while the coordinator is still decomposing the goal:+ * same silhouette as a task node, dashed and pulsing, so the map promises the+ * structure that is about to arrive instead of sitting empty.+ */+export const GhostNodeView = memo(() => {+ const { t } = useTranslation('chat');+ return (+ <div style={{ position: 'relative' }}>+ <Handle+ className={styles.handle}+ isConnectable={false}+ position={Position.Top}+ type={'target'}+ />+ <div className={cx(styles.card, styles.ghost)}>+ <div className={styles.head}>+ <div+ className={styles.glyph}+ style={{ background: KIND_COLOR.task.soft, color: KIND_COLOR.task.line }}+ >+ <Icon icon={KIND_ICON.task} size={16} />+ </div>+ <Flexbox gap={7} style={{ flex: 1, minWidth: 0, paddingBlockStart: 1 }}>+ <span className={cx(styles.title, shinyTextStyles.shinyText)}>+ {t('goalProcess.node.generating')}+ </span>+ <span className={styles.ghostBar} style={{ width: '84%' }} />+ <span className={styles.ghostBar} style={{ width: '56%' }} />+ </Flexbox>+ </div>+ </div>+ </div>+ );+});++GhostNodeView.displayName = 'GoalGraphGhostNodeView';+export default GraphNodeView;diff --git a/src/features/AgentGoals/ProcessControl/Graph/index.tsx b/src/features/AgentGoals/ProcessControl/Graph/index.tsxindex dc9e885a009..4f882df7a98 100644--- a/src/features/AgentGoals/ProcessControl/Graph/index.tsx+++ b/src/features/AgentGoals/ProcessControl/Graph/index.tsx@@ -23,7 +23,7 @@ import { useTranslation } from 'react-i18next';import type { GoalGraphView, GoalNodeView } from '../goalGraphViewModel';import { KindDot } from '../shared';-import GraphNodeView, { type GraphNodeData } from './GraphNode';+import GraphNodeView, { GhostNodeView, type GraphNodeData } from './GraphNode';import { layoutGraph, NODE_WIDTH } from './layout';/**@@ -81,17 +81,36 @@ const styles = createStaticStyles(({ css }) => ({font-size: 12px;color: ${cssVar.colorTextTertiary};`,- overlay: css`- position: fixed;- z-index: 1000;- inset: 0;+ /* Fullscreen chrome floats over the canvas in two corner cards instead of a+ full-width bar, so a node panned to the top edge is never hidden behind an+ opaque header strip. */+ float: css`+ position: absolute;+ z-index: 1;+ inset-block-start: 16px;display: flex;- flex-direction: column;+ gap: 12px;+ align-items: center;- padding-block: 12px 16px;- padding-inline: 24px;+ padding-block: 8px;+ padding-inline: 14px;+ border: 1px solid ${cssVar.colorBorderSecondary};+ border-radius: ${cssVar.borderRadiusLG};+ background: ${cssVar.colorBgContainer};+ box-shadow: ${cssVar.boxShadowTertiary};+ `,+ floatLeft: css`+ inset-inline-start: 16px;+ `,+ floatRight: css`+ inset-inline-end: 16px;+ `,+ overlay: css`+ position: fixed;+ z-index: 1000;+ inset: 0;background: ${cssVar.colorBgLayout};`,}));@@ -101,6 +120,8 @@ type GraphViewMode = 'stage' | 'all';interface GraphProps {graph: GoalGraphView;onSelect: (nodeId: string) => void;+ /** The coordinator is still decomposing: show ghost task cards under the problem. */+ planning?: boolean;selectedId?: string;}@@ -182,10 +203,16 @@ const useEdgeLabel = () => {);};-const nodeTypes = { goalNode: GraphNodeView };+const nodeTypes = { goalGhost: GhostNodeView, goalNode: GraphNodeView };++/** Ghost placeholders rendered beneath the problem while planning runs. */+const GHOST_COUNT = 3;+const GHOST_GAP = 32;+const GHOST_RANK_GAP = 56;+const GHOST_HEIGHT = 88;const Canvas = memo<GraphProps & { className: string; interactive: boolean; view: GraphViewMode }>(- ({ className, graph, interactive, onSelect, selectedId, view }) => {+ ({ className, graph, interactive, onSelect, planning, selectedId, view }) => {const { fitView } = useReactFlow();const subtitleOf = useSubtitle();const edgeLabel = useEdgeLabel();@@ -205,17 +232,50 @@ const Canvas = memo<GraphProps & { className: string; interactive: boolean; viewreturn layoutGraph(nodes, edges);}, [graph, visibleIds]);+ const ghosts = useMemo(() => {+ if (!planning) return [];+ const problem = graph.nodes.find((item) => item.node.kind === 'problem');+ const box = problem ? positions[problem.node.id] : undefined;+ const centerX = box ? box.x + box.width / 2 : 0;+ const y = box ? box.y + box.height + GHOST_RANK_GAP : 0;+ const width = NODE_WIDTH.task;+ const total = width * GHOST_COUNT + GHOST_GAP * (GHOST_COUNT - 1);+ return Array.from({ length: GHOST_COUNT }, (_, i) => ({+ id: `goal-ghost-${i}`,+ sourceId: problem && box ? problem.node.id : undefined,+ x: centerX - total / 2 + i * (width + GHOST_GAP),+ y,+ }));+ }, [planning, graph, positions]);+// Inline, the canvas hugs its content: a two-node graph in a fixed 560px// frame is mostly empty margin, and `fitView` then shrinks the nodes to// fill it. Sizing the frame from the layout keeps small graphs at natural// node scale; 560px stays the ceiling so large graphs still zoom out.const inlineHeight = useMemo(() => {const boxes = Object.values(positions);- if (boxes.length === 0) return 216;- const top = Math.min(...boxes.map((box) => box.y));- const bottom = Math.max(...boxes.map((box) => box.y + box.height));+ if (boxes.length === 0 && ghosts.length === 0) return 216;+ const top = Math.min(...boxes.map((box) => box.y), ...ghosts.map((ghost) => ghost.y));+ const bottom = Math.max(+ ...boxes.map((box) => box.y + box.height),+ ...ghosts.map((ghost) => ghost.y + GHOST_HEIGHT),+ );return Math.min(560, Math.max(216, bottom - top + 72));- }, [positions]);+ }, [positions, ghosts]);++ const ghostFlowNodes: FlowNode[] = useMemo(+ () =>+ ghosts.map((ghost) => ({+ data: {},+ draggable: false,+ id: ghost.id,+ position: { x: ghost.x, y: ghost.y },+ selectable: false,+ type: 'goalGhost',+ width: NODE_WIDTH.task,+ })),+ [ghosts],+ );const flowNodes: FlowNode[] = useMemo(() =>@@ -272,13 +332,30 @@ const Canvas = memo<GraphProps & { className: string; interactive: boolean; view[graph, visibleIds, selectedId, edgeLabel],);+ const ghostFlowEdges: FlowEdge[] = useMemo(+ () =>+ ghosts+ .filter((ghost) => ghost.sourceId)+ .map((ghost) => ({+ animated: true,+ id: `${ghost.id}-edge`,+ source: ghost.sourceId!,+ target: ghost.id,+ type: 'default',+ })),+ [ghosts],+ );++ const allNodes = useMemo(() => [...flowNodes, ...ghostFlowNodes], [flowNodes, ghostFlowNodes]);+ const allEdges = useMemo(() => [...flowEdges, ...ghostFlowEdges], [flowEdges, ghostFlowEdges]);+useEffect(() => {const timer = setTimeout(() => fitView({ duration: 200, maxZoom: 1, minZoom: 0.6, padding: 0.12 }),30,);return () => clearTimeout(timer);- }, [view, flowNodes.length, fitView]);+ }, [view, allNodes.length, fitView]);return (<div className={className} style={interactive ? undefined : { height: inlineHeight }}>@@ -288,21 +365,26 @@ const Canvas = memo<GraphProps & { className: string; interactive: boolean; viewthe framing the layout chose. Fullscreen is where it is navigable. */}<ReactFlowfitView- edges={flowEdges}+ edges={allEdges}maxZoom={interactive ? 1.5 : 1}minZoom={0.3}nodeTypes={nodeTypes}- nodes={flowNodes}+ nodes={allNodes}nodesConnectable={false}nodesDraggable={false}panOnDrag={interactive}- panOnScroll={false}+ // Fullscreen reads like Figma on a trackpad: two-finger scroll pans+ // and pinch (ctrl+wheel) zooms. Wheel-to-zoom is off — on a mouse,+ // zooming stays on pinch/double-click and the +/- controls.+ panOnScroll={interactive}preventScrolling={interactive}proOptions={{ hideAttribution: true }}zoomOnDoubleClick={interactive}zoomOnPinch={interactive}- zoomOnScroll={interactive}- onNodeClick={(_, node) => onSelect(node.id)}+ zoomOnScroll={false}+ onNodeClick={(_, node) => {+ if (node.type !== 'goalGhost') onSelect(node.id);+ }}><Backgroundcolor={cssVar.colorBorderSecondary}@@ -324,56 +406,68 @@ const Graph = memo<GraphProps>((props) => {const [view, setView] = useState<GraphViewMode>('stage');const [fullscreen, setFullscreen] = useState(false);- const head = (- <Flexbox horizontal align={'center'} justify={'space-between'} paddingBlock={4}>- <Flexbox horizontal align={'center'} gap={12}>- <Text fontSize={16} weight={600}>- {t('goalProcess.graph.title')}- </Text>- <Segmented- size={'small'}- value={view}- options={[- { label: t('goalProcess.graph.view.stage'), value: 'stage' },- { label: t('goalProcess.graph.view.all'), value: 'all' },- ]}- onChange={(value) => setView(value as GraphViewMode)}- />- </Flexbox>- <Flexbox horizontal align={'center'} gap={12}>- <Flexbox horizontal align={'center'} className={styles.legend} gap={10}>- {(['problem', 'task', 'finding', 'decision'] as const).map((kind) => (- <Flexbox horizontal align={'center'} gap={4} key={kind}>- <KindDot kind={kind} />- <span>{t(`goalProcess.kind.${kind}` as const)}</span>- </Flexbox>- ))}+ const titleAndViews = (+ <>+ <Text fontSize={16} weight={600}>+ {t('goalProcess.graph.title')}+ </Text>+ <Segmented+ size={'small'}+ value={view}+ options={[+ { label: t('goalProcess.graph.view.stage'), value: 'stage' },+ { label: t('goalProcess.graph.view.all'), value: 'all' },+ ]}+ onChange={(value) => setView(value as GraphViewMode)}+ />+ </>+ );+ const legend = (+ <Flexbox horizontal align={'center'} className={styles.legend} gap={10}>+ {(['problem', 'task', 'finding', 'decision'] as const).map((kind) => (+ <Flexbox horizontal align={'center'} gap={4} key={kind}>+ <KindDot kind={kind} />+ <span>{t(`goalProcess.kind.${kind}` as const)}</span></Flexbox>- <ActionIcon- icon={fullscreen ? X : Maximize2}- size={'small'}- title={- fullscreen ? t('goalProcess.graph.exitFullscreen') : t('goalProcess.graph.fullscreen')- }- onClick={() => setFullscreen(!fullscreen)}- />- </Flexbox>+ ))}</Flexbox>);+ const toggle = (+ <ActionIcon+ icon={fullscreen ? X : Maximize2}+ size={'small'}+ title={fullscreen ? t('goalProcess.graph.exitFullscreen') : t('goalProcess.graph.fullscreen')}+ onClick={() => setFullscreen(!fullscreen)}+ />+ );if (fullscreen)return (<div className={styles.overlay}>- {head}<ReactFlowProvider><Canvas {...props} interactive className={cx(styles.canvas, styles.full)} view={view} /></ReactFlowProvider>+ {/* Corner cards float over the canvas — the map owns the whole screen+ and panned content stays visible between them. */}+ <div className={cx(styles.float, styles.floatLeft)}>{titleAndViews}</div>+ <div className={cx(styles.float, styles.floatRight)}>+ {legend}+ {toggle}+ </div></div>);return (<Flexbox gap={4}>- {head}+ <Flexbox horizontal align={'center'} justify={'space-between'} paddingBlock={4}>+ <Flexbox horizontal align={'center'} gap={12}>+ {titleAndViews}+ </Flexbox>+ <Flexbox horizontal align={'center'} gap={12}>+ {legend}+ {toggle}+ </Flexbox>+ </Flexbox><ReactFlowProvider><Canvas {...props} className={styles.canvas} interactive={false} view={view} /></ReactFlowProvider>diff --git a/src/features/AgentGoals/ProcessControl/index.tsx b/src/features/AgentGoals/ProcessControl/index.tsxindex adc41e0d359..65ea734e11b 100644--- a/src/features/AgentGoals/ProcessControl/index.tsx+++ b/src/features/AgentGoals/ProcessControl/index.tsx@@ -1,9 +1,8 @@'use client';-import { Accordion, AccordionItem, Flexbox, Icon } from '@lobehub/ui';-import { Button, Tag, Text } from '@lobehub/ui/base-ui';+import { Accordion, AccordionItem, Flexbox } from '@lobehub/ui';+import { Tag, Text } from '@lobehub/ui/base-ui';import { createStaticStyles } from 'antd-style';-import { Pause, Play } from 'lucide-react';import { memo, useCallback, useMemo, useState } from 'react';import { useTranslation } from 'react-i18next';@@ -43,8 +42,6 @@ const ProcessControl = memo<ProcessControlProps>(({ goalId }) => {const useFetchGoalGraph = useGoalStore((s) => s.useFetchGoalGraph);const decideGoal = useGoalStore((s) => s.decideGoal);- const pauseGoal = useGoalStore((s) => s.pauseGoal);- const resumeGoal = useGoalStore((s) => s.resumeGoal);const refreshGoalGraph = useGoalStore((s) => s.refreshGoalGraph);const openTaskDetail = useChatStore((s) => s.openTaskDetail);const openGoalNode = useChatStore((s) => s.openGoalNode);@@ -55,8 +52,8 @@ const ProcessControl = memo<ProcessControlProps>(({ goalId }) => {const actions: FrontierActions = useMemo(() => ({- addTask: async (title: string) => {- await goalService.addNode({ id: goalId, kind: 'task', title });+ addTask: async (title: string, description?: string) => {+ await goalService.addNode({ description, id: goalId, kind: 'task', title });await refreshGoalGraph(goalId);},decide: (decisionId, optionId, resolution) =>@@ -83,7 +80,14 @@ const ProcessControl = memo<ProcessControlProps>(({ goalId }) => {// to control here, so the page keeps its original shape.if (!graph || graph.nodes.length === 0) return null;- const paused = graph.goal.status === 'paused';+ // The coordinator is decomposing the problem into tasks. `running` with zero+ // Works counts too: the decomposition claim flips the status before the+ // planner returns, and a re-plan after all Works were removed is the same+ // state. The surfaces below promise the incoming structure instead of+ // reading as an empty goal — the graph poll fills them in as nodes land.+ const planning =+ ['planning', 'running'].includes(graph.goal.status) &&+ !graph.nodes.some((view) => view.node.kind === 'task');// A closed goal cannot move: the coordinator returns immediately for these,// and a Work added here would sit `proposed` forever. Stop offering actions// that cannot land. The goal otherwise advances entirely on its own — the@@ -94,27 +98,16 @@ const ProcessControl = memo<ProcessControlProps>(({ goalId }) => {return (<Flexbox gap={20}><Flexbox gap={12}>- <Flexbox horizontal align={'center'} gap={8}>- {canAct && (- <Button- icon={<Icon icon={paused ? Play : Pause} />}- size={'small'}- onClick={() => void (paused ? resumeGoal(goalId) : pauseGoal(goalId))}- >- {paused ? t('goalProcess.resume') : t('goalProcess.pause')}- </Button>- )}- {paused && (- <Text fontSize={12} type={'secondary'}>- {t('goalProcess.paused')}- </Text>- )}- </Flexbox>-- <Frontier actions={actions} canEdit={canAct} graph={graph} onSelect={select} />+ <Frontier+ actions={actions}+ canEdit={canAct}+ graph={graph}+ planning={planning}+ onSelect={select}+ /></Flexbox>- <Graph graph={graph} selectedId={selectedId} onSelect={select} />+ <Graph graph={graph} planning={planning} selectedId={selectedId} onSelect={select} /><Accordion defaultExpandedKeys={['findings', 'activity']} gap={0}><AccordionItemdiff --git a/src/features/AgentGoals/ProcessControl/shared.tsx b/src/features/AgentGoals/ProcessControl/shared.tsxindex fe60689c47b..07c56524503 100644--- a/src/features/AgentGoals/ProcessControl/shared.tsx+++ b/src/features/AgentGoals/ProcessControl/shared.tsx@@ -12,10 +12,14 @@ import { memo } from 'react';* filling a node with its status color.*/export const KIND_COLOR: Record<GoalNodeKind, { line: string; soft: string }> = {- decision: { line: cssVar.orange6, soft: cssVar.orange1 },- finding: { line: cssVar.green6, soft: cssVar.green1 },- problem: { line: cssVar.purple6, soft: cssVar.purple1 },- task: { line: cssVar.blue6, soft: cssVar.blue1 },+ // LobeHub's theme palette is an 11-step scale, not antd's 10-step one: the+ // primary-strength band sits at x9–x10, and x6/x7 resolve to near-pastel+ // tints (light-mode blue-7 is #93c8ff). x3/x10 gives the glyph a visible+ // tinted tile with a saturated line in both themes.+ decision: { line: cssVar.orange10, soft: cssVar.orange3 },+ finding: { line: cssVar.green10, soft: cssVar.green3 },+ problem: { line: cssVar.purple10, soft: cssVar.purple3 },+ task: { line: cssVar.blue10, soft: cssVar.blue3 },};export const KIND_ICON: Record<GoalNodeKind, LucideIcon> = {diff --git a/src/services/goal.ts b/src/services/goal.tsindex 68902c63d62..40303e69b17 100644--- a/src/services/goal.ts+++ b/src/services/goal.ts@@ -90,6 +90,9 @@ class GoalService {priority?: number;title: string;}) => lambdaClient.goal.addNode.mutate(params);++ updateRequirement = async (id: string, requirement: string) =>+ lambdaClient.goal.updateRequirement.mutate({ id, requirement });}export const goalService = new GoalService();diff --git a/src/store/goal/action.ts b/src/store/goal/action.tsindex 8721d140b67..c92bece33d1 100644--- a/src/store/goal/action.ts+++ b/src/store/goal/action.ts@@ -124,6 +124,11 @@ export class GoalActionImpl {await this.refreshGoalGraph(goalId);};+ updateGoalRequirement = async (goalId: string, requirement: string): Promise<void> => {+ await goalService.updateRequirement(goalId, requirement);+ await this.refreshGoalGraph(goalId);+ };+/*** Ask the server to run the coordinator now. The goal keeps advancing on its* own afterwards as its Work Tasks settle, so this is a nudge rather than the