From 57fb1de45df87fa16298d43d421e560e9ef985cc Mon Sep 17 00:00:00 2001 From: wizardchen Date: Thu, 30 Jul 2026 12:03:43 +0800 Subject: [PATCH] fix(knowledge): harden batch tag dialog submit and list refresh Keep the batch tag dialog open until the API succeeds, reset pagination after batch updates, and add structural tests for BatchTagDialog. --- .../src/views/knowledge/KnowledgeBase.vue | 4 ++ .../components/BatchTagDialog.test.ts | 42 +++++++++++++++++++ .../knowledge/components/BatchTagDialog.vue | 17 +++----- .../knowledge/components/DocumentBatchBar.vue | 2 + 4 files changed, 54 insertions(+), 11 deletions(-) create mode 100644 frontend/src/views/knowledge/components/BatchTagDialog.test.ts diff --git a/frontend/src/views/knowledge/KnowledgeBase.vue b/frontend/src/views/knowledge/KnowledgeBase.vue index 17aaa3914..b6ff33e8c 100644 --- a/frontend/src/views/knowledge/KnowledgeBase.vue +++ b/frontend/src/views/knowledge/KnowledgeBase.vue @@ -1922,6 +1922,7 @@ const handleBatchTag = () => { }; const onBatchTagConfirm = async (tagIds: string[]) => { + if (batchTagging.value || selectedIds.value.size === 0) return; const ids = Array.from(selectedIds.value); const updateMap: Record = {}; for (const id of ids) { @@ -1931,8 +1932,10 @@ const onBatchTagConfirm = async (tagIds: string[]) => { try { await updateKnowledgeTagBatch({ updates: updateMap }); MessagePlugin.success(t('knowledgeBase.batchTagSuccess', { count: ids.length })); + batchTagDialogVisible.value = false; clearSelection(); batchMode.value = false; + resetPage(); loadKnowledgeFiles(kbId.value); loadTags(kbId.value, true); } catch (e: any) { @@ -2427,6 +2430,7 @@ async function createNewSession(value: string): Promise { diff --git a/frontend/src/views/knowledge/components/BatchTagDialog.test.ts b/frontend/src/views/knowledge/components/BatchTagDialog.test.ts new file mode 100644 index 000000000..2cecdf201 --- /dev/null +++ b/frontend/src/views/knowledge/components/BatchTagDialog.test.ts @@ -0,0 +1,42 @@ +import assert from 'node:assert/strict' +import test from 'node:test' +import { readFileSync } from 'node:fs' + +const component = readFileSync(new URL('./BatchTagDialog.vue', import.meta.url), 'utf8') +const zhCN = readFileSync(new URL('../../../i18n/locales/zh-CN.ts', import.meta.url), 'utf8') +const enUS = readFileSync(new URL('../../../i18n/locales/en-US.ts', import.meta.url), 'utf8') +const koKR = readFileSync(new URL('../../../i18n/locales/ko-KR.ts', import.meta.url), 'utf8') +const ruRU = readFileSync(new URL('../../../i18n/locales/ru-RU.ts', import.meta.url), 'utf8') + +test('uses a compact flat dialog with selected and available sections', () => { + assert.match(component, /dialog-class-name="batch-tag-dialog"/) + assert.match(component, /width="420px"/) + assert.match(component, /