diff --git a/frontend/src/components/doc-content.vue b/frontend/src/components/doc-content.vue index c5db28ed..6293a935 100644 --- a/frontend/src/components/doc-content.vue +++ b/frontend/src/components/doc-content.vue @@ -1045,6 +1045,7 @@ const saveChunkEdit = async (item: any) => { editingChunkId.value = ''; props.details.summary_status = result.summary_status || props.details.summary_status; props.details.description = result.description ?? props.details.description; + void refreshChunkHistoryAfterMutation(item); MessagePlugin.success(t('common.saveSuccess')); } catch (error: any) { MessagePlugin.error(error?.message || t('common.saveFailed')); @@ -1063,6 +1064,7 @@ const toggleChunkEnabled = async (item: any, isEnabled: boolean) => { Object.assign(item, result.data); props.details.summary_status = result.summary_status || props.details.summary_status; props.details.description = result.description ?? props.details.description; + void refreshChunkHistoryAfterMutation(item); } catch (error: any) { MessagePlugin.error(error?.message || t('common.error')); } finally { @@ -1089,18 +1091,41 @@ const chunkHistoryPopup = ref(''); const chunkHistoryLoading = ref(''); const chunkHistories = ref>({}); const selectedChunkRevision = ref>({}); +const chunkHistoryRequestSequence = ref>({}); const revertingRevision = ref(''); -const showChunkHistory = async (item: any) => { - if (chunkHistories.value[item.id]) return; +const loadChunkHistory = async (item: any, force = false, silent = false) => { + if (!force && Object.prototype.hasOwnProperty.call(chunkHistories.value, item.id)) return; + const requestSequence = (chunkHistoryRequestSequence.value[item.id] || 0) + 1; + chunkHistoryRequestSequence.value[item.id] = requestSequence; chunkHistoryLoading.value = item.id; try { const result: any = await listChunkRevisions(props.details.id, item.id); - chunkHistories.value[item.id] = result?.data || []; + if (chunkHistoryRequestSequence.value[item.id] === requestSequence) { + chunkHistories.value[item.id] = result?.data || []; + } } catch (error: any) { - MessagePlugin.error(error?.message || t('common.error')); + if (!silent) MessagePlugin.error(error?.message || t('common.error')); } finally { + if (chunkHistoryRequestSequence.value[item.id] === requestSequence) { + chunkHistoryLoading.value = ''; + } + } +}; + +const showChunkHistory = async (item: any) => loadChunkHistory(item); + +const refreshChunkHistoryAfterMutation = async (item: any) => { + const wasLoaded = Object.prototype.hasOwnProperty.call(chunkHistories.value, item.id); + const shouldReload = wasLoaded || chunkHistoryPopup.value === item.id; + // Invalidate both the cached list and any older request still in flight. + chunkHistoryRequestSequence.value[item.id] = (chunkHistoryRequestSequence.value[item.id] || 0) + 1; + delete chunkHistories.value[item.id]; + selectedChunkRevision.value[item.id] = null; + if (shouldReload) { + await loadChunkHistory(item, true, true); + } else if (chunkHistoryLoading.value === item.id) { chunkHistoryLoading.value = ''; } }; @@ -1164,10 +1189,7 @@ const revertChunk = async (item: any, revision: number) => { Object.assign(item, result.data); props.details.summary_status = result.summary_status || props.details.summary_status; props.details.description = result.description ?? props.details.description; - delete chunkHistories.value[item.id]; - const historyResult: any = await listChunkRevisions(props.details.id, item.id); - chunkHistories.value[item.id] = historyResult?.data || []; - selectedChunkRevision.value[item.id] = null; + await refreshChunkHistoryAfterMutation(item); MessagePlugin.success(t('knowledgeBase.chunkReverted')); } catch (error: any) { MessagePlugin.error(error?.message || t('common.error')); @@ -1189,6 +1211,10 @@ watch(() => props.details?.id, () => { metadataEditing.value = false; editingChunkId.value = ''; chunkHistoryPopup.value = ''; + chunkHistoryLoading.value = ''; + chunkHistories.value = {}; + selectedChunkRevision.value = {}; + chunkHistoryRequestSequence.value = {}; parentContextPopup.value = ''; questionPopupChunk.value = ''; questionComposerChunk.value = ''; @@ -1554,66 +1580,69 @@ const handleDetailsScroll = () => { - + - + @@ -2170,34 +2199,15 @@ const handleDetailsScroll = () => { word-break: break-word; } -.doc-metadata-row { - display: block; - margin-top: 4px; - padding-top: 12px; - border-top: 1px solid var(--td-component-stroke); -} - -.metadata-card-head, -.metadata-card-title, .metadata-editor-row { display: flex; align-items: center; } -.metadata-card-head { - justify-content: space-between; - min-height: 28px; -} - -.metadata-card-title { - gap: 7px; - color: var(--td-text-color-primary); - font-size: 13px; - font-weight: 600; - - > .t-icon { - color: var(--td-text-color-secondary); - } +.metadata-capability-icon { + flex-shrink: 0; + color: var(--td-text-color-placeholder); + cursor: help; } .metadata-count { @@ -2206,9 +2216,8 @@ const handleDetailsScroll = () => { font-weight: 400; } -.metadata-display, -.metadata-editor { - margin-top: 10px; +.metadata-display { + min-width: 0; } .metadata-grid { diff --git a/frontend/src/i18n/locales/en-US.ts b/frontend/src/i18n/locales/en-US.ts index ac99d5fa..a4e51854 100755 --- a/frontend/src/i18n/locales/en-US.ts +++ b/frontend/src/i18n/locales/en-US.ts @@ -530,6 +530,7 @@ export default { confirmDeleteQuestion: 'Are you sure you want to delete this question? The corresponding vector index will also be removed.', legacyQuestionCannotDelete: 'Legacy format questions cannot be deleted. Please regenerate questions.', customMetadata: 'Custom metadata', + metadataCapabilityHint: 'Used to support indexing and retrieval, document summaries, knowledge-base answers, and agent search', noCustomMetadata: 'No custom metadata', metadataObjectRequired: 'Metadata must be a JSON object', addMetadataField: 'Add metadata field', diff --git a/frontend/src/i18n/locales/ko-KR.ts b/frontend/src/i18n/locales/ko-KR.ts index 96e7cdaf..51d634ff 100755 --- a/frontend/src/i18n/locales/ko-KR.ts +++ b/frontend/src/i18n/locales/ko-KR.ts @@ -540,6 +540,7 @@ export default { "이 질문을 삭제하시겠습니까? 삭제 시 해당 벡터 인덱스도 함께 제거됩니다.", legacyQuestionCannotDelete: "이전 형식의 질문은 삭제할 수 없습니다. 질문을 다시 생성하세요", customMetadata: "사용자 정의 메타데이터", + metadataCapabilityHint: "인덱싱 및 검색, 문서 요약, 지식베이스 답변, 에이전트 검색을 지원하는 데 사용됩니다", noCustomMetadata: "사용자 정의 메타데이터 없음", metadataObjectRequired: "메타데이터는 JSON 객체여야 합니다", addMetadataField: "메타데이터 필드 추가", diff --git a/frontend/src/i18n/locales/ru-RU.ts b/frontend/src/i18n/locales/ru-RU.ts index 862c69c5..c140d52c 100755 --- a/frontend/src/i18n/locales/ru-RU.ts +++ b/frontend/src/i18n/locales/ru-RU.ts @@ -465,6 +465,7 @@ export default { confirmDeleteQuestion: 'Вы уверены, что хотите удалить этот вопрос? Соответствующий векторный индекс также будет удален.', legacyQuestionCannotDelete: 'Вопросы в устаревшем формате нельзя удалить. Пожалуйста, сгенерируйте вопросы заново.', customMetadata: 'Пользовательские метаданные', + metadataCapabilityHint: 'Используются для индексации и поиска, сводок, ответов по базе знаний и поиска агента', noCustomMetadata: 'Нет пользовательских метаданных', metadataObjectRequired: 'Метаданные должны быть JSON-объектом', addMetadataField: 'Добавить поле метаданных', diff --git a/frontend/src/i18n/locales/zh-CN.ts b/frontend/src/i18n/locales/zh-CN.ts index 282647ad..37445855 100755 --- a/frontend/src/i18n/locales/zh-CN.ts +++ b/frontend/src/i18n/locales/zh-CN.ts @@ -529,6 +529,7 @@ export default { confirmDeleteQuestion: "确定要删除这个问题吗?删除后将同时移除对应的向量索引。", legacyQuestionCannotDelete: "旧格式问题无法删除,请重新生成问题", customMetadata: "自定义元数据", + metadataCapabilityHint: "用于辅助索引召回、文档总结、知识库问答和智能体检索", noCustomMetadata: "暂无自定义元数据", metadataObjectRequired: "元数据必须是 JSON 对象", addMetadataField: "添加元数据字段",