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(task): show when a running task is waiting on acceptance (#21802)

Rdmclin2d818df352e79
diff --git a/locales/en-US/chat.json b/locales/en-US/chat.json
index 094f3ba60a1..596d720e77f 100644
--- a/locales/en-US/chat.json
+++ b/locales/en-US/chat.json
@@ -2365,6 +2365,7 @@
"taskDetail.acceptanceState.rejected": "Sent back",
"taskDetail.acceptanceState.repairing": "Repairing",
"taskDetail.acceptanceState.verifying": "Verifying",
+ "taskDetail.acceptanceWait.title": "Waiting on acceptance",
"taskDetail.activities": "Activities",
"taskDetail.activities.assignment.agentAssigned": "<actor/> set the agent to <target/>",
"taskDetail.activities.assignment.agentUnassigned": "<actor/> removed the agent",
@@ -2487,6 +2488,8 @@
"taskDetail.runVerify.failed": "Not passed",
"taskDetail.runVerify.passed": "Passed",
"taskDetail.runVerify.pending": "Awaiting verification",
+ "taskDetail.runVerify.repairing": "Repairing",
+ "taskDetail.runVerify.review": "Awaiting review",
"taskDetail.runVerify.round": "Round {{index}}",
"taskDetail.runVerify.running": "Verifying",
"taskDetail.runtimeConfig.cliDefault": "CLI default",
@@ -2506,6 +2509,7 @@
"taskDetail.runtimeConfig.topicScope": "Configuration for this Topic, using its pinned settings and current Agent defaults.",
"taskDetail.saveModelConfig": "Save",
"taskDetail.sendFollowUp": "Send follow up message",
+ "taskDetail.status.awaitingAcceptance": "In acceptance",
"taskDetail.status.backlog": "Backlog",
"taskDetail.status.canceled": "Canceled",
"taskDetail.status.completed": "Completed",
diff --git a/locales/zh-CN/chat.json b/locales/zh-CN/chat.json
index 4c437d92b70..c5c7cd617b9 100644
--- a/locales/zh-CN/chat.json
+++ b/locales/zh-CN/chat.json
@@ -2365,6 +2365,7 @@
"taskDetail.acceptanceState.rejected": "已打回",
"taskDetail.acceptanceState.repairing": "修复中",
"taskDetail.acceptanceState.verifying": "验证中",
+ "taskDetail.acceptanceWait.title": "等待验收",
"taskDetail.activities": "活动",
"taskDetail.activities.assignment.agentAssigned": "<actor/> 将 Agent 设为 <target/>",
"taskDetail.activities.assignment.agentUnassigned": "<actor/> 取消了 Agent 指派",
@@ -2487,6 +2488,8 @@
"taskDetail.runVerify.failed": "未通过",
"taskDetail.runVerify.passed": "已通过",
"taskDetail.runVerify.pending": "待验证",
+ "taskDetail.runVerify.repairing": "修复中",
+ "taskDetail.runVerify.review": "待审核",
"taskDetail.runVerify.round": "第 {{index}} 轮",
"taskDetail.runVerify.running": "验证中",
"taskDetail.runtimeConfig.cliDefault": "CLI 默认",
@@ -2506,6 +2509,7 @@
"taskDetail.runtimeConfig.topicScope": "此 Topic 的配置,结合 Topic 固定值与当前 Agent 默认值。",
"taskDetail.saveModelConfig": "保存",
"taskDetail.sendFollowUp": "发送追加消息",
+ "taskDetail.status.awaitingAcceptance": "验收中",
"taskDetail.status.backlog": "待办",
"taskDetail.status.canceled": "已取消",
"taskDetail.status.completed": "已完成",
diff --git a/packages/locales/src/default/chat.ts b/packages/locales/src/default/chat.ts
index b96253ca2fb..0740e8d81cb 100644
--- a/packages/locales/src/default/chat.ts
+++ b/packages/locales/src/default/chat.ts
@@ -2035,6 +2035,7 @@ export default {
'taskDetail.acceptanceState.rejected': 'Sent back',
'taskDetail.acceptanceState.repairing': 'Repairing',
'taskDetail.acceptanceState.verifying': 'Verifying',
+ 'taskDetail.acceptanceWait.title': 'Waiting on acceptance',
'taskDetail.assignee': 'Assignee',
'taskDetail.goalTimeline.hover.cost': 'Cost',
'taskDetail.goalTimeline.hover.duration': 'Duration',
@@ -2090,6 +2091,8 @@ export default {
'taskDetail.runVerify.failed': 'Not passed',
'taskDetail.runVerify.passed': 'Passed',
'taskDetail.runVerify.pending': 'Awaiting verification',
+ 'taskDetail.runVerify.repairing': 'Repairing',
+ 'taskDetail.runVerify.review': 'Awaiting review',
'taskDetail.runVerify.round': 'Round {{index}}',
'taskDetail.runVerify.running': 'Verifying',
'taskDetail.runExpand': 'Expand run',
@@ -2141,6 +2144,7 @@ export default {
'taskDetail.priority.normal': 'Normal',
'taskDetail.priority.urgent': 'Urgent',
'taskDetail.properties': 'Properties',
+ 'taskDetail.status.awaitingAcceptance': 'In acceptance',
'taskDetail.status.backlog': 'Backlog',
'taskDetail.status.canceled': 'Canceled',
'taskDetail.status.completed': 'Completed',
diff --git a/src/features/AgentTasks/AgentTaskDetail/RunVerifyTag.test.ts b/src/features/AgentTasks/AgentTaskDetail/RunVerifyTag.test.ts
index 9ebb3902453..81fc60bdf26 100644
--- a/src/features/AgentTasks/AgentTaskDetail/RunVerifyTag.test.ts
+++ b/src/features/AgentTasks/AgentTaskDetail/RunVerifyTag.test.ts
@@ -20,4 +20,9 @@ describe('resolveVerdict', () => {
expect(resolveVerdict('planned')).toBe('pending');
expect(resolveVerdict(null)).toBe('pending');
});
+
+ it('tells a round under repair and a delivered round apart from an unchecked one', () => {
+ expect(resolveVerdict('repairing')).toBe('repairing');
+ expect(resolveVerdict('delivered')).toBe('review');
+ });
});
diff --git a/src/features/AgentTasks/AgentTaskDetail/RunVerifyTag.tsx b/src/features/AgentTasks/AgentTaskDetail/RunVerifyTag.tsx
index fcf578c08c1..87d09b168ff 100644
--- a/src/features/AgentTasks/AgentTaskDetail/RunVerifyTag.tsx
+++ b/src/features/AgentTasks/AgentTaskDetail/RunVerifyTag.tsx
@@ -2,7 +2,15 @@
import type { TaskRunVerifySummary } from '@lobechat/types';
import { cssVar, Icon, Tag } from '@lobehub/ui';
-import { CircleCheck, CircleDashed, CircleX, Loader2, TriangleAlert } from 'lucide-react';
+import {
+ CircleCheck,
+ CircleDashed,
+ CircleX,
+ Loader2,
+ RefreshCw,
+ Stamp,
+ TriangleAlert,
+} from 'lucide-react';
import { memo } from 'react';
import { useTranslation } from 'react-i18next';
@@ -22,6 +30,8 @@ const VERDICT_META = {
failed: { color: cssVar.colorError, icon: CircleX, labelKey: 'failed' },
passed: { color: cssVar.colorSuccess, icon: CircleCheck, labelKey: 'passed' },
pending: { color: cssVar.colorTextTertiary, icon: CircleDashed, labelKey: 'pending' },
+ repairing: { color: cssVar.colorWarning, icon: RefreshCw, labelKey: 'repairing' },
+ review: { color: cssVar.colorWarning, icon: Stamp, labelKey: 'review' },
running: { color: cssVar.colorInfo, icon: Loader2, labelKey: 'running', spin: true },
} as const;
@@ -42,6 +52,14 @@ export const resolveVerdict = (status: string | null): VerdictKey => {
case 'verifying': {
return 'running';
}
+ // Not passed, and a repair round has to deliver again. Reading it as
+ // "awaiting verification" hid that the round had already been judged.
+ case 'repairing': {
+ return 'repairing';
+ }
+ case 'delivered': {
+ return 'review';
+ }
// A verify session exists but has not produced a verdict — planned, or
// waiting on the run it verifies.
default: {
diff --git a/src/features/AgentTasks/AgentTaskDetail/TaskAcceptanceWaitNotice.tsx b/src/features/AgentTasks/AgentTaskDetail/TaskAcceptanceWaitNotice.tsx
new file mode 100644
index 00000000000..b33c5e2b1e8
--- /dev/null
+++ b/src/features/AgentTasks/AgentTaskDetail/TaskAcceptanceWaitNotice.tsx
@@ -0,0 +1,84 @@
+'use client';
+
+import type { TaskDetailActivity } from '@lobechat/types';
+import { Flexbox, Icon } from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
+import { ChevronRight, Stamp } from 'lucide-react';
+import { memo } from 'react';
+import { useTranslation } from 'react-i18next';
+
+import { useOpenAcceptanceInPanel } from './useOpenAcceptanceInPanel';
+import { useRunAcceptanceWait } from './useTaskAcceptanceWait';
+
+// Same weight as the composer's OpStatusTray: one quiet status line, not a banner.
+const styles = stylex.create({
+ container: {
+ color: cssVar.colorTextSecondary,
+ fontSize: 12,
+ paddingInline: 4,
+ },
+ link: {
+ cursor: 'pointer',
+ color: {
+ 'default': cssVar.colorTextSecondary,
+ ':hover': cssVar.colorText,
+ },
+ },
+ icon: {
+ color: cssVar.colorWarning,
+ flex: 'none',
+ },
+});
+
+interface TaskAcceptanceWaitNoticeProps {
+ /** The run open in the drawer; it may belong to a descendant task. */
+ activity?: TaskDetailActivity;
+ /** The drawer's live operation, which can arrive before the activity's marker. */
+ runningOperation?: TaskDetailActivity['runningOperation'];
+}
+
+/**
+ * Says why a `running` run is not generating: its agent stopped and the
+ * acceptance round bound to it still has to settle.
+ */
+const TaskAcceptanceWaitNotice = memo<TaskAcceptanceWaitNoticeProps>(
+ ({ activity, runningOperation }) => {
+ const { t } = useTranslation('chat');
+ const openAcceptanceInPanel = useOpenAcceptanceInPanel();
+
+ // Same rule as the run card's status icon, so the drawer and the card agree.
+ const runWait = useRunAcceptanceWait(activity);
+ const wait = runningOperation ? undefined : runWait;
+ if (!wait) return null;
+
+ const { acceptanceId } = wait;
+
+ return (
+ <Flexbox
+ horizontal
+ align={'center'}
+ gap={6}
+ {...stylex.props(styles.container, !!acceptanceId && styles.link)}
+ role={acceptanceId ? 'button' : undefined}
+ tabIndex={acceptanceId ? 0 : undefined}
+ onClick={acceptanceId ? () => openAcceptanceInPanel(acceptanceId) : undefined}
+ onKeyDown={
+ acceptanceId
+ ? (e) => {
+ if (e.key === 'Enter' || e.key === ' ') openAcceptanceInPanel(acceptanceId);
+ }
+ : undefined
+ }
+ >
+ <Icon icon={Stamp} size={14} {...stylex.props(styles.icon)} />
+ <span>{t('taskDetail.acceptanceWait.title')}</span>
+ {acceptanceId && <Icon icon={ChevronRight} size={12} />}
+ </Flexbox>
+ );
+ },
+);
+
+TaskAcceptanceWaitNotice.displayName = 'TaskAcceptanceWaitNotice';
+
+export default TaskAcceptanceWaitNotice;
diff --git a/src/features/AgentTasks/AgentTaskDetail/TaskProperties.tsx b/src/features/AgentTasks/AgentTaskDetail/TaskProperties.tsx
index b13b431755a..03bcc4c5c3d 100644
--- a/src/features/AgentTasks/AgentTaskDetail/TaskProperties.tsx
+++ b/src/features/AgentTasks/AgentTaskDetail/TaskProperties.tsx
@@ -1,6 +1,6 @@
import type { TaskPriority, TaskStatus } from '@lobechat/types';
import { Block, cssVar, Icon, Text } from '@lobehub/ui';
-import { ArchiveIcon } from 'lucide-react';
+import { ArchiveIcon, Stamp } from 'lucide-react';
import { memo } from 'react';
import { useTranslation } from 'react-i18next';
@@ -19,6 +19,7 @@ import { useUserDisplayMeta } from '../shared/useUserDisplayMeta';
import TaskAcceptanceStateRow from './TaskAcceptanceStateRow';
import { taskDetailLayoutStyles as styles } from './taskDetailLayoutStyles';
import TaskScheduleConfig from './TaskScheduleConfig';
+import { useTaskAcceptanceWait } from './useTaskAcceptanceWait';
interface StatusMeta {
labelKey: string;
@@ -62,6 +63,7 @@ const TaskProperties = memo(() => {
const scheduleTimezone = useTaskStore(taskDetailSelectors.activeTaskScheduleTimezone);
const memberMeta = useUserDisplayMeta(assigneeUserId);
const activeWorkspaceId = useActiveWorkspaceId();
+ const acceptanceWait = useTaskAcceptanceWait();
if (!taskId) return null;
@@ -79,8 +81,18 @@ const TaskProperties = memo(() => {
gap={8}
variant={'borderless'}
>
- <TaskStatusTag disableDropdown size={16} status={status} taskIdentifier={taskId} />
- <Text weight={500}>{t(`taskDetail.${statusMeta.labelKey}` as never)}</Text>
+ {/* `running` covers both an executing agent and a stopped one whose
+ acceptance round has yet to settle; only the first is "in progress". */}
+ {acceptanceWait ? (
+ <Icon color={cssVar.colorWarning} icon={Stamp} size={16} />
+ ) : (
+ <TaskStatusTag disableDropdown size={16} status={status} taskIdentifier={taskId} />
+ )}
+ <Text weight={500}>
+ {acceptanceWait
+ ? t('taskDetail.status.awaitingAcceptance')
+ : t(`taskDetail.${statusMeta.labelKey}` as never)}
+ </Text>
</Block>
</TaskStatusTag>
diff --git a/src/features/AgentTasks/AgentTaskDetail/TopicCard.tsx b/src/features/AgentTasks/AgentTaskDetail/TopicCard.tsx
index 15053d5cdb6..a04babb837e 100644
--- a/src/features/AgentTasks/AgentTaskDetail/TopicCard.tsx
+++ b/src/features/AgentTasks/AgentTaskDetail/TopicCard.tsx
@@ -40,6 +40,7 @@ import RunVerifyTag from './RunVerifyTag';
import { shouldShowRunFollowUp } from './shouldShowRunFollowUp';
import TopicStatusIcon from './TopicStatusIcon';
import { resolveRunAgentId, useRunFollowUp } from './useRunFollowUp';
+import { useRunAcceptanceWait } from './useTaskAcceptanceWait';
// The run's last message (`content`) is the raw assistant output — markdown, and
// often long. Render it as rich text, but keep it a bounded preview in the feed:
@@ -94,6 +95,7 @@ const TopicCard = memo<TopicCardProps>(({ activity, defaultExpanded = true, prim
const { allowed: canEditTask } = usePermission('create_content');
const [commenting, setCommenting] = useState(false);
const isRunning = activity.status === 'running';
+ const acceptanceWait = useRunAcceptanceWait(activity);
// A run cannot be answered while it is still going: the follow-up is a turn
// in the same conversation, so it would land mid-run.
const showRunFollowUp = shouldShowRunFollowUp(canFollowUp, isRunning);
@@ -296,7 +298,12 @@ const TopicCard = memo<TopicCardProps>(({ activity, defaultExpanded = true, prim
) : (
avatarNode
)}
- <TopicStatusIcon size={16} status={activity.status} />
+ <TopicStatusIcon
+ size={16}
+ // The topic of a verify-bound run is `completed` while its task
+ // stays running until the acceptance round settles.
+ status={acceptanceWait ? 'awaiting_acceptance' : activity.status}
+ />
{activity.sourceTaskIdentifier && (
<Tag
size={'small'}
diff --git a/src/features/AgentTasks/AgentTaskDetail/TopicChatDrawer/index.tsx b/src/features/AgentTasks/AgentTaskDetail/TopicChatDrawer/index.tsx
index a015e8ef395..98010e71e66 100644
--- a/src/features/AgentTasks/AgentTaskDetail/TopicChatDrawer/index.tsx
+++ b/src/features/AgentTasks/AgentTaskDetail/TopicChatDrawer/index.tsx
@@ -51,6 +51,7 @@ import { isForbiddenError } from '@/utils/forbiddenError';
import AssigneeAvatar from '../../features/AssigneeAvatar';
import { useTopicDrawerArtifactPortal } from '../../hooks/useTopicDrawerArtifactPortal';
+import TaskAcceptanceWaitNotice from '../TaskAcceptanceWaitNotice';
import FeedbackInput from './FeedbackInput';
const SHARE_ICON_SIZE = { blockSize: 32, size: 16 } as const;
@@ -139,7 +140,13 @@ export const TopicChatDrawerBody = memo<TopicChatDrawerBodyProps>(
<Flexbox flex={1} style={{ minHeight: 0, overflow: 'hidden' }}>
<ChatList disableActionsBar itemContent={itemContent} />
</Flexbox>
- <Flexbox paddingBlock={'0 12px'} paddingInline={12} style={{ flexShrink: 0 }}>
+ <Flexbox gap={8} paddingBlock={'0 12px'} paddingInline={12} style={{ flexShrink: 0 }}>
+ {/* A run whose agent stopped but whose acceptance round has not
+ settled still reads as running; say what it waits on. */}
+ <TaskAcceptanceWaitNotice
+ activity={drawerActivity}
+ runningOperation={currentRunningOperation}
+ />
<FeedbackInput
defaultExpanded={defaultInputExpanded}
disableCollapse={disableInputCollapse}
diff --git a/src/features/AgentTasks/AgentTaskDetail/TopicStatusIcon.tsx b/src/features/AgentTasks/AgentTaskDetail/TopicStatusIcon.tsx
index 89dc046bc48..1d8a4a2d4bf 100644
--- a/src/features/AgentTasks/AgentTaskDetail/TopicStatusIcon.tsx
+++ b/src/features/AgentTasks/AgentTaskDetail/TopicStatusIcon.tsx
@@ -1,10 +1,11 @@
import { cssVar, Icon } from '@lobehub/ui';
-import { CircleAlert } from 'lucide-react';
+import { CircleAlert, Stamp } from 'lucide-react';
import { memo } from 'react';
import { EXECUTION_STATUS_VISUALS, type ExecutionStatusVisual } from '@/components/ExecutionStatus';
type TopicRunStatus =
+ | 'awaiting_acceptance'
| 'canceled'
| 'completed'
| 'device_offline'
@@ -16,6 +17,8 @@ type TopicRunStatus =
| 'transient_failed';
const STATIC_META: Record<Exclude<TopicRunStatus, 'running'>, ExecutionStatusVisual> = {
+ // The agent stopped; the run's acceptance round still has to settle.
+ awaiting_acceptance: { color: cssVar.colorWarning, icon: Stamp },
canceled: EXECUTION_STATUS_VISUALS.canceled,
completed: EXECUTION_STATUS_VISUALS.completed,
// The run's device was unavailable; it is retried, not failed.
diff --git a/src/features/AgentTasks/AgentTaskDetail/taskAcceptanceWait.test.ts b/src/features/AgentTasks/AgentTaskDetail/taskAcceptanceWait.test.ts
new file mode 100644
index 00000000000..ebc3f302b20
--- /dev/null
+++ b/src/features/AgentTasks/AgentTaskDetail/taskAcceptanceWait.test.ts
@@ -0,0 +1,238 @@
+import type { TaskDetailActivity } from '@lobechat/types';
+import { describe, expect, it } from 'vitest';
+
+import {
+ resolveRunAcceptanceWait,
+ resolveRunAcceptanceWaitInTask,
+ resolveTaskAcceptanceWait,
+} from './taskAcceptanceWait';
+
+type Topic = Pick<TaskDetailActivity, 'id' | 'runningOperation' | 'verify'>;
+
+const verify = (status: string | null, passed = 0, total = 0) => ({
+ acceptanceId: 'acc-1',
+ passed,
+ roundIndex: 9,
+ runId: 'run-1',
+ status,
+ total,
+});
+
+const liveOperation = { operationId: 'op-live' } as NonNullable<Topic['runningOperation']>;
+
+describe('resolveTaskAcceptanceWait', () => {
+ it('reports the repairing round of a running task whose agent has stopped', () => {
+ const topics: Topic[] = [
+ { id: 'tpc-1', runningOperation: null, verify: null },
+ { id: 'tpc-4', runningOperation: null, verify: verify('repairing', 2, 4) },
+ ];
+
+ expect(resolveTaskAcceptanceWait('running', topics)).toEqual({
+ acceptanceId: 'acc-1',
+ passed: 2,
+ phase: 'repairing',
+ roundIndex: 9,
+ topicId: 'tpc-4',
+ total: 4,
+ });
+ });
+
+ it('keeps an executing task as executing while any run holds a live operation', () => {
+ const topics: Topic[] = [
+ { id: 'tpc-4', runningOperation: null, verify: verify('repairing', 2, 4) },
+ { id: 'tpc-5', runningOperation: liveOperation, verify: null },
+ ];
+
+ expect(resolveTaskAcceptanceWait('running', topics)).toBeUndefined();
+ });
+
+ it('claims nothing for a task that is not running', () => {
+ const topics: Topic[] = [{ id: 'tpc-4', runningOperation: null, verify: verify('repairing') }];
+
+ expect(resolveTaskAcceptanceWait('paused', topics)).toBeUndefined();
+ expect(resolveTaskAcceptanceWait('completed', topics)).toBeUndefined();
+ });
+
+ it('claims nothing when no run is verify-bound', () => {
+ expect(
+ resolveTaskAcceptanceWait('running', [{ id: 'tpc-1', runningOperation: null, verify: null }]),
+ ).toBeUndefined();
+ });
+
+ it('follows the newest verify-bound run', () => {
+ const topics: Topic[] = [
+ { id: 'tpc-1', runningOperation: null, verify: verify('repairing', 1, 4) },
+ { id: 'tpc-2', runningOperation: null, verify: verify('delivered', 4, 4) },
+ ];
+
+ expect(resolveTaskAcceptanceWait('running', topics)).toMatchObject({
+ phase: 'awaitingReview',
+ topicId: 'tpc-2',
+ });
+ });
+});
+
+describe('resolveRunAcceptanceWait', () => {
+ it.each([
+ ['planned', 'awaitingEvidence'],
+ ['collecting_evidence', 'awaitingEvidence'],
+ [null, 'awaitingEvidence'],
+ ['verifying', 'verifying'],
+ ['repairing', 'repairing'],
+ ['delivered', 'awaitingReview'],
+ ] as const)('maps a %s round of an ended run to %s', (status, phase) => {
+ expect(
+ resolveRunAcceptanceWait({
+ id: 'tpc',
+ runningOperation: null,
+ status: 'completed',
+ verify: verify(status),
+ })?.phase,
+ ).toBe(phase);
+ });
+
+ it.each(['passed', 'failed', 'errored'])(
+ 'does not report a settled %s round as waiting',
+ (status) => {
+ expect(
+ resolveRunAcceptanceWait({
+ id: 'tpc',
+ runningOperation: null,
+ status: 'completed',
+ verify: verify(status),
+ }),
+ ).toBeUndefined();
+ },
+ );
+});
+
+describe('acceptance wait evidence and scope', () => {
+ it('does not read a run that has not delivered yet as waiting before its marker is written', () => {
+ const starting = {
+ id: 'tpc-5',
+ runningOperation: null,
+ status: 'running',
+ verify: verify(null),
+ };
+
+ expect(resolveRunAcceptanceWait(starting)).toBeUndefined();
+ expect(resolveTaskAcceptanceWait('running', [starting])).toBeUndefined();
+ });
+
+ it('reads an undelivered round as waiting once its run has ended', () => {
+ const ended = {
+ id: 'tpc-5',
+ runningOperation: null,
+ status: 'completed',
+ verify: verify(null),
+ };
+
+ expect(resolveRunAcceptanceWait(ended)?.phase).toBe('awaitingEvidence');
+ });
+
+ it("ignores a descendant task's runs when resolving the parent", () => {
+ const own = { id: 'tpc-1', runningOperation: null, verify: verify('repairing', 2, 4) };
+ const childWaiting = {
+ id: 'tpc-c1',
+ runningOperation: null,
+ sourceTaskId: 'task-child',
+ verify: verify('delivered', 4, 4),
+ };
+ const childLive = {
+ id: 'tpc-c2',
+ runningOperation: liveOperation,
+ sourceTaskId: 'task-child',
+ verify: null,
+ };
+
+ expect(
+ resolveTaskAcceptanceWait('running', [own, childWaiting, childLive], 'task-parent'),
+ ).toMatchObject({
+ phase: 'repairing',
+ topicId: 'tpc-1',
+ });
+ expect(
+ resolveTaskAcceptanceWait('running', [{ ...own, verify: null }, childWaiting], 'task-parent'),
+ ).toBeUndefined();
+ });
+});
+
+describe('resolveRunAcceptanceWaitInTask', () => {
+ // A verify-bound run's topic is `completed` while its task stays running.
+ const delivered = {
+ id: 'tpc-4',
+ runningOperation: null,
+ seq: 4,
+ status: 'completed',
+ type: 'topic' as const,
+ verify: verify('repairing', 2, 4),
+ };
+ const older = { ...delivered, id: 'tpc-3', seq: 3, verify: verify('failed', 1, 4) };
+
+ it('explains the completed run whose round holds the running task', () => {
+ const detail = { activities: [older, delivered], status: 'running' };
+
+ expect(resolveRunAcceptanceWaitInTask(detail, 'task-1', delivered)).toMatchObject({
+ phase: 'repairing',
+ topicId: 'tpc-4',
+ });
+ expect(resolveRunAcceptanceWaitInTask(detail, 'task-1', older)).toBeUndefined();
+ });
+
+ it('claims nothing once the task has left running', () => {
+ const detail = { activities: [delivered], status: 'paused' };
+
+ expect(resolveRunAcceptanceWaitInTask(detail, 'task-1', delivered)).toBeUndefined();
+ });
+
+ it("decides a descendant's run by that descendant's own status and runs", () => {
+ const childRun = { ...delivered, id: 'tpc-c1', seq: 1, sourceTaskId: 'task-child' };
+ const parentRun = { ...delivered, id: 'tpc-p9', seq: 9, verify: null };
+ const subtask = (status: string) => ({ id: 'task-child', identifier: 'T-2', status });
+
+ expect(
+ resolveRunAcceptanceWaitInTask(
+ { activities: [parentRun, childRun], status: 'running', subtasks: [subtask('running')] },
+ 'task-root',
+ childRun,
+ ),
+ ).toMatchObject({ topicId: 'tpc-c1' });
+ expect(
+ resolveRunAcceptanceWaitInTask(
+ { activities: [parentRun, childRun], status: 'running', subtasks: [subtask('completed')] },
+ 'task-root',
+ childRun,
+ ),
+ ).toBeUndefined();
+ });
+});
+
+describe('a rerun after a settled round', () => {
+ const failedRound = {
+ id: 'tpc-3',
+ runningOperation: null,
+ seq: 3,
+ status: 'completed',
+ verify: verify('failed', 1, 4),
+ };
+
+ it('reads a running task as executing while only the failed predecessor is listed', () => {
+ expect(resolveTaskAcceptanceWait('running', [failedRound])).toBeUndefined();
+ });
+
+ it('reads a running task as executing while its newer run is starting', () => {
+ const repairing = { ...failedRound, verify: verify('repairing', 2, 4) };
+ const starting = {
+ id: 'tpc-4',
+ runningOperation: null,
+ seq: 4,
+ status: 'running',
+ verify: null,
+ };
+
+ expect(resolveTaskAcceptanceWait('running', [repairing, starting])).toBeUndefined();
+ expect(
+ resolveTaskAcceptanceWait('running', [repairing, { ...starting, status: 'completed' }]),
+ ).toMatchObject({ phase: 'repairing', topicId: 'tpc-3' });
+ });
+});
diff --git a/src/features/AgentTasks/AgentTaskDetail/taskAcceptanceWait.ts b/src/features/AgentTasks/AgentTaskDetail/taskAcceptanceWait.ts
new file mode 100644
index 00000000000..4f9c4ece672
--- /dev/null
+++ b/src/features/AgentTasks/AgentTaskDetail/taskAcceptanceWait.ts
@@ -0,0 +1,163 @@
+import type {
+ TaskDetailActivity,
+ TaskDetailData,
+ TaskDetailSubtask,
+ TaskRunVerifySummary,
+} from '@lobechat/types';
+
+/**
+ * Where a run that has stopped executing is waiting inside its acceptance round.
+ *
+ * - `awaitingEvidence`: the round is planned but its evidence has not arrived.
+ * - `verifying`: the checks are being judged.
+ * - `repairing`: the round did not pass and a repair round has to deliver again.
+ * - `awaitingReview`: the round was delivered and waits for the person's review.
+ */
+export type TaskAcceptanceWaitPhase =
+ 'awaitingEvidence' | 'awaitingReview' | 'repairing' | 'verifying';
+
+export interface TaskAcceptanceWait {
+ acceptanceId: string | null;
+ passed: number;
+ phase: TaskAcceptanceWaitPhase;
+ roundIndex: number | null;
+ /** The run whose acceptance round holds the task. */
+ topicId?: string;
+ total: number;
+}
+
+const TERMINAL_RUN_STATUSES = new Set(['canceled', 'completed', 'failed', 'timeout']);
+
+type RunActivity = Pick<
+ TaskDetailActivity,
+ 'id' | 'runningOperation' | 'seq' | 'sourceTaskId' | 'status' | 'verify'
+>;
+
+const resolvePhase = (status: string | null): TaskAcceptanceWaitPhase | undefined => {
+ switch (status) {
+ case null:
+ case 'collecting_evidence':
+ case 'planned':
+ case 'unverified': {
+ return 'awaitingEvidence';
+ }
+ case 'running':
+ case 'verifying': {
+ return 'verifying';
+ }
+ case 'repairing': {
+ return 'repairing';
+ }
+ case 'delivered': {
+ return 'awaitingReview';
+ }
+ // A settled round moves the task on by itself: `passed` completes it, and
+ // `failed` / `errored` pause or complete it. A `running` task listing one
+ // as its newest round is starting its next run, so claim nothing; the same
+ // for any value we cannot explain.
+ default: {
+ return undefined;
+ }
+ }
+};
+
+/**
+ * The acceptance wait of one run whose agent has already stopped, if any.
+ *
+ * A run still holding a live operation is executing, whatever its round says.
+ * A missing operation marker alone is not proof the run stopped: it is written
+ * after the run starts. Phases past delivery only exist once the agent has
+ * delivered, but a round still awaiting evidence also needs the run itself to
+ * have reached a terminal status.
+ */
+export const resolveRunAcceptanceWait = (activity: RunActivity): TaskAcceptanceWait | undefined => {
+ if (activity.runningOperation) return undefined;
+ const verify: TaskRunVerifySummary | null | undefined = activity.verify;
+ if (!verify) return undefined;
+
+ const phase = resolvePhase(verify.status);
+ if (!phase) return undefined;
+ if (phase === 'awaitingEvidence' && !TERMINAL_RUN_STATUSES.has(activity.status ?? ''))
+ return undefined;
+
+ return {
+ acceptanceId: verify.acceptanceId,
+ passed: verify.passed,
+ phase,
+ roundIndex: verify.roundIndex,
+ topicId: activity.id,
+ total: verify.total,
+ };
+};
+
+/**
+ * Why a `running` task is not executing anything.
+ *
+ * A verify-bound run hands the completion decision to its acceptance round, so
+ * the task stays `running` after the agent has stopped. Rendering that as
+ * "in progress" hides the one thing the user can act on. Returns the round the
+ * task waits on, or `undefined` while any run is still executing (or the task
+ * is not `running`), so an executing task never reads as waiting.
+ *
+ * A parent's detail also lists its descendants' runs (`sourceTaskId`); only
+ * the task's own runs decide.
+ */
+export const resolveTaskAcceptanceWait = (
+ status: string | undefined,
+ allTopics: RunActivity[],
+ taskId?: string | null,
+ rootTaskId: string | null | undefined = taskId,
+): TaskAcceptanceWait | undefined => {
+ if (status !== 'running') return undefined;
+ // Root runs carry no `sourceTaskId`; `seq` restarts per task, so order only
+ // after keeping one task's runs.
+ const topics = allTopics
+ .filter((topic) => (topic.sourceTaskId ?? rootTaskId) === taskId)
+ .sort((a, b) => (a.seq ?? 0) - (b.seq ?? 0));
+ if (topics.some((topic) => topic.runningOperation)) return undefined;
+
+ // The newest round decides: an older round that is still open was superseded
+ // by the run after it. A newer run that has not ended is starting (its marker
+ // is not written yet), so the task is executing, not waiting.
+ const latestVerified = topics.findLast((topic) => topic.verify);
+ if (!latestVerified) return undefined;
+ const latest = topics.at(-1);
+ if (latest !== latestVerified && !TERMINAL_RUN_STATUSES.has(latest?.status ?? '')) {
+ return undefined;
+ }
+ return resolveRunAcceptanceWait(latestVerified);
+};
+
+const findSubtaskStatus = (
+ subtasks: TaskDetailSubtask[] | undefined,
+ taskId: string,
+): string | undefined => {
+ for (const subtask of subtasks ?? []) {
+ if (subtask.id === taskId) return subtask.status;
+ const nested = findSubtaskStatus(subtask.children, taskId);
+ if (nested) return nested;
+ }
+ return undefined;
+};
+
+/**
+ * The acceptance wait one run explains, if it is the round its owning task
+ * waits on.
+ *
+ * A verify-bound run's topic is marked `completed` while its task stays
+ * `running` until the round settles, so the run's own status cannot decide.
+ * The owner is the task in view, or the descendant named by `sourceTaskId`.
+ */
+export const resolveRunAcceptanceWaitInTask = (
+ detail: Pick<TaskDetailData, 'activities' | 'status' | 'subtasks'> | undefined,
+ rootTaskId: string | null | undefined,
+ run: Pick<TaskDetailActivity, 'id' | 'sourceTaskId'>,
+): TaskAcceptanceWait | undefined => {
+ if (!detail || !rootTaskId || !run.id) return undefined;
+ const ownerId = run.sourceTaskId ?? rootTaskId;
+ const ownerStatus =
+ ownerId === rootTaskId ? detail.status : findSubtaskStatus(detail.subtasks, ownerId);
+ const topics = (detail.activities ?? []).filter((activity) => activity.type === 'topic');
+ const wait = resolveTaskAcceptanceWait(ownerStatus, topics, ownerId, rootTaskId);
+ return wait?.topicId === run.id ? wait : undefined;
+};
diff --git a/src/features/AgentTasks/AgentTaskDetail/useTaskAcceptanceWait.ts b/src/features/AgentTasks/AgentTaskDetail/useTaskAcceptanceWait.ts
new file mode 100644
index 00000000000..26303e6cba2
--- /dev/null
+++ b/src/features/AgentTasks/AgentTaskDetail/useTaskAcceptanceWait.ts
@@ -0,0 +1,48 @@
+import type { TaskDetailActivity } from '@lobechat/types';
+import { useMemo } from 'react';
+
+import { useTaskStore } from '@/store/task';
+import { taskDetailSelectors } from '@/store/task/selectors';
+
+import {
+ resolveRunAcceptanceWaitInTask,
+ resolveTaskAcceptanceWait,
+ type TaskAcceptanceWait,
+} from './taskAcceptanceWait';
+
+/** The acceptance round the active `running` task waits on, if its agent has stopped. */
+export const useTaskAcceptanceWait = (): TaskAcceptanceWait | undefined => {
+ const taskId = useTaskStore(taskDetailSelectors.activeTaskId);
+ const status = useTaskStore(taskDetailSelectors.activeTaskStatus);
+ // The raw array keeps a stable reference between refreshes; the derived
+ // topic list would not.
+ const activities = useTaskStore((s) => taskDetailSelectors.activeTaskDetail(s)?.activities);
+
+ return useMemo(
+ () =>
+ resolveTaskAcceptanceWait(
+ status,
+ (activities ?? []).filter((activity) => activity.type === 'topic'),
+ taskId,
+ ),
+ [activities, status, taskId],
+ );
+};
+
+/** The acceptance round one run holds its owning task in, if any. */
+export const useRunAcceptanceWait = (
+ run: Pick<TaskDetailActivity, 'id' | 'sourceTaskId'> | undefined,
+): TaskAcceptanceWait | undefined => {
+ const taskId = useTaskStore(taskDetailSelectors.activeTaskId);
+ const detail = useTaskStore(taskDetailSelectors.activeTaskDetail);
+ const runId = run?.id;
+ const sourceTaskId = run?.sourceTaskId;
+
+ return useMemo(
+ () =>
+ runId
+ ? resolveRunAcceptanceWaitInTask(detail, taskId, { id: runId, sourceTaskId })
+ : undefined,
+ [detail, runId, sourceTaskId, taskId],
+ );
+};