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): surface each task's verification, and make its result readable (#19171)

Arvin Xu002a70c41d70
diff --git a/apps/server/src/services/goal/index.ts b/apps/server/src/services/goal/index.ts
index 136e5ace50d..b28767fae6c 100644
--- a/apps/server/src/services/goal/index.ts
+++ b/apps/server/src/services/goal/index.ts
@@ -8,6 +8,7 @@ import type {
GoalGraphSnapshot,
GoalItem,
GoalMetricCriterion,
+ GoalNodeAcceptance,
GoalNodeKind,
GoalNodeStatus,
GoalPauseReason,
@@ -472,11 +473,93 @@ export class GoalService {
graph = async (goalId: string) => {
const graph = await this.requireGraph(goalId);
- const [runHeartbeats, spend] = await Promise.all([
+ const [runHeartbeats, deliveredAt, acceptances, spend] = await Promise.all([
this.collectRunHeartbeats(graph),
+ this.collectDeliveredAt(graph),
+ this.collectAcceptances(graph),
this.resolveSpend(graph),
]);
- return { ...graph, runHeartbeats, spend };
+ return { ...graph, acceptances, deliveredAt, runHeartbeats, spend };
+ };
+
+ /**
+ * Verification state per task node.
+ *
+ * Every dispatched task already owns an Acceptance (`createResponsibleTask`
+ * creates one), but the goal surfaced only the criteria it would be judged
+ * against — never the judgment. A reader could see that a task finished and
+ * still have no idea whether it held up, which is the gap that made the page
+ * feel unverifiable.
+ */
+ private collectAcceptances = async (
+ graph: GoalGraphSnapshot,
+ ): Promise<Record<string, GoalNodeAcceptance> | undefined> => {
+ const taskNodes = graph.nodes.filter(
+ (node): node is GoalGraphNode & { taskId: string } => node.kind === 'task' && !!node.taskId,
+ );
+ if (taskNodes.length === 0) return undefined;
+
+ const nodeByTaskId = new Map(taskNodes.map((node) => [node.taskId, node.id]));
+ const rows = await this.acceptanceService.acceptanceModel.findBySubjects(
+ 'task',
+ taskNodes.map((node) => node.taskId),
+ );
+
+ const result: Record<string, GoalNodeAcceptance> = {};
+ for (const row of rows) {
+ const nodeId = nodeByTaskId.get(row.subjectId);
+ if (!nodeId) continue;
+ result[nodeId] = { id: row.id, status: row.status };
+ }
+ return Object.keys(result).length > 0 ? result : undefined;
+ };
+
+ /**
+ * When an active task node's newest run delivered, for the nodes waiting on
+ * verification to settle.
+ *
+ * A verify-bound task keeps its node `active` while its topic is already
+ * `completed`, and the judgment is a full agent run that routinely outlives
+ * the operation lease — `decideNextMove` holds off re-dispatching such a node
+ * for a whole `VERIFY_SETTLE_GRACE_MS`. But a completed topic is not a
+ * *running* one, so it contributes no heartbeat, and a client judging
+ * liveness from heartbeats alone declared the goal's most informative moment
+ * — delivered, being verified — lost. Reporting the delivery instant lets the
+ * client name that state and apply the coordinator's own grace window instead
+ * of the lease.
+ */
+ private collectDeliveredAt = async (
+ graph: GoalGraphSnapshot,
+ ): Promise<Record<string, Date> | undefined> => {
+ const activeTasks = graph.nodes.filter(
+ (node): node is GoalGraphNode & { taskId: string } =>
+ node.kind === 'task' && node.status === 'active' && !!node.taskId,
+ );
+ if (activeTasks.length === 0) return undefined;
+
+ const nodeByTaskId = new Map(activeTasks.map((node) => [node.taskId, node.id]));
+ // Newest run per task: `findWithHandoffByTaskIds` orders by seq desc, so the
+ // first row seen for a task is its latest.
+ const topics = await this.taskTopicModel.findWithHandoffByTaskIds(
+ activeTasks.map((n) => n.taskId),
+ activeTasks.length,
+ );
+
+ const delivered: Record<string, Date> = {};
+ const seen = new Set<string>();
+ for (const topic of topics) {
+ const taskId = topic.sourceTaskId;
+ if (!taskId || seen.has(taskId)) continue;
+ seen.add(taskId);
+ const nodeId = nodeByTaskId.get(taskId);
+ // Only the newest run counts, and only while it is a delivery: an older
+ // completed run under a newer running one is history, not a pending
+ // verification.
+ if (!nodeId || topic.status !== 'completed') continue;
+ delivered[nodeId] = topic.completedAt ?? topic.createdAt;
+ }
+
+ return Object.keys(delivered).length > 0 ? delivered : undefined;
};
/**
diff --git a/locales/en-US/chat.json b/locales/en-US/chat.json
index 8152f60b0b3..34b465576b8 100644
--- a/locales/en-US/chat.json
+++ b/locales/en-US/chat.json
@@ -507,6 +507,12 @@
"goalPage.title": "Overview",
"goalPage.view.card": "Cards",
"goalPage.view.list": "List",
+ "goalProcess.acceptance.accepted": "Accepted",
+ "goalProcess.acceptance.delivered": "Awaiting your call",
+ "goalProcess.acceptance.errored": "Verification error",
+ "goalProcess.acceptance.rejected": "Rejected",
+ "goalProcess.acceptance.repairing": "Repairing",
+ "goalProcess.acceptance.verifying": "Verifying",
"goalProcess.activity.empty": "No activity yet",
"goalProcess.activity.finding": "Recorded finding: {{title}}",
"goalProcess.activity.title": "Activity",
@@ -1617,6 +1623,7 @@
"taskDetail.notFound.desc": "This task may have been deleted, or you don't have permission to view it.",
"taskDetail.notFound.title": "Task not found",
"taskDetail.openDetail": "Open detail",
+ "taskDetail.openRunChat": "Open this run’s conversation",
"taskDetail.pauseTask": "Pause task",
"taskDetail.priority.high": "High",
"taskDetail.priority.low": "Low",
@@ -1632,6 +1639,8 @@
"taskDetail.reassignDisabled": "Cannot reassign agent while task is running",
"taskDetail.replyInThread": "Reply in this thread",
"taskDetail.replyPlaceholder": "Reply in this thread...",
+ "taskDetail.reportedBy": "Reported by {{name}}",
+ "taskDetail.reportedByAgent": "the agent",
"taskDetail.rerunTask": "Re-run task",
"taskDetail.runAll": "Run all",
"taskDetail.runAll.cancel": "Cancel",
diff --git a/locales/zh-CN/chat.json b/locales/zh-CN/chat.json
index 10a40741af4..1ac5990d183 100644
--- a/locales/zh-CN/chat.json
+++ b/locales/zh-CN/chat.json
@@ -507,6 +507,12 @@
"goalPage.title": "概览",
"goalPage.view.card": "卡片",
"goalPage.view.list": "列表",
+ "goalProcess.acceptance.accepted": "已验收",
+ "goalProcess.acceptance.delivered": "待你确认",
+ "goalProcess.acceptance.errored": "验收出错",
+ "goalProcess.acceptance.rejected": "验收未通过",
+ "goalProcess.acceptance.repairing": "修复中",
+ "goalProcess.acceptance.verifying": "验收中",
"goalProcess.activity.empty": "暂无活动",
"goalProcess.activity.finding": "沉淀结论:{{title}}",
"goalProcess.activity.title": "活动",
@@ -1617,6 +1623,7 @@
"taskDetail.notFound.desc": "该任务可能已被删除,或你没有查看权限。",
"taskDetail.notFound.title": "找不到该任务",
"taskDetail.openDetail": "展开详情",
+ "taskDetail.openRunChat": "打开这次运行的对话",
"taskDetail.pauseTask": "暂停任务",
"taskDetail.priority.high": "高",
"taskDetail.priority.low": "低",
@@ -1632,6 +1639,8 @@
"taskDetail.reassignDisabled": "任务运行中,无法切换助理",
"taskDetail.replyInThread": "在此对话中回复",
"taskDetail.replyPlaceholder": "在此对话中回复…",
+ "taskDetail.reportedBy": "由 {{name}} 汇报",
+ "taskDetail.reportedByAgent": "该 agent",
"taskDetail.rerunTask": "重新运行",
"taskDetail.runAll": "全部运行",
"taskDetail.runAll.cancel": "取消",
diff --git a/packages/database/src/models/acceptance.ts b/packages/database/src/models/acceptance.ts
index f7ef5f933e4..dad0117e6c5 100644
--- a/packages/database/src/models/acceptance.ts
+++ b/packages/database/src/models/acceptance.ts
@@ -94,6 +94,25 @@ export class AcceptanceModel {
});
};
+ /**
+ * The acceptances for many subjects of one type, for surfaces that show a
+ * verification state per row. Batched because the caller (the Goal graph
+ * read) polls every few seconds and would otherwise issue one query per task.
+ */
+ findBySubjects = async (subjectType: AcceptanceSubjectType, subjectIds: string[]) => {
+ if (subjectIds.length === 0) return [];
+ return this.db
+ .select()
+ .from(acceptances)
+ .where(
+ and(
+ eq(acceptances.subjectType, subjectType),
+ inArray(acceptances.subjectId, subjectIds),
+ this.ownership(),
+ ),
+ );
+ };
+
/**
* Resolve an execution policy for a subject. Unlike report-facing reads,
* workspace policy lookup is shared by every workspace member: a private
diff --git a/packages/locales/src/default/chat.ts b/packages/locales/src/default/chat.ts
index e79670a70dc..fd4cd795747 100644
--- a/packages/locales/src/default/chat.ts
+++ b/packages/locales/src/default/chat.ts
@@ -1549,6 +1549,9 @@ export default {
'taskDetail.runVerify.round': 'Round {{index}}',
'taskDetail.runVerify.running': 'Verifying',
'taskDetail.runExpand': 'Expand run',
+ 'taskDetail.openRunChat': 'Open this run’s conversation',
+ 'taskDetail.reportedBy': 'Reported by {{name}}',
+ 'taskDetail.reportedByAgent': 'the agent',
'taskDetail.runFollowUp': 'Ask a follow-up',
'taskDetail.runFollowUpPlaceholder': 'Ask a follow-up about this run...',
'taskDetail.collapseReply': 'Collapse',
@@ -1890,6 +1893,13 @@ export default {
'goalProcess.planning.description':
'The coordinator is breaking the goal into executable tasks — they will appear here shortly.',
'goalProcess.tag.needsDecision': 'Needs your decision',
+ 'goalProcess.acceptance.repairing': 'Repairing',
+ 'goalProcess.acceptance.verifying': 'Verifying',
+ 'goalProcess.acceptance.accepted': 'Accepted',
+ 'goalProcess.acceptance.delivered': 'Awaiting your call',
+ 'goalProcess.acceptance.errored': 'Verification error',
+ 'goalProcess.acceptance.rejected': 'Rejected',
+ 'goalProcess.tag.verifying': 'Verifying',
'goalProcess.tag.lost': 'Lost',
'goalProcess.tag.done': 'Done',
'goalProcess.tag.retired': 'Retired',
diff --git a/packages/types/src/goal.ts b/packages/types/src/goal.ts
index 7af64735156..70d64edbead 100644
--- a/packages/types/src/goal.ts
+++ b/packages/types/src/goal.ts
@@ -1,4 +1,5 @@
import type { InitialGoalOverviewContext } from './stepContext';
+import type { AcceptanceStatus } from './verify';
import type { WorkType } from './work';
// ============================================
@@ -296,8 +297,28 @@ export interface GoalGraphWorkVersionDisplay {
workId: string;
}
+/** Where a task node's own verification stands, for a reader scanning the goal. */
+export interface GoalNodeAcceptance {
+ id: string;
+ status: AcceptanceStatus;
+}
+
export interface GoalGraphSnapshot {
+ /**
+ * Verification state per task node, keyed by node id. Every dispatched task
+ * gets its own Acceptance, but the goal used to show only the standard it was
+ * judged against and never the judgment — so the page could say a task
+ * finished without saying whether it held up.
+ */
+ acceptances?: Record<string, GoalNodeAcceptance>;
decisions: GoalGraphDecision[];
+ /**
+ * When an active task node's newest run delivered, present only while that
+ * node is waiting on verification to settle. A verify-bound task holds its
+ * node `active` with an already-`completed` topic, which contributes no
+ * heartbeat — without this the client reads the wait as lost.
+ */
+ deliveredAt?: Record<string, Date>;
edges: GoalGraphEdge[];
events: GoalGraphEvent[];
goal: GoalItem;
diff --git a/src/features/Acceptance/Viewer/CheckList.tsx b/src/features/Acceptance/Viewer/CheckList.tsx
index af115707749..ed5f7bc4973 100644
--- a/src/features/Acceptance/Viewer/CheckList.tsx
+++ b/src/features/Acceptance/Viewer/CheckList.tsx
@@ -919,7 +919,7 @@ const IterationTimeline = memo<{
);
});
-const CheckRow = memo<{
+export const AcceptanceCheckRow = memo<{
canReview: boolean;
check: AcceptanceCheck;
detailMode?: boolean;
@@ -1618,7 +1618,7 @@ interface FocusedCheckDetailsProps {
/** Full check content for the dedicated second-level acceptance workspace. */
export const FocusedCheckDetails = memo<FocusedCheckDetailsProps>(
({ canReview, check, onDismissProposal, onOpenTrace, onReview, onRound, reviewPending }) => (
- <CheckRow
+ <AcceptanceCheckRow
detailMode
expanded
canReview={canReview}
@@ -1816,7 +1816,7 @@ const CheckList = memo<CheckListProps>(
return (
<Flexbox className={styles.groupCard}>
{visibleRows.map((check) => (
- <CheckRow
+ <AcceptanceCheckRow
canReview={canReview}
check={check}
expanded={expanded.has(check.id)}
@@ -2055,7 +2055,7 @@ const CheckList = memo<CheckListProps>(
)}
{!collapsed &&
rows.map((check) => (
- <CheckRow
+ <AcceptanceCheckRow
canReview={canReview}
check={check}
expanded={expanded.has(check.id)}
diff --git a/src/features/Acceptance/index.ts b/src/features/Acceptance/index.ts
index 7732bf07aef..aac4d7742cb 100644
--- a/src/features/Acceptance/index.ts
+++ b/src/features/Acceptance/index.ts
@@ -22,6 +22,7 @@ export { checkDisplayTitle, countResults, isDraftUnconfirmed, phaseFromStatus }
export { default as AcceptanceViewer } from './Viewer';
export type { AcceptanceCheck, CheckReviewInput } from './Viewer/CheckList';
export {
+ AcceptanceCheckRow,
checkHeadMeta,
FocusedCheckDetails,
groupChecks,
diff --git a/src/features/AgentGoals/GoalDetailPage.tsx b/src/features/AgentGoals/GoalDetailPage.tsx
index 126beef08ea..9f43a3a73ed 100644
--- a/src/features/AgentGoals/GoalDetailPage.tsx
+++ b/src/features/AgentGoals/GoalDetailPage.tsx
@@ -4,7 +4,7 @@ import { Flexbox } from '@lobehub/ui';
import { Button, Text } from '@lobehub/ui/base-ui';
import { createStaticStyles, cssVar } from 'antd-style';
import { PauseIcon, PlayIcon } from 'lucide-react';
-import { memo, type ReactNode, useEffect, useMemo, useState } from 'react';
+import { memo, type ReactNode, useEffect, useMemo, useRef, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { Link } from 'react-router';
@@ -24,6 +24,8 @@ import { usePermission } from '@/hooks/usePermission';
import { useChatStore } from '@/store/chat';
import { chatPortalSelectors } from '@/store/chat/selectors';
import { type GoalMetricKind } from '@/store/chat/slices/portal/initialState';
+import { useGlobalStore } from '@/store/global';
+import { systemStatusSelectors } from '@/store/global/selectors';
import { goalSelectors, useGoalStore } from '@/store/goal';
import GoalChat from './GoalChat';
@@ -130,6 +132,50 @@ const GoalDetailPage = memo<GoalDetailPageProps>(({ agentId, goalId }) => {
// under the 'goal' scope: resizing here never affects the chat surface.
const { maxWidth, minWidth, updateWidth, width } = usePortalPanelWidth(currentViewType, 'goal');
+ /**
+ * Give a drill-down its reading room by folding the app rail, not the goal.
+ *
+ * Opened beside the goal, the Portal used to leave both panes cramped — the
+ * goal's title wrapping to four lines, its task rows truncated to a few
+ * characters. Folding the goal pane itself was tried and is wrong: it hides
+ * the task's own verification state, which is exactly what the reader drilled
+ * in to check. The rail is the one thing on screen that no one is reading.
+ *
+ * `showLeftPanel` is a persisted preference, so this only ever restores what
+ * it collapsed: a user who already works with the rail folded is left alone,
+ * and one who folds or opens it themselves while a drill-down is up keeps
+ * that choice.
+ */
+ const showLeftPanel = useGlobalStore(systemStatusSelectors.showLeftPanel);
+ const toggleLeftPanel = useGlobalStore((s) => s.toggleLeftPanel);
+ const collapsedRailRef = useRef(false);
+
+ useEffect(() => {
+ if (showPortal) {
+ if (showLeftPanel && !collapsedRailRef.current) {
+ collapsedRailRef.current = true;
+ toggleLeftPanel(false);
+ }
+ return;
+ }
+ if (collapsedRailRef.current) {
+ collapsedRailRef.current = false;
+ toggleLeftPanel(true);
+ }
+ }, [showPortal, showLeftPanel, toggleLeftPanel]);
+
+ // Leaving the page with the rail still folded would strand it on every other
+ // surface, so give it back on the way out.
+ useEffect(
+ () => () => {
+ if (collapsedRailRef.current) {
+ collapsedRailRef.current = false;
+ useGlobalStore.getState().toggleLeftPanel(true);
+ }
+ },
+ [],
+ );
+
// The portal stack belongs to this goal's inspection session — leaving the
// page (or switching goals) must not leak it into the conversation surface.
useEffect(() => () => clearPortalStack(), [clearPortalStack, goalId]);
diff --git a/src/features/AgentGoals/ProcessControl/Frontier.tsx b/src/features/AgentGoals/ProcessControl/Frontier.tsx
index c23975184b8..e624181f2ee 100644
--- a/src/features/AgentGoals/ProcessControl/Frontier.tsx
+++ b/src/features/AgentGoals/ProcessControl/Frontier.tsx
@@ -1,6 +1,6 @@
'use client';
-import type { GoalDecisionOption } from '@lobechat/types';
+import type { AcceptanceStatus, GoalDecisionOption } from '@lobechat/types';
import { Block, Flexbox, Icon, TextArea, Tooltip } from '@lobehub/ui';
import { Button, Tag, Text } from '@lobehub/ui/base-ui';
import { Divider } from 'antd';
@@ -13,6 +13,7 @@ import { TASK_STATUS_VISUALS } from '@/components/ExecutionStatus';
import { openAddGoalTaskModal } from '@/features/AgentGoals/AddTaskModal';
import RunningGlyph from '@/features/Home/components/RunningGlyph';
import { useActivityTime } from '@/hooks/useActivityTime';
+import { useChatStore } from '@/store/chat';
import {
coordinatorGateReason,
@@ -280,6 +281,55 @@ const StaleBody = memo<{ view: GoalNodeView }>(({ view }) => {
StaleBody.displayName = 'GoalStaleBody';
+/**
+ * Whether this task's own delivery held up.
+ *
+ * Only the statuses a reader would act on: a settled judgment, a rejection, a
+ * delivery waiting on them, or a verification that broke. `pending` / `planned`
+ * say nothing yet, and `verifying` / `repairing` are already what the row's own
+ * state chip says — repeating either would cost the row its scannability for no
+ * information.
+ *
+ * `verifying` / `repairing` are in the map even though the row's own state chip
+ * already names them: that chip is a label, and while the judgment is running is
+ * exactly when a reader wants to look INTO it. Leaving them out meant the one
+ * state where the acceptance matters most offered no way to reach it.
+ */
+const ACCEPTANCE_CHIP: Partial<Record<AcceptanceStatus, { color: string; key: string }>> = {
+ accepted: { color: 'success', key: 'accepted' },
+ delivered: { color: 'info', key: 'delivered' },
+ errored: { color: 'error', key: 'errored' },
+ rejected: { color: 'error', key: 'rejected' },
+ repairing: { color: 'info', key: 'repairing' },
+ verifying: { color: 'info', key: 'verifying' },
+};
+
+const AcceptanceChip = memo<{ view: GoalNodeView }>(({ view }) => {
+ const { t } = useTranslation('chat');
+ const openAcceptance = useChatStore((s) => s.openAcceptance);
+ const acceptance = view.acceptance;
+ const chip = acceptance ? ACCEPTANCE_CHIP[acceptance.status] : undefined;
+ if (!acceptance || !chip) return null;
+
+ return (
+ <Tag
+ color={chip.color}
+ size={'small'}
+ style={{ cursor: 'pointer' }}
+ // The evidence is the point: the chip is the way into it, opened in the
+ // side Portal like every other drill-down on this page.
+ onClick={(event) => {
+ event.stopPropagation();
+ openAcceptance(acceptance.id);
+ }}
+ >
+ {t(`goalProcess.acceptance.${chip.key}` as any)}
+ </Tag>
+ );
+});
+
+AcceptanceChip.displayName = 'GoalAcceptanceChip';
+
const FrontierRow = memo<{
actions: FrontierActions;
canEdit: boolean;
@@ -308,16 +358,26 @@ const FrontierRow = memo<{
// Gate rows carry no tag: the expanded card with its action buttons already
// says "this needs you", and a warning chip next to it is noise.
+ // While verifying, the acceptance chip carries the same word AND opens the
+ // judgment, so a second inert label beside it would only take space.
+ const verifyingChipShown =
+ item.kind === 'verifying' && !!view.acceptance && !!ACCEPTANCE_CHIP[view.acceptance.status];
const tag =
- item.kind === 'stale'
- ? { color: 'error', text: t('goalProcess.tag.lost') }
- : item.kind === 'done'
- ? {
- color: undefined,
- text:
- node.status === 'resolved' ? t('goalProcess.tag.done') : t('goalProcess.tag.retired'),
- }
- : null;
+ item.kind === 'verifying'
+ ? verifyingChipShown
+ ? null
+ : { color: 'info', text: t('goalProcess.tag.verifying') }
+ : item.kind === 'stale'
+ ? { color: 'error', text: t('goalProcess.tag.lost') }
+ : item.kind === 'done'
+ ? {
+ color: undefined,
+ text:
+ node.status === 'resolved'
+ ? t('goalProcess.tag.done')
+ : t('goalProcess.tag.retired'),
+ }
+ : null;
const stop = (event: React.MouseEvent) => event.stopPropagation();
@@ -347,6 +407,7 @@ const FrontierRow = memo<{
)}
<Flexbox flex={1} />
<Flexbox horizontal align={'center'} gap={8} style={{ flex: 'none' }}>
+ <AcceptanceChip view={view} />
{item.kind === 'running' && <RunningClock startedAt={view.startedAt} />}
{item.kind === 'done' && <DoneTime view={view} />}
</Flexbox>
diff --git a/src/features/AgentGoals/ProcessControl/goalGraphViewModel.test.ts b/src/features/AgentGoals/ProcessControl/goalGraphViewModel.test.ts
index 1f91cb5d4e0..fe7637612c8 100644
--- a/src/features/AgentGoals/ProcessControl/goalGraphViewModel.test.ts
+++ b/src/features/AgentGoals/ProcessControl/goalGraphViewModel.test.ts
@@ -170,6 +170,60 @@ describe('buildGoalGraphView', () => {
expect(view.needsYou).toBe(1);
});
+ it('reads a delivered task as verifying, not lost, while the judgment settles', () => {
+ // A verify-bound task keeps its node `active` with an already-`completed`
+ // topic, so it contributes no heartbeat and the node row goes quiet. The
+ // coordinator deliberately leaves it alone for a full hour; the UI used to
+ // spend that hour showing a failure-coloured "lost" badge over the most
+ // informative moment of the run.
+ const view = buildGoalGraphView(
+ snapshot({
+ deliveredAt: { w1: at(90) },
+ events: [event('w1', 'activated', 30)],
+ nodes: [node('w1', { status: 'active', taskId: 'task-1', updatedAt: at(30) })],
+ }),
+ NOW,
+ );
+
+ expect(view.byId.w1).toMatchObject({ isStale: false, isVerifying: true });
+ // In flight, not something the reader has to deal with.
+ expect(view.frontier[0]).toMatchObject({ kind: 'verifying', rank: 1 });
+ expect(view.needsYou).toBe(0);
+ });
+
+ it('never calls a node lost while its own acceptance says it is being judged', () => {
+ // The settle window and the acceptance row are two views of one fact. Read
+ // separately, an aged delivery timestamp put a red "lost" badge on the same
+ // row as a "verifying" chip — a contradiction the reader has no way to
+ // resolve.
+ const view = buildGoalGraphView(
+ snapshot({
+ acceptances: { w1: { id: 'acc-1', status: 'verifying' } },
+ deliveredAt: { w1: at(30) },
+ events: [event('w1', 'activated', 30)],
+ nodes: [node('w1', { status: 'active', taskId: 'task-1', updatedAt: at(30) })],
+ }),
+ NOW,
+ );
+
+ expect(view.byId.w1).toMatchObject({ isStale: false, isVerifying: true });
+ });
+
+ it('gives up on a delivery the coordinator itself would no longer wait for', () => {
+ // Past the coordinator's settle grace the verify run really is stuck, and
+ // the honest reading flips back to lost.
+ const view = buildGoalGraphView(
+ snapshot({
+ deliveredAt: { w1: at(30) },
+ events: [event('w1', 'activated', 30)],
+ nodes: [node('w1', { status: 'active', taskId: 'task-1', updatedAt: at(30) })],
+ }),
+ NOW,
+ );
+
+ expect(view.byId.w1).toMatchObject({ isStale: true, isVerifying: false });
+ });
+
it('keeps a task running when the run operation heartbeat is fresh despite a quiet node row', () => {
// The node row only moves on observations / status changes; a long tool
// call or the verify stage keeps the operation lease fresh while the row
diff --git a/src/features/AgentGoals/ProcessControl/goalGraphViewModel.ts b/src/features/AgentGoals/ProcessControl/goalGraphViewModel.ts
index 068dab78ea7..a0e15e823c0 100644
--- a/src/features/AgentGoals/ProcessControl/goalGraphViewModel.ts
+++ b/src/features/AgentGoals/ProcessControl/goalGraphViewModel.ts
@@ -5,6 +5,7 @@ import type {
GoalGraphNode,
GoalGraphSnapshot,
GoalItem,
+ GoalNodeAcceptance,
WorkType,
} from '@lobechat/types';
@@ -22,6 +23,9 @@ import type {
/** Mirrors the reclaim window the coordinator uses when a Task holds no lease. */
const DEFAULT_LEASE_TIMEOUT_MS = 15 * 60 * 1000;
+/** Mirrors the coordinator's grace period for a delivered task's verification. */
+const VERIFY_SETTLE_GRACE_MS = 60 * 60 * 1000;
+
/** How many just-finished tasks stay visible so the list fades instead of items vanishing. */
export const RECENT_DONE = 2;
@@ -65,6 +69,8 @@ export interface GoalArtifactView {
}
export interface GoalNodeView {
+ /** This task's own verification, when it has been dispatched. */
+ acceptance?: GoalNodeAcceptance;
/** Problems this finding was linked to with a `supports` edge. */
answers: GoalGraphNode[];
/** Deliverables this node produced, newest first. */
@@ -85,6 +91,8 @@ export interface GoalNodeView {
humanTouches: GoalGraphDecision[];
/** Active for longer than the lease window with no heartbeat — the coordinator would reclaim it. */
isStale: boolean;
+ /** Delivered and waiting for its Acceptance judgment to settle. */
+ isVerifying: boolean;
node: GoalGraphNode;
/** The Task that produced this finding. */
producedBy?: GoalGraphNode;
@@ -110,7 +118,7 @@ export const isTroubledTaskNode = (view: GoalNodeView): boolean => {
return view.attempts.at(-1)?.outcome === 'failed';
};
-export type FrontierItemKind = 'gate' | 'stale' | 'running' | 'ready' | 'done';
+export type FrontierItemKind = 'gate' | 'stale' | 'verifying' | 'running' | 'ready' | 'done';
export interface FrontierItem {
key: string;
@@ -227,7 +235,17 @@ export const buildGoalGraphView = (
snapshot: GoalGraphSnapshot,
now: number = Date.now(),
): GoalGraphView => {
- const { decisions, edges, events, goal, nodes, runHeartbeats, workVersions } = snapshot;
+ const {
+ acceptances,
+ decisions,
+ deliveredAt,
+ edges,
+ events,
+ goal,
+ nodes,
+ runHeartbeats,
+ workVersions,
+ } = snapshot;
const nodeById = new Map(nodes.map((node) => [node.id, node]));
const lease = leaseTimeoutMs(goal);
@@ -298,9 +316,28 @@ export const buildGoalGraphView = (
const heartbeatAt = new Date(
Math.max(node.updatedAt.getTime(), runHeartbeats?.[node.id]?.getTime() ?? 0),
);
+ // A delivered run contributes no heartbeat — its topic is `completed`, not
+ // running — so liveness alone would call the verification window lost. That
+ // window is where the goal is most informative, and it lasted up to an hour
+ // showing a failure-coloured "lost" badge.
+ const delivered = deliveredAt?.[node.id];
+ // Two independent signals say a delivery is being judged: the coordinator's
+ // own settle window, and the acceptance row's status. They must not be read
+ // separately — a graph whose delivery timestamp had aged past the window
+ // while its acceptance still said `verifying` rendered a red "lost" badge
+ // next to a "verifying" chip on the same row, which cannot both be true.
+ const acceptanceVerifying =
+ acceptances?.[node.id]?.status === 'verifying' ||
+ acceptances?.[node.id]?.status === 'repairing';
+ const isVerifying =
+ node.kind === 'task' &&
+ node.status === 'active' &&
+ (acceptanceVerifying || (!!delivered && now - delivered.getTime() <= VERIFY_SETTLE_GRACE_MS));
+
return {
answers: supportsByFinding.get(node.id) ?? [],
artifacts: artifactsByNode.get(node.id) ?? [],
+ ...(acceptances?.[node.id] ? { acceptance: acceptances[node.id] } : {}),
attempts,
blockers: (dependsOn.get(node.id) ?? [])
.map((id) => nodeById.get(id))
@@ -312,7 +349,11 @@ export const buildGoalGraphView = (
heartbeatAt,
humanTouches: nodeDecisions.filter((d) => d.status === 'resolved' && !!d.resolvedByUserId),
isStale:
- node.kind === 'task' && node.status === 'active' && now - heartbeatAt.getTime() > lease,
+ node.kind === 'task' &&
+ node.status === 'active' &&
+ !isVerifying &&
+ now - heartbeatAt.getTime() > lease,
+ isVerifying,
node,
producedBy: producedByFinding.get(node.id),
seq: node.kind === 'task' ? ++seq : undefined,
@@ -335,7 +376,7 @@ export const buildGoalGraphView = (
if (node.status === 'active') {
frontier.push({
key: node.id,
- kind: view.isStale ? 'stale' : 'running',
+ kind: view.isStale ? 'stale' : view.isVerifying ? 'verifying' : 'running',
rank: view.isStale ? 0 : 1,
view,
});
diff --git a/src/features/AgentTasks/AgentTaskDetail/TaskAcceptance.test.tsx b/src/features/AgentTasks/AgentTaskDetail/TaskAcceptance.test.tsx
index 5529afb7b37..1019c3532c7 100644
--- a/src/features/AgentTasks/AgentTaskDetail/TaskAcceptance.test.tsx
+++ b/src/features/AgentTasks/AgentTaskDetail/TaskAcceptance.test.tsx
@@ -65,6 +65,11 @@ vi.mock('@/components/NeuralNetworkLoading', () => ({ default: () => <div>loadin
vi.mock('@/features/Acceptance', async () => ({
// The real row/list primitives: the assertions cover the shared grammar.
...(await vi.importActual('@/features/Acceptance/CriterionList')),
+ AcceptanceCheckRow: ({ check, onToggle }: { check: { title: string }; onToggle: () => void }) => (
+ <button data-testid="acceptance-check-item" type="button" onClick={onToggle}>
+ item: {check.title}
+ </button>
+ ),
CheckRow: ({ check }: { check: { title: string } }) => (
<div data-testid="acceptance-check-detail">detail: {check.title}</div>
),
@@ -232,6 +237,21 @@ describe('TaskAcceptance', () => {
expect(mocks.openAcceptance).toHaveBeenCalledWith('acceptance-1');
});
+ it('renders the canonical Acceptance check item in the task result panel', () => {
+ mocks.acceptanceSubject = { id: 'acceptance-1' };
+ mocks.bundle = {
+ acceptance: { id: 'acceptance-1', requirement: 'Everything is verifiable.' },
+ checks: [{ category: 'Setup', id: 'c1', seq: 1, title: 'Create task' }],
+ isOwner: true,
+ };
+
+ render(<TaskAcceptance variant={'result'} />);
+
+ expect(screen.getByTestId('acceptance-check-item')).toHaveTextContent('item: Create task');
+ fireEvent.click(screen.getByTestId('acceptance-check-item'));
+ expect(mocks.openAcceptanceCheck).toHaveBeenCalledWith('acceptance-1', 'c1');
+ });
+
it('groups a checklist with more than 10 checks', () => {
mocks.acceptanceSubject = { id: 'acceptance-1' };
mocks.bundle = {
diff --git a/src/features/AgentTasks/AgentTaskDetail/TaskAcceptance.tsx b/src/features/AgentTasks/AgentTaskDetail/TaskAcceptance.tsx
index 4fbe13126c0..6f176a06b16 100644
--- a/src/features/AgentTasks/AgentTaskDetail/TaskAcceptance.tsx
+++ b/src/features/AgentTasks/AgentTaskDetail/TaskAcceptance.tsx
@@ -17,6 +17,7 @@ import { useTranslation } from 'react-i18next';
import NeuralNetworkLoading from '@/components/NeuralNetworkLoading';
import {
type AcceptanceCheck,
+ AcceptanceCheckRow,
checkDisplayTitle,
checkHeadMeta,
CriterionList,
@@ -60,6 +61,8 @@ const styles = createStaticStyles(({ css }) => ({
`,
}));
+const readOnlyReview = async () => false;
+
interface AcceptanceErrorProps {
onRetry: () => void;
}
@@ -103,7 +106,18 @@ const CompactCheckRow = memo<CompactCheckRowProps>(({ check, onOpen }) => {
CompactCheckRow.displayName = 'TaskAcceptanceCompactCheckRow';
-const TaskAcceptance = memo(() => {
+interface TaskAcceptanceProps {
+ /**
+ * `result` — the task result panel. The reader there has just read the
+ * delivery and wants one thing from this block: the checklist and how each
+ * check came out. The round timeline and the 验收目标 contract answer "how
+ * was this judged", which the full report keeps; leading with them buried
+ * the verdicts they came for.
+ */
+ variant?: 'default' | 'result';
+}
+
+const TaskAcceptance = memo<TaskAcceptanceProps>(({ variant = 'default' }) => {
const { t } = useTranslation(['chat', 'verify']);
const openAcceptance = useChatStore((state) => state.openAcceptance);
const openAcceptanceCheck = useChatStore((state) => state.openAcceptanceCheck);
@@ -114,6 +128,7 @@ const TaskAcceptance = memo(() => {
const verify = useTaskStore(taskDetailSelectors.activeTaskVerifyConfig);
const [sectionExpanded, setSectionExpanded] = useState(true);
const [collapsedGroups, setCollapsedGroups] = useState<Set<string>>(() => new Set());
+ const [requirementExpanded, setRequirementExpanded] = useState(false);
const {
data: acceptanceSubject,
@@ -246,36 +261,49 @@ const TaskAcceptance = memo(() => {
{bundleError && <AcceptanceError onRetry={() => void mutateBundle()} />}
{bundle && (
<>
- <GoalRoundTimeline rounds={bundle.rounds} />
- {requirement && (
+ {variant !== 'result' && <GoalRoundTimeline rounds={bundle.rounds} />}
+ {variant !== 'result' && requirement && (
<Flexbox gap={6}>
<Text fontSize={12} type={'secondary'}>
{t('taskDetail.acceptance.goal')}
</Text>
- <Text>{requirement}</Text>
+ {/* The contract, not the result. A goal-dispatched task carries
+ a generated paragraph here, and printing it in full pushed
+ the checks — the thing the reader came for — below the
+ fold. Two lines, and the rest on demand. */}
+ <Text
+ ellipsis={requirementExpanded ? undefined : { rows: 2 }}
+ style={{ cursor: 'pointer' }}
+ title={requirement}
+ onClick={() => setRequirementExpanded((open) => !open)}
+ >
+ {requirement}
+ </Text>
</Flexbox>
)}
<Flexbox gap={7}>
- <Flexbox horizontal align={'center'} gap={8}>
- <Text fontSize={12} type={'secondary'}>
- {t('taskDetail.acceptance.checklist')}
- </Text>
- <Flexbox flex={1} />
- {grouped && groupKeys.length > 0 && (
- <ActionIcon
- icon={allGroupsCollapsed ? ChevronsUpDown : ChevronsDownUp}
- size={'small'}
- title={
- allGroupsCollapsed
- ? t('taskDetail.acceptance.expandAll')
- : t('taskDetail.acceptance.collapseAll')
- }
- onClick={() =>
- setCollapsedGroups(allGroupsCollapsed ? new Set() : new Set(groupKeys))
- }
- />
- )}
- </Flexbox>
+ {(variant !== 'result' || (grouped && groupKeys.length > 0)) && (
+ <Flexbox horizontal align={'center'} gap={8}>
+ <Text fontSize={12} type={'secondary'}>
+ {t('taskDetail.acceptance.checklist')}
+ </Text>
+ <Flexbox flex={1} />
+ {grouped && groupKeys.length > 0 && (
+ <ActionIcon
+ icon={allGroupsCollapsed ? ChevronsUpDown : ChevronsDownUp}
+ size={'small'}
+ title={
+ allGroupsCollapsed
+ ? t('taskDetail.acceptance.expandAll')
+ : t('taskDetail.acceptance.collapseAll')
+ }
+ onClick={() =>
+ setCollapsedGroups(allGroupsCollapsed ? new Set() : new Set(groupKeys))
+ }
+ />
+ )}
+ </Flexbox>
+ )}
<CriterionList>
{grouped
? groups.map((group) => {
@@ -313,23 +341,47 @@ const TaskAcceptance = memo(() => {
/>
</Flexbox>
{!collapsed &&
- group.checks.map((check) => (
- <CompactCheckRow
- check={check}
- key={check.id}
- onOpen={() => openCheck(bundle.acceptance.id, check.id)}
- />
- ))}
+ group.checks.map((check) =>
+ variant === 'result' ? (
+ <AcceptanceCheckRow
+ canReview={false}
+ check={check}
+ expanded={false}
+ key={check.id}
+ reviewPending={false}
+ onReview={readOnlyReview}
+ onToggle={() => openCheck(bundle.acceptance.id, check.id)}
+ />
+ ) : (
+ <CompactCheckRow
+ check={check}
+ key={check.id}
+ onOpen={() => openCheck(bundle.acceptance.id, check.id)}
+ />
+ ),
+ )}
</Flexbox>
);
})
- : checks.map((check) => (
- <CompactCheckRow
- check={check}
- key={check.id}
- onOpen={() => openCheck(bundle.acceptance.id, check.id)}
- />
- ))}
+ : checks.map((check) =>
+ variant === 'result' ? (
+ <AcceptanceCheckRow
+ canReview={false}
+ check={check}
+ expanded={false}
+ key={check.id}
+ reviewPending={false}
+ onReview={readOnlyReview}
+ onToggle={() => openCheck(bundle.acceptance.id, check.id)}
+ />
+ ) : (
+ <CompactCheckRow
+ check={check}
+ key={check.id}
+ onOpen={() => openCheck(bundle.acceptance.id, check.id)}
+ />
+ ),
+ )}
</CriterionList>
</Flexbox>
</>
diff --git a/src/features/AgentTasks/AgentTaskDetail/TaskActivities.tsx b/src/features/AgentTasks/AgentTaskDetail/TaskActivities.tsx
index 673450f7dc7..f7c171ade27 100644
--- a/src/features/AgentTasks/AgentTaskDetail/TaskActivities.tsx
+++ b/src/features/AgentTasks/AgentTaskDetail/TaskActivities.tsx
@@ -17,6 +17,7 @@ import { styles } from '../shared/style';
import CommentCard from './CommentCard';
import CommentInput from './CommentInput';
import TaskBriefCard from './TaskBriefCard';
+import TaskRunReport from './TaskRunReport';
import TopicCard from './TopicCard';
const ROW_TYPE_ICON = {
@@ -157,6 +158,58 @@ const TaskActivities = memo<TaskActivitiesProps>(({ variant = 'activity' }) => {
const commentInput = activeTaskId ? <CommentInput taskId={activeTaskId} /> : null;
+ // A goal loop can produce many rounds; only the newest run opens by default so
+ // the latest result is not buried under older ones.
+ const firstTopicKey = items.find(({ activity }) => activity.type === 'topic')?.key;
+ const rows =
+ items.length > 0 ? (
+ items.map(({ activity, brief, key }) => {
+ if (brief) {
+ return (
+ <TaskBriefCard
+ brief={brief}
+ key={key}
+ onAfterAddComment={refreshActiveTask}
+ onAfterDelete={refreshActiveTask}
+ onAfterResolve={refreshActiveTask}
+ />
+ );
+ }
+ if (activity.type === 'topic') {
+ // The result panel's newest run is not a row in a list — it is the
+ // agent's report of what this task produced, so it gets its own
+ // presentation rather than the activity card's chrome.
+ if (variant === 'result' && key === firstTopicKey) {
+ return <TaskRunReport activity={activity} key={key} />;
+ }
+ return <TopicCard activity={activity} defaultExpanded={false} key={key} />;
+ }
+ if (activity.type === 'comment') {
+ return <CommentCard activity={activity} key={key} />;
+ }
+ // Lifecycle bookkeeping ("created the task", reassignments). It belongs
+ // to the activity timeline; in a result panel it is a row between the
+ // reader and the report.
+ if (variant === 'result') return null;
+ return <ActivityRow activity={activity} key={key} />;
+ })
+ ) : (
+ <Empty
+ description={t('taskDetail.activitiesEmpty')}
+ icon={BotMessageSquare}
+ style={{ marginTop: 8 }}
+ />
+ );
+
+ // The Portal header already names the task and the report is the only thing
+ // in this section, so a collapsible "运行结果" band above it labels a section
+ // of one and eats the top of the reading surface.
+ // No comment composer here: the result panel is for reading what came back.
+ // Leaving a note for the next run is one of the report's own actions, which
+ // opens the editor on demand instead of parking an empty box under every
+ // report.
+ if (variant === 'result') return <Flexbox gap={12}>{rows}</Flexbox>;
+
return (
<Accordion defaultExpandedKeys={['activities']} gap={0}>
<AccordionItem
@@ -167,53 +220,14 @@ const TaskActivities = memo<TaskActivitiesProps>(({ variant = 'activity' }) => {
<Flexbox horizontal align="center" gap={8}>
<Icon color={cssVar.colorTextDescription} icon={BotMessageSquare} size={16} />
<Text color={cssVar.colorTextSecondary} fontSize={13} weight={500}>
- {t(variant === 'result' ? 'taskDetail.runResults' : 'taskDetail.activities')}
+ {t('taskDetail.activities')}
</Text>
</Flexbox>
}
>
<Flexbox gap={12} paddingBlock={12} paddingInline={12}>
- {variant === 'activity' && commentInput}
- {items.length > 0 ? (
- // A goal loop can produce many rounds; only the newest run opens by
- // default so the latest result is not buried under older ones.
- (() => {
- const firstTopicKey = items.find(({ activity }) => activity.type === 'topic')?.key;
- return items.map(({ activity, brief, key }) => {
- if (brief) {
- return (
- <TaskBriefCard
- brief={brief}
- key={key}
- onAfterAddComment={refreshActiveTask}
- onAfterDelete={refreshActiveTask}
- onAfterResolve={refreshActiveTask}
- />
- );
- }
- if (activity.type === 'topic') {
- return (
- <TopicCard
- activity={activity}
- defaultExpanded={key === firstTopicKey}
- key={key}
- />
- );
- }
- if (activity.type === 'comment') {
- return <CommentCard activity={activity} key={key} />;
- }
- return <ActivityRow activity={activity} key={key} />;
- });
- })()
- ) : (
- <Empty
- description={t('taskDetail.activitiesEmpty')}
- icon={BotMessageSquare}
- style={{ marginTop: 8 }}
- />
- )}
- {variant === 'result' && commentInput}
+ {commentInput}
+ {rows}
</Flexbox>
</AccordionItem>
</Accordion>
diff --git a/src/features/AgentTasks/AgentTaskDetail/TaskRunReport.tsx b/src/features/AgentTasks/AgentTaskDetail/TaskRunReport.tsx
new file mode 100644
index 00000000000..99bd3e3bd62
--- /dev/null
+++ b/src/features/AgentTasks/AgentTaskDetail/TaskRunReport.tsx
@@ -0,0 +1,105 @@
+'use client';
+
+import type { TaskDetailActivity } from '@lobechat/types';
+import { Flexbox, Markdown } from '@lobehub/ui';
+import { ActionIcon, Avatar, Text } from '@lobehub/ui/base-ui';
+import { MessageCircle, MessagesSquare } from 'lucide-react';
+import { memo, useCallback, useState } from 'react';
+import { useTranslation } from 'react-i18next';
+
+import { DEFAULT_AVATAR } from '@/const/meta';
+import { useTaskStore } from '@/store/task';
+import { taskDetailSelectors } from '@/store/task/selectors';
+
+import RunReplyEditor from './RunReplyEditor';
+
+/**
+ * What the agent reported for this task, presented as a report.
+ *
+ * Deliberately NOT the activity card: no run chips, no attempt number, no
+ * status glyph, no collapse chevron, no overflow menu, no outline. Every one of
+ * those answers "which row of the list is this", and the reader of a result
+ * panel already knows — the panel header names the task. What is left is the
+ * delivery itself, which is the only thing they came for.
+ *
+ * The author does stay, at the head: a report names who wrote it, and that is a
+ * different job from the avatar's job in a list row.
+ *
+ * The two actions stay because reading a report is not the end of the job: you
+ * either ask the agent about it or leave a note for the next run. They sit under
+ * the report rather than inside it, so they never compete with the content.
+ */
+
+interface TaskRunReportProps {
+ activity: TaskDetailActivity;
+}
+
+const TaskRunReport = memo<TaskRunReportProps>(({ activity }) => {
+ const { t } = useTranslation('chat');
+ const openTopicDrawer = useTaskStore((s) => s.openTopicDrawer);
+ const addComment = useTaskStore((s) => s.addComment);
+ const activeTaskId = useTaskStore(taskDetailSelectors.activeTaskId);
+ const [commenting, setCommenting] = useState(false);
+
+ // A descendant run belongs to `sourceTaskId`, not the open parent.
+ const runTaskId = activity.sourceTaskId ?? activeTaskId;
+
+ const openConversation = useCallback(() => {
+ if (!activity.id) return;
+ openTopicDrawer(activity.id, {
+ agentId:
+ activity.author?.type === 'agent' ? activity.author.id : activity.agentId || undefined,
+ title: activity.title,
+ });
+ }, [activity.agentId, activity.author, activity.id, activity.title, openTopicDrawer]);
+
+ // Nothing was reported yet — the panel's own empty handling covers that case.
+ const body = activity.content || activity.summary;
+ if (!body) return null;
+
+ return (
+ <Flexbox gap={16}>
+ {/* Who is reporting, at the top where a report names its author — not a
+ footnote under the text it wrote. */}
+ <Flexbox horizontal align={'center'} gap={8}>
+ <Avatar avatar={activity.author?.avatar || DEFAULT_AVATAR} size={24} />
+ <Text weight={500}>{activity.author?.name ?? t('taskDetail.reportedByAgent')}</Text>
+ </Flexbox>
+ <Markdown style={{ overflow: 'unset' }} variant={'chat'}>
+ {body}
+ </Markdown>
+
+ {commenting ? (
+ <RunReplyEditor
+ onCancel={() => setCommenting(false)}
+ onSubmit={async (text) => {
+ if (!runTaskId) return;
+ await addComment(runTaskId, text, { topicId: activity.id });
+ setCommenting(false);
+ }}
+ />
+ ) : (
+ <Flexbox horizontal align={'center'} gap={4} justify={'flex-end'}>
+ <ActionIcon
+ icon={MessagesSquare}
+ size={'small'}
+ title={t('taskDetail.openRunChat')}
+ onClick={openConversation}
+ />
+ {!!runTaskId && (
+ <ActionIcon
+ icon={MessageCircle}
+ size={'small'}
+ title={t('taskDetail.runFollowUp')}
+ onClick={() => setCommenting(true)}
+ />
+ )}
+ </Flexbox>
+ )}
+ </Flexbox>
+ );
+});
+
+TaskRunReport.displayName = 'TaskRunReport';
+
+export default TaskRunReport;
diff --git a/src/features/AgentTasks/AgentTaskDetail/TopicCard.tsx b/src/features/AgentTasks/AgentTaskDetail/TopicCard.tsx
index 1243b7e96be..745e71ea699 100644
--- a/src/features/AgentTasks/AgentTaskDetail/TopicCard.tsx
+++ b/src/features/AgentTasks/AgentTaskDetail/TopicCard.tsx
@@ -17,6 +17,7 @@ import {
Copy,
ExternalLink,
MessageCircle,
+ MessagesSquare,
MoreHorizontal,
Trash,
} from 'lucide-react';
@@ -62,13 +63,23 @@ const formatDuration = (ms: number): string => {
// to. Anything added here that swallows clicks has to earn it again.
const RUN_CONTENT_MAX_HEIGHT = 160;
-const RunContent = memo<{ content: string }>(({ content }) => (
- <CollapsibleContent key={content} maxHeight={RUN_CONTENT_MAX_HEIGHT}>
+const RunContent = memo<{ content: string; unclamped?: boolean }>(({ content, unclamped }) =>
+ // The delivery is the reason the result panel exists. Clamping it a second
+ // time — the card already collapses — meant opening a task and meeting five
+ // lines behind a "show all", which is no way to review anything. Older runs
+ // keep the clamp: there the list is the point.
+ unclamped ? (
<Markdown style={{ overflow: 'unset' }} variant={'chat'}>
{content}
</Markdown>
- </CollapsibleContent>
-));
+ ) : (
+ <CollapsibleContent key={content} maxHeight={RUN_CONTENT_MAX_HEIGHT}>
+ <Markdown style={{ overflow: 'unset' }} variant={'chat'}>
+ {content}
+ </Markdown>
+ </CollapsibleContent>
+ ),
+);
interface TopicCardProps {
activity: TaskDetailActivity;
@@ -78,9 +89,11 @@ interface TopicCardProps {
* opens only the latest and collapses the rest.
*/
defaultExpanded?: boolean;
+ /** The run the reader came to read: its delivery renders in full. */
+ primary?: boolean;
}
-const TopicCard = memo<TopicCardProps>(({ activity, defaultExpanded = true }) => {
+const TopicCard = memo<TopicCardProps>(({ activity, defaultExpanded = true, primary }) => {
const { t } = useTranslation('chat');
const [bodyExpanded, setBodyExpanded] = useState(defaultExpanded);
const openTopicDrawer = useTaskStore((s) => s.openTopicDrawer);
@@ -266,12 +279,17 @@ const TopicCard = memo<TopicCardProps>(({ activity, defaultExpanded = true }) =>
);
return (
+ // The primary result is not one card among many — it is the agent reporting
+ // what this task produced, and it should read like a document rather than a
+ // boxed activity row. The outline, the inner padding and the duplicated
+ // summary line all belong to the list presentation; a report drops them and
+ // lets the delivery own the surface.
<Block
- gap={8}
- paddingBlock={8}
- paddingInline={8}
- style={{ borderRadius: cssVar.borderRadiusLG }}
- variant={'outlined'}
+ gap={primary ? 12 : 8}
+ paddingBlock={primary ? 0 : 8}
+ paddingInline={primary ? 0 : 8}
+ style={primary ? undefined : { borderRadius: cssVar.borderRadiusLG }}
+ variant={primary ? 'borderless' : 'outlined'}
>
<Flexbox horizontal align={'center'} gap={8} justify={'space-between'}>
<Flexbox horizontal align={'center'} gap={8} style={{ minWidth: 0, overflow: 'hidden' }}>
@@ -359,8 +377,8 @@ const TopicCard = memo<TopicCardProps>(({ activity, defaultExpanded = true }) =>
</Flexbox>
{hasBody && bodyExpanded && (
- <Flexbox gap={8} paddingInline={4}>
- {activity.summary && (
+ <Flexbox gap={primary ? 12 : 8} paddingInline={primary ? 0 : 4}>
+ {activity.summary && !(primary && activity.content) && (
<Text
fontSize={13}
style={{ color: cssVar.colorTextDescription, whiteSpace: 'pre-wrap' }}
@@ -368,7 +386,7 @@ const TopicCard = memo<TopicCardProps>(({ activity, defaultExpanded = true }) =>
{activity.summary}
</Text>
)}
- {activity.content && <RunContent content={activity.content} />}
+ {activity.content && <RunContent content={activity.content} unclamped={primary} />}
{/* The verdict's evidence, next to the delivery it judged — reading
one should never require leaving for the acceptance page. */}
{activity.verify && (
@@ -391,7 +409,17 @@ const TopicCard = memo<TopicCardProps>(({ activity, defaultExpanded = true }) =>
/>
</Flexbox>
) : (
- <Flexbox horizontal justify={'flex-end'} onClick={stopPropagation}>
+ <Flexbox horizontal gap={4} justify={'flex-end'} onClick={stopPropagation}>
+ {/* The run's own conversation was reachable only by clicking the
+ title, which said nothing about being a door. Asking the
+ agent a follow-up is the natural next move after reading a
+ delivery, so it gets a real affordance. */}
+ <ActionIcon
+ icon={MessagesSquare}
+ size={'small'}
+ title={t('taskDetail.openRunChat')}
+ onClick={handleOpen}
+ />
<ActionIcon
icon={MessageCircle}
size={'small'}
diff --git a/src/features/Portal/TaskResult/Body.tsx b/src/features/Portal/TaskResult/Body.tsx
index 6b521f26c06..6f70121a88b 100644
--- a/src/features/Portal/TaskResult/Body.tsx
+++ b/src/features/Portal/TaskResult/Body.tsx
@@ -45,9 +45,13 @@ const Body = memo(() => {
<TaskDetailSkeleton />
) : (
<>
+ {/* Report, then the verdict on it, then the artifacts it produced.
+ The acceptance used to sit last, so on any report longer than a
+ screen the checks — the reason to trust what you just read — were
+ off the bottom of the panel and read as missing. */}
<TaskActivities variant={'result'} />
+ <TaskAcceptance variant={'result'} />
<TaskArtifacts />
- <TaskAcceptance />
</>
)}
<TopicChatDrawer />