🤯 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): derive the goal card from a hetero agent's lh goal create call (#20026)
Arvin Xu8c88926b817e
diff --git a/locales/en-US/chat.json b/locales/en-US/chat.jsonindex 984613ef041..55aae0ea2c9 100644--- a/locales/en-US/chat.json+++ b/locales/en-US/chat.json@@ -783,6 +783,8 @@"goalProcess.tag.retired": "Retired","goalProcess.tag.verifying": "Verifying","goalTask.checks": "{{passed}}/{{total}} checks passed",+ "goalTask.currentStep": "Current: {{title}}",+ "goalTask.nextStep": "Up next: {{title}}","goalTask.round": "Round {{current}}","goalTask.roundWithBudget": "Round {{current}}/{{total}}","goalTask.status.achieved": "Achieved",diff --git a/locales/zh-CN/chat.json b/locales/zh-CN/chat.jsonindex 9b9361efd42..c99fd412c20 100644--- a/locales/zh-CN/chat.json+++ b/locales/zh-CN/chat.json@@ -783,6 +783,8 @@"goalProcess.tag.retired": "已放弃","goalProcess.tag.verifying": "验证中","goalTask.checks": "{{passed}}/{{total}} 项通过",+ "goalTask.currentStep": "当前:{{title}}",+ "goalTask.nextStep": "下一步:{{title}}","goalTask.round": "第 {{current}} 轮","goalTask.roundWithBudget": "第 {{current}}/{{total}} 轮","goalTask.status.achieved": "已达成",diff --git a/packages/locales/src/default/chat.ts b/packages/locales/src/default/chat.tsindex d508d2b7bf1..f6318c10193 100644--- a/packages/locales/src/default/chat.ts+++ b/packages/locales/src/default/chat.ts@@ -1960,6 +1960,8 @@ export default {'goalList.status.verifying': 'Verifying','goalList.status.waiting': 'Waiting','goalTask.checks': '{{passed}}/{{total}} checks passed',+ 'goalTask.currentStep': 'Current: {{title}}',+ 'goalTask.nextStep': 'Up next: {{title}}','goalTask.round': 'Round {{current}}','goalTask.roundWithBudget': 'Round {{current}}/{{total}}','goalTask.tasksDone': '{{passed}}/{{total}} tasks done',diff --git a/src/features/Conversation/Messages/GoalTaskCard/GoalStatusLine.tsx b/src/features/Conversation/Messages/GoalTaskCard/GoalStatusLine.tsxindex 61f354907a3..5723e129c94 100644--- a/src/features/Conversation/Messages/GoalTaskCard/GoalStatusLine.tsx+++ b/src/features/Conversation/Messages/GoalTaskCard/GoalStatusLine.tsx@@ -1,5 +1,6 @@'use client';+import type { GoalNodeStatus } from '@lobechat/types';import { Flexbox, Icon } from '@lobehub/ui';import { Text } from '@lobehub/ui/base-ui';import { createStaticStyles, cssVar } from 'antd-style';@@ -17,6 +18,7 @@ import {import { memo } from 'react';import { useTranslation } from 'react-i18next';+import GoalStepTrack from './GoalStepTrack';import type { GoalTaskPhase } from './goalTaskProgress';const PHASE_META = {@@ -35,21 +37,6 @@ const PHASE_META = {>;const styles = createStaticStyles(({ css }) => ({- 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;- `,status: css`font-size: 12px;color: ${cssVar.colorTextTertiary};@@ -57,22 +44,26 @@ const styles = createStaticStyles(({ css }) => ({statusIcon: css`flex-shrink: 0;`,+ track: css`+ flex: 1;+ `,}));export interface GoalStatusLineProps {passed: number;phase: GoalTaskPhase;- progress: number;+ statuses: GoalNodeStatus[];total: number;}/**- * The live Goal status line — phase icon + round budget + acceptance coverage.- * Shared by the running tracker card and the merged task-callback header.- * Once the goal is achieved the coverage bar retires: "已达成" already implies- * full coverage, so repeating "4/4 项通过" is noise.+ * The live Goal status line — lifecycle phase word + the Tasks as a step track+ * + closed count. The phase word shows for every phase: it names the stage the+ * goal is in, which the track alone cannot. Once the goal is achieved the track+ * and count retire: "已达成" already implies full coverage, so repeating "4/4+ * 项通过" is noise.*/-const GoalStatusLine = memo<GoalStatusLineProps>(({ passed, phase, progress, total }) => {+const GoalStatusLine = memo<GoalStatusLineProps>(({ passed, phase, statuses, total }) => {const { t } = useTranslation('chat');const meta = PHASE_META[phase];const showChecks = total > 0 && phase !== 'achieved';@@ -80,23 +71,21 @@ const GoalStatusLine = memo<GoalStatusLineProps>(({ passed, phase, progress, totreturn (<Flexbox horizontal align={'center'} gap={6}>{phase !== 'running' && (- <>- <Icon- className={styles.statusIcon}- color={meta.color}- icon={meta.icon}- size={12}- spin={meta.spin}- />- <Text className={styles.status}>{t(`goalTask.status.${phase}`)}</Text>- <Text className={styles.status}>·</Text>- </>+ <Icon+ className={styles.statusIcon}+ color={meta.color}+ icon={meta.icon}+ size={12}+ spin={meta.spin}+ />)}+ <Text className={styles.status}>{t(`goalTask.status.${phase}`)}</Text>{showChecks && (<>- <div className={styles.progress}>- <div className={styles.progressFill} style={{ width: `${progress}%` }} />- </div>+ <Text className={styles.status}>·</Text>+ <Flexbox className={styles.track}>+ <GoalStepTrack statuses={statuses} total={total} />+ </Flexbox><Text className={styles.status}>{t('goalTask.tasksDone', { passed, total })}</Text></>)}diff --git a/src/features/Conversation/Messages/GoalTaskCard/GoalStepTrack.tsx b/src/features/Conversation/Messages/GoalTaskCard/GoalStepTrack.tsxnew file mode 100644index 00000000000..a5ea2d40bdb--- /dev/null+++ b/src/features/Conversation/Messages/GoalTaskCard/GoalStepTrack.tsx@@ -0,0 +1,77 @@+'use client';++import type { GoalNodeStatus } from '@lobechat/types';+import { createStaticStyles, cssVar, cx } from 'antd-style';+import { memo } from 'react';++import { buildGoalStepSegments } from './goalTaskProgress';++const styles = createStaticStyles(({ css }) => ({+ active: css`+ background: ${cssVar.colorInfo};+ animation: goal-step-active-pulse 1.6s ${cssVar.motionEaseInOut} infinite;+ `,+ done: css`+ background: ${cssVar.colorSuccess};+ `,+ pending: css`+ background: ${cssVar.colorFillSecondary};+ `,+ segment: css`+ flex: 1;+ height: 4px;+ border-radius: 2px;+ `,+ track: css`+ display: flex;+ gap: 3px;++ min-width: 96px;+ max-width: 320px;+ height: 4px;++ @keyframes goal-step-active-pulse {+ 0%,+ 100% {+ opacity: 1;+ }++ 50% {+ opacity: 0.45;+ }+ }+ `,+}));++export interface GoalStepTrackProps {+ statuses: GoalNodeStatus[];+ /** Criteria-count fallback for a goal whose graph has not been seeded yet. */+ total: number;+}++/**+ * The Goal's Tasks as a row of step segments: closed steps fill success, the+ * running step pulses info, and the rest stay neutral — the plan reads as+ * steps advancing left to right, not one anonymous bar. Before the graph is+ * seeded the count is only a draft, so the track shows that many pending+ * segments instead of disappearing. Companion count text carries the numbers,+ * so the track stays decorative.+ */+const GoalStepTrack = memo<GoalStepTrackProps>(({ statuses, total }) => {+ const segments = buildGoalStepSegments(+ statuses.length > 0 ? statuses : Array.from({ length: total }, () => 'proposed' as const),+ );+ if (segments.length === 0) return null;++ return (+ <div aria-hidden className={styles.track}>+ {segments.map((state, index) => (+ <div className={cx(styles.segment, styles[state])} key={index} />+ ))}+ </div>+ );+});++GoalStepTrack.displayName = 'GoalStepTrack';++export default GoalStepTrack;diff --git a/src/features/Conversation/Messages/GoalTaskCard/deriveOperationGoals.test.ts b/src/features/Conversation/Messages/GoalTaskCard/deriveOperationGoals.test.tsindex 2efb91a6791..1470d7b13b9 100644--- a/src/features/Conversation/Messages/GoalTaskCard/deriveOperationGoals.test.ts+++ b/src/features/Conversation/Messages/GoalTaskCard/deriveOperationGoals.test.ts@@ -82,4 +82,119 @@ describe('deriveOperationGoals', () => {]),).toEqual([]);});++ it("derives a Goal from a heterogeneous agent's `lh goal create --json` shell call", () => {+ const goals = deriveOperationGoals([+ block([+ {+ apiName: 'Bash',+ arguments: JSON.stringify({+ command:+ 'lh goal create "Weekly digest" --conversation -r "Summarize the week" --criterion "Covers every merged PR" --criterion "Written in Chinese" --json',+ }),+ id: 'call-1',+ identifier: 'claude-code',+ result: {+ content: JSON.stringify({+ edges: [],+ goal: { id: 'goal_abc123', status: 'running', title: 'Weekly digest' },+ nodes: [],+ turnToken: 'tt-1',+ url: 'https://app.lobehub.com/goal/goal_abc123',+ }),+ id: 'tool-1',+ },+ type: 'default',+ },+ ]),+ ]);++ expect(goals).toEqual([{ criteriaCount: 2, goalId: 'goal_abc123', name: 'Weekly digest' }]);+ });++ it('falls back to the printed goal URL when the CLI output is not JSON', () => {+ const goals = deriveOperationGoals([+ block([+ {+ apiName: 'shell',+ arguments: JSON.stringify({+ command: ['lh', 'goal', 'create', 'Weekly digest', '--conversation'],+ }),+ id: 'call-1',+ identifier: 'codex',+ result: {+ content:+ 'Weekly digest goal_abc123 [running]\n\ngoal: https://app.lobehub.com/goal/goal_abc123',+ id: 'tool-1',+ },+ type: 'default',+ },+ ]),+ ]);++ expect(goals).toEqual([{ criteriaCount: 0, goalId: 'goal_abc123', name: 'goal_abc123' }]);+ });++ it('recovers the goal id from truncated output with a shell notice suffix', () => {+ // Real stored shape: a long graph snapshot is cut mid-JSON before the url+ // field, and the shell appends its own cwd notice after it.+ const goals = deriveOperationGoals([+ block([+ {+ apiName: 'Bash',+ arguments: JSON.stringify({+ command:+ 'cd /tmp && lh goal create "凭证委托场景全景" --conversation --criterion "覆盖 sudo 场景" --json',+ }),+ id: 'call-1',+ identifier: 'claude-code',+ result: {+ content:+ '{\n "decisions": [],\n "events": [\n {\n "goalId": "goal_4aVZVqoD5jhu",\n "eventType": "created",\n "resolvedAt": null,\nShell cwd was reset to /Users/lobehub',+ id: 'tool-1',+ },+ type: 'default',+ },+ ]),+ ]);++ expect(goals).toEqual([+ { criteriaCount: 1, goalId: 'goal_4aVZVqoD5jhu', name: '凭证委托场景全景' },+ ]);+ });++ it('ignores shell calls that errored, created nothing, or are still running', () => {+ expect(+ deriveOperationGoals([+ block([+ {+ apiName: 'Bash',+ arguments: JSON.stringify({ command: 'lh goal create "x" --conversation --json' }),+ id: 'errored',+ identifier: 'kimi-code',+ result: { content: null, error: { message: 'exit 1' }, id: 'tool-1' },+ type: 'default',+ },+ {+ apiName: 'Bash',+ arguments: JSON.stringify({ command: 'lh goal list --json' }),+ id: 'not-create',+ identifier: 'kimi-code',+ result: {+ content: JSON.stringify({ goals: [{ id: 'goal_other' }] }),+ id: 'tool-2',+ },+ type: 'default',+ },+ {+ apiName: 'Bash',+ arguments: JSON.stringify({ command: 'lh goal create "x" --conversation --json' }),+ id: 'running',+ identifier: 'claude-code',+ type: 'default',+ },+ ]),+ ]),+ ).toEqual([]);+ });});diff --git a/src/features/Conversation/Messages/GoalTaskCard/deriveOperationGoals.ts b/src/features/Conversation/Messages/GoalTaskCard/deriveOperationGoals.tsindex 34dd5e0ea02..2b554e78061 100644--- a/src/features/Conversation/Messages/GoalTaskCard/deriveOperationGoals.ts+++ b/src/features/Conversation/Messages/GoalTaskCard/deriveOperationGoals.ts@@ -1,4 +1,4 @@-import type { AssistantContentBlock } from '@lobechat/types';+import type { AssistantContentBlock, ChatToolPayloadWithResult } from '@lobechat/types';import { safeParseJSON } from '@lobechat/utils';export interface OperationGoal {@@ -14,28 +14,89 @@ const isRecord = (value: unknown): value is Record<string, unknown> =>const nonEmptyString = (value: unknown): string | undefined =>typeof value === 'string' && value.trim() ? value : undefined;+const deriveBuiltinGoal = (tool: ChatToolPayloadWithResult): OperationGoal[] => {+ if (!['lobe-goal', 'lobe-task'].includes(tool.identifier) || tool.apiName !== 'createGoal')+ return [];+ if (tool.result?.error || !isRecord(tool.result?.state) || tool.result.state.success !== true)+ return [];++ const goalId = nonEmptyString(tool.result.state.goalId);+ if (!goalId) return [];++ const parsedArgs = safeParseJSON(tool.arguments);+ const args = isRecord(parsedArgs) ? parsedArgs : undefined;+ const name = nonEmptyString(tool.result.state.name) ?? nonEmptyString(args?.name) ?? goalId;+ const criteriaCount = Array.isArray(args?.criteria) ? args.criteria.length : 0;++ return [{ criteriaCount, goalId, name }];+};++const GOAL_CREATE_COMMAND = /\blh\s+goal\s+create\b/;+const GOAL_URL_ID = /\/goal\/(goal_[A-Za-z0-9]+)/;+const GOAL_BARE_ID = /\b(goal_[A-Za-z0-9]+)\b/;+const CREATE_TITLE = /\blh\s+goal\s+create\s+"([^"\n]+)"|\blh\s+goal\s+create\s+'([^'\n]+)'/;+const CRITERION_FLAG = /--criterion\b/g;++/**+ * Shell tools name their command differently per CLI: Claude Code and Kimi pass+ * a `command` string, Codex passes a string array.+ */+const shellCommand = (args: Record<string, unknown> | undefined): string | undefined => {+ const command = args?.command;+ if (typeof command === 'string') return command;+ if (Array.isArray(command))+ return command.filter((part): part is string => typeof part === 'string').join(' ');+ return undefined;+};++/**+ * A heterogeneous agent (Claude Code, Kimi, Codex…) never receives the builtin+ * Goal tool — its `/goal` instructions tell it to run `lh goal create` in its+ * own shell instead, so the created goal only exists as a shell command plus+ * its stdout in the tool result. Recover the card's pointer from that pair. The+ * output is not always parseable: a long graph snapshot is truncated mid-JSON+ * and the shell can append its own notices, so the id falls back from the+ * `--json` output's `goal.id` to the printed goal URL to the first bare+ * `goal_*` id — a create call's output only ever names the goal it created.+ */+const deriveCliGoal = (tool: ChatToolPayloadWithResult): OperationGoal[] => {+ if (tool.result?.error) return [];++ const parsedArgs = safeParseJSON(tool.arguments);+ const command = shellCommand(isRecord(parsedArgs) ? parsedArgs : undefined) ?? tool.arguments;+ if (!GOAL_CREATE_COMMAND.test(command)) return [];++ const content = nonEmptyString(tool.result?.content);+ if (!content) return [];++ const output = safeParseJSON(content.trim());+ const goal = isRecord(output) && isRecord(output.goal) ? output.goal : undefined;+ const goalId =+ nonEmptyString(goal?.id) ?? GOAL_URL_ID.exec(content)?.[1] ?? GOAL_BARE_ID.exec(content)?.[1];+ if (!goalId) return [];++ const titleMatch = CREATE_TITLE.exec(command);++ return [+ {+ criteriaCount: command.match(CRITERION_FLAG)?.length ?? 0,+ goalId,+ name: nonEmptyString(goal?.title) ?? titleMatch?.[1] ?? titleMatch?.[2] ?? goalId,+ },+ ];+};+/*** 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.+ * group — the builtin Goal tool for server-side agents, an `lh goal create`+ * shell call for heterogeneous ones. 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 (!['lobe-goal', 'lobe-task'].includes(tool.identifier) || tool.apiName !== 'createGoal')- return [];- if (tool.result?.error || !isRecord(tool.result?.state) || tool.result.state.success !== true)- return [];-- const goalId = nonEmptyString(tool.result.state.goalId);- if (!goalId) return [];-- const parsedArgs = safeParseJSON(tool.arguments);- const args = isRecord(parsedArgs) ? parsedArgs : undefined;- const name = nonEmptyString(tool.result.state.name) ?? nonEmptyString(args?.name) ?? goalId;- const criteriaCount = Array.isArray(args?.criteria) ? args.criteria.length : 0;-- return [{ criteriaCount, goalId, name }];+ const builtin = deriveBuiltinGoal(tool);+ return builtin.length > 0 ? builtin : deriveCliGoal(tool);}),);diff --git a/src/features/Conversation/Messages/GoalTaskCard/goalTaskProgress.test.ts b/src/features/Conversation/Messages/GoalTaskCard/goalTaskProgress.test.tsindex 4d7e9213d89..a1a5b9df544 100644--- a/src/features/Conversation/Messages/GoalTaskCard/goalTaskProgress.test.ts+++ b/src/features/Conversation/Messages/GoalTaskCard/goalTaskProgress.test.ts@@ -1,6 +1,6 @@import { describe, expect, it } from 'vitest';-import { getGoalTaskProgress } from './goalTaskProgress';+import { buildGoalStepSegments, getGoalStepPointer, getGoalTaskProgress } from './goalTaskProgress';describe('getGoalTaskProgress', () => {it('reports how much of the graph is closed while it runs', () => {@@ -37,3 +37,59 @@ describe('getGoalTaskProgress', () => {expect(getGoalTaskProgress({ criteriaCount: 1, status }).phase).toBe(phase);});});++describe('buildGoalStepSegments', () => {+ it('maps one segment per task in plan order', () => {+ expect(+ buildGoalStepSegments(['resolved', 'active', 'proposed', 'waiting', 'rejected']),+ ).toEqual(['done', 'active', 'pending', 'pending', 'done']);+ });++ it('retired tasks count as closed steps', () => {+ expect(buildGoalStepSegments(['retired', 'proposed'])).toEqual(['done', 'pending']);+ });++ it('slices graphs longer than the segment cap, keeping the least advanced state', () => {+ const statuses = Array.from({ length: 25 }, (_, index) =>+ index < 12 ? 'resolved' : 'proposed',+ );++ // ceil(25 / 12) = 3 tasks per segment: indices 0–11 done, 12–24 pending.+ expect(buildGoalStepSegments(statuses)).toEqual([+ ...Array.from({ length: 4 }, () => 'done'),+ ...Array.from({ length: 5 }, () => 'pending'),+ ]);+ });+});++describe('getGoalStepPointer', () => {+ const steps = [+ { status: 'resolved', title: 'Reproduce' },+ { status: 'active', title: 'Fix the parser' },+ { status: 'proposed', title: 'Add regression coverage' },+ ] as const;++ it('points at the first active task while one runs', () => {+ expect(getGoalStepPointer([...steps], 'running')).toEqual({+ kind: 'current',+ title: 'Fix the parser',+ });+ });++ it('falls back to the first open task as up next when nothing is active', () => {+ const paused = steps.map((step) =>+ step.status === 'active' ? { ...step, status: 'waiting' as const } : step,+ );++ expect(getGoalStepPointer(paused, 'paused')).toEqual({+ kind: 'next',+ title: 'Fix the parser',+ });+ });++ it('has no pointer once the goal reached a terminal phase', () => {+ expect(getGoalStepPointer([...steps], 'achieved')).toBeUndefined();+ expect(getGoalStepPointer([...steps], 'error')).toBeUndefined();+ expect(getGoalStepPointer([...steps], 'canceled')).toBeUndefined();+ });+});diff --git a/src/features/Conversation/Messages/GoalTaskCard/goalTaskProgress.ts b/src/features/Conversation/Messages/GoalTaskCard/goalTaskProgress.tsindex 2a6cf6791b6..4c10bd2e767 100644--- a/src/features/Conversation/Messages/GoalTaskCard/goalTaskProgress.ts+++ b/src/features/Conversation/Messages/GoalTaskCard/goalTaskProgress.ts@@ -1,4 +1,5 @@import type { GoalStatus } from '@lobechat/const/goal';+import type { GoalNodeStatus } from '@lobechat/types';export type GoalTaskPhase =| 'achieved'@@ -63,3 +64,65 @@ export const getGoalTaskProgress = (input: GoalTaskProgressInput) => {total,};};++export type GoalStepState = 'active' | 'done' | 'pending';++export interface GoalStep {+ status: GoalNodeStatus;+ title: string;+}++const CLOSED_NODE_STATUSES = new Set<GoalNodeStatus>(['rejected', 'resolved', 'retired']);++export const toGoalStepState = (status: GoalNodeStatus): GoalStepState => {+ if (CLOSED_NODE_STATUSES.has(status)) return 'done';+ if (status === 'active') return 'active';+ return 'pending';+};++/** A chat card can show at most this many step segments before they stop reading as steps. */+export const MAX_GOAL_STEP_SEGMENTS = 12;++/**+ * One track segment per Task so the card reads as a plan of steps instead of one+ * anonymous bar. Graphs longer than the segment cap are sliced evenly; a slice+ * keeps the least advanced state it contains (pending < active < done), so the+ * fill still advances left to right and never overstates progress.+ */+export const buildGoalStepSegments = (statuses: GoalNodeStatus[]): GoalStepState[] => {+ const states = statuses.map(toGoalStepState);+ if (states.length <= MAX_GOAL_STEP_SEGMENTS) return states;++ const perSegment = Math.ceil(states.length / MAX_GOAL_STEP_SEGMENTS);+ const segments: GoalStepState[] = [];+ for (let start = 0; start < states.length; start += perSegment) {+ const slice = states.slice(start, start + perSegment);+ segments.push(+ slice.includes('pending') ? 'pending' : slice.includes('active') ? 'active' : 'done',+ );+ }+ return segments;+};++export interface GoalStepPointer {+ kind: 'current' | 'next';+ title: string;+}++/**+ * The step the card should point at: the first active Task while one runs, else+ * the first not-yet-closed Task as what's up next. Terminal phases have no+ * pointer — the phase word already says the outcome.+ */+export const getGoalStepPointer = (+ steps: GoalStep[],+ phase: GoalTaskPhase,+): GoalStepPointer | undefined => {+ if (['achieved', 'canceled', 'error'].includes(phase)) return undefined;++ const active = steps.find((step) => step.status === 'active');+ if (active) return { kind: 'current', title: active.title };++ const next = steps.find((step) => !CLOSED_NODE_STATUSES.has(step.status));+ return next ? { kind: 'next', title: next.title } : undefined;+};diff --git a/src/features/Conversation/Messages/GoalTaskCard/index.tsx b/src/features/Conversation/Messages/GoalTaskCard/index.tsxindex ad85e4bf81c..0b385de2a6e 100644--- a/src/features/Conversation/Messages/GoalTaskCard/index.tsx+++ b/src/features/Conversation/Messages/GoalTaskCard/index.tsx@@ -3,8 +3,9 @@import { Center, Flexbox, Icon } from '@lobehub/ui';import { Text } from '@lobehub/ui/base-ui';import { createStaticStyles, cssVar } from 'antd-style';-import { ChevronRightIcon, TargetIcon } from 'lucide-react';+import { ChevronRightIcon, CornerDownRightIcon, TargetIcon } from 'lucide-react';import { memo } from 'react';+import { useTranslation } from 'react-i18next';import RingLoadingIcon from '@/components/RingLoading';import { useChatStore } from '@/store/chat';@@ -13,6 +14,7 @@ import type { OperationGoal } from './deriveOperationGoals';import GoalElapsedTime from './GoalElapsedTime';import GoalStatusLine from './GoalStatusLine';import type { GoalTaskPhase } from './goalTaskProgress';+import { getGoalStepPointer } from './goalTaskProgress';import { useGoalTaskStatus } from './useGoalTaskStatus';const ACTIVE_PHASES = new Set<GoalTaskPhase>(['repairing', 'running', 'verifying']);@@ -48,6 +50,13 @@ const styles = createStaticStyles(({ css }) => ({background: ${cssVar.colorFillTertiary};`,+ stepIcon: css`+ flex-shrink: 0;+ `,+ stepLine: css`+ font-size: 12px;+ color: ${cssVar.colorTextTertiary};+ `,title: css`min-width: 0;font-size: 14px;@@ -56,12 +65,14 @@ const styles = createStaticStyles(({ css }) => ({}));const GoalCard = memo<{ goal: OperationGoal }>(({ goal }) => {+ const { t } = useTranslation('chat');const openGoalPortal = useChatStore((s) => s.openGoal);- const { progress, startedAt, title } = useGoalTaskStatus({+ const { progress, startedAt, steps, title } = useGoalTaskStatus({criteriaCount: goal.criteriaCount,goalId: goal.goalId,});const isActive = ACTIVE_PHASES.has(progress.phase);+ const stepPointer = getGoalStepPointer(steps, progress.phase);// Same destination as the tool card: the goal's progress beside the chat.const openGoal = () => openGoalPortal(goal.goalId);@@ -95,7 +106,25 @@ const GoalCard = memo<{ goal: OperationGoal }>(({ goal }) => {<Text ellipsis className={styles.title}>{title ?? goal.name}</Text>- <GoalStatusLine {...progress} />+ <GoalStatusLine+ passed={progress.passed}+ phase={progress.phase}+ statuses={steps.map((step) => step.status)}+ total={progress.total}+ />+ {stepPointer && (+ <Flexbox horizontal align={'center'} gap={4}>+ <Icon+ className={styles.stepIcon}+ color={cssVar.colorTextTertiary}+ icon={CornerDownRightIcon}+ size={12}+ />+ <Text ellipsis className={styles.stepLine}>+ {t(`goalTask.${stepPointer.kind}Step`, { title: stepPointer.title })}+ </Text>+ </Flexbox>+ )}</Flexbox>{isActive && <GoalElapsedTime startedAt={startedAt} />}<ChevronRightIcon className={styles.chevron} size={16} />diff --git a/src/features/Conversation/Messages/GoalTaskCard/useGoalTaskStatus.test.ts b/src/features/Conversation/Messages/GoalTaskCard/useGoalTaskStatus.test.tsindex 6e5f3cf1a32..c7ec92c7247 100644--- a/src/features/Conversation/Messages/GoalTaskCard/useGoalTaskStatus.test.ts+++ b/src/features/Conversation/Messages/GoalTaskCard/useGoalTaskStatus.test.ts@@ -81,4 +81,28 @@ describe('useGoalTaskStatus', () => {expect(result.current.progress.phase).toBe('waiting');});++ it('exposes the task nodes as steps in graph creation order', () => {+ const task = (id: string, status: string, createdAt: string, title: string) => ({+ createdAt: new Date(createdAt),+ id,+ kind: 'task',+ status,+ title,+ });+ mocks.goalGraphById['goal-1'] = snapshot({+ nodes: [+ task('w2', 'active', '2026-08-14T08:05:00.000Z', 'Fix the parser'),+ task('w1', 'resolved', '2026-08-14T08:00:00.000Z', 'Reproduce'),+ { id: 'f1', kind: 'finding', status: 'resolved', title: 'Root cause' },+ ] as never,+ });++ const { result } = renderHook(() => useGoalTaskStatus({ goalId: 'goal-1' }));++ expect(result.current.steps).toEqual([+ { status: 'resolved', title: 'Reproduce' },+ { status: 'active', title: 'Fix the parser' },+ ]);+ });});diff --git a/src/features/Conversation/Messages/GoalTaskCard/useGoalTaskStatus.ts b/src/features/Conversation/Messages/GoalTaskCard/useGoalTaskStatus.tsindex 2d6c418bbdc..be14a16c2f7 100644--- a/src/features/Conversation/Messages/GoalTaskCard/useGoalTaskStatus.ts+++ b/src/features/Conversation/Messages/GoalTaskCard/useGoalTaskStatus.ts@@ -1,11 +1,11 @@import { goalSelectors, useGoalStore } from '@/store/goal';-import { getGoalTaskProgress } from './goalTaskProgress';+import { getGoalTaskProgress, type GoalStep } from './goalTaskProgress';/**- * Live Goal status for one `goals` row: the graph snapshot → phase and how much- * of its Tasks are closed. The card only holds the goal id, so everything else is- * fetched here.+ * Live Goal status for one `goals` row: the graph snapshot → phase, the Tasks+ * as ordered steps, and how much of them is closed. The card only holds the+ * goal id, so everything else is fetched here.*/export const useGoalTaskStatus = ({criteriaCount = 0,@@ -19,6 +19,10 @@ export const useGoalTaskStatus = ({const snapshot = useGoalStore(goalSelectors.goalGraph(goalId));const taskNodes = snapshot?.nodes.filter((node) => node.kind === 'task') ?? [];+ // The graph numbers Tasks in creation order; the step track must read the same.+ const steps: GoalStep[] = [...taskNodes]+ .sort((a, b) => new Date(a.createdAt).getTime() - new Date(b.createdAt).getTime())+ .map((node) => ({ status: node.status, title: node.title }));return {agentId: snapshot?.goal.agentId ?? undefined,@@ -33,6 +37,7 @@ export const useGoalTaskStatus = ({taskTotal: taskNodes.length,}),startedAt: snapshot?.goal.startedAt ?? undefined,+ steps,title: snapshot?.goal.title,};};