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): let users remove a task's delivery acceptance (#17895)

Arvin Xu78f132768690
diff --git a/locales/en-US/chat.json b/locales/en-US/chat.json
index fa6b72c2ed3..8a70445811e 100644
--- a/locales/en-US/chat.json
+++ b/locales/en-US/chat.json
@@ -1196,6 +1196,10 @@
"taskDetail.acceptance.loadError": "Could not load delivery acceptance.",
"taskDetail.acceptance.multimodalLlm": "Multimodal LLM",
"taskDetail.acceptance.openReport": "Acceptance report",
+ "taskDetail.acceptance.remove": "Remove acceptance",
+ "taskDetail.acceptance.removeConfirm.content": "This removes the task's acceptance goal, checklist, and recorded acceptance results. Task artifacts are unaffected.",
+ "taskDetail.acceptance.removeConfirm.ok": "Remove",
+ "taskDetail.acceptance.removeConfirm.title": "Remove delivery acceptance?",
"taskDetail.acceptance.requiredEvidence": "Required evidence",
"taskDetail.acceptance.retry": "Retry",
"taskDetail.acceptance.reviewError": "Could not save this review.",
@@ -1647,6 +1651,7 @@
"verifyConfig.generateFailed": "Failed to generate acceptance plan",
"verifyConfig.generating": "Breaking down acceptance criteria…",
"verifyConfig.manualAdd": "Add manually",
+ "verifyConfig.moreActions": "More actions",
"verifyConfig.optional": "Optional",
"verifyConfig.regenerate": "Regenerate",
"verifyConfig.removeCriterion": "Remove criterion",
diff --git a/locales/zh-CN/chat.json b/locales/zh-CN/chat.json
index 5b0e31724ec..d431fe91ad5 100644
--- a/locales/zh-CN/chat.json
+++ b/locales/zh-CN/chat.json
@@ -1196,6 +1196,10 @@
"taskDetail.acceptance.loadError": "交付验收加载失败。",
"taskDetail.acceptance.multimodalLlm": "多模态 LLM",
"taskDetail.acceptance.openReport": "验收报告",
+ "taskDetail.acceptance.remove": "移除验收",
+ "taskDetail.acceptance.removeConfirm.content": "将移除该任务的验收目标、验收清单及已有的验收记录,任务产物不受影响。",
+ "taskDetail.acceptance.removeConfirm.ok": "移除",
+ "taskDetail.acceptance.removeConfirm.title": "移除交付验收?",
"taskDetail.acceptance.requiredEvidence": "所需证据",
"taskDetail.acceptance.retry": "重试",
"taskDetail.acceptance.reviewError": "复核结果保存失败。",
@@ -1647,6 +1651,7 @@
"verifyConfig.generateFailed": "生成验收方案失败",
"verifyConfig.generating": "正在拆解验收项…",
"verifyConfig.manualAdd": "手动添加",
+ "verifyConfig.moreActions": "更多操作",
"verifyConfig.optional": "可选",
"verifyConfig.regenerate": "重新生成",
"verifyConfig.removeCriterion": "删除验收项",
diff --git a/packages/locales/src/default/chat.ts b/packages/locales/src/default/chat.ts
index 80ff56e53b0..b329e8f9587 100644
--- a/packages/locales/src/default/chat.ts
+++ b/packages/locales/src/default/chat.ts
@@ -1273,6 +1273,11 @@ export default {
'taskDetail.acceptance.loadError': 'Could not load delivery acceptance.',
'taskDetail.acceptance.multimodalLlm': 'Multimodal LLM',
'taskDetail.acceptance.openReport': 'Acceptance report',
+ 'taskDetail.acceptance.remove': 'Remove acceptance',
+ 'taskDetail.acceptance.removeConfirm.content':
+ "This removes the task's acceptance goal, checklist, and recorded acceptance results. Task artifacts are unaffected.",
+ 'taskDetail.acceptance.removeConfirm.ok': 'Remove',
+ 'taskDetail.acceptance.removeConfirm.title': 'Remove delivery acceptance?',
'taskDetail.acceptance.retry': 'Retry',
'taskDetail.acceptance.requiredEvidence': 'Required evidence',
'taskDetail.acceptance.reviewError': 'Could not save this review.',
@@ -2204,6 +2209,7 @@ export default {
'verifyConfig.generateFailed': 'Failed to generate acceptance plan',
'verifyConfig.generating': 'Breaking down acceptance criteria…',
'verifyConfig.manualAdd': 'Add manually',
+ 'verifyConfig.moreActions': 'More actions',
'verifyConfig.optional': 'Optional',
'verifyConfig.regenerate': 'Regenerate',
'verifyConfig.removeCriterion': 'Remove criterion',
diff --git a/src/features/AgentTasks/AgentTaskDetail/TaskAcceptance.test.tsx b/src/features/AgentTasks/AgentTaskDetail/TaskAcceptance.test.tsx
index c0dc78bc9bb..0a84634c97d 100644
--- a/src/features/AgentTasks/AgentTaskDetail/TaskAcceptance.test.tsx
+++ b/src/features/AgentTasks/AgentTaskDetail/TaskAcceptance.test.tsx
@@ -27,6 +27,8 @@ const mocks = vi.hoisted(() => ({
isOwner: boolean;
},
currentPortalView: null as null | string,
+ confirmModal: vi.fn(),
+ deleteAcceptance: vi.fn(),
mutateBundle: vi.fn(),
mutateSubject: vi.fn(),
navigate: vi.fn(),
@@ -34,6 +36,7 @@ const mocks = vi.hoisted(() => ({
openAcceptanceCheck: vi.fn(),
subjectArgs: [] as unknown[],
toggleTaskAgentPanel: vi.fn(),
+ updateVerifyConfig: vi.fn(),
}));
vi.mock('@lobehub/ui', () => ({
@@ -61,6 +64,7 @@ vi.mock('@lobehub/ui/base-ui', () => ({
{children}
</button>
),
+ confirmModal: (opts: unknown) => mocks.confirmModal(opts),
}));
vi.mock('@/features/Workspace/useWorkspaceAwareNavigate', () => ({
@@ -124,8 +128,15 @@ vi.mock('@/features/Verify', () => ({
},
}));
+vi.mock('@/hooks/usePermission', () => ({
+ usePermission: () => ({ allowed: true }),
+}));
+
vi.mock('@/services/verify', () => ({
- verifyService: { reviewChecks: vi.fn() },
+ verifyService: {
+ deleteAcceptance: (id: string) => mocks.deleteAcceptance(id),
+ reviewChecks: vi.fn(),
+ },
}));
vi.mock('@/store/chat', () => ({
@@ -149,13 +160,17 @@ vi.mock('@/store/global', () => ({
selector({ toggleTaskAgentPanel: mocks.toggleTaskAgentPanel }),
}));
-vi.mock('@/store/task', () => ({
- useTaskStore: (selector: (state: Record<string, unknown>) => unknown) =>
+vi.mock('@/store/task', () => {
+ const useTaskStore = (selector: (state: Record<string, unknown>) => unknown) =>
selector({
activeTaskId: 'T-231',
taskDetailMap: { 'T-231': { id: 'task-database-231', identifier: 'T-231' } },
- }),
-}));
+ });
+ useTaskStore.getState = () => ({
+ updateVerifyConfig: mocks.updateVerifyConfig,
+ });
+ return { useTaskStore };
+});
vi.mock('../shared/AccordionArrowIcon', () => ({ default: () => <span>arrow</span> }));
vi.mock('./TaskVerifyConfig', () => ({
@@ -276,6 +291,70 @@ describe('TaskAcceptance', () => {
expect(screen.getByText('Check 11')).toBeInTheDocument();
});
+ it('removes the acceptance and clears the task verify config from the header delete button', async () => {
+ 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 />);
+
+ fireEvent.click(screen.getByText('taskDetail.acceptance.remove'));
+ expect(mocks.confirmModal).toHaveBeenCalledTimes(1);
+ expect(mocks.deleteAcceptance).not.toHaveBeenCalled();
+
+ const opts = mocks.confirmModal.mock.calls[0][0] as { onOk: () => Promise<void> };
+ await opts.onOk();
+
+ expect(mocks.deleteAcceptance).toHaveBeenCalledWith('acceptance-1');
+ expect(mocks.updateVerifyConfig).toHaveBeenCalledWith('T-231', {
+ enabled: false,
+ requirement: null,
+ verifyCriteriaIds: null,
+ });
+ // Config clears BEFORE the aggregate is deleted: the inverse order could
+ // destroy the record and then fail, leaving a stale config to recreate it.
+ expect(mocks.updateVerifyConfig.mock.invocationCallOrder[0]).toBeLessThan(
+ mocks.deleteAcceptance.mock.invocationCallOrder[0],
+ );
+ expect(mocks.mutateSubject).toHaveBeenCalled();
+ });
+
+ it('aborts removal without deleting the aggregate when the config clear fails', async () => {
+ 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,
+ };
+ mocks.updateVerifyConfig.mockRejectedValueOnce(new Error('config write failed'));
+
+ render(<TaskAcceptance />);
+
+ fireEvent.click(screen.getByText('taskDetail.acceptance.remove'));
+ const opts = mocks.confirmModal.mock.calls[0][0] as { onOk: () => Promise<void> };
+ await expect(opts.onOk()).rejects.toThrow('config write failed');
+
+ expect(mocks.deleteAcceptance).not.toHaveBeenCalled();
+ expect(mocks.mutateSubject).not.toHaveBeenCalled();
+ });
+
+ it('hides the remove button when the viewer does not own the acceptance', () => {
+ 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: false,
+ };
+
+ render(<TaskAcceptance />);
+
+ expect(screen.getByText('Create task')).toBeInTheDocument();
+ expect(screen.queryByText('taskDetail.acceptance.remove')).not.toBeInTheDocument();
+ });
+
it('keeps the Acceptance cross-round union visible in Task detail', () => {
mocks.acceptanceSubject = { id: 'acceptance-1' };
mocks.bundle = {
diff --git a/src/features/AgentTasks/AgentTaskDetail/TaskAcceptance.tsx b/src/features/AgentTasks/AgentTaskDetail/TaskAcceptance.tsx
index a9015033371..21ac6f4c174 100644
--- a/src/features/AgentTasks/AgentTaskDetail/TaskAcceptance.tsx
+++ b/src/features/AgentTasks/AgentTaskDetail/TaskAcceptance.tsx
@@ -1,7 +1,7 @@
'use client';
import { ActionIcon, Block, Flexbox, Icon, Text } from '@lobehub/ui';
-import { Button } from '@lobehub/ui/base-ui';
+import { Button, confirmModal } from '@lobehub/ui/base-ui';
import { createStaticStyles, cssVar } from 'antd-style';
import {
ChevronRight,
@@ -9,6 +9,7 @@ import {
ChevronsUpDown,
ExternalLink,
RotateCcw,
+ Trash,
} from 'lucide-react';
import { memo, useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next';
@@ -22,6 +23,8 @@ import {
useAcceptanceBundle,
useAcceptanceBySubject,
} from '@/features/Verify';
+import { usePermission } from '@/hooks/usePermission';
+import { verifyService } from '@/services/verify';
import { useChatStore } from '@/store/chat';
import { useGlobalStore } from '@/store/global';
import { useTaskStore } from '@/store/task';
@@ -135,6 +138,8 @@ const TaskAcceptance = memo(() => {
const openAcceptance = useChatStore((state) => state.openAcceptance);
const openAcceptanceCheck = useChatStore((state) => state.openAcceptanceCheck);
const showTaskAgentPanel = useGlobalStore((state) => state.toggleTaskAgentPanel);
+ const { allowed: canEditTask } = usePermission('create_content');
+ const taskId = useTaskStore(taskDetailSelectors.activeTaskId);
const taskDatabaseId = useTaskStore(taskDetailSelectors.activeTaskDatabaseId);
const verify = useTaskStore(taskDetailSelectors.activeTaskVerifyConfig);
const [sectionExpanded, setSectionExpanded] = useState(true);
@@ -188,6 +193,36 @@ const TaskAcceptance = memo(() => {
// replace the definitions with their live/result projection below.
if (!acceptanceSubject && !subjectError) return <TaskVerifyConfig />;
+ // Removing the acceptance drops the aggregate (round reports detach) AND
+ // clears the task's verify config — otherwise the section would fall back to
+ // the configured-criteria view and the next run would recreate the aggregate.
+ // Ordering makes the two writes safe without a server transaction: the config
+ // is cleared FIRST (a failure aborts before anything is destroyed), and only
+ // then is the aggregate deleted (a failure there leaves it intact for retry).
+ // The inverse order could delete the record while the stale config survives
+ // to recreate it on the next run.
+ const handleRemoveAcceptance = () => {
+ if (!acceptanceSubject || !taskId) return;
+ confirmModal({
+ content: t('taskDetail.acceptance.removeConfirm.content'),
+ okButtonProps: { danger: true },
+ okText: t('taskDetail.acceptance.removeConfirm.ok'),
+ onOk: async () => {
+ await useTaskStore.getState().updateVerifyConfig(taskId, {
+ enabled: false,
+ requirement: null,
+ verifyCriteriaIds: null,
+ });
+ await verifyService.deleteAcceptance(acceptanceSubject.id);
+ await mutateSubject();
+ },
+ title: t('taskDetail.acceptance.removeConfirm.title'),
+ });
+ };
+
+ // `acceptance.remove` only authorizes the acceptance creator (or a workspace
+ // owner, cloud-side), not everyone who can edit the task — so the affordance
+ // follows the bundle's isOwner rather than dead-ending in FORBIDDEN.
const header = (
<TaskAcceptanceHeader
count={checks.length}
@@ -197,14 +232,24 @@ const TaskAcceptance = memo(() => {
isOpen={sectionExpanded}
extra={
acceptanceSubject && (
- <Button
- icon={<Icon icon={ExternalLink} />}
- size={'small'}
- type={'text'}
- onClick={() => openReport(acceptanceSubject.id)}
- >
- {t('taskDetail.acceptance.openReport')}
- </Button>
+ <Flexbox horizontal align={'center'} gap={4}>
+ <Button
+ icon={<Icon icon={ExternalLink} />}
+ size={'small'}
+ type={'text'}
+ onClick={() => openReport(acceptanceSubject.id)}
+ >
+ {t('taskDetail.acceptance.openReport')}
+ </Button>
+ {canEditTask && bundle?.isOwner && (
+ <ActionIcon
+ icon={Trash}
+ size={'small'}
+ title={t('taskDetail.acceptance.remove')}
+ onClick={handleRemoveAcceptance}
+ />
+ )}
+ </Flexbox>
)
}
onToggle={() => setSectionExpanded((expanded) => !expanded)}
diff --git a/src/features/AgentTasks/AgentTaskDetail/TaskVerifyConfig.tsx b/src/features/AgentTasks/AgentTaskDetail/TaskVerifyConfig.tsx
index 72c9a251edf..5488064ed23 100644
--- a/src/features/AgentTasks/AgentTaskDetail/TaskVerifyConfig.tsx
+++ b/src/features/AgentTasks/AgentTaskDetail/TaskVerifyConfig.tsx
@@ -1,23 +1,21 @@
'use client';
+import { ActionIcon, Block, Flexbox, Icon, SortableList, Tag, Text, TextArea } from '@lobehub/ui';
import {
- ActionIcon,
- Block,
+ Button,
+ confirmModal,
+ Drawer,
type DropdownItem,
DropdownMenu,
- Flexbox,
- Icon,
- SortableList,
- Tag,
- Text,
- TextArea,
-} from '@lobehub/ui';
-import { Button, Checkbox, Drawer, Select, toast } from '@lobehub/ui/base-ui';
+ Select,
+ toast,
+} from '@lobehub/ui/base-ui';
import { createStaticStyles, cssVar } from 'antd-style';
import {
ChevronRight,
ChevronUp,
MoreHorizontal,
+ Pencil,
Plus,
RotateCcw,
ShieldCheck,
@@ -388,6 +386,22 @@ const TaskVerifyConfig = memo(() => {
[drafts, commit],
);
+ // One-click teardown of the whole acceptance config; collapses back to the
+ // "+" trigger instead of leaving an empty editor open.
+ const handleRemoveAll = useCallback(() => {
+ confirmModal({
+ content: t('taskDetail.acceptance.removeConfirm.content'),
+ okButtonProps: { danger: true },
+ okText: t('taskDetail.acceptance.removeConfirm.ok'),
+ onOk: () => {
+ setEditing(false);
+ setExpanded(false);
+ commit([], { enabled: false, requirement: '' });
+ },
+ title: t('taskDetail.acceptance.removeConfirm.title'),
+ });
+ }, [commit, t]);
+
// New criteria are authored in the detail modal, not via an inline empty row —
// so a half-typed criterion never leaks into the read-only preview.
const handleManualAdd = useCallback(() => {
@@ -623,6 +637,32 @@ const TaskVerifyConfig = memo(() => {
// ---- C. configured ----
const requirementText = requirement.trim();
+ // Reviewer contract: the configured header exposes ONE overflow trigger; enable,
+ // edit, and remove all live inside it so the title row stays a single affordance.
+ const headerMenuItems: DropdownItem[] = [
+ {
+ checked: enabled,
+ key: 'enabled',
+ label: t('verifyConfig.enable'),
+ onCheckedChange: handleToggleEnabled,
+ type: 'checkbox',
+ },
+ {
+ icon: <Icon icon={Pencil} />,
+ key: 'edit',
+ label: t('verifyConfig.edit'),
+ onClick: () => setEditing(true),
+ },
+ { type: 'divider' },
+ {
+ danger: true,
+ icon: <Icon icon={Trash} />,
+ key: 'remove',
+ label: t('taskDetail.acceptance.remove'),
+ onClick: handleRemoveAll,
+ },
+ ];
+
// Title + verifier/required tags — the shared meta shown in both preview and edit rows.
const renderCriterionMeta = (item: DraftItem) => (
<>
@@ -643,17 +683,21 @@ const TaskVerifyConfig = memo(() => {
controls stay on the right without changing the information hierarchy. */}
<Flexbox horizontal align={'center'} justify={'space-between'}>
<TaskAcceptanceHeader isOpen count={drafts.length} onToggle={() => setExpanded(false)} />
- <Flexbox horizontal align={'center'} gap={4}>
- <Checkbox
- aria-label={t('verifyConfig.enable')}
- checked={enabled}
- size={16}
- onChange={handleToggleEnabled}
- />
- <Button size={'small'} type={'text'} onClick={() => setEditing((v) => !v)}>
- {editing ? t('verifyConfig.done') : t('verifyConfig.edit')}
+ {editing ? (
+ // Editing is a mode, not a menu action — finishing it stays a visible
+ // button instead of hiding the only exit inside the overflow.
+ <Button size={'small'} type={'text'} onClick={() => setEditing(false)}>
+ {t('verifyConfig.done')}
</Button>
- </Flexbox>
+ ) : (
+ <DropdownMenu items={headerMenuItems} placement={'bottomRight'}>
+ <ActionIcon
+ icon={MoreHorizontal}
+ size={'small'}
+ title={t('verifyConfig.moreActions')}
+ />
+ </DropdownMenu>
+ )}
</Flexbox>
{/* requirement: read-only sentence by default; TextArea + regenerate in edit mode */}
diff --git a/src/store/task/slices/config/action.ts b/src/store/task/slices/config/action.ts
index cd41425710c..ee6cd9756fe 100644
--- a/src/store/task/slices/config/action.ts
+++ b/src/store/task/slices/config/action.ts
@@ -130,6 +130,9 @@ export class TaskConfigSliceActionImpl {
} catch (error) {
console.error('[TaskStore] Failed to update verify config:', error);
await this.#get().internal_refreshTaskDetail(id);
+ // Rethrow so multi-step callers (e.g. acceptance removal) can abort
+ // instead of proceeding as if the config write landed.
+ throw error;
}
};