Open-source LLM knowledge platform: turn raw documents into a queryable RAG, an autonomous reasoning agent, and a self-maintaining Wiki.
Go agentagenticaichatbotdsh-pluginembeddingsevaluationgenerative-aigolangknowledge-basellmmulti-tenantollamaopenaiquestion-answeringragrerankingsemantic-searchvector-searchwiki
feat(knowledge): enhance folder management and upload confirmation dialog
wizardchen7316d95f56b2
diff --git a/frontend/src/components/UploadConfirmHost.vue b/frontend/src/components/UploadConfirmHost.vueindex b7aa343f9..63814f2d7 100644--- a/frontend/src/components/UploadConfirmHost.vue+++ b/frontend/src/components/UploadConfirmHost.vue@@ -26,6 +26,7 @@ const handleCancel = () => {:accept-file-types="uploadConfirmStore.acceptFileTypes":supported-file-types="uploadConfirmStore.supportedFileTypes":target-folder="uploadConfirmStore.targetFolder"+ :folder-options="uploadConfirmStore.folderOptions"@confirm="handleConfirm"@cancel="handleCancel"/>diff --git a/frontend/src/i18n/locales/en-US.ts b/frontend/src/i18n/locales/en-US.tsindex 80879bef8..087407c8e 100755--- a/frontend/src/i18n/locales/en-US.ts+++ b/frontend/src/i18n/locales/en-US.ts@@ -371,8 +371,8 @@ export default {tagEditNoSelected: 'None selected',folderTree: {title: 'Folders',- rootRow: 'All documents',- rootRowTip: 'The top level of the knowledge base; every folder sits below it',+ rootRow: 'Root',+ rootRowTip: 'Knowledge base root; documents not in a subfolder live here',folderCardCount: '{count} documents',searchingSubtree: '(including sub-folders)',emptyFolder: 'This folder has no documents yet',@@ -391,7 +391,12 @@ export default {action: 'Move to folder',newFolder: 'New sub-folder',newFolderPlaceholder: 'New folder name',+ newFolderCreate: 'Create',+ newFolderAddRoot: 'New sub-folder under root',+ newFolderAddUnder: 'New sub-folder under “{folder}”',newFolderHint: 'Press Enter to create and move',+ newFolderHintRoot: 'Will be created under root',+ newFolderHintUnder: 'Will be created under “{folder}”',success: 'Moved {count} documents',failed: 'Could not move the documents',},@@ -683,8 +688,11 @@ export default {description: 'Useful for web-print, scanned, or image-heavy PDFs. Every page will be rendered as an image and processed via OCR/VLM. May increase processing time and model costs.'},continueAdd: 'Add more',- destinationLabel: 'Upload to',- destinationToRoot: 'Use top level',+ destinationLabel: 'Upload location',+ destinationChange: 'Change upload location',+ destinationToRoot: 'Use root',+ folderUploadTitle: 'Folder “{name}”',+ folderUploadHint: '{count} files; the local folder structure will be kept',filesAdded: 'Added {count} file(s)',filesAllDuplicate: 'Selected files are already in the list',titleManual: 'Confirm online publish',diff --git a/frontend/src/i18n/locales/ko-KR.ts b/frontend/src/i18n/locales/ko-KR.tsindex ffae1adf9..733446173 100755--- a/frontend/src/i18n/locales/ko-KR.ts+++ b/frontend/src/i18n/locales/ko-KR.ts@@ -5098,7 +5098,10 @@ export default {asrModelSelectRequired: '음성 인식이 활성화되었습니다. ASR 모델을 선택하세요',continueAdd: '계속 추가',destinationLabel: '업로드 위치',- destinationToRoot: '최상위로 변경',+ destinationChange: '업로드 위치 변경',+ destinationToRoot: '루트로 변경',+ folderUploadTitle: '폴더 「{name}」',+ folderUploadHint: '파일 {count}개, 로컬 폴더 구조를 유지합니다',filesAdded: '{count}개 파일이 추가되었습니다',filesAllDuplicate: '선택한 파일이 이미 목록에 있습니다',titleManual: '온라인 편집 게시 확인',@@ -5127,8 +5130,8 @@ export default {tagEditNoSelected: '선택 없음',folderTree: {title: '폴더',- rootRow: '전체 문서',- rootRowTip: '지식 베이스의 최상위이며 모든 폴더가 그 아래에 있습니다',+ rootRow: '루트',+ rootRowTip: '지식 베이스 루트 디렉터리, 하위 폴더에 없는 문서가 여기에 있습니다',folderCardCount: '문서 {count}개',searchingSubtree: '(하위 폴더 포함)',emptyFolder: '이 폴더에는 아직 문서가 없습니다',@@ -5148,6 +5151,11 @@ export default {newFolder: '새 하위 폴더',newFolderPlaceholder: '새 폴더 이름',newFolderHint: 'Enter로 만들고 이동',+ newFolderCreate: '생성',+ newFolderAddRoot: '루트 아래에 하위 디렉터리 만들기',+ newFolderAddUnder: '「{folder}」 아래에 하위 디렉터리 만들기',+ newFolderHintRoot: '루트 아래에 생성됩니다',+ newFolderHintUnder: '「{folder}」 아래에 생성됩니다',success: '문서 {count}개를 이동했습니다',failed: '문서를 이동할 수 없습니다',},diff --git a/frontend/src/i18n/locales/ru-RU.ts b/frontend/src/i18n/locales/ru-RU.tsindex ceb6ac027..94d4a740e 100755--- a/frontend/src/i18n/locales/ru-RU.ts+++ b/frontend/src/i18n/locales/ru-RU.ts@@ -5097,8 +5097,11 @@ export default {vlmModelSelectRequired: 'Мультимодальность включена. Выберите модель VLM.',asrModelSelectRequired: 'Распознавание речи включено. Выберите модель ASR.',continueAdd: 'Добавить ещё',- destinationLabel: 'Загрузить в',- destinationToRoot: 'На верхний уровень',+ destinationLabel: 'Куда загрузить',+ destinationChange: 'Изменить папку загрузки',+ destinationToRoot: 'В корень',+ folderUploadTitle: 'Папка «{name}»',+ folderUploadHint: '{count} файлов; структура локальной папки сохранится',filesAdded: 'Добавлено файлов: {count}',filesAllDuplicate: 'Выбранные файлы уже в списке',titleManual: 'Подтверждение публикации',@@ -5127,8 +5130,8 @@ export default {tagEditNoSelected: 'Ничего не выбрано',folderTree: {title: 'Папки',- rootRow: 'Все документы',- rootRowTip: 'Верхний уровень базы знаний — все папки находятся внутри него',+ rootRow: 'Корень',+ rootRowTip: 'Корневая папка базы знаний; документы без подпапки находятся здесь',folderCardCount: 'Документов: {count}',searchingSubtree: '(с вложенными папками)',emptyFolder: 'В этой папке пока нет документов',@@ -5148,6 +5151,11 @@ export default {newFolder: 'Новая вложенная папка',newFolderPlaceholder: 'Название новой папки',newFolderHint: 'Enter — создать и переместить',+ newFolderCreate: 'Создать',+ newFolderAddRoot: 'Создать подкаталог в корне',+ newFolderAddUnder: 'Создать подкаталог в «{folder}»',+ newFolderHintRoot: 'Будет создана в корне',+ newFolderHintUnder: 'Будет создана внутри «{folder}»',success: 'Перемещено документов: {count}',failed: 'Не удалось переместить документы',},diff --git a/frontend/src/i18n/locales/zh-CN.ts b/frontend/src/i18n/locales/zh-CN.tsindex 35f37c237..2723e2243 100755--- a/frontend/src/i18n/locales/zh-CN.ts+++ b/frontend/src/i18n/locales/zh-CN.ts@@ -5097,8 +5097,11 @@ export default {vlmModelSelectRequired: '已启用多模态,请选择 VLM 模型',asrModelSelectRequired: '已启用语音识别,请选择 ASR 模型',continueAdd: '继续添加',- destinationLabel: '上传到',- destinationToRoot: '改到顶层',+ destinationLabel: '上传位置',+ destinationChange: '更改上传位置',+ destinationToRoot: '改到根目录',+ folderUploadTitle: '文件夹「{name}」',+ folderUploadHint: '共 {count} 个文件,将保留本地目录结构',filesAdded: '已添加 {count} 个文件',filesAllDuplicate: '所选文件已在列表中',titleManual: '在线编辑发布确认',@@ -5127,8 +5130,8 @@ export default {tagEditNoSelected: '暂未选择',folderTree: {title: '目录',- rootRow: '全部文档',- rootRowTip: '知识库顶层,所有文件夹都在它下面',+ rootRow: '根目录',+ rootRowTip: '知识库根目录,未归入子文件夹的文档在此',folderCardCount: '{count} 个文档',searchingSubtree: '(含子目录)',emptyFolder: '这个文件夹里还没有文档',@@ -5147,7 +5150,12 @@ export default {action: '移动到目录',newFolder: '新建子目录',newFolderPlaceholder: '输入新目录名称',+ newFolderCreate: '创建',+ newFolderAddRoot: '在根目录下新建子目录',+ newFolderAddUnder: '在「{folder}」下新建子目录',newFolderHint: '回车创建并移动',+ newFolderHintRoot: '将在根目录下创建',+ newFolderHintUnder: '将在「{folder}」下创建',success: '已移动 {count} 个文档',failed: '移动失败',},diff --git a/frontend/src/stores/uploadConfirm.ts b/frontend/src/stores/uploadConfirm.tsindex 7ba3223f5..3dfc2abd5 100644--- a/frontend/src/stores/uploadConfirm.ts+++ b/frontend/src/stores/uploadConfirm.ts@@ -47,6 +47,8 @@ export interface OpenUploadConfirmOptions {supportedFileTypes?: string[]/** Folder pre-selected from the sidebar tree; '' means the root. */targetFolder?: string+ /** Existing folders the dialog can offer as upload destinations. */+ folderOptions?: Array<{ path: string; name: string; depth: number }>}export const useUploadConfirmStore = defineStore('uploadConfirm', {@@ -62,6 +64,7 @@ export const useUploadConfirmStore = defineStore('uploadConfirm', {acceptFileTypes: '',supportedFileTypes: [] as string[],targetFolder: '',+ folderOptions: [] as Array<{ path: string; name: string; depth: number }>,pendingResolve: null as ((value: UploadConfirmResult) => void) | null,pendingReject: null as (() => void) | null,}),@@ -82,6 +85,7 @@ export const useUploadConfirmStore = defineStore('uploadConfirm', {this.acceptFileTypes = options.acceptFileTypes || ''this.supportedFileTypes = options.supportedFileTypes ? [...options.supportedFileTypes] : []this.targetFolder = options.targetFolder || ''+ this.folderOptions = options.folderOptions ? [...options.folderOptions] : []this.pendingResolve = resolvethis.pendingReject = reject})@@ -109,6 +113,7 @@ export const useUploadConfirmStore = defineStore('uploadConfirm', {this.acceptFileTypes = ''this.supportedFileTypes = []this.targetFolder = ''+ this.folderOptions = []this.pendingResolve = nullthis.pendingReject = null},diff --git a/frontend/src/views/knowledge/KnowledgeBase.vue b/frontend/src/views/knowledge/KnowledgeBase.vueindex 82fca3321..d806c8d5f 100644--- a/frontend/src/views/knowledge/KnowledgeBase.vue+++ b/frontend/src/views/knowledge/KnowledgeBase.vue@@ -647,10 +647,13 @@ const isFiltering = computed(() =>}),);// Sub-folder entries shown at the top of the list while browsing. Search results-// are flat, so they are dropped as soon as a filter is active.-const currentChildFolders = computed(() =>- isFiltering.value ? [] : childFolders(folderTree.value, selectedFolderPath.value),-);+// are flat, so they are dropped as soon as a filter is active. When the sidebar+// tree is open it already lists the same folders, so skip the duplicate rows.+const currentChildFolders = computed(() => {+ if (isFiltering.value) return [];+ if (showFolderTree.value && !folderTreeCollapsed.value) return [];+ return childFolders(folderTree.value, selectedFolderPath.value);+});// A row's folder is worth showing only when the list can span folders.const showDocumentFolderPath = computed(() => hasFolders.value && isFiltering.value);const folderBreadcrumbs = computed(() => buildFolderBreadcrumbs(selectedFolderPath.value));@@ -1775,8 +1778,9 @@ const openUploadConfirmDialog = async (files: File[], urls: string[] = []) => {acceptFileTypes: acceptFileTypes.value,supportedFileTypes: [...supportedFileTypes.value],// Pre-fill the destination with the folder being browsed; the dialog shows- // it and lets the user send the batch to the root instead.+ // it and lets the user pick another folder (or the root) before confirming.targetFolder: selectedFolderPath.value,+ folderOptions: folderOptions.value,});await handleUploadConfirmResult(result);} catch {@@ -2327,15 +2331,25 @@ async function createNewSession(value: string): Promise<void> {<template v-if="activeKbTab === 'documents' || !isWiki"><div class="knowledge-main">- <KbFolderTree v-if="showFolderTree" :tree="folderTree" :selected-path="selectedFolderPath"- :loading="folderTreeLoading" :collapsed="folderTreeCollapsed" :can-edit="canEdit"+ <KbFolderTree v-if="showFolderTree && !folderTreeCollapsed" :tree="folderTree" :selected-path="selectedFolderPath"+ :loading="folderTreeLoading" :can-edit="canEdit"@select="handleFolderSelect" @update:collapsed="handleFolderTreeCollapsedChange"@rename="handleFolderRename" /><div class="tag-content"><div class="doc-card-area">- <nav v-if="showFolderTree && (folderBreadcrumbs.length || isFiltering)" class="doc-folder-path"+ <nav v-if="showFolderTree" class="doc-folder-path":aria-label="$t('knowledgeBase.folderTree.title')">- <button type="button" class="doc-folder-path__crumb" :class="{ 'is-current': !folderBreadcrumbs.length }"+ <t-tooltip v-if="folderTreeCollapsed" :content="$t('knowledgeBase.folderTree.expand')" placement="top">+ <button type="button" class="doc-folder-path__tree-toggle"+ :aria-label="$t('knowledgeBase.folderTree.expand')"+ @click="handleFolderTreeCollapsedChange(false)">+ <t-icon name="folder" size="14px" />+ </button>+ </t-tooltip>+ <span v-if="!folderBreadcrumbs.length" class="doc-folder-path__crumb is-current">+ {{ $t('knowledgeBase.folderTree.rootRow') }}+ </span>+ <button v-else type="button" class="doc-folder-path__crumb"@click="handleFolderSelect('')">{{ $t('knowledgeBase.folderTree.rootRow') }}</button>@@ -2517,13 +2531,16 @@ async function createNewSession(value: string): Promise<void> {</div></div><div class="doc-scroll-container"- :class="{ 'is-empty': !cardList.length && !docListLoading, 'is-marquee-active': docMarqueeVisible }"+ :class="{+ 'is-empty': !cardList.length && !currentChildFolders.length && !docListLoading,+ 'is-marquee-active': docMarqueeVisible,+ }"ref="knowledgeScroll" @scroll="handleScroll" @mousedown="onDocMarqueeMouseDown"><div v-if="docMarqueeVisible" class="doc-marquee-box":class="{ 'is-add': docMarqueeMode === 'add', 'is-subtract': docMarqueeMode === 'subtract' }":style="docMarqueeBoxStyle" aria-hidden="true" /><!-- 文档骨架屏 -->- <div v-if="docListLoading && cardList.length === 0" class="doc-card-list doc-card-list-animated">+ <div v-if="docListLoading && cardList.length === 0 && !currentChildFolders.length" class="doc-card-list doc-card-list-animated"><div v-for="n in 8" :key="'doc-skel-' + n" class="knowledge-card knowledge-card-skeleton"><div class="card-content"><div class="card-content-nav">@@ -3013,6 +3030,29 @@ async function createNewSession(value: string): Promise<void> {padding: 0 0 8px;flex-shrink: 0;+ &__tree-toggle {+ flex-shrink: 0;+ display: inline-flex;+ align-items: center;+ justify-content: center;+ width: 24px;+ height: 24px;+ margin-right: 4px;+ padding: 0;+ border: 1px solid var(--td-component-border);+ border-radius: 6px;+ background: var(--td-bg-color-container);+ color: var(--td-text-color-secondary);+ cursor: pointer;+ transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;++ &:hover {+ border-color: var(--td-brand-color);+ color: var(--td-brand-color);+ background: var(--td-bg-color-container-hover);+ }+ }+&__crumb {max-width: 220px;padding: 2px 4px;diff --git a/frontend/src/views/knowledge/components/DocumentCardView.vue b/frontend/src/views/knowledge/components/DocumentCardView.vueindex 723d6b43a..7fdddb989 100644--- a/frontend/src/views/knowledge/components/DocumentCardView.vue+++ b/frontend/src/views/knowledge/components/DocumentCardView.vue@@ -100,6 +100,7 @@ const openMenu = (index: number) => {const onMenuVisibleChange = (visible: boolean, item: KnowledgeCard) => {if (!visible) {activeMenuIndex.value = -1;+ folderPickerItemId.value = null;}emit('menu-visible-change', visible, item);};@@ -291,26 +292,26 @@ const handleAction = (action: 'edit' | 'view-trace' | 'reparse' | 'cancel-parse'</script><template>- <div class="doc-card-list doc-card-list-animated">- <!-- Sub-folders of the folder being browsed, listed first the way a file- manager does, so navigating down does not require the sidebar. -->- <div- v-for="folder in folders"- :key="'folder-' + folder.path"- class="folder-card"- :title="folder.path"- role="button"- tabindex="0"- @click="emit('open-folder', folder.path)"- @keydown.enter="emit('open-folder', folder.path)"- >- <t-icon name="folder" class="folder-card__icon" />- <div class="folder-card__text">- <span class="folder-card__name">{{ folder.name }}</span>- <span class="folder-card__meta">{{ t('knowledgeBase.folderTree.folderCardCount', { count: folder.total_count }) }}</span>+ <div class="doc-card-view">+ <div class="doc-card-list doc-card-list-animated">+ <div+ v-for="folder in folders"+ :key="'folder-' + folder.path"+ class="folder-card"+ :title="folder.path"+ role="button"+ tabindex="0"+ @click="emit('open-folder', folder.path)"+ @keydown.enter="emit('open-folder', folder.path)"+ >+ <div class="folder-card__body">+ <t-icon name="folder" class="folder-card__icon" />+ <span class="folder-card__title">{{ folder.name }}</span>+ </div>+ <div class="folder-card__footer">+ {{ t('knowledgeBase.folderTree.folderCardCount', { count: folder.total_count }) }}+ </div></div>- <t-icon name="chevron-right" class="folder-card__chevron" />- </div><divclass="knowledge-card"@@ -352,8 +353,19 @@ const handleAction = (action: 'edit' | 'view-trace' | 'reparse' | 'cancel-parse'<img class="more-icon" src="@/assets/img/more.png" alt="" /></div><template #content>+ <!-- Move: folder picker (must win over the normal menu while open) -->+ <div v-if="folderPickerItemId === item.id" class="card-menu move-menu">+ <FolderPickerMenu+ :options="folderOptions || []"+ :current-path="item.folder_path || ''"+ show-back+ @back="folderPickerItemId = null"+ @confirm="(path: string) => onFolderPicked(item, path)"+ />+ </div>+<!-- Normal menu -->- <div v-if="moveMenuMode === 'normal'" class="card-menu">+ <div v-else-if="moveMenuMode === 'normal'" class="card-menu"><DocumentActionMenu:item="item":can-mutate-knowledge="canMutateKnowledge"@@ -369,17 +381,6 @@ const handleAction = (action: 'edit' | 'view-trace' | 'reparse' | 'cancel-parse'/></div>- <!-- Move: folder picker -->- <div v-else-if="folderPickerItemId === item.id" class="card-menu move-menu">- <FolderPickerMenu- :options="folderOptions || []"- :current-path="item.folder_path || ''"- show-back- @back="folderPickerItemId = null"- @confirm="(path: string) => onFolderPicked(item, path)"- />- </div>-<!-- Move: target KB list --><div v-else-if="moveMenuMode === 'targets'" class="card-menu move-menu"><div class="move-menu-header" @click.stop="emit('move-back')">@@ -590,6 +591,7 @@ const handleAction = (action: 'edit' | 'view-trace' | 'reparse' | 'cancel-parse'</div></div></div>+ </div></div><!-- Hover popover -->@@ -665,6 +667,10 @@ const handleAction = (action: 'edit' | 'view-trace' | 'reparse' | 'cancel-parse'to { opacity: 1; transform: translateY(0); }}+.doc-card-view {+ width: 100%;+}+.doc-card-list {box-sizing: border-box;display: grid;@@ -678,29 +684,23 @@ const handleAction = (action: 'edit' | 'view-trace' | 'reparse' | 'cancel-parse'}}-// Folder entries share the grid with the document cards but are deliberately-// shorter: they are navigation, not content..folder-card {min-width: 240px;- height: 56px;+ height: 136px;box-sizing: border-box;display: flex;- align-items: center;- gap: 10px;- padding: 0 12px;+ flex-direction: column;border: 1px solid var(--td-component-border);- border-radius: 6px;+ border-radius: 8px;+ overflow: hidden;background: var(--td-bg-color-container);+ box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);cursor: pointer;- transition: border-color 0.15s ease, background 0.15s ease;+ transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;&:hover {- border-color: var(--td-brand-color);- background: var(--td-bg-color-container-hover);-- .folder-card__chevron {- color: var(--td-brand-color);- }+ border-color: color-mix(in srgb, var(--td-component-stroke) 55%, var(--td-brand-color));+ box-shadow: 0 4px 14px rgba(0, 0, 0, 0.07);}&:focus-visible {@@ -709,41 +709,49 @@ const handleAction = (action: 'edit' | 'view-trace' | 'reparse' | 'cancel-parse'}}-.folder-card__icon {- flex: 0 0 auto;- font-size: 20px;- color: var(--td-brand-color);-}--.folder-card__text {+.folder-card__body {flex: 1;- min-width: 0;+ min-height: 0;display: flex;flex-direction: column;- gap: 2px;+ justify-content: flex-start;+ gap: 8px;+ padding: 12px 14px 10px;+ overflow: hidden;+}++.folder-card__icon {+ flex-shrink: 0;+ font-size: 28px;+ line-height: 1;+ color: var(--td-brand-color);+ opacity: 0.88;}-.folder-card__name {+.folder-card__title {+ flex: 1;+ min-height: 0;font-size: 14px;font-weight: 500;+ line-height: 20px;+ max-height: 40px;color: var(--td-text-color-primary);+ display: -webkit-box;+ -webkit-box-orient: vertical;+ -webkit-line-clamp: 2;overflow: hidden;- text-overflow: ellipsis;- white-space: nowrap;+ word-break: break-all;}-.folder-card__meta {+.folder-card__footer {+ flex-shrink: 0;+ padding: 8px 14px;+ border-top: 1px solid var(--td-component-stroke);font-size: 12px;+ line-height: 1.4;color: var(--td-text-color-placeholder);}-.folder-card__chevron {- flex: 0 0 auto;- font-size: 16px;- color: var(--td-text-color-placeholder);- transition: color 0.15s ease;-}-.knowledge-card {min-width: 240px;display: flex;diff --git a/frontend/src/views/knowledge/components/DocumentListView.vue b/frontend/src/views/knowledge/components/DocumentListView.vueindex 73699b023..8e561fe72 100644--- a/frontend/src/views/knowledge/components/DocumentListView.vue+++ b/frontend/src/views/knowledge/components/DocumentListView.vue@@ -194,6 +194,7 @@ const onMoreVisible = (id: string, visible: boolean) => {const it = props.items.find(i => i.id === id);if (it) emit('probe-trace', it);} else {+ folderPickerItemId.value = null;// Reset move state when popup closes naturallyemit('reset-move-state');}@@ -264,10 +265,14 @@ const handleAction = (action: 'edit' | 'reparse' | 'cancel-parse' | 'move' | 'mo</div><div class="doc-list-body">- <!-- Sub-folders of the folder being browsed, listed above the documents- the way a file manager does. -->- <div v-for="folder in folders" :key="'folder-' + folder.path" class="doc-list-row doc-list-row--folder"- :title="folder.path" role="row" @click="emit('open-folder', folder.path)">+ <div+ v-for="folder in folders"+ :key="'folder-' + folder.path"+ class="doc-list-row doc-list-row--folder"+ :title="folder.path"+ role="row"+ @click="emit('open-folder', folder.path)"+ ><div class="cell cell-check" aria-hidden="true"></div><div class="cell cell-name"><span class="row-file-icon-wrap">@@ -286,9 +291,7 @@ const handleAction = (action: 'edit' | 'reparse' | 'cancel-parse' | 'move' | 'mo<div class="cell cell-size"></div><div class="cell cell-status"></div><div class="cell cell-time"></div>- <div v-if="canEdit" class="cell cell-actions">- <t-icon name="chevron-right" class="row-folder-chevron" />- </div>+ <div v-if="canEdit" class="cell cell-actions" aria-hidden="true"></div></div><div v-for="item in items" :key="item.id" class="doc-list-row"@@ -376,8 +379,19 @@ const handleAction = (action: 'edit' | 'reparse' | 'cancel-parse' | 'move' | 'mo<t-icon name="more" size="16px" /></button><template #content>+ <!-- Move: folder picker (must win over the normal menu while open) -->+ <div v-if="folderPickerItemId === item.id" class="card-menu move-menu">+ <FolderPickerMenu+ :options="folderOptions || []"+ :current-path="item.folder_path || ''"+ show-back+ @back="folderPickerItemId = null"+ @confirm="(path: string) => onFolderPicked(item, path)"+ />+ </div>+<!-- Normal menu -->- <div v-if="moveMenuMode === 'normal'" class="card-menu">+ <div v-else-if="moveMenuMode === 'normal'" class="card-menu"><DocumentActionMenu:item="item":can-mutate-knowledge="canMutateKnowledge"@@ -393,17 +407,6 @@ const handleAction = (action: 'edit' | 'reparse' | 'cancel-parse' | 'move' | 'mo/></div>- <!-- Move: folder picker -->- <div v-else-if="folderPickerItemId === item.id" class="card-menu move-menu">- <FolderPickerMenu- :options="folderOptions || []"- :current-path="item.folder_path || ''"- show-back- @back="folderPickerItemId = null"- @confirm="(path: string) => onFolderPicked(item, path)"- />- </div>-<!-- Move: target KB list --><div v-else-if="moveMenuMode === 'targets'" class="card-menu move-menu"><div class="move-menu-header" @click.stop="emit('move-back')">@@ -677,8 +680,8 @@ const handleAction = (action: 'edit' | 'reparse' | 'cancel-parse' | 'move' | 'mo.doc-list-row--folder {cursor: pointer;- &:hover .row-folder-chevron {- color: var(--td-brand-color);+ .row-file-name {+ font-weight: 500;}}diff --git a/frontend/src/views/knowledge/components/FolderPickerMenu.vue b/frontend/src/views/knowledge/components/FolderPickerMenu.vueindex c227667c1..570a1fb64 100644--- a/frontend/src/views/knowledge/components/FolderPickerMenu.vue+++ b/frontend/src/views/knowledge/components/FolderPickerMenu.vue@@ -5,101 +5,229 @@<span>{{ t('knowledgeBase.moveToFolder.action') }}</span></div>- <div class="folder-picker__list">- <div- class="folder-picker__item"- :class="{ current: currentPath === '' }"- @click.stop="choose('')"- >- <t-icon name="folder-open" class="folder-picker__icon" />- <span class="folder-picker__name">{{ t('knowledgeBase.folderTree.rootRow') }}</span>- <t-icon v-if="currentPath === ''" name="check" class="folder-picker__current" />- </div>-- <div- v-for="option in options"- :key="option.path"- class="folder-picker__item"- :class="{ current: currentPath === option.path }"- :style="{ '--folder-picker-depth': option.depth }"- :title="option.path"- @click.stop="choose(option.path)"- >- <t-icon name="folder" class="folder-picker__icon" />- <span class="folder-picker__name">{{ option.name }}</span>- <t-icon v-if="currentPath === option.path" name="check" class="folder-picker__current" />- </div>- </div>+ <div ref="listRef" class="folder-picker__list">+ <template v-for="row in renderRows" :key="row.key">+ <div+ v-if="row.kind === 'folder'"+ :data-folder-path="row.path || undefined"+ class="folder-picker__item"+ :class="{ current: effectiveCurrentPath === row.path }"+ :style="{ '--folder-picker-depth': row.depth }"+ :title="row.path || undefined"+ @click.stop="choose(row.path)"+ >+ <t-icon :name="row.isRoot ? 'folder-open' : 'folder'" class="folder-picker__icon" />+ <span class="folder-picker__name">{{ row.label }}</span>+ <button+ type="button"+ class="folder-picker__add"+ :title="row.isRoot+ ? t('knowledgeBase.moveToFolder.newFolderAddRoot')+ : t('knowledgeBase.moveToFolder.newFolderAddUnder', { folder: row.label })"+ :aria-label="row.isRoot+ ? t('knowledgeBase.moveToFolder.newFolderAddRoot')+ : t('knowledgeBase.moveToFolder.newFolderAddUnder', { folder: row.label })"+ @click.stop="startCreatingUnder(row.path)"+ >+ <t-icon name="folder-add" />+ </button>+ <t-icon v-if="effectiveCurrentPath === row.path" name="check" class="folder-picker__current" />+ </div>- <div class="folder-picker__create" @click.stop>- <div v-if="!creating" class="folder-picker__item" @click.stop="startCreating">- <t-icon name="folder-add" class="folder-picker__icon is-action" />- <span class="folder-picker__name is-action">{{ t('knowledgeBase.moveToFolder.newFolder') }}</span>- </div>- <template v-else>- <input- ref="newFolderInputRef"- v-model.trim="newFolderName"- class="folder-picker__input"- :placeholder="t('knowledgeBase.moveToFolder.newFolderPlaceholder')"- @keydown.enter.stop="commitNewFolder"- @keydown.esc.stop="creating = false"- />- <p class="folder-picker__hint">{{ t('knowledgeBase.moveToFolder.newFolderHint') }}</p>+ <div+ v-else+ class="folder-picker__item folder-picker__item--create"+ :style="{ '--folder-picker-depth': row.depth }"+ @click.stop+ >+ <t-icon name="folder" class="folder-picker__icon" />+ <input+ ref="newFolderInputRef"+ v-model.trim="newFolderName"+ class="folder-picker__input"+ :placeholder="t('knowledgeBase.moveToFolder.newFolderPlaceholder')"+ @keydown.enter.stop="commitNewFolder"+ @keydown.esc.stop="cancelCreating"+ />+ </div></template></div></div></template><script setup lang="ts">-import { nextTick, ref } from 'vue'+import { computed, nextTick, ref, watch } from 'vue'import { useI18n } from 'vue-i18n'-import { normalizeFolderPath } from '../folderTree'+import { folderOptionFromPath, joinFolderPath, normalizeFolderPath, sortFolderOptions } from '../folderTree'export type FolderOption = { path: string; name: string; depth: number }+type FolderRow = {+ kind: 'folder'+ key: string+ path: string+ label: string+ depth: number+ isRoot?: boolean+}++type CreateRow = {+ kind: 'create'+ key: string+ parentPath: string+ depth: number+}++type RenderRow = FolderRow | CreateRow+const props = withDefaults(defineProps<{options: FolderOption[]- /** Folder the documents are in today, marked so the current place is obvious. */currentPath?: string- /** Show a back row when embedded in a menu that has a parent level. */showBack?: boolean+ allowReselect?: boolean}>(), {currentPath: '',showBack: false,+ allowReselect: false,})const emit = defineEmits<{back: []confirm: [folderPath: string]+ create: [folderPath: string]}>()const { t } = useI18n()-const creating = ref(false)+const creatingUnder = ref<string | null>(null)const newFolderName = ref('')const newFolderInputRef = ref<HTMLInputElement | null>(null)+const listRef = ref<HTMLElement | null>(null)+const localCreatedPaths = ref<string[]>([])+const selectedPath = ref<string | null>(null)++const effectiveCurrentPath = computed(() =>+ selectedPath.value !== null ? selectedPath.value : (props.currentPath ?? ''),+)++const displayOptions = computed(() => {+ const byPath = new Map<string, FolderOption>()+ props.options.forEach((option) => byPath.set(option.path, option))+ localCreatedPaths.value.forEach((path) => {+ if (!byPath.has(path)) byPath.set(path, folderOptionFromPath(path))+ })+ return sortFolderOptions([...byPath.values()])+})++const renderRows = computed<RenderRow[]>(() => {+ const rows: RenderRow[] = [{+ kind: 'folder',+ key: 'root',+ path: '',+ label: t('knowledgeBase.folderTree.rootRow'),+ depth: 0,+ isRoot: true,+ }]++ if (creatingUnder.value === '') {+ rows.push({+ kind: 'create',+ key: 'create-root',+ parentPath: '',+ depth: childCreateDepth(''),+ })+ }++ displayOptions.value.forEach((option) => {+ rows.push({+ kind: 'folder',+ key: option.path,+ path: option.path,+ label: option.name,+ depth: option.depth,+ })+ if (creatingUnder.value === option.path) {+ rows.push({+ kind: 'create',+ key: `create-${option.path}`,+ parentPath: option.path,+ depth: childCreateDepth(option.path),+ })+ }+ })++ return rows+})++watch(+ creatingUnder,+ async (value) => {+ if (value === null) return+ await nextTick()+ newFolderInputRef.value?.focus()+ },+)++watch(+ () => props.options,+ (options) => {+ const existing = new Set(options.map((option) => option.path))+ localCreatedPaths.value = localCreatedPaths.value.filter((path) => !existing.has(path))+ },+ { deep: true },+)++watch(+ () => props.currentPath,+ () => {+ selectedPath.value = null+ },+)++function childCreateDepth(parentPath: string): number {+ return parentPath.split('/').filter(Boolean).length+}-// Picking a folder is the whole action — there is nothing else to configure, so-// there is no confirm step to sit through.const choose = (path: string) => {- if (path === props.currentPath) return+ if (path === effectiveCurrentPath.value && !props.allowReselect) return+ selectedPath.value = pathemit('confirm', path)}-const startCreating = async () => {- creating.value = true+const startCreatingUnder = (parentPath: string) => {+ if (creatingUnder.value === parentPath) {+ cancelCreating()+ return+ }+ creatingUnder.value = parentPathnewFolderName.value = ''+}++const cancelCreating = () => {+ creatingUnder.value = null+ newFolderName.value = ''+}++const scrollToFolder = async (path: string) => {await nextTick()- newFolderInputRef.value?.focus()+ const row = listRef.value?.querySelector(`[data-folder-path="${CSS.escape(path)}"]`)+ row?.scrollIntoView({ block: 'nearest' })}-const commitNewFolder = () => {- const path = normalizeFolderPath(newFolderName.value)- if (!path) return- creating.value = false+const commitNewFolder = async () => {+ if (creatingUnder.value === null) return+ const name = normalizeFolderPath(newFolderName.value)+ if (!name) return+ const path = joinFolderPath(creatingUnder.value, name)+ if (displayOptions.value.some((option) => option.path === path)) return++ if (!localCreatedPaths.value.includes(path)) {+ localCreatedPaths.value = [...localCreatedPaths.value, path]+ }+ creatingUnder.value = nullnewFolderName.value = ''- emit('confirm', path)+ emit('create', path)+ await scrollToFolder(path)}</script>@@ -127,7 +255,7 @@ const commitNewFolder = () => {}.folder-picker__list {- max-height: 220px;+ max-height: 260px;overflow-y: auto;scrollbar-width: thin;@@ -144,10 +272,10 @@ const commitNewFolder = () => {.folder-picker__item {display: flex;align-items: center;- gap: 8px;+ gap: 6px;height: 30px;box-sizing: border-box;- padding: 0 10px 0 calc(var(--folder-picker-depth, 0) * var(--folder-picker-indent) + 10px);+ padding: 0 8px 0 calc(var(--folder-picker-depth, 0) * var(--folder-picker-indent) + 10px);border-radius: 6px;color: var(--td-text-color-primary);font-size: 13px;@@ -156,12 +284,30 @@ const commitNewFolder = () => {&:hover {background: var(--td-bg-color-container-hover);++ .folder-picker__add {+ opacity: 1;+ pointer-events: auto;+ }}&.current {color: var(--td-text-color-placeholder);cursor: default;+ &:hover {+ background: transparent;++ .folder-picker__add {+ opacity: 1;+ pointer-events: auto;+ }+ }+ }++ &--create {+ cursor: default;+&:hover {background: transparent;}@@ -172,10 +318,6 @@ const commitNewFolder = () => {flex: 0 0 auto;font-size: 15px;color: var(--td-text-color-placeholder);-- &.is-action {- color: var(--td-brand-color);- }}.folder-picker__name {@@ -184,9 +326,29 @@ const commitNewFolder = () => {overflow: hidden;text-overflow: ellipsis;white-space: nowrap;+}- &.is-action {+.folder-picker__add {+ flex: 0 0 auto;+ display: inline-flex;+ align-items: center;+ justify-content: center;+ width: 22px;+ height: 22px;+ margin-right: -2px;+ padding: 0;+ border: 0;+ border-radius: 4px;+ background: transparent;+ color: var(--td-text-color-placeholder);+ opacity: 0;+ pointer-events: none;+ cursor: pointer;+ transition: opacity 0.15s ease, color 0.15s ease, background 0.15s ease;++ &:hover {color: var(--td-brand-color);+ background: var(--td-bg-color-component);}}@@ -196,18 +358,11 @@ const commitNewFolder = () => {color: var(--td-text-color-placeholder);}-.folder-picker__create {- margin-top: 2px;- padding-top: 2px;- border-top: 1px solid var(--td-component-stroke);-}-.folder-picker__input {- box-sizing: border-box;- width: calc(100% - 20px);- height: 28px;- margin: 4px 10px 0;- padding: 0 8px;+ flex: 1;+ min-width: 0;+ height: 24px;+ padding: 0 6px;border: 1px solid var(--td-brand-color);border-radius: 4px;background: var(--td-bg-color-container);@@ -216,11 +371,4 @@ const commitNewFolder = () => {font-size: 13px;outline: none;}--.folder-picker__hint {- margin: 4px 10px 6px;- font-size: 11px;- line-height: 1.5;- color: var(--td-text-color-placeholder);-}</style>diff --git a/frontend/src/views/knowledge/components/KbFolderTree.test.ts b/frontend/src/views/knowledge/components/KbFolderTree.test.tsindex c216f13f6..61c36c6e8 100644--- a/frontend/src/views/knowledge/components/KbFolderTree.test.ts+++ b/frontend/src/views/knowledge/components/KbFolderTree.test.ts@@ -18,6 +18,8 @@ test('the rename sentinel cannot collide with the root folder path', () => {test('only real folders expose a rename affordance', () => {assert.match(tree, /v-if="canEdit && row\.kind === 'folder'"/)+ assert.match(tree, /popup-menu-item/)+ assert.match(tree, /onFolderMenuRename/)})// Picking a folder is a small, reversible action, so it stays a popup: in the row@@ -31,3 +33,15 @@ test('the folder picker is a popup rather than a modal', () => {assert.doesNotMatch(source, /MoveToFolderDialog/)}})++// The folder picker must render ahead of the normal action menu; otherwise+// moveMenuMode === 'normal' keeps the menu visible and clicks look dead.+test('the folder picker wins over the normal action menu', () => {+ for (const source of [cardView, listView]) {+ const pickerIdx = source.indexOf('v-if="folderPickerItemId === item.id"')+ const normalIdx = source.indexOf('v-else-if="moveMenuMode === \'normal\'"')+ assert.ok(pickerIdx >= 0)+ assert.ok(normalIdx >= 0)+ assert.ok(pickerIdx < normalIdx)+ }+})diff --git a/frontend/src/views/knowledge/components/KbFolderTree.vue b/frontend/src/views/knowledge/components/KbFolderTree.vueindex e50cb1840..7475054ca 100644--- a/frontend/src/views/knowledge/components/KbFolderTree.vue+++ b/frontend/src/views/knowledge/components/KbFolderTree.vue@@ -37,7 +37,12 @@v-for="row in rows":key="row.path || '__root__'"class="kb-folder-row"- :class="{ active: selectedPath === row.path, 'is-root': row.kind === 'root' }"+ :class="{+ active: selectedPath === row.path,+ 'is-root': row.kind === 'root',+ 'is-editable': canEdit && row.kind === 'folder',+ 'is-menu-open': menuOpenPath === row.path,+ }":style="{ '--kb-folder-depth': row.depth }":title="row.kind === 'root' ? t('knowledgeBase.folderTree.rootRowTip') : row.path"role="button"@@ -78,14 +83,36 @@<span class="kb-folder-row__label">{{ row.kind === 'root' ? t('knowledgeBase.folderTree.rootRow') : row.name }}</span>- <t-tooltip v-if="canEdit && row.kind === 'folder'"- :content="t('knowledgeBase.folderTree.rename')" placement="top">- <button type="button" class="kb-folder-row__action"- :aria-label="t('knowledgeBase.folderTree.rename')" @click.stop="startRename(row)">- <t-icon name="edit" />- </button>- </t-tooltip>- <span class="kb-folder-row__count">{{ row.totalCount }}</span>+ <span class="kb-folder-row__trailing">+ <span class="kb-folder-row__count">{{ row.totalCount }}</span>+ <t-popup+ v-if="canEdit && row.kind === 'folder'"+ :visible="menuOpenPath === row.path"+ trigger="click"+ placement="bottom-right"+ destroy-on-close+ overlay-class-name="card-more-popup"+ @visible-change="(visible: boolean) => onFolderMenuVisible(row.path, visible)"+ >+ <button+ type="button"+ class="kb-folder-row__more"+ :class="{ 'is-open': menuOpenPath === row.path }"+ :aria-label="t('knowledgeBase.moreOptions')"+ @click.stop+ >+ <t-icon name="more" />+ </button>+ <template #content>+ <div class="popup-menu kb-folder-row__menu" @click.stop>+ <div class="popup-menu-item" @click="onFolderMenuRename(row)">+ <t-icon name="edit" class="menu-icon" />+ <span>{{ t('knowledgeBase.folderTree.rename') }}</span>+ </div>+ </div>+ </template>+ </t-popup>+ </span></template></div></template>@@ -131,6 +158,7 @@ const expanded = ref(new Set<string>([ROOT_FOLDER_PATH]))// null, not '', because '' is the root's own path: a falsy sentinel would put// the root row into rename mode permanently.const renamingPath = ref<string | null>(null)+const menuOpenPath = ref<string | null>(null)const renameValue = ref('')const renameInputRef = ref<HTMLInputElement | HTMLInputElement[] | null>(null)@@ -158,6 +186,15 @@ const startRename = async (row: FolderRow) => {input?.select()}+const onFolderMenuVisible = (path: string, visible: boolean) => {+ menuOpenPath.value = visible ? path : null+}++const onFolderMenuRename = async (row: FolderRow) => {+ menuOpenPath.value = null+ await startRename(row)+}+const cancelRename = () => {renamingPath.value = nullrenameValue.value = ''@@ -202,11 +239,11 @@ watch(<style scoped lang="less">.kb-folder-tree {- --kb-folder-indent: 14px;+ --kb-folder-indent: 10px;display: flex;flex-direction: column;flex-shrink: 0;- width: 232px;+ width: 268px;min-height: 0;padding-right: 12px;margin-right: 12px;@@ -283,11 +320,11 @@ watch(.kb-folder-row {display: flex;align-items: center;- gap: 6px;+ gap: 4px;box-sizing: border-box;width: 100%;height: 30px;- padding: 0 8px 0 calc(var(--kb-folder-depth, 0) * var(--kb-folder-indent) + 8px);+ padding: 0 8px 0 calc(var(--kb-folder-depth, 0) * var(--kb-folder-indent));border-radius: 6px;background: transparent;color: var(--td-text-color-primary);@@ -300,10 +337,6 @@ watch(&:hover {background: var(--td-bg-color-container-hover);-- .kb-folder-row__action {- opacity: 1;- }}&:focus-visible {@@ -364,8 +397,25 @@ watch(white-space: nowrap;}-.kb-folder-row__action {+.kb-folder-row__trailing {flex: 0 0 auto;+ width: 22px;+ height: 20px;+ display: flex;+ align-items: center;+ justify-content: center;+ margin-left: 2px;+}++.kb-folder-row__count {+ font-size: 11px;+ color: var(--td-text-color-placeholder);+ font-variant-numeric: tabular-nums;+ line-height: 1;+}++.kb-folder-row__more {+ display: none;width: 20px;height: 20px;padding: 0;@@ -373,12 +423,10 @@ watch(border-radius: 4px;background: transparent;color: var(--td-text-color-placeholder);- display: inline-flex;align-items: center;justify-content: center;cursor: pointer;- opacity: 0;- transition: opacity 0.15s ease, color 0.15s ease, background-color 0.15s ease;+ transition: color 0.15s ease, background-color 0.15s ease;&:hover {color: var(--td-brand-color);@@ -386,10 +434,29 @@ watch(}.t-icon {- font-size: 13px;+ font-size: 14px;+ }+}++.kb-folder-row.is-editable:hover,+.kb-folder-row.is-menu-open {+ .kb-folder-row__count {+ display: none;+ }++ .kb-folder-row__more {+ display: inline-flex;}}+.kb-folder-row__more.is-open {+ color: var(--td-brand-color);+}++.kb-folder-row__menu {+ min-width: 140px;+}+.kb-folder-row__rename {flex: 1;min-width: 0;@@ -403,11 +470,4 @@ watch(font-size: 13px;outline: none;}--.kb-folder-row__count {- flex: 0 0 auto;- font-size: 11px;- color: var(--td-text-color-placeholder);- font-variant-numeric: tabular-nums;-}</style>diff --git a/frontend/src/views/knowledge/components/UploadConfirmDialog.test.ts b/frontend/src/views/knowledge/components/UploadConfirmDialog.test.tsindex 18dcdfc3c..312c68017 100644--- a/frontend/src/views/knowledge/components/UploadConfirmDialog.test.ts+++ b/frontend/src/views/knowledge/components/UploadConfirmDialog.test.ts@@ -30,11 +30,35 @@ test('uses confirmed tags for file and URL imports instead of reading the list f// selection as it stands when the uploads actually start.test('takes the upload destination folder from the confirmation result', () => {assert.match(host, /:target-folder="uploadConfirmStore\.targetFolder"/)+ assert.match(host, /:folder-options="uploadConfirmStore\.folderOptions"/)assert.match(dialog, /class="destination-row"/)+ assert.match(dialog, /attach="body"/)+ assert.match(dialog, /overlay-class-name="upload-destination-popup"/)+ assert.match(dialog, /FolderPickerMenu/)+ assert.match(dialog, /onDestinationPicked/)assert.match(dialog, /targetFolder: localTargetFolder\.value/)- assert.match(dialog, /@click="localTargetFolder = ''"/)assert.match(knowledgeBase, /targetFolder: result\.targetFolder \|\| ROOT_FOLDER_PATH/)assert.match(knowledgeBase, /targetFolder: selectedFolderPath\.value/)+ assert.match(knowledgeBase, /folderOptions: folderOptions\.value/)+})++test('creates sub-folders from per-row actions without changing the selected destination', () => {+ const picker = readFileSync(new URL('./FolderPickerMenu.vue', import.meta.url), 'utf8')+ assert.match(picker, /startCreatingUnder/)+ assert.match(picker, /folder-picker__add/)+ assert.match(picker, /folder-picker__item--create/)+ assert.match(picker, /@keydown\.enter\.stop="commitNewFolder"/)+ assert.doesNotMatch(picker, /newFolderHintText/)+ assert.doesNotMatch(picker, /folder-picker__create-actions/)+ assert.doesNotMatch(picker, /newFolderParent/)+ assert.match(dialog, /pendingFolderPaths/)+ assert.match(dialog, /pickerFolderOptions/)+ assert.match(dialog, /@create="onDestinationCreated"/)+})++test('calls out directory uploads via relative paths in the file list', () => {+ assert.match(dialog, /fileRelativeDir/)+ assert.doesNotMatch(dialog, /folder-upload-banner/)})test('routes global knowledge file drops through the upload confirmation flow', () => {diff --git a/frontend/src/views/knowledge/components/UploadConfirmDialog.vue b/frontend/src/views/knowledge/components/UploadConfirmDialog.vueindex ef0f174f5..266734f13 100644--- a/frontend/src/views/knowledge/components/UploadConfirmDialog.vue+++ b/frontend/src/views/knowledge/components/UploadConfirmDialog.vue@@ -26,20 +26,41 @@/></div></div>- </div>- <!-- Where the batch lands. Only shown when it is somewhere other- than the top level, i.e. when browsing a folder made the- destination non-obvious. -->- <div v-if="mode === 'file' && localTargetFolder" class="destination-row">- <t-icon name="folder" class="destination-icon" />- <span class="destination-text">- {{ t('uploadConfirm.destinationLabel') }}- <strong class="destination-path" :title="localTargetFolder">{{ destinationLeaf }}</strong>- </span>- <button type="button" class="destination-reset" @click="localTargetFolder = ''">- {{ t('uploadConfirm.destinationToRoot') }}- </button>+ <div v-if="mode === 'file'" class="destination-row">+ <t-popup+ v-model:visible="destinationPickerVisible"+ trigger="click"+ placement="bottom-left"+ attach="body"+ :z-index="3100"+ overlay-class-name="upload-destination-popup"+ destroy-on-close+ >+ <button+ type="button"+ class="destination-crumb"+ :title="destinationFullLabel"+ :aria-label="t('uploadConfirm.destinationChange')"+ :aria-expanded="destinationPickerVisible"+ >+ <span class="destination-crumb__label">{{ t('uploadConfirm.destinationLabel') }}</span>+ <span class="destination-crumb__path">{{ destinationBreadcrumb }}</span>+ <t-icon name="chevron-down" class="destination-crumb__caret" />+ </button>+ <template #content>+ <div class="card-menu" @click.stop>+ <FolderPickerMenu+ :options="pickerFolderOptions"+ :current-path="localTargetFolder"+ allow-reselect+ @create="onDestinationCreated"+ @confirm="onDestinationPicked"+ />+ </div>+ </template>+ </t-popup>+ </div></div><div class="files-list-wrap">@@ -78,12 +99,13 @@<t-icon :name="getFileIcon(file.name)" class="file-icon" /></span><div class="file-meta">- <span class="file-name" :title="file.name">{{ file.name }}</span>+ <span class="file-name" :title="fileDisplayTitle(file)">{{ file.name }}</span><span class="file-size">- {{ formatFileSize(file.size) }}<template v-if="fileRelativeDir(file)">- · <span class="file-relative-dir" :title="fileRelativeDir(file)">{{ fileRelativeDir(file) }}</span>+ <span class="file-relative-dir" :title="fileRelativeDir(file)">{{ fileRelativeDir(file) }}</span>+ <span class="file-meta-sep">·</span></template>+ {{ formatFileSize(file.size) }}</span></div><button@@ -541,6 +563,8 @@ import { formatFileSize, getFileIcon } from '@/utils/files'import { getUploadFileKey } from '../utils/uploadSources'import { listKnowledgeTags } from '@/api/knowledge-base'import KbUploadSourceDropdown from './KbUploadSourceDropdown.vue'+import FolderPickerMenu, { type FolderOption } from './FolderPickerMenu.vue'+import { folderOptionFromPath, sortFolderOptions } from '../folderTree'import type { KnowledgeProcessOverrides } from '@/types/knowledgeProcess'import type {UploadConfirmManualSource,@@ -604,6 +628,8 @@ const props = withDefaults(defineProps<{supportedFileTypes?: string[]/** Folder the batch will be uploaded into; '' means the knowledge base root. */targetFolder?: string+ /** Existing folders offered as upload destinations. */+ folderOptions?: FolderOption[]}>(), {mode: 'file',files: () => [],@@ -614,6 +640,7 @@ const props = withDefaults(defineProps<{acceptFileTypes: '',supportedFileTypes: () => [],targetFolder: '',+ folderOptions: () => [],})const emit = defineEmits<{@@ -640,20 +667,36 @@ const uiState = ref<UploadUIState>(createDefaultUIState())// Destination folder for this batch. Pre-filled from the sidebar tree, but// editable here so browsing a folder never silently decides where files land.const localTargetFolder = ref('')+const destinationPickerVisible = ref(false)+// Folders created in this dialog before upload; the server tree only gains them+// once files land, so keep them here across picker open/close cycles.+const pendingFolderPaths = ref<string[]>([])++const pickerFolderOptions = computed(() => {+ const byPath = new Map<string, FolderOption>()+ ;(props.folderOptions || []).forEach((option) => byPath.set(option.path, option))+ pendingFolderPaths.value.forEach((path) => {+ if (!byPath.has(path)) byPath.set(path, folderOptionFromPath(path))+ })+ return sortFolderOptions([...byPath.values()])+})const dialogVisible = computed({get: () => props.visible,set: (value: boolean) => emit('update:visible', value),})-// Deep paths are shown by their last segment; the full path stays in the title.-// Truncating from the left with `direction: rtl` mangled CJK folder names.-const destinationLeaf = computed(() => {- const path = localTargetFolder.value- const idx = path.lastIndexOf('/')- return idx >= 0 ? path.slice(idx + 1) : path+// Deep paths are shown as root / segment / segment in the picker row.+const destinationBreadcrumb = computed(() => {+ if (!localTargetFolder.value) return t('knowledgeBase.folderTree.rootRow')+ const parts = localTargetFolder.value.split('/').filter(Boolean)+ return [t('knowledgeBase.folderTree.rootRow'), ...parts].join(' / ')})+const destinationFullLabel = computed(() =>+ localTargetFolder.value || t('knowledgeBase.folderTree.rootRow'),+)+/*** Directory a folder-upload file came from, shown under its name so a batch of* same-named files (README.md in five folders) stays distinguishable and the@@ -665,6 +708,21 @@ function fileRelativeDir(file: File): string {return relativePath.split('/').filter(Boolean).slice(0, -1).join('/')}+function fileDisplayTitle(file: File): string {+ const relativePath = (file as File & { webkitRelativePath?: string }).webkitRelativePath+ return relativePath || file.name+}++function onDestinationCreated(path: string) {+ if (!path || pendingFolderPaths.value.includes(path)) return+ pendingFolderPaths.value = [...pendingFolderPaths.value, path]+}++function onDestinationPicked(path: string) {+ localTargetFolder.value = path+ destinationPickerVisible.value = false+}+function getModelName(modelId: string): string {if (!modelId) return t('uploadConfirm.notSet')const model = allModels.value.find((m: any) => m.id === modelId)@@ -1234,6 +1292,8 @@ watch(localUrls.value = props.mode === 'file' ? [...(props.urls || [])] : []selectedTagIds.value = props.mode === 'reparse' ? [] : [...(props.tagIds || [])]localTargetFolder.value = props.mode === 'file' ? (props.targetFolder || '') : ''+ pendingFolderPaths.value = []+ destinationPickerVisible.value = falseinitFromKbInfo(props.kbInfo)if (props.mode === 'reparse') {applyOverridesToState(props.reparsePreview?.processOverrides)@@ -1451,11 +1511,17 @@ const handleConfirm = () => {flex-shrink: 0;align-items: center;box-sizing: border-box;- height: 56px;- padding: 0 12px;+ min-height: 56px;+ padding: 12px;border-bottom: 1px solid var(--td-component-stroke);}+.sidebar-header {+ flex-direction: column;+ align-items: stretch;+ gap: 10px;+}+.sidebar-header-row {display: flex;align-items: center;@@ -1497,55 +1563,60 @@ const handleConfirm = () => {color: var(--td-text-color-secondary);}-// A quiet line rather than a banner: it is a fact about the batch, not a control-// that should compete with the file list.+// Destination sits under the title inside the header block..destination-row {- display: flex;- align-items: baseline;- gap: 6px;flex-shrink: 0;- margin: 0 10px;+ padding: 0;+}++.destination-row :deep(.t-popup__reference) {+ display: block;+ max-width: 100%;+}++.destination-crumb {+ display: inline-flex;+ align-items: center;+ gap: 4px;+ max-width: 100%;+ min-width: 0;+ padding: 0;+ border: 0;+ background: transparent;+ font-family: var(--app-font-family);font-size: 12px;line-height: 18px;- color: var(--td-text-color-placeholder);+ color: var(--td-text-color-secondary);+ cursor: pointer;+ transition: color 0.15s ease;++ &:hover {+ color: var(--td-brand-color);++ .destination-crumb__path,+ .destination-crumb__caret {+ color: var(--td-brand-color);+ }+ }}-.destination-icon {+.destination-crumb__label {flex-shrink: 0;- align-self: center;- font-size: 13px;}-.destination-text {- flex: 1;+.destination-crumb__path {min-width: 0;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;-}--.destination-path {color: var(--td-text-color-primary);font-weight: 500;}-.destination-reset {+.destination-crumb__caret {flex-shrink: 0;- padding: 0;- border: 0;- background: transparent;- color: var(--td-text-color-placeholder);- font-family: var(--app-font-family);font-size: 12px;- text-decoration: underline;- text-decoration-color: transparent;- cursor: pointer;- transition: color 0.15s ease, text-decoration-color 0.15s ease;-- &:hover {- color: var(--td-brand-color);- text-decoration-color: currentColor;- }+ color: var(--td-text-color-placeholder);}.files-list-wrap {@@ -1632,6 +1703,11 @@ const handleConfirm = () => {color: var(--td-text-color-secondary);}+.file-meta-sep {+ margin: 0 4px;+ color: var(--td-text-color-placeholder);+}+.file-remove {display: flex;flex-shrink: 0;@@ -2139,3 +2215,24 @@ const handleConfirm = () => {opacity: 0;}</style>++<style lang="less">+// Must sit above the upload modal (z-index 3000). Do not reuse card-more-popup here —+// its global z-index: 99 !important would hide the menu behind the modal overlay.+.upload-destination-popup {+ z-index: 3100 !important;++ .t-popup__content {+ padding: 4px !important;+ margin-top: 6px !important;+ min-width: 208px;+ border-radius: 10px !important;+ background: var(--td-bg-color-container) !important;+ border: 0.5px solid var(--td-component-stroke) !important;+ box-shadow:+ 0 0 0 0.5px rgba(0, 0, 0, 0.03),+ 0 2px 4px rgba(0, 0, 0, 0.04),+ 0 8px 24px rgba(0, 0, 0, 0.1) !important;+ }+}+</style>diff --git a/frontend/src/views/knowledge/folderTree.test.ts b/frontend/src/views/knowledge/folderTree.test.tsindex 662143072..14f848c84 100644--- a/frontend/src/views/knowledge/folderTree.test.ts+++ b/frontend/src/views/knowledge/folderTree.test.ts@@ -8,12 +8,14 @@ import {childFolders,folderAncestorPaths,folderBreadcrumbs,+ folderOptionFromPath,folderPathExists,isFilteringDocuments,isFolderUpload,joinFolderPath,normalizeFolderPath,ROOT_FOLDER_PATH,+ sortFolderOptions,} from './folderTree.ts'const folders = [@@ -204,3 +206,19 @@ test('a folder cannot be moved inside itself', () => {assert.equal(canMoveFolderTo('docs', ''), false)assert.equal(canMoveFolderTo('', 'docs'), false)})++test('folderOptionFromPath derives picker row metadata from a canonical path', () => {+ assert.deepEqual(folderOptionFromPath('handbook/onboarding'), {+ path: 'handbook/onboarding',+ name: 'onboarding',+ depth: 1,+ })+ assert.deepEqual(+ sortFolderOptions([+ { path: 'handbook/onboarding' },+ { path: 'handbook' },+ { path: 'archive' },+ ]).map((row) => row.path),+ ['archive', 'handbook', 'handbook/onboarding'],+ )+})diff --git a/frontend/src/views/knowledge/folderTree.ts b/frontend/src/views/knowledge/folderTree.tsindex a0e4f7359..546176f1a 100644--- a/frontend/src/views/knowledge/folderTree.ts+++ b/frontend/src/views/knowledge/folderTree.ts@@ -212,6 +212,34 @@ export function joinFolderPath(parent: string, name: string): string {return normalizeFolderPath(parent ? `${parent}/${name}` : name)}+/** Flat picker row for a canonical folder path (used for optimistic create rows). */+export function folderOptionFromPath(path: string): { path: string; name: string; depth: number } {+ const segments = path.split('/').filter(Boolean)+ return {+ path,+ name: segments[segments.length - 1] || path,+ depth: Math.max(segments.length - 1, 0),+ }+}++/** Sort folder picker rows in tree order (parent before child, siblings lexicographic). */+export function sortFolderOptions<T extends { path: string }>(options: T[]): T[] {+ return [...options].sort((a, b) => {+ const aParts = a.path.split('/').filter(Boolean)+ const bParts = b.path.split('/').filter(Boolean)+ const max = Math.max(aParts.length, bParts.length)+ for (let i = 0; i < max; i += 1) {+ const aSeg = aParts[i]+ const bSeg = bParts[i]+ if (aSeg === undefined) return -1+ if (bSeg === undefined) return 1+ const cmp = aSeg.localeCompare(bSeg)+ if (cmp !== 0) return cmp+ }+ return 0+ })+}+/*** Whether a folder can be renamed/moved to `to`: a folder cannot land inside its* own subtree, which would make that subtree unreachable.