🤯 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
🐛 fix(goal): open task detail directly from goal metric task rows (#20878)
Arvin Xu83c6ca8dc0c8
diff --git a/src/features/Portal/GoalMetric/Body.tsx b/src/features/Portal/GoalMetric/Body.tsxindex dced4955c65..8e4474622e7 100644--- a/src/features/Portal/GoalMetric/Body.tsx+++ b/src/features/Portal/GoalMetric/Body.tsx@@ -25,7 +25,13 @@ import { chatPortalSelectors } from '@/store/chat/selectors';import { goalSelectors, useGoalStore } from '@/store/goal';import Lifecycle from './Lifecycle';-import { taskRowSpan, type TaskRowState, taskRowState, taskRowStateLabelKey } from './taskRowState';+import {+ metricRowTaskId,+ taskRowSpan,+ type TaskRowState,+ taskRowState,+ taskRowStateLabelKey,+} from './taskRowState';/*** Drill-down behind each header metric of the goal detail page. Every view is@@ -73,8 +79,10 @@ const NodeRow = memo<{leading?: ReactNode;}>(({ afterTitle, extra, goalId, graph, leading, nodeId }) => {const openGoalNode = useChatStore((s) => s.openGoalNode);+ const openTaskDetail = useChatStore((s) => s.openTaskDetail);const view = graph.byId[nodeId];if (!view) return null;+ const taskId = metricRowTaskId(view);return (<Flexbox@@ -82,7 +90,7 @@ const NodeRow = memo<{align={'center'}className={styles.row}gap={8}- onClick={() => openGoalNode(goalId, nodeId)}+ onClick={() => (taskId ? openTaskDetail(taskId) : openGoalNode(goalId, nodeId))}>{view.seq !== undefined && (<Text className={styles.mono} fontSize={12} style={{ flex: 'none' }} type={'secondary'}>@@ -363,86 +371,84 @@ const formatTokens = (value: number): string =>* Rows are ordered by spend, and a Task whose runs have not settled shows $0* rather than being dropped: it is still consuming rounds.*/-const CostBreakdown = memo<{ goalId: string; graph: GoalGraphView; spend?: GoalSpend }>(- ({ goalId, graph, spend }) => {- const { t } = useTranslation('chat');- const openGoalNode = useChatStore((s) => s.openGoalNode);-- const rows = useMemo(() => {- const nodeByTaskId = new Map(- graph.nodes- .filter((view) => view.node.taskId)- .map((view) => [view.node.taskId!, view] as const),- );- return (spend?.byTask ?? [])- .map((row) => ({ ...row, view: nodeByTaskId.get(row.taskId) }))- .sort((a, b) => b.totalCost - a.totalCost || b.totalTokens - a.totalTokens);- }, [graph, spend]);-- if (rows.length === 0)- return (- <Text fontSize={13} type={'secondary'}>- {t('goalProcess.metricDetail.budget.perTaskEmpty')}- </Text>- );+const CostBreakdown = memo<{ graph: GoalGraphView; spend?: GoalSpend }>(({ graph, spend }) => {+ const { t } = useTranslation('chat');+ const openTaskDetail = useChatStore((s) => s.openTaskDetail);++ const rows = useMemo(() => {+ const nodeByTaskId = new Map(+ graph.nodes+ .filter((view) => view.node.taskId)+ .map((view) => [view.node.taskId!, view] as const),+ );+ return (spend?.byTask ?? [])+ .map((row) => ({ ...row, view: nodeByTaskId.get(row.taskId) }))+ .sort((a, b) => b.totalCost - a.totalCost || b.totalTokens - a.totalTokens);+ }, [graph, spend]);+ if (rows.length === 0)return (- <Flexbox gap={4}>- <span className={styles.label}>{t('goalProcess.metricDetail.budget.perTaskTitle')}</span>- <Flexbox gap={0}>- {rows.map((row) => {- const body = (- <Flexbox horizontal align={'center'} gap={8} key={row.taskId}>- {row.view?.seq !== undefined && (- <Text- className={styles.mono}- fontSize={12}- style={{ flex: 'none' }}- type={'secondary'}- >- #{row.view.seq}- </Text>- )}- <Text ellipsis style={{ flex: 1, minWidth: 0 }}>- {row.view?.node.title ?? row.taskId}- </Text>+ <Text fontSize={13} type={'secondary'}>+ {t('goalProcess.metricDetail.budget.perTaskEmpty')}+ </Text>+ );++ return (+ <Flexbox gap={4}>+ <span className={styles.label}>{t('goalProcess.metricDetail.budget.perTaskTitle')}</span>+ <Flexbox gap={0}>+ {rows.map((row) => {+ const body = (+ <Flexbox horizontal align={'center'} gap={8} key={row.taskId}>+ {row.view?.seq !== undefined && (<TextclassName={styles.mono}fontSize={12}style={{ flex: 'none' }}type={'secondary'}>- {t('goalProcess.metricDetail.budget.tokensValue', {- value: formatTokens(row.totalTokens),- })}- </Text>- <Text className={styles.mono} style={{ flex: 'none' }} weight={500}>- {formatUsd(row.totalCost)}+ #{row.view.seq}</Text>- </Flexbox>- );-- // A row without a graph node is a Task the snapshot no longer- // carries — still billed, but nothing to open.- return row.view ? (- <Flexbox- className={styles.row}- key={row.taskId}- onClick={() => openGoalNode(goalId, row.view!.node.id)}+ )}+ <Text ellipsis style={{ flex: 1, minWidth: 0 }}>+ {row.view?.node.title ?? row.taskId}+ </Text>+ <Text+ className={styles.mono}+ fontSize={12}+ style={{ flex: 'none' }}+ type={'secondary'}>- {body}- </Flexbox>- ) : (- <Flexbox className={styles.staticRow} key={row.taskId}>- {body}- </Flexbox>- );- })}- </Flexbox>+ {t('goalProcess.metricDetail.budget.tokensValue', {+ value: formatTokens(row.totalTokens),+ })}+ </Text>+ <Text className={styles.mono} style={{ flex: 'none' }} weight={500}>+ {formatUsd(row.totalCost)}+ </Text>+ </Flexbox>+ );++ // A row without a graph node is a Task the snapshot no longer+ // carries — still billed, but nothing to open.+ return row.view ? (+ <Flexbox+ className={styles.row}+ key={row.taskId}+ onClick={() => openTaskDetail(row.taskId)}+ >+ {body}+ </Flexbox>+ ) : (+ <Flexbox className={styles.staticRow} key={row.taskId}>+ {body}+ </Flexbox>+ );+ })}</Flexbox>- );- },-);+ </Flexbox>+ );+});CostBreakdown.displayName = 'GoalMetricCostBreakdown';@@ -476,7 +482,7 @@ const Budget = memo<{ goalId: string; graph: GoalGraphView }>(({ goalId, graph }{t('goalProcess.metricDetail.budget.raiseNote')}</Text></Flexbox>- <CostBreakdown goalId={goalId} graph={graph} spend={spend} />+ <CostBreakdown graph={graph} spend={spend} /></Flexbox>);});diff --git a/src/features/Portal/GoalMetric/taskRowState.test.ts b/src/features/Portal/GoalMetric/taskRowState.test.tsindex f1c126c918f..8cfe3c1e36f 100644--- a/src/features/Portal/GoalMetric/taskRowState.test.ts+++ b/src/features/Portal/GoalMetric/taskRowState.test.ts@@ -2,7 +2,7 @@ import { describe, expect, it } from 'vitest';import type { GoalNodeView } from '@/features/AgentGoals/ProcessControl/goalGraphViewModel';-import { taskRowSpan, taskRowState, taskRowStateLabelKey } from './taskRowState';+import { metricRowTaskId, taskRowSpan, taskRowState, taskRowStateLabelKey } from './taskRowState';const STARTED = new Date('2026-09-26T10:00:00Z');const HEARTBEAT = new Date('2026-09-26T10:20:00Z');@@ -67,3 +67,19 @@ describe('taskRowState', () => {expect(taskRowSpan(queued)).toBeUndefined();});});++describe('metricRowTaskId', () => {+ it('opens the Task detail for a Task row backed by a real Task', () => {+ const task = view({ node: { kind: 'task', status: 'resolved', taskId: 'task_1' } } as never);++ expect(metricRowTaskId(task)).toBe('task_1');+ });++ it('keeps the node drill-down for nodes without a Task', () => {+ const planned = view({ node: { kind: 'task', status: 'pending' } } as never);+ const finding = view({ node: { kind: 'finding', status: 'resolved', taskId: 't' } } as never);++ expect(metricRowTaskId(planned)).toBeUndefined();+ expect(metricRowTaskId(finding)).toBeUndefined();+ });+});diff --git a/src/features/Portal/GoalMetric/taskRowState.ts b/src/features/Portal/GoalMetric/taskRowState.tsindex bb78e2dfc58..dcb47b9ca49 100644--- a/src/features/Portal/GoalMetric/taskRowState.ts+++ b/src/features/Portal/GoalMetric/taskRowState.ts@@ -48,3 +48,11 @@ export const taskRowSpan = (const endedAt = last.endedAt ?? (state === 'running' ? undefined : view.heartbeatAt);return { endedAt, startedAt: first.startedAt };};++/**+ * A metric row backed by a real Task opens that Task's detail directly — the+ * node drill-down would only repeat the row and add one more click. Other node+ * kinds (findings, decisions…) have no Task to open and keep the drill-down.+ */+export const metricRowTaskId = (view: GoalNodeView): string | undefined =>+ view.node.kind === 'task' ? (view.node.taskId ?? undefined) : undefined;