🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
✨ feat(acceptance): batch move the list's multi-selection into a project (#18987)
Arvin Xu8f274231d688
diff --git a/apps/server/src/routers/lambda/_helpers/acceptanceWriteScope.test.ts b/apps/server/src/routers/lambda/_helpers/acceptanceWriteScope.test.tsindex 4bc3f1178af..87a7891e09b 100644--- a/apps/server/src/routers/lambda/_helpers/acceptanceWriteScope.test.ts+++ b/apps/server/src/routers/lambda/_helpers/acceptanceWriteScope.test.ts@@ -1,7 +1,7 @@// @vitest-environment nodeimport { beforeEach, describe, expect, it, vi } from 'vitest';-import { canManageAcceptance } from './acceptanceWriteScope';+import { canManageAcceptance, filterManageableAcceptances } from './acceptanceWriteScope';const getMember = vi.hoisted(() => vi.fn());@@ -21,9 +21,9 @@ beforeEach(() => {describe('canManageAcceptance', () => {it('always lets the creator write, without a membership lookup', async () => {- await expect(canManageAcceptance({ serverDB: db, userId: 'me' }, row('me', 'ws_a'))).resolves.toBe(- true,- );+ await expect(+ canManageAcceptance({ serverDB: db, userId: 'me' }, row('me', 'ws_a')),+ ).resolves.toBe(true);expect(getMember).not.toHaveBeenCalled();});@@ -62,7 +62,53 @@ describe('canManageAcceptance', () => {});it('refuses an anonymous caller', async () => {- await expect(canManageAcceptance({ serverDB: db }, row('teammate', 'ws_a'))).resolves.toBe(false);+ await expect(canManageAcceptance({ serverDB: db }, row('teammate', 'ws_a'))).resolves.toBe(+ false,+ );+ expect(getMember).not.toHaveBeenCalled();+ });+});++describe('filterManageableAcceptances', () => {+ it('applies the same rule as the single-row check', async () => {+ getMember.mockImplementation(async (workspaceId: string) =>+ workspaceId === 'ws_owned' ? { role: 'owner' } : { role: 'member' },+ );++ const rows = [+ row('me', null),+ row('me', 'ws_member'),+ row('teammate', 'ws_owned'),+ row('teammate', 'ws_member'),+ row('teammate', null),+ ];+ await expect(+ filterManageableAcceptances({ serverDB: db, userId: 'me' }, rows),+ ).resolves.toEqual([row('me', null), row('me', 'ws_member'), row('teammate', 'ws_owned')]);+ });++ it('looks membership up once per distinct workspace, not once per row', async () => {+ getMember.mockResolvedValue({ role: 'owner' });++ const rows = [+ row('teammate', 'ws_a'),+ row('teammate', 'ws_a'),+ row('teammate', 'ws_a'),+ row('teammate', 'ws_b'),+ // Creator rows and personal rows need no lookup at all.+ row('me', 'ws_c'),+ row('teammate', null),+ ];+ await expect(+ filterManageableAcceptances({ serverDB: db, userId: 'me' }, rows),+ ).resolves.toHaveLength(5);+ expect(getMember).toHaveBeenCalledTimes(2);+ });++ it('returns nothing for an anonymous caller', async () => {+ await expect(filterManageableAcceptances({ serverDB: db }, [row('me', null)])).resolves.toEqual(+ [],+ );expect(getMember).not.toHaveBeenCalled();});});diff --git a/apps/server/src/routers/lambda/_helpers/acceptanceWriteScope.ts b/apps/server/src/routers/lambda/_helpers/acceptanceWriteScope.tsindex cc3ce5b1805..bcb2a1ae9fe 100644--- a/apps/server/src/routers/lambda/_helpers/acceptanceWriteScope.ts+++ b/apps/server/src/routers/lambda/_helpers/acceptanceWriteScope.ts@@ -31,3 +31,35 @@ export async function canManageAcceptance();return member?.role === 'owner';}++/**+ * Batch twin of {@link canManageAcceptance} for sweep endpoints: same rule,+ * but ONE membership lookup per distinct workspace instead of one per row —+ * a 200-row sweep must not turn authorization into 200 serial queries.+ */+export async function filterManageableAcceptances<+ T extends Pick<AcceptanceItem, 'userId' | 'workspaceId'>,+>(ctx: AcceptanceScopeCtx, rows: T[]): Promise<T[]> {+ if (!ctx.userId) return [];+ const userId = ctx.userId;++ const foreignWorkspaceIds = [+ ...new Set(+ rows+ .filter((row) => row.userId !== userId && row.workspaceId)+ .map((row) => row.workspaceId as string),+ ),+ ];+ const owned = new Set<string>();+ for (const workspaceId of foreignWorkspaceIds) {+ const member = await new WorkspaceMemberModel(ctx.serverDB, userId).getMember(+ workspaceId,+ userId,+ );+ if (member?.role === 'owner') owned.add(workspaceId);+ }++ return rows.filter(+ (row) => row.userId === userId || (row.workspaceId ? owned.has(row.workspaceId) : false),+ );+}diff --git a/apps/server/src/routers/lambda/acceptance.ts b/apps/server/src/routers/lambda/acceptance.tsindex 86a45cdc386..e052e844e5b 100644--- a/apps/server/src/routers/lambda/acceptance.ts+++ b/apps/server/src/routers/lambda/acceptance.ts@@ -8,7 +8,7 @@ import {} from '@lobechat/const/verify';import type { AcceptanceAttachment } from '@lobechat/types';import { TRPCError } from '@trpc/server';-import { eq } from 'drizzle-orm';+import { eq, inArray } from 'drizzle-orm';import { z } from 'zod';import {@@ -40,7 +40,7 @@ import {} from '@/server/services/verify';import { after } from '@/server/utils/scheduleAfterResponse';-import { canManageAcceptance } from './_helpers/acceptanceWriteScope';+import { canManageAcceptance, filterManageableAcceptances } from './_helpers/acceptanceWriteScope';import { assertWorkspaceRowManageable } from './_helpers/assertWorkspaceRowManageable';const subjectTypeSchema = z.enum(acceptanceSubjectTypes);@@ -1020,6 +1020,65 @@ export const acceptanceRouter = router({return { success: true };}),+ /**+ * The multi-select twin of `setProject`: file a whole selection under one+ * project (or take it out of any) in one action.+ *+ * The target project is validated ONCE, up front — a missing project fails+ * the sweep wholesale, because every row was headed to the same place. Rows+ * keep the batch contract — one the caller cannot write lands in `failedIds`+ * instead of voiding the rest — but unlike the status sweep there is no+ * per-row recomputation, so the whole move is three bounded queries (resolve,+ * authorize, bulk update) rather than a round trip per row.+ */+ setProjectBatch: acceptanceWriteProcedure+ .input(+ z.object({+ ids: z.array(z.string()).min(1).max(ACCEPTANCE_BATCH_LIMIT),+ projectId: z.string().nullable(),+ }),+ )+ .mutation(async ({ ctx, input }) => {+ if (input.projectId) {+ const project = await new ProjectModel(+ ctx.serverDB,+ ctx.userId,+ ctx.workspaceId ?? undefined,+ ).findById(input.projectId);+ if (!project) throw new TRPCError({ code: 'NOT_FOUND', message: 'Project not found' });+ }++ const ids = [...new Set(input.ids)];+ const resolvableIds = ids.filter((id) => isUuid(id));+ const rows =+ resolvableIds.length > 0+ ? await ctx.serverDB.query.acceptances.findMany({+ columns: { id: true, userId: true, workspaceId: true },+ where: inArray(acceptances.id, resolvableIds),+ })+ : [];+ const manageable = await filterManageableAcceptances(ctx, rows);++ let updatedIds: string[] = [];+ if (manageable.length > 0) {+ updatedIds = (+ await ctx.serverDB+ .update(acceptances)+ .set({ projectId: input.projectId })+ .where(+ inArray(+ acceptances.id,+ manageable.map((row) => row.id),+ ),+ )+ .returning({ id: acceptances.id })+ ).map((row) => row.id);+ }++ const updatedSet = new Set(updatedIds);+ return { failedIds: ids.filter((id) => !updatedSet.has(id)), updated: updatedIds.length };+ }),+/*** Manually move the acceptance's user-facing lifecycle state from the list —* an owner override (mark accepted / closed / rejected, or reopen for another look).diff --git a/locales/en-US/verify.json b/locales/en-US/verify.jsonindex 7499f7d5ff0..f76a00fe1b7 100644--- a/locales/en-US/verify.json+++ b/locales/en-US/verify.json@@ -272,7 +272,10 @@"acceptance.workspace.batch.enter": "Select multiple","acceptance.workspace.batch.error": "The batch action failed. Try again.","acceptance.workspace.batch.exit": "Done",+ "acceptance.workspace.batch.move": "Move to","acceptance.workspace.batch.partial": "{{count}} updated, {{failed}} unchanged",+ "acceptance.workspace.batch.projectRemoveSuccess": "{{count}} acceptance(s) removed from their projects",+ "acceptance.workspace.batch.projectSuccess": "{{count}} acceptance(s) moved to the project","acceptance.workspace.batch.selectAll": "Select all","acceptance.workspace.batch.selected": "{{count}} selected","acceptance.workspace.batch.statusSuccess": "{{count}} acceptance(s) updated",diff --git a/locales/zh-CN/verify.json b/locales/zh-CN/verify.jsonindex 8661cc28e44..c6fb4e45dd8 100644--- a/locales/zh-CN/verify.json+++ b/locales/zh-CN/verify.json@@ -272,7 +272,10 @@"acceptance.workspace.batch.enter": "多选","acceptance.workspace.batch.error": "批量操作失败,请重试","acceptance.workspace.batch.exit": "完成",+ "acceptance.workspace.batch.move": "移动到","acceptance.workspace.batch.partial": "已更新 {{count}} 项,{{failed}} 项未变更",+ "acceptance.workspace.batch.projectRemoveSuccess": "已将 {{count}} 项验收移出项目",+ "acceptance.workspace.batch.projectSuccess": "已将 {{count}} 项验收移入项目","acceptance.workspace.batch.selectAll": "全选","acceptance.workspace.batch.selected": "已选 {{count}} 项","acceptance.workspace.batch.statusSuccess": "已更新 {{count}} 项验收",diff --git a/packages/locales/src/default/verify.ts b/packages/locales/src/default/verify.tsindex b91ea76cc16..6647b12f3a6 100644--- a/packages/locales/src/default/verify.ts+++ b/packages/locales/src/default/verify.ts@@ -310,7 +310,11 @@ export default {'acceptance.workspace.batch.enter': 'Select multiple','acceptance.workspace.batch.error': 'The batch action failed. Try again.','acceptance.workspace.batch.exit': 'Done',+ 'acceptance.workspace.batch.move': 'Move to','acceptance.workspace.batch.partial': '{{count}} updated, {{failed}} unchanged',+ 'acceptance.workspace.batch.projectRemoveSuccess':+ '{{count}} acceptance(s) removed from their projects',+ 'acceptance.workspace.batch.projectSuccess': '{{count}} acceptance(s) moved to the project','acceptance.workspace.batch.selectAll': 'Select all','acceptance.workspace.batch.selected': '{{count}} selected','acceptance.workspace.batch.statusSuccess': '{{count}} acceptance(s) updated',diff --git a/src/features/Acceptance/Workspace/AcceptanceBatchBar.tsx b/src/features/Acceptance/Workspace/AcceptanceBatchBar.tsxindex 2e5578a72f8..255509c312b 100644--- a/src/features/Acceptance/Workspace/AcceptanceBatchBar.tsx+++ b/src/features/Acceptance/Workspace/AcceptanceBatchBar.tsx@@ -1,12 +1,14 @@'use client';import { Flexbox } from '@lobehub/ui';-import { ActionIcon, Button } from '@lobehub/ui/base-ui';+import { ActionIcon, Button, DropdownMenu } from '@lobehub/ui/base-ui';import { createStaticStyles, cssVar } from 'antd-style';-import { CircleCheck, Trash2, X } from 'lucide-react';+import { CircleCheck, FolderInput, Trash2, X } from 'lucide-react';import { memo } from 'react';import { useTranslation } from 'react-i18next';+import { useAcceptanceProjectMenu } from './useAcceptanceProjectMenuItem';+const styles = createStaticStyles(({ css }) => ({bar: css`flex: none;@@ -22,11 +24,15 @@ const styles = createStaticStyles(({ css }) => ({interface AcceptanceBatchBarProps {/** Selected rows the accept sweep can actually move. */acceptCount: number;+ /** Whether any selected row is filed under a project, so "remove" has work. */+ canRemoveProject: boolean;/** Selected rows the close sweep can actually move. */closeCount: number;onAccept: () => void;onClose: () => void;onDelete: () => void;+ /** `null` takes the selection out of its projects. */+ onMoveToProject: (projectId: string | null) => void;pending: boolean;}@@ -35,12 +41,28 @@ interface AcceptanceBatchBarProps {** Each status action is disabled when nothing in the selection can take it —* an already-accepted delivery cannot be accepted again — so a live button is- * always a button that will change something. Delete stays an icon: it is the- * destructive one and must not read as a peer of the two routine sweeps.+ * always a button that will change something. The move action opens the same+ * project menu a single row offers; which rows a given project can actually+ * move is only known once a target is picked, so the button itself only waits+ * on the selection. Move and delete stay icons: the bar lives in a panel that+ * narrows to 260px, and a third labeled button would spill out of it.*/const AcceptanceBatchBar = memo<AcceptanceBatchBarProps>(- ({ acceptCount, closeCount, onAccept, onClose, onDelete, pending }) => {+ ({+ acceptCount,+ canRemoveProject,+ closeCount,+ onAccept,+ onClose,+ onDelete,+ onMoveToProject,+ pending,+ }) => {const { t } = useTranslation('verify');+ const projectMenu = useAcceptanceProjectMenu({+ onSelect: onMoveToProject,+ showRemove: canRemoveProject,+ });return (<Flexbox horizontal align={'center'} className={styles.bar} gap={6}>@@ -62,6 +84,19 @@ const AcceptanceBatchBar = memo<AcceptanceBatchBarProps>(>{t('acceptance.workspace.batch.close')}</Button>+ <DropdownMenu+ items={projectMenu.items}+ placement={'topLeft'}+ popupProps={{ style: { minWidth: 160 } }}+ onOpenChange={projectMenu.onOpenChange}+ >+ <ActionIcon+ disabled={pending}+ icon={FolderInput}+ size={'small'}+ title={t('acceptance.workspace.batch.move')}+ />+ </DropdownMenu><Flexbox flex={1} /><ActionIcondangerdiff --git a/src/features/Acceptance/Workspace/AcceptanceListPanel.tsx b/src/features/Acceptance/Workspace/AcceptanceListPanel.tsxindex 4a30e49b3ba..e61c6c6d8d7 100644--- a/src/features/Acceptance/Workspace/AcceptanceListPanel.tsx+++ b/src/features/Acceptance/Workspace/AcceptanceListPanel.tsx@@ -32,6 +32,7 @@ import {Group,ListChecks,ListFilter,+ MoreHorizontal,PanelLeftClose,Search,TriangleAlert,@@ -63,6 +64,7 @@ import {import AcceptanceRow from './AcceptanceRow';import {acceptanceBatchTargets,+ acceptanceProjectTargets,acceptanceSelectAllState,chunkAcceptanceBatch,nextAcceptanceSelectAll,@@ -87,7 +89,10 @@ const ACCEPTANCE_GROUP_MODE_STORAGE_KEY = 'lobehub-acceptance-group-mode';/** Pull the next page before the sentinel is actually on screen. */const LOAD_MORE_ROOT_MARGIN = '240px';type BatchSuccessKey =- 'acceptance.workspace.batch.deleteSuccess' | 'acceptance.workspace.batch.statusSuccess';+ | 'acceptance.workspace.batch.deleteSuccess'+ | 'acceptance.workspace.batch.projectRemoveSuccess'+ | 'acceptance.workspace.batch.projectSuccess'+ | 'acceptance.workspace.batch.statusSuccess';const EMPTY_FILTER_KEYS = {active: 'acceptance.workspace.filters.empty.active',completed: 'acceptance.workspace.filters.empty.completed',@@ -267,12 +272,14 @@ const styles = createStaticStyles(({ css }) => ({interface AcceptanceListPanelProps extends ReportPanelExpand {headerLeading?: ReactNode;/**- * Renders the per-project action menu. Injected by the main app rather than- * imported here: the actions open the create-project modal and navigate to+ * The per-project entries, as MENU ITEMS. Injected by the main app rather+ * than imported here: they open the create-project modal and navigate to* `/project/:id`, neither of which exists in the standalone workbench app —- * and a direct import would drag the project store into its bundle.+ * and a direct import would drag the project store into its bundle. The menu+ * chrome stays here so the header can carry ONE overflow menu for everything+ * it offers, the multi-select toggle included.*/- renderProjectActions?: (projectId?: string) => ReactNode;+ projectActionItems?: (projectId?: string) => DropdownItem[];}/**@@ -281,7 +288,7 @@ interface AcceptanceListPanelProps extends ReportPanelExpand {* same persisted panel-width preference so the two surfaces read as one family.*/const AcceptanceListPanel = memo<AcceptanceListPanelProps>(- ({ expand, headerLeading, isNarrow, renderProjectActions, setExpand }) => {+ ({ expand, headerLeading, isNarrow, projectActionItems, setExpand }) => {const { t } = useTranslation('verify');const navigate = useNavigate();const { acceptanceId } = useParams<{ acceptanceId: string }>();@@ -466,6 +473,60 @@ const AcceptanceListPanel = memo<AcceptanceListPanelProps>(}};+ /**+ * File the visible selection under one project (`null` takes it out of+ * any). Rows already where they are headed count as "unchanged" in the+ * report, same as a status sweep — so moving a mixed pick states honestly+ * how many actually moved.+ */+ const sweepProject = async (projectId: string | null) => {+ const targets = acceptanceProjectTargets(items, selectedVisible, projectId);+ const attempted = selectedVisible.length;+ const successKey: BatchSuccessKey = projectId+ ? 'acceptance.workspace.batch.projectSuccess'+ : 'acceptance.workspace.batch.projectRemoveSuccess';+ // Every selected row is already in place: nothing to send, but silence+ // would read as a broken button — report the unchanged sweep instead.+ if (targets.length === 0) {+ reportBatch(0, attempted, successKey);+ return;+ }++ setBatchPending(true);+ try {+ const chunks = chunkAcceptanceBatch(targets);+ const settled = await Promise.allSettled(+ chunks.map((chunk) => verifyService.setAcceptanceProjectBatch(chunk, projectId)),+ );++ let updated = 0;+ const failedIds: string[] = [];+ settled.forEach((part, index) => {+ if (part.status === 'fulfilled') {+ updated += part.value.updated;+ failedIds.push(...part.value.failedIds);+ return;+ }+ // A chunk that never reached the server: every id in it is unchanged.+ console.error('[acceptance:batchProject]', part.reason);+ failedIds.push(...chunks[index]);+ });++ const failedSet = new Set(failedIds);+ await settleBatch(+ selectedVisible,+ targets.filter((id) => !failedSet.has(id)),+ selectedVisible.filter((id) => !targets.includes(id) || failedSet.has(id)),+ );+ reportBatch(updated, attempted, successKey);+ } catch (cause) {+ console.error('[acceptance:batchProject]', cause);+ toast.error(t('acceptance.workspace.batch.error'));+ } finally {+ setBatchPending(false);+ }+ };+const deleteSelected = () => {const targets = selectedVisible;if (targets.length === 0) return;@@ -569,6 +630,24 @@ const AcceptanceListPanel = memo<AcceptanceListPanelProps>(},];+ // One overflow menu for everything the header offers. Multi-select used to+ // sit outside as its own icon; a 260px header cannot carry a fourth control+ // without crowding the search field, and "enter selection mode" is a rare+ // deliberate act, not something to keep one tap away at all times. The+ // project entries join it only when they have nowhere better to live —+ // under project grouping each group header carries its own.+ const overflowItems: DropdownItem[] = [+ {+ icon: <Icon icon={ListChecks} />,+ key: 'select',+ label: t('acceptance.workspace.batch.enter'),+ onClick: () => (selecting ? leaveSelecting() : setSelecting(true)),+ },+ ...(showGroups || !projectActionItems+ ? []+ : [{ type: 'divider' as const }, ...projectActionItems()]),+ ];+const [panelWidth, updateSystemStatus] = useGlobalStore((s) => [systemStatusSelectors.verifyReportPanelWidth(s),s.updateSystemStatus,@@ -645,15 +724,15 @@ const AcceptanceListPanel = memo<AcceptanceListPanelProps>(title={t('acceptance.workspace.filters.title')}/></DropdownMenu>- <ActionIcon- active={selecting}- className={styles.filterButton}- icon={ListChecks}- size={'small'}- title={t('acceptance.workspace.batch.enter')}- onClick={() => (selecting ? leaveSelecting() : setSelecting(true))}- />- {!showGroups && renderProjectActions?.()}+ <DropdownMenu items={overflowItems} placement={'bottomRight'}>+ <ActionIcon+ active={selecting}+ className={styles.filterButton}+ icon={MoreHorizontal}+ size={'small'}+ title={t('acceptance.workspace.actions.more')}+ />+ </DropdownMenu></div>{selecting && (<div className={styles.selectionRow}>@@ -748,9 +827,18 @@ const AcceptanceListPanel = memo<AcceptanceListPanelProps>(paddingBlock={4}paddingInline={8}action={- groupMode === 'project'- ? renderProjectActions?.(group.projectName ? group.key : undefined)- : undefined+ groupMode === 'project' && projectActionItems ? (+ <DropdownMenu+ placement={'bottomRight'}+ items={projectActionItems(group.projectName ? group.key : undefined)}+ >+ <ActionIcon+ icon={MoreHorizontal}+ size={'small'}+ title={t('acceptance.workspace.groups.actions')}+ />+ </DropdownMenu>+ ) : undefined}title={<span className={styles.groupTitle}>@@ -805,11 +893,13 @@ const AcceptanceListPanel = memo<AcceptanceListPanelProps>({selecting && (<AcceptanceBatchBaracceptCount={acceptanceBatchTargets(items, selectedVisible, 'accept').length}+ canRemoveProject={acceptanceProjectTargets(items, selectedVisible, null).length > 0}closeCount={acceptanceBatchTargets(items, selectedVisible, 'close').length}pending={batchPending || selectedVisible.length === 0}onAccept={() => void sweepStatus('accept', 'accepted')}onClose={() => void sweepStatus('close', 'closed')}onDelete={deleteSelected}+ onMoveToProject={(projectId) => void sweepProject(projectId)}/>)}</DraggablePanelContainer>diff --git a/src/features/Acceptance/Workspace/AcceptanceProjectActions.tsx b/src/features/Acceptance/Workspace/AcceptanceProjectActions.tsxindex b01b10f591a..dd6fa4a7551 100644--- a/src/features/Acceptance/Workspace/AcceptanceProjectActions.tsx+++ b/src/features/Acceptance/Workspace/AcceptanceProjectActions.tsx@@ -1,55 +1,51 @@'use client';import type { DropdownItem } from '@lobehub/ui/base-ui';-import { DropdownMenu } from '@lobehub/ui/base-ui';-import ActionIcon from '@lobehub/ui/es/ActionIcon/index';import Icon from '@lobehub/ui/es/Icon/index';-import { Eye, MoreHorizontal, Plus } from 'lucide-react';-import { memo } from 'react';+import { Eye, Plus } from 'lucide-react';+import { useCallback } from 'react';import { useTranslation } from 'react-i18next';import { openCreateProjectModal } from '@/features/Projects/CreateProjectModal';import { useWorkspaceAwareNavigate } from '@/features/Workspace/useWorkspaceAwareNavigate';-interface AcceptanceProjectActionsProps {- projectId?: string;-}-export const getAcceptanceProjectActionTypes = (projectId?: string) =>projectId ? (['viewProject', 'divider', 'createProject'] as const) : (['createProject'] as const);-const AcceptanceProjectActions = memo<AcceptanceProjectActionsProps>(({ projectId }) => {+/**+ * The project entries the acceptance list offers, as MENU ITEMS rather than a+ * rendered menu.+ *+ * The list panel owns the menu chrome so the header can carry one overflow menu+ * for everything it offers — the multi-select toggle lives there too, and two+ * adjacent "…" buttons would be nonsense. What stays injected is the ITEMS:+ * they open the create-project modal and navigate to `/project/:id`, neither of+ * which exists in the standalone workbench app, and importing them directly+ * would drag the project store into its bundle.+ */+export const useAcceptanceProjectActionItems = () => {const { t } = useTranslation('verify');const navigate = useWorkspaceAwareNavigate();- const items: DropdownItem[] = getAcceptanceProjectActionTypes(projectId).map((action) => {- if (action === 'divider') return { type: 'divider' };-- return action === 'viewProject'- ? {- icon: <Icon icon={Eye} />,- key: action,- label: t('acceptance.workspace.groups.viewProject'),- onClick: () => navigate(`/project/${projectId}`),- }- : {- icon: <Icon icon={Plus} />,- key: action,- label: t('acceptance.workspace.groups.createProject'),- onClick: () => openCreateProjectModal(),- };- });- return (- <DropdownMenu items={items} placement={'bottomRight'}>- <ActionIcon- icon={MoreHorizontal}- size={'small'}- title={t('acceptance.workspace.groups.actions')}- />- </DropdownMenu>+ return useCallback(+ (projectId?: string): DropdownItem[] =>+ getAcceptanceProjectActionTypes(projectId).map((action) => {+ if (action === 'divider') return { type: 'divider' };++ return action === 'viewProject'+ ? {+ icon: <Icon icon={Eye} />,+ key: action,+ label: t('acceptance.workspace.groups.viewProject'),+ onClick: () => navigate(`/project/${projectId}`),+ }+ : {+ icon: <Icon icon={Plus} />,+ key: action,+ label: t('acceptance.workspace.groups.createProject'),+ onClick: () => openCreateProjectModal(),+ };+ }),+ [navigate, t],);-});--AcceptanceProjectActions.displayName = 'AcceptanceProjectActions';--export default AcceptanceProjectActions;+};diff --git a/src/features/Acceptance/Workspace/batchSelection.test.ts b/src/features/Acceptance/Workspace/batchSelection.test.tsindex 9ec2cf7ba51..7a81ea848a3 100644--- a/src/features/Acceptance/Workspace/batchSelection.test.ts+++ b/src/features/Acceptance/Workspace/batchSelection.test.ts@@ -5,6 +5,7 @@ import type { AcceptanceListItem } from '@/services/verify';import {ACCEPTANCE_BATCH_CHUNK,acceptanceBatchTargets,+ acceptanceProjectTargets,acceptanceSelectAllState,chunkAcceptanceBatch,nextAcceptanceSelectAll,@@ -12,8 +13,14 @@ import {visibleAcceptanceSelection,} from './batchSelection';-const item = (id: string, status: string) =>- ({ id, status, subject: { title: id }, subjectId: id }) as unknown as AcceptanceListItem;+const item = (id: string, status: string, projectId?: string) =>+ ({+ id,+ project: projectId ? { id: projectId, name: projectId } : undefined,+ status,+ subject: { title: id },+ subjectId: id,+ }) as unknown as AcceptanceListItem;describe('toggleAcceptanceSelection', () => {it('adds an unselected row and removes a selected one', () => {@@ -79,6 +86,29 @@ describe('acceptanceBatchTargets', () => {});});+describe('acceptanceProjectTargets', () => {+ const items = [+ item('loose', 'delivered'),+ item('in-p1', 'delivered', 'p1'),+ item('in-p2', 'accepted', 'p2'),+ ];+ const selected = items.map((entry) => entry.id);++ it('moves every selected row not already in the target project', () => {+ // 'in-p1' is already where the sweep is headed; counting it would report a+ // move that never happened.+ expect(acceptanceProjectTargets(items, selected, 'p1')).toEqual(['loose', 'in-p2']);+ });++ it('removes only rows that actually have a project', () => {+ expect(acceptanceProjectTargets(items, selected, null)).toEqual(['in-p1', 'in-p2']);+ });++ it('ignores rows outside the selection', () => {+ expect(acceptanceProjectTargets(items, ['loose'], 'p1')).toEqual(['loose']);+ });+});+describe('chunkAcceptanceBatch', () => {const ids = (count: number) => Array.from({ length: count }, (_, index) => `id-${index}`);diff --git a/src/features/Acceptance/Workspace/batchSelection.ts b/src/features/Acceptance/Workspace/batchSelection.tsindex 40589f1308e..074e6055627 100644--- a/src/features/Acceptance/Workspace/batchSelection.ts+++ b/src/features/Acceptance/Workspace/batchSelection.ts@@ -74,6 +74,24 @@ export const acceptanceBatchTargets = (.map((item) => item.id);};+/**+ * The subset of a selection a project move can actually change.+ *+ * A row already filed under the target project (or, for `null`, one that is in+ * no project at all) has nowhere to move — leaving it out keeps the reported+ * count honest, the same rule the status sweep applies.+ */+export const acceptanceProjectTargets = (+ items: AcceptanceListItem[],+ selected: string[],+ projectId: string | null,+): string[] => {+ const selectedSet = new Set(selected);+ return items+ .filter((item) => selectedSet.has(item.id) && (item.project?.id ?? null) !== projectId)+ .map((item) => item.id);+};+/*** The server caps one sweep at 200 ids, so a select-all after enough scrolling* would be rejected wholesale — accept, close and delete all failing beforediff --git a/src/features/Acceptance/Workspace/index.tsx b/src/features/Acceptance/Workspace/index.tsxindex 409b9c91cae..911d8a72093 100644--- a/src/features/Acceptance/Workspace/index.tsx+++ b/src/features/Acceptance/Workspace/index.tsx@@ -12,13 +12,9 @@ import { RouteMetaBridge } from '@/features/RouteMeta';import { useAcceptanceList } from '../hooks';import AcceptanceListPanel from './AcceptanceListPanel';import AcceptanceOnboarding from './AcceptanceOnboarding';-import AcceptanceProjectActions from './AcceptanceProjectActions';+import { useAcceptanceProjectActionItems } from './AcceptanceProjectActions';import { useReportPanelExpand } from './useReportPanelExpand';-const renderProjectActions = (projectId?: string) => (- <AcceptanceProjectActions projectId={projectId} />-);-const styles = createStaticStyles(({ css }) => ({expandBtn: css`cursor: pointer;@@ -83,6 +79,7 @@ export const shouldShowAcceptanceOnboarding = ({const AcceptanceWorkspace = memo(() => {const { t } = useTranslation('verify');const panel = useReportPanelExpand();+ const projectActionItems = useAcceptanceProjectActionItems();const { acceptanceId, checkId } = useParams<{ acceptanceId: string; checkId: string }>();const [searchParams] = useSearchParams();const hasFocusedCheck = Boolean(checkId || searchParams.get('check'));@@ -114,7 +111,7 @@ const AcceptanceWorkspace = memo(() => {return (<Flexbox horizontal height={'100dvh'} style={{ overflow: 'hidden' }} width={'100%'}><RouteMetaBridge />- {showList && <AcceptanceListPanel {...panel} renderProjectActions={renderProjectActions} />}+ {showList && <AcceptanceListPanel {...panel} projectActionItems={projectActionItems} />}<div className={styles.main}>{showList && !panel.expand && (<buttondiff --git a/src/features/Acceptance/Workspace/useAcceptanceProjectMenuItem.tsx b/src/features/Acceptance/Workspace/useAcceptanceProjectMenuItem.tsxindex d9d3cbbbdff..2b1d0d57d66 100644--- a/src/features/Acceptance/Workspace/useAcceptanceProjectMenuItem.tsx+++ b/src/features/Acceptance/Workspace/useAcceptanceProjectMenuItem.tsx@@ -21,30 +21,44 @@ import { buildAcceptanceProjectMenuState } from './acceptanceProjectOptions';*/const PROJECT_OPTIONS_KEY = ['acceptance:projectOptions'];-interface AcceptanceProjectMenuItemParams {+interface AcceptanceProjectMenuParams {/** The project the acceptance is filed under, if any. */currentProjectId?: string | null;/** `null` takes the acceptance out of its project. */onSelect: (projectId: string | null) => void;+ /**+ * Offer the "remove from project" entry. Defaults to whether+ * `currentProjectId` is set; a multi-selection passes its own answer, since+ * a mixed pick has no single current project.+ */+ showRemove?: boolean;+}++interface AcceptanceProjectMenu {+ items: DropdownItem[];+ /** Wire to the menu's open change so projects load on first open, not mount. */+ onOpenChange: (open: boolean) => void;}/**- * The "file this delivery under a project" submenu on an acceptance row.+ * The "file this delivery under a project" menu contents, shared between the+ * per-row submenu and the batch bar's move dropdown.*- * The projects are fetched the first time the submenu opens, not on row mount:- * a list of 50 rows must not fire a project read nobody asked for.+ * The projects are fetched the first time the menu opens, not on mount: a list+ * of 50 rows must not fire a project read nobody asked for.*- * Creating a project is offered from inside the submenu — it is the only way- * out of the empty state, and the newly created project immediately receives- * this delivery instead of navigating the user away from their list.+ * Creating a project is offered from inside the menu — it is the only way out+ * of the empty state, and the newly created project immediately receives the+ * delivery instead of navigating the user away from their list.** The caller owns the write (and its toast); this hook only decides what the* menu offers.*/-export const useAcceptanceProjectMenuItem = ({+export const useAcceptanceProjectMenu = ({currentProjectId,onSelect,-}: AcceptanceProjectMenuItemParams): DropdownItem => {+ showRemove = Boolean(currentProjectId),+}: AcceptanceProjectMenuParams): AcceptanceProjectMenu => {const { t } = useTranslation('verify');const [requested, setRequested] = useState(false);@@ -104,19 +118,28 @@ export const useAcceptanceProjectMenuItem = ({};return {- children: [- ...listItems,- { type: 'divider' },- createItem,- ...(currentProjectId ? [removeItem] : []),- ],+ items: [...listItems, { type: 'divider' }, createItem, ...(showRemove ? [removeItem] : [])],+ onOpenChange: (open) => {+ if (open) setRequested(true);+ },+ };+};++/** The per-row "file under a project" submenu item, built on the shared menu. */+export const useAcceptanceProjectMenuItem = ({+ currentProjectId,+ onSelect,+}: Omit<AcceptanceProjectMenuParams, 'showRemove'>): DropdownItem => {+ const { t } = useTranslation('verify');+ const { items, onOpenChange } = useAcceptanceProjectMenu({ currentProjectId, onSelect });++ return {+ children: items,icon: <Icon icon={FolderInput} />,key: 'project',label: currentProjectId? t('acceptance.workspace.project.move'): t('acceptance.workspace.project.add'),- onOpenChange: (open) => {- if (open) setRequested(true);- },+ onOpenChange,};};diff --git a/src/services/verify.ts b/src/services/verify.tsindex 99fa279cf55..feb2abb06a8 100644--- a/src/services/verify.ts+++ b/src/services/verify.ts@@ -293,6 +293,14 @@ export class VerifyService {setAcceptanceProject = (id: string, projectId: string | null) =>lambdaClient.acceptance.setProject.mutate({ id, projectId });+ /**+ * Batch twin of `setAcceptanceProject` for the list's multi-selection. Rows+ * the caller cannot write come back in `failedIds` instead of failing the+ * whole sweep.+ */+ setAcceptanceProjectBatch = (ids: string[], projectId: string | null) =>+ lambdaClient.acceptance.setProjectBatch.mutate({ ids, projectId });+/** Owner override of the acceptance's decision state from the list. */updateAcceptanceStatus = (id: string, status: AcceptanceStatusOverride) =>lambdaClient.acceptance.updateStatus.mutate({ id, status });