🤯 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): show a live goal card and lighten acceptance interactions (#18041)
Arvin Xub3c954558215
diff --git a/apps/server/src/services/toolExecution/serverRuntimes/task.ts b/apps/server/src/services/toolExecution/serverRuntimes/task.tsindex 6b51c188b2d..dd3573ed109 100644--- a/apps/server/src/services/toolExecution/serverRuntimes/task.ts+++ b/apps/server/src/services/toolExecution/serverRuntimes/task.ts@@ -306,7 +306,7 @@ export const createTaskRuntime = (deps: TaskRuntimeDeps) => {const runTopicId = (run as { topicId?: string }).topicId;return {- content: `Goal task ${created.identifier} created and started with ${drafts.length} acceptance criteria.`,+ content: `Goal task ${created.identifier} created and started with ${drafts.length} acceptance criteria. Execution continues in its separate task topic; do not perform or reproduce the task in this conversation.`,state: {identifier: created.identifier,name: args.name,diff --git a/locales/en-US/chat.json b/locales/en-US/chat.jsonindex 8df081f1e20..0bef6df96b5 100644--- a/locales/en-US/chat.json+++ b/locales/en-US/chat.json@@ -379,6 +379,18 @@"goalPage.title": "Overview","goalPage.view.card": "Cards","goalPage.view.list": "List",+ "goalWork.checks": "{{passed}}/{{total}} checks passed",+ "goalWork.round": "Round {{current}}",+ "goalWork.roundWithBudget": "Round {{current}}/{{total}}",+ "goalWork.status.achieved": "Achieved",+ "goalWork.status.canceled": "Canceled",+ "goalWork.status.error": "Needs attention",+ "goalWork.status.paused": "Paused",+ "goalWork.status.repairing": "Repairing",+ "goalWork.status.review": "Pending acceptance",+ "goalWork.status.running": "Executing",+ "goalWork.status.verifying": "Verifying",+ "goalWork.status.waiting": "Waiting","group.desc": "Move a task forward with multiple Agents in one shared space.","group.memberTooltip": "There are {{count}} members in the group","group.orchestratorThinking": "Orchestrator is thinking...",diff --git a/locales/zh-CN/chat.json b/locales/zh-CN/chat.jsonindex 6b12dcf3443..fff9b80ee29 100644--- a/locales/zh-CN/chat.json+++ b/locales/zh-CN/chat.json@@ -379,6 +379,18 @@"goalPage.title": "概览","goalPage.view.card": "卡片","goalPage.view.list": "列表",+ "goalWork.checks": "{{passed}}/{{total}} 项通过",+ "goalWork.round": "第 {{current}} 轮",+ "goalWork.roundWithBudget": "第 {{current}}/{{total}} 轮",+ "goalWork.status.achieved": "已达成",+ "goalWork.status.canceled": "已取消",+ "goalWork.status.error": "需要处理",+ "goalWork.status.paused": "已暂停",+ "goalWork.status.repairing": "修复中",+ "goalWork.status.review": "待验收",+ "goalWork.status.running": "执行中",+ "goalWork.status.verifying": "验证中",+ "goalWork.status.waiting": "等待中","group.desc": "在同一对话空间,让多个助理一起推进任务","group.memberTooltip": "群组内有 {{count}} 名成员","group.orchestratorThinking": "主持人思考中…",diff --git a/packages/builtin-tool-task/src/client/Intervention/CreateGoal.tsx b/packages/builtin-tool-task/src/client/Intervention/CreateGoal.tsxindex 5b4a2b2d1bb..d82f7509df3 100644--- a/packages/builtin-tool-task/src/client/Intervention/CreateGoal.tsx+++ b/packages/builtin-tool-task/src/client/Intervention/CreateGoal.tsx@@ -34,6 +34,12 @@ const styles = createStaticStyles(({ css }) => ({&:hover {background: ${cssVar.colorFillQuaternary};}++ /* Kept after :hover so specificity stays ascending for stylelint — the+ secondary border is too faint to read on the dark elevated surface. */+ html[data-theme='dark'] & + & {+ border-block-start-color: ${cssVar.colorBorder};+ }`,header: css`position: sticky;@@ -45,9 +51,9 @@ const styles = createStaticStyles(({ css }) => ({positions identical — the title simply never moves. */inset-block-start: -8px;- padding-block: 4px 2px;+ padding-block: 8px 4px;- background: ${cssVar.colorBgContainer};+ background: ${cssVar.colorBgElevated};`,instructionEditor: css`padding-block: 8px;@@ -67,6 +73,7 @@ const styles = createStaticStyles(({ css }) => ({list: css`overflow: hidden;padding: 0;+ background: transparent;`,criterionTitle: css`font-size: 13px;diff --git a/packages/builtin-tool-task/src/client/executor/index.ts b/packages/builtin-tool-task/src/client/executor/index.tsindex 9dd95f00bac..faac05247f7 100644--- a/packages/builtin-tool-task/src/client/executor/index.ts+++ b/packages/builtin-tool-task/src/client/executor/index.ts@@ -359,7 +359,7 @@ class TaskExecutor extends BaseExecutor<typeof TaskApiName> {};return {- content: `Goal task ${identifier} created and started with ${criteria.length} acceptance criteria.`,+ content: `Goal task ${identifier} created and started with ${criteria.length} acceptance criteria. Execution continues in its separate task topic; do not perform or reproduce the task in this conversation.`,state: {identifier,name: params.name,diff --git a/packages/builtin-tool-task/src/manifest.test.ts b/packages/builtin-tool-task/src/manifest.test.tsnew file mode 100644index 00000000000..4c281d54a19--- /dev/null+++ b/packages/builtin-tool-task/src/manifest.test.ts@@ -0,0 +1,14 @@+import { describe, expect, it } from 'vitest';++import { TaskManifest } from './manifest';+import { TaskApiName } from './types';++describe('TaskManifest Work semantics', () => {+ it('keeps Goal as a virtual message artifact instead of a persisted Work', () => {+ const createGoal = TaskManifest.api.find((api) => api.name === TaskApiName.createGoal);+ const createTask = TaskManifest.api.find((api) => api.name === TaskApiName.createTask);++ expect(createGoal?.work).toBeUndefined();+ expect(createTask?.work).toEqual({ action: 'create', resourceType: 'task' });+ });+});diff --git a/packages/builtin-tool-task/src/manifest.ts b/packages/builtin-tool-task/src/manifest.tsindex 7c395057334..d7edc42a047 100644--- a/packages/builtin-tool-task/src/manifest.ts+++ b/packages/builtin-tool-task/src/manifest.ts@@ -12,7 +12,7 @@ export const TaskManifest: BuiltinToolManifest = {// ==================== Task CRUD ===================={description:- 'Create and immediately start a goal-driven task with an editable acceptance plan. Use this only when the user explicitly starts their request with /goal. The call pauses for confirmation; after approval it creates the task, persists the acceptance criteria, enables bounded automatic repair, and runs the current agent in a task topic.',+ 'Create and immediately start a goal-driven task with an editable acceptance plan. Use this only when the user explicitly starts their request with /goal. The call pauses for confirmation; after approval it creates the task, persists the acceptance criteria, enables bounded automatic repair, and runs the current agent in a separate task topic. Once it succeeds, do not execute or reproduce the work in the current conversation; the live result card is the progress and result entry point.',humanIntervention: 'required',name: TaskApiName.createGoal,parameters: {@@ -54,7 +54,6 @@ export const TaskManifest: BuiltinToolManifest = {type: 'object',},renderDisplayControl: 'expand',- work: { action: 'create', resourceType: 'task' },},{description:diff --git a/packages/builtin-tool-task/src/systemRole.test.ts b/packages/builtin-tool-task/src/systemRole.test.tsindex ff9a4092567..608c0cb15dd 100644--- a/packages/builtin-tool-task/src/systemRole.test.ts+++ b/packages/builtin-tool-task/src/systemRole.test.ts@@ -3,6 +3,14 @@ import { describe, expect, it } from 'vitest';import { systemPrompt } from './systemRole';describe('systemPrompt', () => {+ it('hands successful goal execution off instead of duplicating it in the origin conversation', () => {+ expect(systemPrompt).toContain('the work has been handed off to a separate task topic');+ expect(systemPrompt).toContain(+ 'do not perform, reproduce, preview, or self-check the requested work in the current conversation',+ );+ expect(systemPrompt).toContain('its live card shows progress');+ });+it('starts a configured cron schedule by default without running it immediately', () => {expect(systemPrompt).toContain('start its schedule by default with updateTaskStatus(identifier, "scheduled")',diff --git a/packages/builtin-tool-task/src/systemRole.ts b/packages/builtin-tool-task/src/systemRole.tsindex 9d914821492..58274226d14 100644--- a/packages/builtin-tool-task/src/systemRole.ts+++ b/packages/builtin-tool-task/src/systemRole.ts@@ -1,6 +1,6 @@export const systemPrompt = `You have access to Task management tools. Use them to:-- **createGoal**: When — and only when — the user's message starts with \`/goal\`, turn the request into one editable goal plan and call createGoal before doing any substantive work. Use the current agent implicitly. Derive one concrete criterion per explicit requirement, default failed criteria to auto_repair, default maxIterations to 3, and omit maxTotalCost unless the user set one. The user confirms or edits the complete plan before the task starts. Do not call createTask/setTaskVerify/runTask separately for a /goal request+- **createGoal**: When — and only when — the user's message starts with \`/goal\`, turn the request into one editable goal plan and call createGoal before doing any substantive work. Use the current agent implicitly. Derive one concrete criterion per explicit requirement, default failed criteria to auto_repair, default maxIterations to 3, and omit maxTotalCost unless the user set one. The user confirms or edits the complete plan before the task starts. Do not call createTask/setTaskVerify/runTask separately for a /goal request. After createGoal succeeds, the work has been handed off to a separate task topic: do not perform, reproduce, preview, or self-check the requested work in the current conversation. End the turn with at most one brief sentence saying the goal is running and its live card shows progress- **createTask**: Create a new task. Use parentIdentifier to make it a subtask- **createTasks**: Create multiple tasks in one call. Prefer this when you are about to create more than one task in a row (e.g. all subtasks under one parent, or all chapters of an outline) — it cuts the number of tool calls and keeps the batch atomic from the user's perspective- **listTasks**: List tasks. With no filters, defaults to top-level unfinished tasks of the current agent in normal agent conversations, or top-level unfinished tasks across all agents in task manager conversations. If you provide any filter, omitted filters are not applied implicitlydiff --git a/packages/locales/src/default/chat.ts b/packages/locales/src/default/chat.tsindex 32a588400d3..af9c73bc04e 100644--- a/packages/locales/src/default/chat.ts+++ b/packages/locales/src/default/chat.ts@@ -1445,6 +1445,18 @@ export default {'goalList.status.running': 'Pursuing','goalList.status.verifying': 'Verifying','goalList.status.waiting': 'Waiting',+ 'goalWork.checks': '{{passed}}/{{total}} checks passed',+ 'goalWork.round': 'Round {{current}}',+ 'goalWork.roundWithBudget': 'Round {{current}}/{{total}}',+ 'goalWork.status.achieved': 'Achieved',+ 'goalWork.status.canceled': 'Canceled',+ 'goalWork.status.error': 'Needs attention',+ 'goalWork.status.paused': 'Paused',+ 'goalWork.status.repairing': 'Repairing',+ 'goalWork.status.review': 'Pending acceptance',+ 'goalWork.status.running': 'Executing',+ 'goalWork.status.verifying': 'Verifying',+ 'goalWork.status.waiting': 'Waiting','goalList.title': 'Goals','goalDetail.acceptance': 'Acceptance checks','goalDetail.acceptanceError': 'Could not load acceptance checks.',diff --git a/src/features/AgentTasks/AgentTaskDetail/RunVerifyDetail.tsx b/src/features/AgentTasks/AgentTaskDetail/RunVerifyDetail.tsxindex b318318c131..6177c02f821 100644--- a/src/features/AgentTasks/AgentTaskDetail/RunVerifyDetail.tsx+++ b/src/features/AgentTasks/AgentTaskDetail/RunVerifyDetail.tsx@@ -1,9 +1,10 @@'use client';import { Flexbox, Icon, Text } from '@lobehub/ui';+import { Button } from '@lobehub/ui/base-ui';import { createStaticStyles, cssVar } from 'antd-style';-import { CircleCheck, CircleDashed, CircleX } from 'lucide-react';-import { memo, type ReactNode } from 'react';+import { Check, ChevronDown, ChevronRight, CircleDashed, X } from 'lucide-react';+import { memo, type ReactNode, useState } from 'react';import { useTranslation } from 'react-i18next';import { useVerifyResults } from '@/features/Verify';@@ -17,6 +18,21 @@ const styles = createStaticStyles(({ css }) => ({border-block-start: 1px solid ${cssVar.colorBorderSecondary};}`,+ header: css`+ justify-content: flex-start;++ width: 100%;+ height: auto;+ margin: -4px;+ padding: 4px;+ border-radius: ${cssVar.borderRadius};++ text-align: start;++ &:hover {+ background: ${cssVar.colorFillQuaternary};+ }+ `,list: css`overflow: hidden;border: 1px solid ${cssVar.colorBorderSecondary};@@ -29,8 +45,8 @@ const styles = createStaticStyles(({ css }) => ({}));const verdictIcon = (verdict: string | null) => {- if (verdict === 'passed') return { color: cssVar.colorSuccess, icon: CircleCheck };- if (verdict) return { color: cssVar.colorError, icon: CircleX };+ if (verdict === 'passed') return { color: cssVar.colorSuccess, icon: Check };+ if (verdict) return { color: cssVar.colorError, icon: X };return { color: cssVar.colorTextQuaternary, icon: CircleDashed };};@@ -46,41 +62,57 @@ const RunVerifyDetail = memo<{}>(({ extra, operationId }) => {const { t } = useTranslation('chat');const { data: results } = useVerifyResults(operationId ?? null);+ const [expanded, setExpanded] = useState(true);if (!results?.length) return null;return (<Flexbox gap={6}>- <Flexbox horizontal align={'center'} gap={8}>- <Text fontSize={12} type={'secondary'}>- {t('taskDetail.runVerify.checklist')}- </Text>- {extra}- </Flexbox>- <Flexbox className={styles.list}>- {results.map((result) => {- const meta = verdictIcon(result.verdict);- // An LLM judge's reasoning IS its product; a programmatic check- // usually has none, and then the verdict alone is the whole story.- const reasoning = (result.toulmin as { reasoning?: string } | null)?.reasoning;+ <Button+ aria-expanded={expanded}+ className={styles.header}+ title={t(expanded ? 'taskDetail.runCollapse' : 'taskDetail.runExpand')}+ type={'text'}+ onClick={() => setExpanded((open) => !open)}+ >+ <Flexbox horizontal align={'center'} gap={8}>+ <Icon+ color={cssVar.colorTextQuaternary}+ icon={expanded ? ChevronDown : ChevronRight}+ size={12}+ />+ <Text fontSize={12} type={'secondary'}>+ {t('taskDetail.runVerify.checklist')}+ </Text>+ {extra}+ </Flexbox>+ </Button>+ {expanded && (+ <Flexbox className={styles.list}>+ {results.map((result) => {+ const meta = verdictIcon(result.verdict);+ // An LLM judge's reasoning IS its product; a programmatic check+ // usually has none, and then the verdict alone is the whole story.+ const reasoning = (result.toulmin as { reasoning?: string } | null)?.reasoning;- return (- <Flexbox className={styles.check} gap={4} key={result.id}>- <Flexbox horizontal align={'center'} gap={8}>- <Icon color={meta.color} icon={meta.icon} size={14} style={{ flex: 'none' }} />- <Text ellipsis fontSize={13} style={{ flex: 1, minWidth: 0 }}>- {result.checkItemTitle}- </Text>+ return (+ <Flexbox className={styles.check} gap={4} key={result.id}>+ <Flexbox horizontal align={'center'} gap={8}>+ <Icon color={meta.color} icon={meta.icon} size={14} style={{ flex: 'none' }} />+ <Text ellipsis fontSize={13} style={{ flex: 1, minWidth: 0 }}>+ {result.checkItemTitle}+ </Text>+ </Flexbox>+ {reasoning && (+ <Text className={styles.reason} style={{ whiteSpace: 'pre-wrap' }}>+ {reasoning}+ </Text>+ )}</Flexbox>- {reasoning && (- <Text className={styles.reason} style={{ whiteSpace: 'pre-wrap' }}>- {reasoning}- </Text>- )}- </Flexbox>- );- })}- </Flexbox>+ );+ })}+ </Flexbox>+ )}</Flexbox>);});diff --git a/src/features/AgentTasks/AgentTaskDetail/TopicCard.tsx b/src/features/AgentTasks/AgentTaskDetail/TopicCard.tsxindex 92ef36926c6..87529ae5491 100644--- a/src/features/AgentTasks/AgentTaskDetail/TopicCard.tsx+++ b/src/features/AgentTasks/AgentTaskDetail/TopicCard.tsx@@ -52,8 +52,8 @@ const formatDuration = (ms: number): string => {// The run's last message (`content`) is the raw assistant output — markdown, and// often long. Render it as rich text, but keep it a bounded preview in the feed:// the shared collapse clamps it with a fade and offers "show more", while the-// whole card still opens the run drawer for deeper reading. `pointerEvents: none`-// keeps every click inside markdown falling through to the card.+// run drawer remains available from the explicit overflow action. The preview+// itself is reading content, not an unlabeled navigation target.const RUN_CONTENT_MAX_HEIGHT = 160;const RunContent = memo<{ content: string }>(({ content }) => (@@ -201,13 +201,11 @@ const TopicCard = memo<TopicCardProps>(({ activity, defaultExpanded = true }) =>return (<Block- clickable={!!activity.id}gap={8}paddingBlock={8}paddingInline={8}style={{ borderRadius: cssVar.borderRadiusLG }}variant={'outlined'}- onClick={activity.id ? handleOpen : undefined}><Flexbox horizontal align={'center'} gap={8} justify={'space-between'}><Flexbox horizontal align={'center'} gap={8} style={{ minWidth: 0, overflow: 'hidden' }}>diff --git a/src/features/Conversation/Messages/AssistantGroup/index.tsx b/src/features/Conversation/Messages/AssistantGroup/index.tsxindex 075cbf017af..c2f5583c35e 100644--- a/src/features/Conversation/Messages/AssistantGroup/index.tsx+++ b/src/features/Conversation/Messages/AssistantGroup/index.tsx@@ -40,6 +40,8 @@ import {} from '../Contexts/message-action-context';import EditedFilesCard from '../EditedFilesCard';import { useOperationEditedFiles } from '../EditedFilesCard/useOperationEditedFiles';+import GoalWorkCard from '../GoalWorkCard';+import { useOperationGoals } from '../GoalWorkCard/useOperationGoals';import MessageWorks from '../MessageWorks';import SignalCallbacks from '../SignalCallbacks';import FileListViewer from '../User/components/FileListViewer';@@ -139,6 +141,7 @@ const GroupMessage = memo<GroupMessageProps>(// (the work anchor marks them); without it the card keeps every entry.!!workRootOperationId,);+ const operationGoals = useOperationGoals(isGroupGenerating ? undefined : children);const isInbox = useAgentStore(builtinAgentSelectors.isInboxAgent);const [toggleSystemRole] = useGlobalStore((s) => [s.toggleSystemRole]);@@ -260,13 +263,14 @@ const GroupMessage = memo<GroupMessageProps>()}afterActions={- // Wrap in a Flexbox only when the edited-files card is present: the- // work anchor is stamped on every tool round while `MessageWorks`- // renders null when that round has no works, so the wrapper would- // otherwise mount as an empty container on plain tool-only turns.- editedFiles.length > 0 ? (+ // Virtual round artifacts (edited files / Goal handoffs) are derived+ // from the group's tool calls and stay visible after the tool steps+ // collapse. Only mount the wrapper when one exists: a work anchor can+ // be present while `MessageWorks` itself resolves to null.+ editedFiles.length > 0 || operationGoals.length > 0 ? (<Flexbox gap={8}>- <EditedFilesCard entries={editedFiles} />+ {editedFiles.length > 0 && <EditedFilesCard entries={editedFiles} />}+ {operationGoals.length > 0 && <GoalWorkCard goals={operationGoals} />}{workRootOperationId && <MessageWorks rootOperationId={workRootOperationId} />}</Flexbox>) : workRootOperationId ? (diff --git a/src/features/Conversation/Messages/GoalWorkCard/deriveOperationGoals.test.ts b/src/features/Conversation/Messages/GoalWorkCard/deriveOperationGoals.test.tsnew file mode 100644index 00000000000..e32872e0a96--- /dev/null+++ b/src/features/Conversation/Messages/GoalWorkCard/deriveOperationGoals.test.ts@@ -0,0 +1,91 @@+import type { AssistantContentBlock } from '@lobechat/types';+import { describe, expect, it } from 'vitest';++import { deriveOperationGoals } from './deriveOperationGoals';++const block = (tools: AssistantContentBlock['tools']): AssistantContentBlock => ({+ content: '',+ id: 'assistant-1',+ tools,+});++describe('deriveOperationGoals', () => {+ it('derives a virtual Goal artifact from a successful createGoal result', () => {+ const goals = deriveOperationGoals([+ block([+ {+ apiName: 'createGoal',+ arguments: JSON.stringify({+ criteria: [{ title: 'Four lines' }, { title: 'No English' }],+ maxIterations: 3,+ name: 'San Francisco night fog',+ }),+ id: 'call-1',+ identifier: 'lobe-task',+ result: {+ content: 'started',+ id: 'tool-1',+ state: {+ identifier: 'T-41',+ name: 'San Francisco night fog',+ success: true,+ taskId: 'task-41',+ },+ },+ type: 'builtin',+ },+ ]),+ ]);++ expect(goals).toEqual([+ {+ criteriaCount: 2,+ identifier: 'T-41',+ maxRounds: 3,+ name: 'San Francisco night fog',+ taskId: 'task-41',+ },+ ]);+ });++ it('ignores pending, failed, and non-Goal tool calls', () => {+ expect(+ deriveOperationGoals([+ block([+ {+ apiName: 'createGoal',+ arguments: '{}',+ id: 'pending',+ identifier: 'lobe-task',+ type: 'builtin',+ },+ {+ apiName: 'createGoal',+ arguments: '{}',+ id: 'failed',+ identifier: 'lobe-task',+ result: {+ content: 'failed',+ error: { message: 'boom' },+ id: 'tool-failed',+ state: { identifier: 'T-42', success: false, taskId: 'task-42' },+ },+ type: 'builtin',+ },+ {+ apiName: 'createTask',+ arguments: '{}',+ id: 'task',+ identifier: 'lobe-task',+ result: {+ content: 'created',+ id: 'tool-task',+ state: { identifier: 'T-43', success: true, taskId: 'task-43' },+ },+ type: 'builtin',+ },+ ]),+ ]),+ ).toEqual([]);+ });+});diff --git a/src/features/Conversation/Messages/GoalWorkCard/deriveOperationGoals.ts b/src/features/Conversation/Messages/GoalWorkCard/deriveOperationGoals.tsnew file mode 100644index 00000000000..a3efb380bd8--- /dev/null+++ b/src/features/Conversation/Messages/GoalWorkCard/deriveOperationGoals.ts@@ -0,0 +1,46 @@+import type { AssistantContentBlock } from '@lobechat/types';+import { safeParseJSON } from '@lobechat/utils';++export interface OperationGoal {+ criteriaCount: number;+ identifier: string;+ maxRounds?: number;+ name: string;+ taskId: string;+}++const isRecord = (value: unknown): value is Record<string, unknown> =>+ typeof value === 'object' && value !== null;++const nonEmptyString = (value: unknown): string | undefined =>+ typeof value === 'string' && value.trim() ? value : undefined;++/**+ * Derive Goal artifacts from the completed createGoal calls in one assistant+ * group. Like the edited-files aggregate, this is display-only: no Work row is+ * created and nothing enters Work Gallery/history.+ */+export const deriveOperationGoals = (blocks: AssistantContentBlock[] = []): OperationGoal[] => {+ const goals = blocks.flatMap((block) =>+ (block.tools ?? []).flatMap((tool) => {+ if (tool.identifier !== 'lobe-task' || tool.apiName !== 'createGoal') return [];+ if (tool.result?.error || !isRecord(tool.result?.state) || tool.result.state.success !== true)+ return [];++ const identifier = nonEmptyString(tool.result.state.identifier);+ const taskId = nonEmptyString(tool.result.state.taskId);+ if (!identifier || !taskId) return [];++ const parsedArgs = safeParseJSON(tool.arguments);+ const args = isRecord(parsedArgs) ? parsedArgs : undefined;+ const name =+ nonEmptyString(tool.result.state.name) ?? nonEmptyString(args?.name) ?? identifier;+ const criteriaCount = Array.isArray(args?.criteria) ? args.criteria.length : 0;+ const maxRounds = typeof args?.maxIterations === 'number' ? args.maxIterations : undefined;++ return [{ criteriaCount, identifier, maxRounds, name, taskId }];+ }),+ );++ return [...new Map(goals.map((goal) => [goal.taskId, goal])).values()];+};diff --git a/src/features/Conversation/Messages/GoalWorkCard/goalWorkProgress.test.ts b/src/features/Conversation/Messages/GoalWorkCard/goalWorkProgress.test.tsnew file mode 100644index 00000000000..d73c17547c1--- /dev/null+++ b/src/features/Conversation/Messages/GoalWorkCard/goalWorkProgress.test.ts@@ -0,0 +1,55 @@+import { describe, expect, it } from 'vitest';++import { getGoalWorkProgress } from './goalWorkProgress';++describe('getGoalWorkProgress', () => {+ it('keeps a planned acceptance in execution while its task is running', () => {+ expect(+ getGoalWorkProgress({+ acceptanceStatus: 'planned',+ criteriaCount: 4,+ maxRounds: 3,+ rounds: 1,+ taskStatus: 'running',+ }),+ ).toEqual({+ maxRounds: 3,+ passed: 0,+ phase: 'running',+ progress: 0,+ round: 1,+ total: 4,+ });+ });++ it('reports the verification phase and real acceptance coverage', () => {+ expect(+ getGoalWorkProgress({+ acceptanceStatus: 'verifying',+ checks: [{ state: 'passed' }, { state: 'running' }, { state: 'passed' }],+ criteriaCount: 3,+ maxRounds: 3,+ rounds: 2,+ taskStatus: 'running',+ }),+ ).toEqual({+ maxRounds: 3,+ passed: 2,+ phase: 'verifying',+ progress: 67,+ round: 2,+ total: 3,+ });+ });++ it.each([+ ['repairing', 'repairing'],+ ['delivered', 'review'],+ ['accepted', 'achieved'],+ ['errored', 'error'],+ ])('maps acceptance status %s to phase %s', (acceptanceStatus, phase) => {+ expect(+ getGoalWorkProgress({ acceptanceStatus, criteriaCount: 1, taskStatus: 'running' }).phase,+ ).toBe(phase);+ });+});diff --git a/src/features/Conversation/Messages/GoalWorkCard/goalWorkProgress.ts b/src/features/Conversation/Messages/GoalWorkCard/goalWorkProgress.tsnew file mode 100644index 00000000000..c2c12e742da--- /dev/null+++ b/src/features/Conversation/Messages/GoalWorkCard/goalWorkProgress.ts@@ -0,0 +1,77 @@+export type GoalWorkPhase =+ | 'achieved'+ | 'canceled'+ | 'error'+ | 'paused'+ | 'repairing'+ | 'review'+ | 'running'+ | 'verifying'+ | 'waiting';++interface GoalWorkProgressInput {+ acceptanceStatus?: string;+ checks?: Array<{ state: string }>;+ criteriaCount: number;+ maxRounds?: number | null;+ rounds?: number;+ taskStatus?: string;+}++const resolvePhase = (acceptanceStatus?: string, taskStatus?: string): GoalWorkPhase => {+ switch (acceptanceStatus) {+ case 'accepted': {+ return 'achieved';+ }+ case 'delivered': {+ return 'review';+ }+ case 'errored': {+ return 'error';+ }+ case 'rejected':+ case 'closed': {+ return 'paused';+ }+ case 'repairing': {+ return 'repairing';+ }+ case 'verifying': {+ return 'verifying';+ }+ }++ switch (taskStatus) {+ case 'canceled': {+ return 'canceled';+ }+ case 'failed': {+ return 'error';+ }+ case 'paused': {+ return 'paused';+ }+ case 'scheduled': {+ return 'waiting';+ }+ default: {+ return 'running';+ }+ }+};++/** Honest Goal progress: lifecycle phase + round budget + acceptance coverage. */+export const getGoalWorkProgress = (input: GoalWorkProgressInput) => {+ const checks = input.checks ?? [];+ const passed = checks.filter((check) => check.state === 'passed').length;+ const total = checks.length || input.criteriaCount;++ return {+ maxRounds: input.maxRounds ?? undefined,+ passed,+ phase: resolvePhase(input.acceptanceStatus, input.taskStatus),+ progress: total > 0 ? Math.round((passed / total) * 100) : 0,+ round: Math.max(1, input.rounds ?? 1),+ total,+ };+};diff --git a/src/features/Conversation/Messages/GoalWorkCard/index.tsx b/src/features/Conversation/Messages/GoalWorkCard/index.tsxnew file mode 100644index 00000000000..0636af3abab--- /dev/null+++ b/src/features/Conversation/Messages/GoalWorkCard/index.tsx@@ -0,0 +1,202 @@+'use client';++import { Center, Flexbox, Icon, Text } from '@lobehub/ui';+import { createStaticStyles, cssVar } from 'antd-style';+import {+ AlertTriangleIcon,+ CheckCircle2Icon,+ ChevronRightIcon,+ CircleSlashIcon,+ Clock3Icon,+ LoaderCircleIcon,+ PauseCircleIcon,+ RefreshCwIcon,+ StampIcon,+ TargetIcon,+} from 'lucide-react';+import { memo } from 'react';+import { useTranslation } from 'react-i18next';++import { useAcceptanceBundle, useAcceptanceBySubject } from '@/features/Verify';+import { useChatStore } from '@/store/chat';+import { useTaskStore } from '@/store/task';++import type { OperationGoal } from './deriveOperationGoals';+import { getGoalWorkProgress, type GoalWorkPhase } from './goalWorkProgress';++const PHASE_META = {+ achieved: { color: cssVar.colorSuccess, icon: CheckCircle2Icon, spin: false },+ canceled: { color: cssVar.colorTextTertiary, icon: CircleSlashIcon, spin: false },+ error: { color: cssVar.colorError, icon: AlertTriangleIcon, spin: false },+ paused: { color: cssVar.colorTextTertiary, icon: PauseCircleIcon, spin: false },+ repairing: { color: cssVar.colorWarning, icon: RefreshCwIcon, spin: true },+ review: { color: cssVar.colorWarning, icon: StampIcon, spin: false },+ running: { color: cssVar.colorInfo, icon: LoaderCircleIcon, spin: true },+ verifying: { color: cssVar.colorInfo, icon: LoaderCircleIcon, spin: true },+ waiting: { color: cssVar.colorTextSecondary, icon: Clock3Icon, spin: false },+} as const satisfies Record<+ GoalWorkPhase,+ { color: string; icon: typeof TargetIcon; spin: boolean }+>;++const styles = createStaticStyles(({ css }) => ({+ card: css`+ cursor: pointer;++ width: 100%;+ padding-block: 10px;+ padding-inline: 12px;+ border: 1px solid ${cssVar.colorBorderSecondary};+ border-radius: 8px;++ background: ${cssVar.colorBgElevated};++ &:hover {+ background: ${cssVar.colorFillQuaternary};+ }+ `,+ chevron: css`+ flex-shrink: 0;+ color: ${cssVar.colorTextTertiary};+ `,+ icon: css`+ flex-shrink: 0;++ width: 36px;+ height: 36px;+ border-radius: 8px;++ color: ${cssVar.colorTextSecondary};++ background: ${cssVar.colorFillTertiary};+ `,+ identifier: css`+ flex-shrink: 0;+ font-family: ${cssVar.fontFamilyCode};+ font-size: 12px;+ color: ${cssVar.colorTextTertiary};+ `,+ progress: css`+ overflow: hidden;++ width: 72px;+ height: 3px;+ border-radius: 2px;++ background: ${cssVar.colorFillSecondary};+ `,+ progressFill: css`+ height: 100%;+ border-radius: inherit;+ background: ${cssVar.colorSuccess};+ transition: width 0.25s ease;+ `,+ statusIcon: css`+ flex-shrink: 0;+ `,+ status: css`+ font-size: 12px;+ color: ${cssVar.colorTextTertiary};+ `,+ title: css`+ min-width: 0;+ font-size: 14px;+ font-weight: 500;+ `,+}));++const GoalCard = memo<{ goal: OperationGoal }>(({ goal }) => {+ const { t } = useTranslation('chat');+ const openTaskDetail = useChatStore((s) => s.openTaskDetail);+ const useFetchTaskDetail = useTaskStore((s) => s.useFetchTaskDetail);+ useFetchTaskDetail(goal.identifier);+ const task = useTaskStore((s) => s.taskDetailMap[goal.identifier]);+ const { data: acceptance } = useAcceptanceBySubject('task', goal.taskId);+ const { data: bundle } = useAcceptanceBundle(acceptance?.id ?? null);+ const config = task?.config as { goal?: { maxIterations?: number | null } } | undefined;+ const progress = getGoalWorkProgress({+ acceptanceStatus: acceptance?.status,+ checks: bundle?.checks,+ criteriaCount: goal.criteriaCount,+ maxRounds: config?.goal?.maxIterations ?? goal.maxRounds,+ rounds: task?.topicCount ?? 0,+ taskStatus: task?.status,+ });+ const phase = PHASE_META[progress.phase];++ return (+ <Flexbox+ horizontal+ align={'center'}+ className={styles.card}+ gap={10}+ role={'button'}+ tabIndex={0}+ onClick={() => openTaskDetail(goal.identifier)}+ onKeyDown={(event) => {+ if (event.key !== 'Enter' && event.key !== ' ') return;+ event.preventDefault();+ openTaskDetail(goal.identifier);+ }}+ >+ <Center className={styles.icon}>+ <Icon icon={TargetIcon} size={20} />+ </Center>+ <Flexbox flex={1} gap={2} style={{ minWidth: 0 }}>+ <Text ellipsis className={styles.title}>+ {goal.name}+ </Text>+ <Flexbox horizontal align={'center'} gap={6}>+ <Icon+ className={styles.statusIcon}+ color={phase.color}+ icon={phase.icon}+ size={12}+ spin={phase.spin}+ />+ <Text className={styles.status}>{t(`goalWork.status.${progress.phase}`)}</Text>+ <Text className={styles.status}>·</Text>+ <Text className={styles.status}>+ {progress.maxRounds+ ? t('goalWork.roundWithBudget', {+ current: progress.round,+ total: progress.maxRounds,+ })+ : t('goalWork.round', { current: progress.round })}+ </Text>+ {progress.total > 0 && (+ <>+ <Text className={styles.status}>·</Text>+ <div className={styles.progress}>+ <div className={styles.progressFill} style={{ width: `${progress.progress}%` }} />+ </div>+ <Text className={styles.status}>+ {t('goalWork.checks', { passed: progress.passed, total: progress.total })}+ </Text>+ </>+ )}+ </Flexbox>+ </Flexbox>+ <Text className={styles.identifier}>{goal.identifier}</Text>+ <ChevronRightIcon className={styles.chevron} size={16} />+ </Flexbox>+ );+});++GoalCard.displayName = 'GoalWorkCardItem';++const GoalWorkCard = memo<{ goals: OperationGoal[] }>(({ goals }) => {+ if (goals.length === 0) return null;++ return (+ <Flexbox gap={8}>+ {goals.map((goal) => (+ <GoalCard goal={goal} key={goal.taskId} />+ ))}+ </Flexbox>+ );+});++GoalWorkCard.displayName = 'GoalWorkCard';++export default GoalWorkCard;diff --git a/src/features/Conversation/Messages/GoalWorkCard/useOperationGoals.ts b/src/features/Conversation/Messages/GoalWorkCard/useOperationGoals.tsnew file mode 100644index 00000000000..6db542cafb7--- /dev/null+++ b/src/features/Conversation/Messages/GoalWorkCard/useOperationGoals.ts@@ -0,0 +1,8 @@+import type { AssistantContentBlock } from '@lobechat/types';+import { useMemo } from 'react';++import { deriveOperationGoals, type OperationGoal } from './deriveOperationGoals';++/** Display-only Goal artifacts derived from one settled assistant group. */+export const useOperationGoals = (blocks?: AssistantContentBlock[]): OperationGoal[] =>+ useMemo(() => deriveOperationGoals(blocks ?? []), [blocks]);