Skip to content

🤯 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.

✨ feat(goal): list who decided what, tab the results, show the activity timeline (#21527)

Arvin Xuc0700c290571
diff --git a/locales/en-US/chat.json b/locales/en-US/chat.json
index 5768964ae36..da773db1611 100644
--- a/locales/en-US/chat.json
+++ b/locales/en-US/chat.json
@@ -835,6 +835,9 @@
"goalProcess.decision.summary.thisTask": "this task",
"goalProcess.decision.system": "Run environment",
"goalProcess.decision.viewRun": "Open task",
+ "goalProcess.decisions.empty": "No decision has been asked on this goal yet.",
+ "goalProcess.decisions.pending": "Awaiting decision",
+ "goalProcess.decisions.title": "Decisions",
"goalProcess.deliverables.empty": "Nothing delivered yet. Documents, generated files and linked resources a task persists show up here — anything left only on a local path does not.",
"goalProcess.deliverables.from": "From “{{title}}”",
"goalProcess.deliverables.title": "Deliverables",
diff --git a/locales/zh-CN/chat.json b/locales/zh-CN/chat.json
index 8588a83317c..1f9369c69b6 100644
--- a/locales/zh-CN/chat.json
+++ b/locales/zh-CN/chat.json
@@ -835,6 +835,9 @@
"goalProcess.decision.summary.thisTask": "这项任务",
"goalProcess.decision.system": "运行环境",
"goalProcess.decision.viewRun": "查看任务",
+ "goalProcess.decisions.empty": "这个目标还没有需要决策的事项。",
+ "goalProcess.decisions.pending": "待决策",
+ "goalProcess.decisions.title": "决策",
"goalProcess.deliverables.empty": "还没有交付物。任务写入产品的文档、生成的文件和关联资源会出现在这里——只留在本地路径上的产物不会。",
"goalProcess.deliverables.from": "来自「{{title}}」",
"goalProcess.deliverables.title": "交付物",
diff --git a/packages/locales/src/default/chat.ts b/packages/locales/src/default/chat.ts
index 9d30444c282..9b2e3faf5d0 100644
--- a/packages/locales/src/default/chat.ts
+++ b/packages/locales/src/default/chat.ts
@@ -2903,6 +2903,9 @@ export default {
'goalProcess.node.artifactsTooltip':
'{{count}} work versions registered. Opening them needs a server read that does not exist yet.',
'goalProcess.node.humanTouched': 'You took part in this task',
+ 'goalProcess.decisions.title': 'Decisions',
+ 'goalProcess.decisions.empty': 'No decision has been asked on this goal yet.',
+ 'goalProcess.decisions.pending': 'Awaiting decision',
'goalProcess.findings.title': 'Findings',
'goalProcess.findings.empty': 'No findings yet.',
'goalProcess.findings.answers': 'Answers “{{title}}”',
diff --git a/src/features/AgentGoals/ProcessControl/Decisions.tsx b/src/features/AgentGoals/ProcessControl/Decisions.tsx
new file mode 100644
index 00000000000..615566660ed
--- /dev/null
+++ b/src/features/AgentGoals/ProcessControl/Decisions.tsx
@@ -0,0 +1,158 @@
+'use client';
+
+import { cssVar, Flexbox, Icon, Tag, Text } from '@lobehub/ui';
+import { cssVar as vars } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
+import { ArrowRight } from 'lucide-react';
+import { memo } from 'react';
+import { useTranslation } from 'react-i18next';
+
+import { useActivityTime } from '@/hooks/useActivityTime';
+
+import { buildDecisionRows, type DecisionRow } from './decisionList';
+import { AgentActor, UserActor } from './GoalActors';
+import type { GoalGraphView } from './goalGraphViewModel';
+import { useDecisionCopy } from './GoalResultFollowUps';
+
+/**
+ * Every call this goal stopped to ask, and who answered it — the trace behind
+ * "why did it go this way". Open questions lead, then settled ones newest
+ * first, each with the answer picked, any guidance written with it, and the
+ * person or agent who gave it.
+ *
+ * Answering still happens where the question is raised (the frontier); a row
+ * only opens the node it was asked on.
+ */
+
+const styles = stylex.create({
+ divided: {
+ borderBlockStartColor: vars.colorBorderSecondary,
+ borderBlockStartStyle: 'solid',
+ borderBlockStartWidth: 1,
+ },
+ row: {
+ backgroundColor: {
+ ':hover': vars.colorFillQuaternary,
+ 'default': 'transparent',
+ },
+ borderRadius: vars.borderRadiusSM,
+ borderWidth: 0,
+ cursor: 'pointer',
+ outlineColor: vars.colorPrimary,
+ outlineOffset: -2,
+ outlineStyle: {
+ ':focus-visible': 'solid',
+ 'default': 'none',
+ },
+ outlineWidth: 2,
+ paddingBlock: 10,
+ paddingInline: 8,
+ textAlign: 'start',
+ width: '100%',
+ },
+});
+
+/** A fixed slot for the timestamp, so the decider and time stay in columns across rows. */
+const TIME_STYLE = { flex: 'none', minWidth: 60, textAlign: 'end' } as const;
+
+const Decider = memo<{ row: DecisionRow }>(({ row }) => {
+ const { t } = useTranslation('chat');
+ const { decision } = row;
+
+ if (row.actor === 'user') return <UserActor userId={decision.resolvedByUserId} />;
+ if (row.actor === 'agent' && decision.resolvedByAgentId)
+ return <AgentActor agentId={decision.resolvedByAgentId} />;
+ if (row.actor === 'pending')
+ return <Tag size={'small'}>{t('goalProcess.decisions.pending')}</Tag>;
+
+ return (
+ <Text fontSize={13} style={{ flex: 'none' }} type={'secondary'} weight={500}>
+ {t('goalProcess.decision.system')}
+ </Text>
+ );
+});
+
+Decider.displayName = 'GoalDecisionDecider';
+
+const DecisionTime = memo<{ at: Date }>(({ at }) => {
+ const { text, title } = useActivityTime(at);
+ return (
+ <Text fontSize={12} style={TIME_STYLE} title={title} type={'secondary'}>
+ {text}
+ </Text>
+ );
+});
+
+DecisionTime.displayName = 'GoalDecisionTime';
+
+const Decisions = memo<{ graph: GoalGraphView; onSelect: (nodeId: string) => void }>(
+ ({ graph, onSelect }) => {
+ const { t } = useTranslation('chat');
+ const copyOf = useDecisionCopy(graph);
+ const rows = buildDecisionRows(graph.decisions);
+
+ if (rows.length === 0)
+ return (
+ <Text fontSize={13} type={'secondary'}>
+ {t('goalProcess.decisions.empty')}
+ </Text>
+ );
+
+ return (
+ <Flexbox gap={0}>
+ {rows.map((row, index) => {
+ const copy = copyOf(row);
+ return (
+ <button
+ key={row.decision.id}
+ type={'button'}
+ {...stylex.props(styles.row, index > 0 && styles.divided)}
+ onClick={() => onSelect(row.decision.nodeId)}
+ >
+ <Flexbox gap={6}>
+ <Flexbox horizontal align={'center'} gap={8}>
+ <Text ellipsis style={{ flex: 1, minWidth: 0 }} weight={500}>
+ {copy.question}
+ </Text>
+ <Decider row={row} />
+ <DecisionTime at={row.resolvedAt ?? row.decision.createdAt} />
+ </Flexbox>
+ {copy.detail && (
+ <Text fontSize={13} style={{ wordBreak: 'break-word' }} type={'secondary'}>
+ {copy.detail}
+ </Text>
+ )}
+ {copy.choice && (
+ <Flexbox horizontal align={'flex-start'} gap={6}>
+ <Icon
+ color={cssVar.colorPrimary}
+ icon={ArrowRight}
+ size={14}
+ style={{ flex: 'none', marginBlockStart: 3 }}
+ />
+ <Text style={{ wordBreak: 'break-word' }} weight={500}>
+ {copy.choice}
+ </Text>
+ </Flexbox>
+ )}
+ {row.note && (
+ <Text
+ fontSize={13}
+ style={{ paddingInlineStart: 20, wordBreak: 'break-word' }}
+ type={'secondary'}
+ >
+ {row.note}
+ </Text>
+ )}
+ </Flexbox>
+ </button>
+ );
+ })}
+ </Flexbox>
+ );
+ },
+);
+
+Decisions.displayName = 'GoalDecisions';
+
+export default Decisions;
diff --git a/src/features/AgentGoals/ProcessControl/DeliveryTabs.test.tsx b/src/features/AgentGoals/ProcessControl/DeliveryTabs.test.tsx
new file mode 100644
index 00000000000..b74f46d7ae8
--- /dev/null
+++ b/src/features/AgentGoals/ProcessControl/DeliveryTabs.test.tsx
@@ -0,0 +1,31 @@
+/**
+ * @vitest-environment happy-dom
+ */
+import { fireEvent, render, screen } from '@testing-library/react';
+import { describe, expect, it, vi } from 'vitest';
+
+import DeliveryTabs from './DeliveryTabs';
+import type { GoalGraphView } from './goalGraphViewModel';
+
+vi.mock('react-i18next', () => ({
+ useTranslation: () => ({ t: (key: string) => key }),
+}));
+
+vi.mock('./Deliverables', () => ({ default: () => <div data-testid="deliverables" /> }));
+vi.mock('./Findings', () => ({ default: () => <div data-testid="findings" /> }));
+
+const graph = { artifacts: [], findings: [] } as unknown as GoalGraphView;
+
+describe('DeliveryTabs', () => {
+ it('opens on the deliverables and switches to the findings', () => {
+ render(<DeliveryTabs graph={graph} onSelect={vi.fn()} />);
+
+ expect(screen.getByTestId('deliverables')).toBeTruthy();
+ expect(screen.queryByTestId('findings')).toBeNull();
+
+ fireEvent.click(screen.getByText('goalProcess.findings.title'));
+
+ expect(screen.getByTestId('findings')).toBeTruthy();
+ expect(screen.queryByTestId('deliverables')).toBeNull();
+ });
+});
diff --git a/src/features/AgentGoals/ProcessControl/DeliveryTabs.tsx b/src/features/AgentGoals/ProcessControl/DeliveryTabs.tsx
new file mode 100644
index 00000000000..d32d5ff8748
--- /dev/null
+++ b/src/features/AgentGoals/ProcessControl/DeliveryTabs.tsx
@@ -0,0 +1,67 @@
+'use client';
+
+import { Flexbox, Tabs, Tag } from '@lobehub/ui';
+import { memo, useState } from 'react';
+import { useTranslation } from 'react-i18next';
+
+import { dedupeArtifacts } from './deliverableList';
+import Deliverables from './Deliverables';
+import Findings from './Findings';
+import type { GoalGraphView } from './goalGraphViewModel';
+
+/**
+ * 交付物 and 结论 are two views of the same output — the artifacts the goal
+ * produced, and what it now believes about them — so they share one block
+ * instead of two stacked sections. It opens on the deliverables: the thing you
+ * can open comes before the prose about it.
+ *
+ * 决策 is deliberately not a third tab: it is where a person stepped into the
+ * run, not something the run produced.
+ */
+
+type DeliveryTab = 'deliverables' | 'findings';
+
+interface DeliveryTabsProps {
+ graph: GoalGraphView;
+ onSelect: (nodeId: string) => void;
+}
+
+const DeliveryTabs = memo<DeliveryTabsProps>(({ graph, onSelect }) => {
+ const { t } = useTranslation('chat');
+ const [tab, setTab] = useState<DeliveryTab>('deliverables');
+
+ // Same fold the list applies, so the count never exceeds the rows below it.
+ const deliverableCount = dedupeArtifacts(graph.artifacts).length;
+ const findingCount = graph.findings.length;
+
+ const label = (text: string, count: number) => (
+ <Flexbox horizontal align={'center'} gap={8}>
+ {text}
+ {count > 0 && <Tag size={'small'}>{count}</Tag>}
+ </Flexbox>
+ );
+
+ return (
+ <Flexbox gap={8}>
+ <Tabs
+ activeKey={tab}
+ style={{ marginInline: -6 }}
+ variant={'square'}
+ items={[
+ {
+ key: 'deliverables',
+ label: label(t('goalProcess.deliverables.title'), deliverableCount),
+ },
+ { key: 'findings', label: label(t('goalProcess.findings.title'), findingCount) },
+ ]}
+ onChange={(key) => setTab(key as DeliveryTab)}
+ />
+ {tab === 'deliverables' && <Deliverables graph={graph} />}
+ {tab === 'findings' && <Findings graph={graph} onSelect={onSelect} />}
+ </Flexbox>
+ );
+});
+
+DeliveryTabs.displayName = 'GoalDeliveryTabs';
+
+export default DeliveryTabs;
diff --git a/src/features/AgentGoals/ProcessControl/GoalActors.tsx b/src/features/AgentGoals/ProcessControl/GoalActors.tsx
new file mode 100644
index 00000000000..0d86cc3e6a2
--- /dev/null
+++ b/src/features/AgentGoals/ProcessControl/GoalActors.tsx
@@ -0,0 +1,60 @@
+'use client';
+
+import { Flexbox, Text } from '@lobehub/ui';
+import { memo } from 'react';
+import { useTranslation } from 'react-i18next';
+
+import { useAgentDisplayMeta } from '@/features/AgentTasks/shared/useAgentDisplayMeta';
+import UserAvatar from '@/features/User/UserAvatar';
+import { useUserStore } from '@/store/user';
+import { userProfileSelectors } from '@/store/user/selectors';
+
+import AssigneeProfileAvatar from './AssigneeProfileAvatar';
+
+/** Who did a thing, by face and name — shared by the activity timeline and the decision list. */
+
+export const AgentActor = memo<{ agentId: string }>(({ agentId }) => {
+ const { t } = useTranslation('chat');
+ const meta = useAgentDisplayMeta(agentId);
+
+ // The node titles give way first — who acted stays readable, and only a very
+ // long agent name is capped.
+ return (
+ <Flexbox horizontal align={'center'} flex={'none'} gap={6}>
+ <AssigneeProfileAvatar agentId={agentId} size={16} />
+ <Text ellipsis fontSize={13} style={{ maxWidth: 120 }} weight={500}>
+ {meta?.title ?? t('goalProcess.actor.agent')}
+ </Text>
+ </Flexbox>
+ );
+});
+
+AgentActor.displayName = 'GoalAgentActor';
+
+export const UserActor = memo<{ userId?: string | null }>(({ userId }) => {
+ const { t } = useTranslation('chat');
+ const [currentUserId, nickName] = useUserStore((s) => [
+ userProfileSelectors.userId(s),
+ userProfileSelectors.nickName(s),
+ ]);
+
+ // Only the signed-in user can be shown by face; another member's event reads
+ // as "Member" rather than borrowing this user's identity or calling it "You".
+ if (userId && userId !== currentUserId)
+ return (
+ <Text fontSize={13} style={{ flex: 'none' }} weight={500}>
+ {t('goalProcess.actor.member')}
+ </Text>
+ );
+
+ return (
+ <Flexbox horizontal align={'center'} flex={'none'} gap={6}>
+ <UserAvatar size={16} />
+ <Text ellipsis fontSize={13} style={{ maxWidth: 120 }} weight={500}>
+ {nickName || t('goalProcess.actor.user')}
+ </Text>
+ </Flexbox>
+ );
+});
+
+UserActor.displayName = 'GoalUserActor';
diff --git a/src/features/AgentGoals/ProcessControl/GoalResultFollowUps.tsx b/src/features/AgentGoals/ProcessControl/GoalResultFollowUps.tsx
index 5d43ab43e86..d5d4f0524f4 100644
--- a/src/features/AgentGoals/ProcessControl/GoalResultFollowUps.tsx
+++ b/src/features/AgentGoals/ProcessControl/GoalResultFollowUps.tsx
@@ -12,6 +12,7 @@ import { createGoalModal } from '../CreateGoalModal';
import {
coordinatorGateKind,
coordinatorGateReason,
+ gateOptionLabelKey,
gateTitleKey,
localizedCoordinatorReason,
} from './coordinatorCopy';
@@ -82,7 +83,7 @@ const DecisionTime = ({ at }: { at: Date }) => {
* recognized gate reads as its localized title, the task it was about and the
* localized reason. Any other decision keeps the wording it was asked in.
*/
-const useDecisionCopy = (graph: GoalGraphView) => {
+export const useDecisionCopy = (graph: GoalGraphView) => {
const { t } = useTranslation('chat');
return (view: UserDecisionView) => {
@@ -94,10 +95,8 @@ const useDecisionCopy = (graph: GoalGraphView) => {
const subject = subjectId ? graph.byId[subjectId]?.node.title : undefined;
const rawReason = coordinatorGateReason(decision.question);
const optionId = decision.resolvedOptionId;
- const choice =
- optionId === 'retry' || optionId === 'retire' || optionId === 'fail'
- ? t(`goalProcess.gate.option.${optionId}`)
- : view.choice;
+ const optionKey = optionId ? gateOptionLabelKey({ id: optionId }, kind) : undefined;
+ const choice = optionKey ? t(optionKey as any) : view.choice;
return {
choice,
diff --git a/src/features/AgentGoals/ProcessControl/decisionList.test.ts b/src/features/AgentGoals/ProcessControl/decisionList.test.ts
new file mode 100644
index 00000000000..32c18350096
--- /dev/null
+++ b/src/features/AgentGoals/ProcessControl/decisionList.test.ts
@@ -0,0 +1,76 @@
+import { describe, expect, it } from 'vitest';
+
+import { buildDecisionRows } from './decisionList';
+
+const decision = (id: string, extra: Record<string, unknown> = {}) =>
+ ({
+ createdAt: new Date(1000),
+ id,
+ options: [
+ { id: 'a', label: 'Option A' },
+ { id: 'answer', label: 'Answer' },
+ ],
+ question: `Question ${id}`,
+ resolution: null,
+ resolvedAt: null,
+ resolvedByAgentId: null,
+ resolvedByUserId: null,
+ resolvedOptionId: null,
+ status: 'resolved',
+ ...extra,
+ }) as any;
+
+describe('buildDecisionRows', () => {
+ it('attributes each decision to whoever settled it', () => {
+ const rows = buildDecisionRows([
+ decision('u', { resolvedAt: new Date(3000), resolvedByUserId: 'u1' }),
+ decision('a', { resolvedAt: new Date(2000), resolvedByAgentId: 'ag1' }),
+ decision('s', { resolvedAt: new Date(1500) }),
+ decision('p', { status: 'pending' }),
+ ]);
+
+ expect(rows.map((row) => [row.decision.id, row.actor])).toEqual([
+ ['p', 'pending'],
+ ['u', 'user'],
+ ['a', 'agent'],
+ ['s', 'system'],
+ ]);
+ });
+
+ it('drops canceled gates and puts open ones before settled ones', () => {
+ const rows = buildDecisionRows([
+ decision('old', { resolvedAt: new Date(9000), resolvedByUserId: 'u1' }),
+ decision('gone', { status: 'canceled' }),
+ decision('open', { createdAt: new Date(10), status: 'pending' }),
+ ]);
+
+ expect(rows.map((row) => row.decision.id)).toEqual(['open', 'old']);
+ });
+
+ it('keeps a picked option and its note apart', () => {
+ const [row] = buildDecisionRows([
+ decision('n', {
+ resolution: ' use the staging db ',
+ resolvedAt: new Date(2000),
+ resolvedByUserId: 'u1',
+ resolvedOptionId: 'a',
+ }),
+ ]);
+
+ expect(row).toMatchObject({ choice: 'Option A', note: 'use the staging db' });
+ });
+
+ it('treats the words as the answer for the free-text option', () => {
+ const [row] = buildDecisionRows([
+ decision('w', {
+ resolution: 'Only the EU region',
+ resolvedAt: new Date(2000),
+ resolvedByUserId: 'u1',
+ resolvedOptionId: 'answer',
+ }),
+ ]);
+
+ expect(row.choice).toBe('Only the EU region');
+ expect(row.note).toBeUndefined();
+ });
+});
diff --git a/src/features/AgentGoals/ProcessControl/decisionList.ts b/src/features/AgentGoals/ProcessControl/decisionList.ts
new file mode 100644
index 00000000000..1ce25a1dd42
--- /dev/null
+++ b/src/features/AgentGoals/ProcessControl/decisionList.ts
@@ -0,0 +1,61 @@
+import { GOAL_CLARIFICATION_OPTION } from '@lobechat/const/goal';
+import type { GoalGraphDecision } from '@lobechat/types';
+
+import type { UserDecisionView } from './goalResultState';
+
+/**
+ * Who a decision row belongs to:
+ * - `pending` — still waiting for an answer
+ * - `user` — a person settled it
+ * - `agent` — an agent settled it on its own authority
+ * - `system` — settled with no recorded decider (the run environment)
+ */
+export type DecisionActor = 'agent' | 'pending' | 'system' | 'user';
+
+export interface DecisionRow extends UserDecisionView {
+ actor: DecisionActor;
+ /** Extra guidance written alongside a picked option; absent when the words *are* the answer. */
+ note?: string;
+}
+
+const actorOf = (decision: GoalGraphDecision): DecisionActor => {
+ if (decision.status === 'pending') return 'pending';
+ if (decision.resolvedByUserId) return 'user';
+ if (decision.resolvedByAgentId) return 'agent';
+ return 'system';
+};
+
+/**
+ * Every call this Goal asked for, newest first with the open ones on top — the
+ * trace of who decided what, not only what the owner decided. A canceled gate
+ * decided nothing, so it is not a decision.
+ */
+export const buildDecisionRows = (decisions: GoalGraphDecision[]): DecisionRow[] => {
+ const rows = decisions
+ .filter((decision) => decision.status !== 'canceled')
+ .map((decision): DecisionRow => {
+ const option = decision.options?.find((item) => item.id === decision.resolvedOptionId);
+ const words = decision.resolution?.trim() || undefined;
+ // The free-text option has no wording of its own: the note is the answer.
+ const answered = decision.resolvedOptionId === GOAL_CLARIFICATION_OPTION.answer;
+ const choice = answered ? words : (option?.label ?? words);
+ const note = !answered && option ? words : undefined;
+ const at = decision.status === 'pending' ? undefined : (decision.resolvedAt ?? undefined);
+
+ return {
+ actor: actorOf(decision),
+ ...(choice ? { choice } : {}),
+ decision,
+ ...(note ? { note } : {}),
+ question: decision.question,
+ ...(at ? { resolvedAt: at } : {}),
+ };
+ });
+
+ const stamp = (row: DecisionRow) => (row.resolvedAt ?? row.decision.createdAt)?.getTime?.() ?? 0;
+
+ return rows.sort((a, b) => {
+ const open = Number(b.actor === 'pending') - Number(a.actor === 'pending');
+ return open || stamp(b) - stamp(a);
+ });
+};
diff --git a/src/features/AgentGoals/ProcessControl/index.tsx b/src/features/AgentGoals/ProcessControl/index.tsx
index 1812146c452..40ac167b75d 100644
--- a/src/features/AgentGoals/ProcessControl/index.tsx
+++ b/src/features/AgentGoals/ProcessControl/index.tsx
@@ -4,15 +4,16 @@ import { Accordion, type AccordionItemType, Flexbox, Tag, Text } from '@lobehub/
import { memo, useCallback, useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next';
+import Lifecycle from '@/features/Portal/GoalMetric/Lifecycle';
import { usePermission } from '@/hooks/usePermission';
import { useChatStore } from '@/store/chat';
import { chatPortalSelectors } from '@/store/chat/selectors';
import { goalSelectors, useGoalStore } from '@/store/goal';
import GoalAcceptanceCriteria from '../GoalAcceptanceCriteria';
-import Activity from './Activity';
-import Deliverables from './Deliverables';
-import Findings from './Findings';
+import { buildDecisionRows } from './decisionList';
+import Decisions from './Decisions';
+import DeliveryTabs from './DeliveryTabs';
import Frontier from './Frontier';
import { buildGoalGraphView } from './goalGraphViewModel';
import GoalResultTabs from './GoalResultTabs';
@@ -24,6 +25,13 @@ import {
useGoalNodeSelect,
} from './useGoalProcessActions';
+// One left edge for headings and their content, so a section's rows line up
+// under its title instead of sitting on an indent.
+const SECTION_STYLES = {
+ panel: { paddingInline: 0 },
+ trigger: { paddingBlock: 8, paddingInline: 0 },
+};
+
/**
* The process-control band of the goal detail page: what can move now
* (frontier), the map of how the goal got here, what it believes, and what it
@@ -78,6 +86,7 @@ const ProcessControl = memo<ProcessControlProps>(
// the incoming structure instead of reading as an empty goal — the graph
// poll fills them in as nodes land.
const planning = isGoalPlanning(graph);
+ const decisionCount = buildDecisionRows(graph.decisions).length;
// Presence of the acceptance block (not a non-empty list) keeps the section
// mounted: removing the last criterion must leave the add control reachable,
// while legacy prose-only goals (no acceptance config at all) show nothing.
@@ -116,18 +125,15 @@ const ProcessControl = memo<ProcessControlProps>(
{map}
- <Accordion
- defaultValue={['deliverables', 'findings', 'activity']}
- gap={16}
- indicatorPlacement="inline"
- // One left edge for headings and their content, so a section's rows
- // line up under its title instead of sitting on an indent.
- items={
- [
- // The structured acceptance standard the terminal goal acceptance is
- // gated on. Collapsed by default — reference material, like the task
- // detail's 交付验收 section. Prose-only legacy goals have none.
- !!acceptanceConfig && {
+ {/* The structured acceptance standard the terminal goal acceptance is
+ gated on. Collapsed by default — reference material, like the task
+ detail's 交付验收 section. Prose-only legacy goals have none. */}
+ {!!acceptanceConfig && (
+ <Accordion
+ indicatorPlacement="inline"
+ styles={SECTION_STYLES}
+ items={[
+ {
children: <GoalAcceptanceCriteria criteriaIds={criteriaIds} goalId={goalId} />,
key: 'acceptance',
title: (
@@ -142,52 +148,52 @@ const ProcessControl = memo<ProcessControlProps>(
</Flexbox>
),
},
- // Between the standard and the conclusions on purpose: 验收标准 says
- // what counts as done, 交付物 what was produced, 结论 what the goal now
- // believes about it. Findings routinely cite these artifacts.
- {
- children: <Deliverables graph={graph} />,
- key: 'deliverables',
+ ]}
+ />
+ )}
+
+ {/* 验收标准 says what counts as done, 交付物 what was produced, 结论 what the
+ goal now believes about it — the last two share one tabbed block. */}
+ <DeliveryTabs graph={graph} onSelect={select} />
+
+ <Accordion
+ defaultValue={['decisions', 'activity']}
+ gap={16}
+ indicatorPlacement="inline"
+ styles={SECTION_STYLES}
+ items={
+ [
+ // Where a person stepped into the run — kept apart from the
+ // results above, which are what the run produced on its own.
+ decisionCount > 0 && {
+ children: <Decisions graph={graph} onSelect={select} />,
+ key: 'decisions',
title: (
<Flexbox horizontal align={'center'} gap={8}>
<Text fontSize={14} weight={600}>
- {t('goalProcess.deliverables.title')}
+ {t('goalProcess.decisions.title')}
</Text>
- {graph.artifacts.length > 0 && (
- <Tag size={'small'}>{graph.artifacts.length}</Tag>
- )}
+ <Tag size={'small'}>{decisionCount}</Tag>
</Flexbox>
),
},
{
- children: <Findings graph={graph} onSelect={select} />,
- key: 'findings',
- title: (
- <Flexbox horizontal align={'center'} gap={8}>
- <Text fontSize={14} weight={600}>
- {t('goalProcess.findings.title')}
- </Text>
- {graph.findings.length > 0 && <Tag size={'small'}>{graph.findings.length}</Tag>}
- </Flexbox>
+ // The timeline carries who decided what (a person's gate answer
+ // reads as their own line), not just what the tasks did. It
+ // lands on the shared `select` so a timeline click also moves
+ // the map's highlight, as the list it replaced did.
+ children: (
+ <Lifecycle goalId={goalId} graph={graph} stickyDays={false} onSelect={select} />
),
- },
- {
- children: <Activity graph={graph} onSelect={select} />,
key: 'activity',
title: (
- <Flexbox horizontal align={'center'} gap={8}>
- <Text fontSize={14} weight={600}>
- {t('goalProcess.activity.title')}
- </Text>
- </Flexbox>
+ <Text fontSize={14} weight={600}>
+ {t('goalProcess.activity.title')}
+ </Text>
),
},
].filter(Boolean) as AccordionItemType[]
}
- styles={{
- panel: { paddingInline: 0 },
- trigger: { paddingBlock: 8, paddingInline: 0 },
- }}
/>
</Flexbox>
);
diff --git a/src/features/Portal/GoalMetric/Lifecycle.tsx b/src/features/Portal/GoalMetric/Lifecycle.tsx
index a9ff390b0ff..cf1ba4e7558 100644
--- a/src/features/Portal/GoalMetric/Lifecycle.tsx
+++ b/src/features/Portal/GoalMetric/Lifecycle.tsx
@@ -22,12 +22,12 @@ import {
import { memo, useMemo } from 'react';
import { useTranslation } from 'react-i18next';
-import AssigneeProfileAvatar from '@/features/AgentGoals/ProcessControl/AssigneeProfileAvatar';
import {
artifactIconOf,
openTargetOf,
useOpenGoalArtifact,
} from '@/features/AgentGoals/ProcessControl/Deliverables';
+import { AgentActor, UserActor } from '@/features/AgentGoals/ProcessControl/GoalActors';
import type {
GoalArtifactView,
GoalGraphView,
@@ -35,11 +35,7 @@ import type {
} from '@/features/AgentGoals/ProcessControl/goalGraphViewModel';
import { KIND_ICON } from '@/features/AgentGoals/ProcessControl/shared';
import { useGoalNodeSelect } from '@/features/AgentGoals/ProcessControl/useGoalProcessActions';
-import { useAgentDisplayMeta } from '@/features/AgentTasks/shared/useAgentDisplayMeta';
-import UserAvatar from '@/features/User/UserAvatar';
import { goalSelectors, useGoalStore } from '@/store/goal';
-import { useUserStore } from '@/store/user';
-import { userProfileSelectors } from '@/store/user/selectors';
import type { LifecycleNote } from './lifecycleEvent';
import { buildLifecycleDays, type LifecycleGroup, type LifecycleRow } from './lifecycleRows';
@@ -130,6 +126,14 @@ const styles = createStaticStyles(({ css }) => ({
background: ${cssVar.colorBgContainer};
`,
+ // The same header for a host that scrolls the whole page instead of owning a
+ // padded scroller: nothing to cancel, so it simply reads as a label.
+ dayPlain: css`
+ padding-block: 12px 6px;
+ font-size: 12px;
+ font-weight: 600;
+ color: ${cssVar.colorTextTertiary};
+ `,
item: css`
position: relative;
padding-block-end: 14px;
@@ -374,52 +378,6 @@ const ArtifactCard = memo<{ artifact: GoalArtifactView }>(({ artifact }) => {
ArtifactCard.displayName = 'GoalMetricLifecycleArtifact';
-const AgentActor = memo<{ agentId: string }>(({ agentId }) => {
- const { t } = useTranslation('chat');
- const meta = useAgentDisplayMeta(agentId);
-
- // The node titles give way first — who acted stays readable, and only a very
- // long agent name is capped.
- return (
- <Flexbox horizontal align={'center'} flex={'none'} gap={6}>
- <AssigneeProfileAvatar agentId={agentId} size={16} />
- <Text ellipsis fontSize={13} style={{ maxWidth: 120 }} weight={500}>
- {meta?.title ?? t('goalProcess.actor.agent')}
- </Text>
- </Flexbox>
- );
-});
-
-AgentActor.displayName = 'GoalMetricLifecycleAgentActor';
-
-const UserActor = memo<{ userId?: string | null }>(({ userId }) => {
- const { t } = useTranslation('chat');
- const [currentUserId, nickName] = useUserStore((s) => [
- userProfileSelectors.userId(s),
- userProfileSelectors.nickName(s),
- ]);
-
- // Only the signed-in user can be shown by face; another member's event reads
- // as "Member" rather than borrowing this user's identity or calling it "You".
- if (userId && userId !== currentUserId)
- return (
- <Text fontSize={13} style={{ flex: 'none' }} weight={500}>
- {t('goalProcess.actor.member')}
- </Text>
- );
-
- return (
- <Flexbox horizontal align={'center'} flex={'none'} gap={6}>
- <UserAvatar size={16} />
- <Text ellipsis fontSize={13} style={{ maxWidth: 120 }} weight={500}>
- {nickName || t('goalProcess.actor.user')}
- </Text>
- </Flexbox>
- );
-});
-
-UserActor.displayName = 'GoalMetricLifecycleUserActor';
-
const Actor = memo<{ event: GoalGraphEvent }>(({ event }) => {
const { t } = useTranslation('chat');
if (event.actorType === 'agent' && event.actorId) return <AgentActor agentId={event.actorId} />;
@@ -543,13 +501,32 @@ const useDayLabel = () => {
};
};
-const Lifecycle = memo<{ goalId: string; graph: GoalGraphView }>(({ goalId, graph }) => {
+interface LifecycleProps {
+ goalId: string;
+ graph: GoalGraphView;
+ /**
+ * Click landing for a row's subject. A host that also renders the graph passes
+ * its own handler so a timeline click keeps the map's selection in sync —
+ * without it the timeline would open the node but leave the graph stale.
+ */
+ onSelect?: (nodeId: string) => void;
+ /**
+ * Pins each day label under the host's top edge. Only right inside the metric
+ * panel, whose padded scroller the offsets are computed against; a host that
+ * scrolls the page turns it off.
+ */
+ stickyDays?: boolean;
+}
+
+const Lifecycle = memo<LifecycleProps>(({ goalId, graph, stickyDays = true, onSelect }) => {
const { t } = useTranslation('chat');
const dayLabel = useDayLabel();
const snapshot = useGoalStore(goalSelectors.goalGraph(goalId));
// Same landing as a click anywhere else on the goal: a Task opens its Task
- // panel, other nodes their drill-down.
- const onSelect = useGoalNodeSelect(goalId, graph);
+ // panel, other nodes their drill-down. A host that owns the graph's selection
+ // passes its own handler instead, so the click updates both surfaces.
+ const openNode = useGoalNodeSelect(goalId, graph);
+ const select = onSelect ?? openNode;
const days = useMemo(() => {
const workTypes = new Map(
@@ -571,14 +548,14 @@ const Lifecycle = memo<{ goalId: string; graph: GoalGraphView }>(({ goalId, grap
<Flexbox gap={0}>
{days.map(({ day, groups }) => (
<Flexbox gap={2} key={day.valueOf()}>
- <div className={styles.day}>{dayLabel(day)}</div>
+ <div className={stickyDays ? styles.day : styles.dayPlain}>{dayLabel(day)}</div>
<Flexbox gap={0}>
{groups.map((group) => (
<EventItem
graph={graph}
group={group}
key={group.rows[0].event.id}
- onSelect={onSelect}
+ onSelect={select}
/>
))}
</Flexbox>