From de8ee5ae165700afc17aadbe940cd24e48222571 Mon Sep 17 00:00:00 2001 From: wizardchen Date: Mon, 25 May 2026 21:01:16 +0800 Subject: [PATCH] feat(frontend): consolidate KB metadata into an info popover MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace the inline meta strip on the knowledge base detail header (role tag · share source · last updated · vector store badge) and the vector-store engine badge on the list cards with a single structured "info" popover next to the settings button. The popover groups Basic, Access, Capabilities, Chunking, Stats and Storage Binding into separate sections, only rendering those with data. A warning dot on the info button surfaces unreachable vector-store bindings without occupying header real estate. The popover caps at min(70vh, 560px) with an internal scrolling body so it never overflows the viewport. Hide the last-updated row when it equals created_at, since GORM only bumps KB.updated_at on metadata edits — never on document uploads — so surfacing two identical timestamps next to "created at" was misleading. Once the KB metadata is actually edited the row reappears naturally. i18n entries added for zh-CN, en-US, ko-KR, ru-RU. --- frontend/src/i18n/locales/en-US.ts | 22 + frontend/src/i18n/locales/ko-KR.ts | 22 + frontend/src/i18n/locales/ru-RU.ts | 22 + frontend/src/i18n/locales/zh-CN.ts | 22 + .../src/views/knowledge/KnowledgeBase.vue | 517 +++++++++++++++--- .../src/views/knowledge/KnowledgeBaseList.vue | 91 --- 6 files changed, 543 insertions(+), 153 deletions(-) diff --git a/frontend/src/i18n/locales/en-US.ts b/frontend/src/i18n/locales/en-US.ts index 120d78a6..57be4e45 100755 --- a/frontend/src/i18n/locales/en-US.ts +++ b/frontend/src/i18n/locales/en-US.ts @@ -83,6 +83,28 @@ export default { sharedAt: 'Shared at', lastUpdated: 'Last updated', }, + infoCard: { + tooltip: 'View knowledge base info', + title: 'Knowledge Base Info', + basic: 'Basic', + access: 'Access', + binding: 'Storage Binding', + capabilities: 'Capabilities', + stats: 'Statistics', + type: 'Type', + createdAt: 'Created at', + source: 'Source', + sharedTo: 'Shared to', + enabled: 'Enabled', + vectorStore: 'Vector store', + fileStorage: 'File storage', + documentCount: 'Documents', + faqCount: 'FAQs', + supportedFileTypes: 'Accepted formats', + chunking: 'Chunking', + parentShort: 'parent', + childShort: 'child', + }, create: 'Create Knowledge Base', edit: 'Edit Knowledge Base', delete: 'Delete Knowledge Base', diff --git a/frontend/src/i18n/locales/ko-KR.ts b/frontend/src/i18n/locales/ko-KR.ts index da202eb4..8b056ed6 100755 --- a/frontend/src/i18n/locales/ko-KR.ts +++ b/frontend/src/i18n/locales/ko-KR.ts @@ -83,6 +83,28 @@ export default { sharedAt: "공유일시", lastUpdated: "마지막 업데이트", }, + infoCard: { + tooltip: "지식베이스 정보 보기", + title: "지식베이스 정보", + basic: "기본", + access: "접근", + binding: "스토리지 바인딩", + capabilities: "기능", + stats: "통계", + type: "유형", + createdAt: "생성일", + source: "출처", + sharedTo: "공유 범위", + enabled: "활성화됨", + vectorStore: "벡터 스토어", + fileStorage: "파일 스토리지", + documentCount: "문서 수", + faqCount: "FAQ 수", + supportedFileTypes: "허용 형식", + chunking: "분할", + parentShort: "부모", + childShort: "자식", + }, create: "지식베이스 생성", edit: "지식베이스 편집", delete: "지식베이스 삭제", diff --git a/frontend/src/i18n/locales/ru-RU.ts b/frontend/src/i18n/locales/ru-RU.ts index 33c68898..4d542aec 100755 --- a/frontend/src/i18n/locales/ru-RU.ts +++ b/frontend/src/i18n/locales/ru-RU.ts @@ -326,6 +326,28 @@ export default { sharedAt: 'Дата общего доступа', lastUpdated: 'Последнее обновление' }, + infoCard: { + tooltip: 'Просмотр информации о базе знаний', + title: 'Информация о базе знаний', + basic: 'Основное', + access: 'Доступ', + binding: 'Привязка хранилища', + capabilities: 'Возможности', + stats: 'Статистика', + type: 'Тип', + createdAt: 'Создано', + source: 'Источник', + sharedTo: 'Общий доступ', + enabled: 'Включено', + vectorStore: 'Векторное хранилище', + fileStorage: 'Файловое хранилище', + documentCount: 'Документы', + faqCount: 'FAQ', + supportedFileTypes: 'Допустимые форматы', + chunking: 'Разделение', + parentShort: 'родитель', + childShort: 'потомок', + }, addDocument: 'Добавить документ', createdAt: 'Создано', updatedAt: 'Обновлено', diff --git a/frontend/src/i18n/locales/zh-CN.ts b/frontend/src/i18n/locales/zh-CN.ts index 0359cb4d..91f0c7c5 100755 --- a/frontend/src/i18n/locales/zh-CN.ts +++ b/frontend/src/i18n/locales/zh-CN.ts @@ -83,6 +83,28 @@ export default { sharedAt: "共享于", lastUpdated: "最后更新", }, + infoCard: { + tooltip: "查看知识库信息", + title: "知识库信息", + basic: "基础", + access: "访问", + binding: "存储绑定", + capabilities: "能力", + stats: "统计", + type: "类型", + createdAt: "创建时间", + source: "来源", + sharedTo: "共享范围", + enabled: "已启用", + vectorStore: "向量存储", + fileStorage: "文件存储", + documentCount: "文档数", + faqCount: "问答数", + supportedFileTypes: "可上传格式", + chunking: "分块", + parentShort: "父", + childShort: "子", + }, create: "创建知识库", edit: "编辑知识库", delete: "删除知识库", diff --git a/frontend/src/views/knowledge/KnowledgeBase.vue b/frontend/src/views/knowledge/KnowledgeBase.vue index e37b803a..51de4692 100644 --- a/frontend/src/views/knowledge/KnowledgeBase.vue +++ b/frontend/src/views/knowledge/KnowledgeBase.vue @@ -180,6 +180,13 @@ const acceptFileTypes = computed(() => [...supportedFileTypes.value].map(t => '.' + t).join(',') ) +// Sorted view of the supported-types set for the info popover. Kept as a +// plain array so the template can use v-for without paying the cost of +// re-sorting on every render. +const supportedFileTypesList = computed(() => + [...supportedFileTypes.value].sort() +) + const unsupportedFileTypes = computed(() => { const engines = parserEngines.value if (!engines.length) return [] @@ -308,6 +315,130 @@ const kbLastUpdated = computed(() => { return formatStringDate(new Date(raw)); }); +// KB.UpdatedAt is auto-bumped by GORM only when the KB row itself is +// touched (rename, config edit, …). For a freshly created KB that +// only had documents uploaded into it, updated_at == created_at and +// surfacing "last updated" alongside "created at" reads as +// duplicated noise. We hide the row in that case and only render it +// once the KB metadata has actually been edited. +const kbHasDistinctUpdate = computed(() => { + const created = kbInfo.value?.created_at; + const updated = kbInfo.value?.updated_at; + if (!updated) return false; + if (!created) return true; + return new Date(updated).getTime() !== new Date(created).getTime(); +}); + +// Enabled capabilities shown in the KB info popover. Only rendered when +// flipped on, so the section stays empty (and the whole block hides) for +// KBs that opted out of everything. +type CapabilityTheme = 'primary' | 'success' | 'warning' | 'default'; +const infoCardCapabilities = computed>(() => { + const kb: any = kbInfo.value; + if (!kb) return []; + const items: Array<{ key: string; label: string; theme: CapabilityTheme }> = []; + if (kb.vlm_config?.enabled) { + items.push({ key: 'vlm', label: 'VLM', theme: 'primary' }); + } + if (kb.asr_config?.enabled) { + items.push({ key: 'asr', label: 'ASR', theme: 'primary' }); + } + if (kb.extract_config?.enabled) { + items.push({ + key: 'kg', + label: t('knowledgeList.features.knowledgeGraph'), + theme: 'success', + }); + } + const idx = kb.indexing_strategy || {}; + if (idx.wiki_enabled) { + items.push({ key: 'wiki', label: 'Wiki', theme: 'warning' }); + } + return items; +}); + +// Document / chunk / share counters for the stats section. We treat +// undefined as "no data" rather than "0" so backends that don't +// populate the field don't get a misleading zero row. +const infoCardStats = computed>(() => { + const kb: any = kbInfo.value; + if (!kb) return []; + const items: Array<{ key: string; label: string; value: number | string }> = []; + if (typeof kb.knowledge_count === 'number') { + items.push({ + key: 'knowledge', + label: kb.type === 'faq' + ? t('knowledgeBase.infoCard.faqCount') + : t('knowledgeBase.infoCard.documentCount'), + value: kb.knowledge_count, + }); + } + return items; +}); + +// Friendly label for the chunking strategy. The backend stores raw +// identifiers ("auto" / "heading" / "heuristic" / "legacy" / "" / …). +// Empty / unknown values fall back to "legacy" semantics, which the +// editor surface labels as "按长度切分". +const chunkingStrategyLabel = computed(() => { + const raw: string = (kbInfo.value?.chunking_config?.strategy || '').toLowerCase(); + const key = (raw === '' || raw === 'recursive') ? 'legacy' : raw; + const path = `knowledgeEditor.chunking.strategies.${key}.label`; + const translated = t(path); + return translated === path ? raw : translated; +}); + +// Compact chunking config rows shown in the info popover. Hidden for +// FAQ KBs since chunking knobs don't drive their indexing path, and +// hidden entirely when chunking_config is absent (defensive — older +// rows on disk may lack the column). +const infoCardChunking = computed>(() => { + const kb: any = kbInfo.value; + if (!kb || kb.type === 'faq') return []; + const cfg = kb.chunking_config; + if (!cfg) return []; + const rows: Array<{ key: string; label: string; value: string }> = []; + if (chunkingStrategyLabel.value) { + rows.push({ + key: 'strategy', + label: t('knowledgeEditor.chunking.strategyLabel'), + value: chunkingStrategyLabel.value, + }); + } + const chars = t('knowledgeEditor.chunking.characters'); + if (typeof cfg.chunk_size === 'number' && cfg.chunk_size > 0) { + rows.push({ + key: 'size', + label: t('knowledgeEditor.chunking.sizeLabel'), + value: `${cfg.chunk_size} ${chars}`, + }); + } + if (typeof cfg.chunk_overlap === 'number') { + rows.push({ + key: 'overlap', + label: t('knowledgeEditor.chunking.overlapLabel'), + value: `${cfg.chunk_overlap} ${chars}`, + }); + } + if (cfg.enable_parent_child) { + const parent = cfg.parent_chunk_size || 4096; + const child = cfg.child_chunk_size || 384; + rows.push({ + key: 'parent-child', + label: t('knowledgeEditor.chunking.parentChildLabel'), + value: `${t('knowledgeBase.infoCard.parentShort')} ${parent} / ${t('knowledgeBase.infoCard.childShort')} ${child}`, + }); + } + if (typeof cfg.token_limit === 'number' && cfg.token_limit > 0) { + rows.push({ + key: 'token-limit', + label: t('knowledgeEditor.chunking.tokenLimitLabel'), + value: String(cfg.token_limit), + }); + } + return rows; +}); + const knowledgeList = ref>([]); let { cardList, total, moreIndex, details, getKnowled, delKnowledge, openMore, onVisibleChange: _onVisibleChange, getCardDetails, getfDetails } = useKnowledgeBase(kbId.value) const onVisibleChange = (visible: boolean) => { @@ -2052,53 +2183,185 @@ async function createNewSession(value: string): Promise { {{ $t('knowledgeEditor.document.title') }} - -
- - - - {{ accessRoleLabel }} - - - - - - - -