🤯 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
🐛 fix(acceptance): return to the list after deleting the open acceptance (#20121)
Inneia89e17a68d64
diff --git a/src/features/Acceptance/Viewer/routes.ts b/src/features/Acceptance/Viewer/routes.tsindex 9a1570cd814..807f95ef386 100644--- a/src/features/Acceptance/Viewer/routes.ts+++ b/src/features/Acceptance/Viewer/routes.ts@@ -1,5 +1,7 @@export const acceptanceHomePath = () => '/';+export const acceptanceListPath = () => '/acceptance';+export const acceptanceOverviewPath = (acceptanceId: string) =>`/acceptance/${encodeURIComponent(acceptanceId)}`;diff --git a/src/features/Acceptance/Workspace/AcceptanceListPanel.tsx b/src/features/Acceptance/Workspace/AcceptanceListPanel.tsxindex aea5bf1b9ae..ac717b69e8f 100644--- a/src/features/Acceptance/Workspace/AcceptanceListPanel.tsx+++ b/src/features/Acceptance/Workspace/AcceptanceListPanel.tsx@@ -58,6 +58,7 @@ import AcceptanceRow from './AcceptanceRow';import {acceptanceBatchTargets,acceptanceProjectTargets,+ acceptanceRedirectAfterDelete,acceptanceSelectAllState,chunkAcceptanceBatch,nextAcceptanceSelectAll,@@ -570,8 +571,8 @@ const AcceptanceListPanel = memo<AcceptanceListPanelProps>(// The open acceptance just stopped existing — leave its dead route// rather than letting the detail pane render a 404.- if (acceptanceId && targets.includes(acceptanceId) && !failedIds.includes(acceptanceId))- navigate(acceptanceHomePath(), { replace: true });+ const redirect = acceptanceRedirectAfterDelete(acceptanceId, targets, failedIds);+ if (redirect) navigate(redirect, { replace: true });await settleBatch(targets, [], failedIds);reportBatch(deleted, targets.length, 'acceptance.workspace.batch.deleteSuccess');} finally {diff --git a/src/features/Acceptance/Workspace/AcceptanceRow.tsx b/src/features/Acceptance/Workspace/AcceptanceRow.tsxindex 5c674588bcb..54b19267444 100644--- a/src/features/Acceptance/Workspace/AcceptanceRow.tsx+++ b/src/features/Acceptance/Workspace/AcceptanceRow.tsx@@ -32,6 +32,7 @@ import { verifyKeys } from '@/libs/swr/keys';import type { AcceptanceListItem } from '@/services/verify';import { verifyService } from '@/services/verify';+import { acceptanceListPath } from '../Viewer/routes';import { getAcceptanceStatusActions } from '../Viewer/statusActions';import { openAcceptanceDeleteConfirm } from './AcceptanceDeleteConfirm';import { openMergeAcceptanceModal } from './MergeAcceptanceModal';@@ -233,7 +234,7 @@ const AcceptanceRow = memo<{setMutating(true);try {await verifyService.deleteAcceptance(item.id, purge);- if (active) navigate('/acceptance', { replace: true });+ if (active) navigate(acceptanceListPath(), { replace: true });await onChanged();toast.success(t('acceptance.workspace.deleteSuccess'));} finally {diff --git a/src/features/Acceptance/Workspace/batchSelection.test.ts b/src/features/Acceptance/Workspace/batchSelection.test.tsindex 13e95c983cf..a0104ec338c 100644--- a/src/features/Acceptance/Workspace/batchSelection.test.ts+++ b/src/features/Acceptance/Workspace/batchSelection.test.ts@@ -6,6 +6,7 @@ import {ACCEPTANCE_BATCH_CHUNK,acceptanceBatchTargets,acceptanceProjectTargets,+ acceptanceRedirectAfterDelete,acceptanceSelectAllState,chunkAcceptanceBatch,nextAcceptanceSelectAll,@@ -147,3 +148,15 @@ describe('chunkAcceptanceBatch', () => {expect(chunkAcceptanceBatch([])).toEqual([]);});});++describe('acceptanceRedirectAfterDelete', () => {+ it('returns to the acceptance list, not the app home, when the open row is deleted', () => {+ expect(acceptanceRedirectAfterDelete('a', ['a', 'b'], [])).toBe('/acceptance');+ });++ it('stays put when the open row survived or was not targeted', () => {+ expect(acceptanceRedirectAfterDelete('a', ['a'], ['a'])).toBeUndefined();+ expect(acceptanceRedirectAfterDelete('a', ['b'], [])).toBeUndefined();+ expect(acceptanceRedirectAfterDelete(undefined, ['a'], [])).toBeUndefined();+ });+});diff --git a/src/features/Acceptance/Workspace/batchSelection.ts b/src/features/Acceptance/Workspace/batchSelection.tsindex 23b74e5e2a9..0bc05be4614 100644--- a/src/features/Acceptance/Workspace/batchSelection.ts+++ b/src/features/Acceptance/Workspace/batchSelection.ts@@ -2,6 +2,7 @@ import type { AcceptanceStatus } from '@lobechat/types';import type { AcceptanceListItem } from '@/services/verify';+import { acceptanceListPath } from '../Viewer/routes';import { type AcceptanceStatusAction, getAcceptanceStatusActions } from '../Viewer/statusActions';export type AcceptanceSelectAllState = 'all' | 'none' | 'partial';@@ -133,3 +134,12 @@ export const chunkAcceptanceBatch = (ids: string[], size = ACCEPTANCE_BATCH_CHUN}return chunks;};++export const acceptanceRedirectAfterDelete = (+ openId: string | undefined,+ targets: string[],+ failedIds: string[],+): string | undefined =>+ openId && targets.includes(openId) && !failedIds.includes(openId)+ ? acceptanceListPath()+ : undefined;