Skip to content

Open-source LLM knowledge platform: turn raw documents into a queryable RAG, an autonomous reasoning agent, and a self-maintaining Wiki.

feat(chat): add global search to the @ mention menu and align its styling (#4249)

lyingbug92382208674a
diff --git a/frontend/src/components/Input-field.vue b/frontend/src/components/Input-field.vue
index 0c35b8228..2e3b2f5be 100644
--- a/frontend/src/components/Input-field.vue
+++ b/frontend/src/components/Input-field.vue
@@ -1272,9 +1272,14 @@ const updateModelDropdownPosition = () => {
// Mention Logic
let lastMentionQuery = '';
+// 关键词变化时旧请求可能晚于新请求返回;只采纳最新一次加载的结果
+let mentionLoadSeq = 0;
const loadMentionItems = async (q: string, resetIndex = true, append = false) => {
console.log('[Mention] loadMentionItems called with query:', q, 'append:', append);
+ const seq = append ? mentionLoadSeq : ++mentionLoadSeq;
+ const isStale = () => seq !== mentionLoadSeq;
+ const nextGroupCounts: Partial<Record<MentionItemType, number>> = append ? mentionGroupCounts.value : {};
if (!append) {
mentionOffset.value = 0;
}
@@ -1392,7 +1397,7 @@ const loadMentionItems = async (q: string, resetIndex = true, append = false) =>
orgName: kb.org_name || sharedAgentOrgName.value || undefined
};
}));
- mentionGroupCounts.value.kb = kbItems.length;
+ nextGroupCounts.kb = kbItems.length;
const tagKeyword = q.trim();
const tagSources = availableKbs;
@@ -1410,7 +1415,7 @@ const loadMentionItems = async (q: string, resetIndex = true, append = false) =>
}));
}));
tagItems = tagResults.flat();
- mentionGroupCounts.value.tag = tagItems.length;
+ nextGroupCounts.tag = tagItems.length;
} catch (e) {
console.error('[Mention] listKnowledgeTags error:', e);
tagItems = [];
@@ -1488,6 +1493,7 @@ const loadMentionItems = async (q: string, resetIndex = true, append = false) =>
fileTypesParam,
searchOptions
);
+ if (isStale()) return;
console.log('[Mention] searchKnowledge response:', res);
if (res.data && Array.isArray(res.data)) {
let files = res.data;
@@ -1528,24 +1534,28 @@ const loadMentionItems = async (q: string, resetIndex = true, append = false) =>
if (!append) {
const clientFiltered = !!mentionAllowedKbIds.value && fileItems.length < apiPageSize;
if (!clientFiltered && rawTotal != null) {
- mentionGroupCounts.value.file = rawTotal;
+ nextGroupCounts.file = rawTotal;
} else {
- delete mentionGroupCounts.value.file;
+ delete nextGroupCounts.file;
}
}
}
mentionHasMore.value = res.has_more || false;
mentionOffset.value += fileItems.length;
} catch (e) {
+ if (isStale()) return;
console.error('[Mention] searchKnowledge error:', e);
mentionHasMore.value = false;
} finally {
- mentionLoading.value = false;
+ if (!isStale()) mentionLoading.value = false;
}
} else {
+ if (isStale()) return;
mentionHasMore.value = false;
}
+ if (isStale()) return;
+ if (!append) mentionGroupCounts.value = nextGroupCounts;
if (append) {
// Append file items to existing list
mentionItems.value = [...mentionItems.value, ...fileItems];
@@ -1571,6 +1581,21 @@ const loadMoreMentionItems = () => {
}
};
+let mentionSearchTimer: ReturnType<typeof setTimeout> | null = null;
+const onMentionSearchInput = (q: string) => {
+ mentionQuery.value = q;
+ if (mentionSearchTimer) clearTimeout(mentionSearchTimer);
+ mentionSearchTimer = setTimeout(() => {
+ mentionSearchTimer = null;
+ loadMentionItems(q, true);
+ }, 180);
+};
+
+const closeMentionFromPopup = () => {
+ showMention.value = false;
+ void focusInput();
+};
+
const getTextareaEl = () => {
if (!textareaRef.value) return null;
// If it's a native element
@@ -1631,10 +1656,8 @@ const onInput = (val: string | InputEvent) => {
showMention.value = false;
return;
}
- // Only reload if query changed
if (q !== mentionQuery.value) {
- mentionQuery.value = q;
- loadMentionItems(q, true); // Reset index when query changes
+ onMentionSearchInput(q);
}
} else {
if (textBeforeCursor.endsWith('@')) {
@@ -1655,7 +1678,7 @@ const onInput = (val: string | InputEvent) => {
const rect = rectToCssPx(textarea.getBoundingClientRect(), zoom);
const { width: vw, height: vh } = cssViewportSize(zoom);
const scrollTop = textarea.scrollTop;
- const menuHeight = 320; // 预估最大高度
+ const menuHeight = 380; // 预估最大高度
let left = rect.left + coords.left;
// Prevent menu from going off-screen horizontally
@@ -1688,6 +1711,7 @@ const onInput = (val: string | InputEvent) => {
};
}
+ if (mentionSearchTimer) clearTimeout(mentionSearchTimer);
loadMentionItems("");
}
}
@@ -1734,7 +1758,7 @@ const triggerMention = () => {
const zoom = getRootZoom();
const rect = rectToCssPx(textarea.getBoundingClientRect(), zoom);
const { height: vh } = cssViewportSize(zoom);
- const menuHeight = 320;
+ const menuHeight = 380;
// 判断输入框上方空间
const spaceAbove = rect.top;
@@ -1757,6 +1781,7 @@ const triggerMention = () => {
};
}
+ if (mentionSearchTimer) clearTimeout(mentionSearchTimer);
loadMentionItems("");
};
@@ -1967,6 +1992,7 @@ onUnmounted(() => {
document.removeEventListener('click', closeAgentModeSelector);
document.removeEventListener('click', closeModelSelector);
document.removeEventListener('click', closeMentionSelector);
+ if (mentionSearchTimer) clearTimeout(mentionSearchTimer);
if (resizeHandler) {
window.removeEventListener('resize', resizeHandler);
}
@@ -2402,6 +2428,10 @@ const onKeydown = (val: string, event: { e: KeyboardEvent }) => {
mentionSelectorRef.value?.confirmActive();
return;
}
+ if (event.e.keyCode === 9 && !event.e.shiftKey) { // Tab
+ if (mentionSelectorRef.value?.enterActiveGroup()) event.e.preventDefault();
+ return;
+ }
if (event.e.keyCode === 27) { // Esc
if (mentionSelectorRef.value?.leaveGroup()) {
return;
@@ -3010,7 +3040,9 @@ defineExpose({
<!-- Mention Selector -->
<Teleport to="body">
<MentionSelector ref="mentionSelectorRef" :visible="showMention" :style="mentionStyle" :items="mentionItems" :hasMore="mentionHasMore"
- :loading="mentionLoading" :emptyHint="mentionEmptyHint" :query="mentionQuery" :group-counts="mentionGroupCounts" v-model:activeIndex="mentionActiveIndex"
+ :loading="mentionLoading" :emptyHint="mentionEmptyHint" :query="mentionQuery" :searchable="isMentionTriggeredByButton"
+ :group-counts="mentionGroupCounts" v-model:activeIndex="mentionActiveIndex"
+ @update:query="onMentionSearchInput" @close="closeMentionFromPopup"
@select="onMentionSelect" @loadMore="loadMoreMentionItems" />
</Teleport>
diff --git a/frontend/src/components/MentionSelector.test.ts b/frontend/src/components/MentionSelector.test.ts
index 8a0b49d52..a3b1dc9f7 100644
--- a/frontend/src/components/MentionSelector.test.ts
+++ b/frontend/src/components/MentionSelector.test.ts
@@ -15,3 +15,24 @@ test('MCP mention hover shows catalog summary instead of a bare name', () => {
assert.doesNotMatch(source, /detail-type-badge doc">MCP/)
assert.doesNotMatch(source, /t-dialog/)
})
+
+test('mention menu exposes a search box that is editable only when opened from the button', () => {
+ assert.match(source, /class="mention-search__input"/)
+ assert.match(source, /:readonly="!searchable"/)
+ assert.match(source, /emit\('update:query'/)
+ assert.match(source, /emit\('close'\)/)
+})
+
+test('global search caps each group and lets the user drill into the full group', () => {
+ assert.match(source, /const FLAT_GROUP_LIMIT = 5/)
+ assert.match(source, /mentionDetail\.viewAll/)
+ assert.match(source, /enterActiveGroup/)
+ // 分组内输入关键词时保持在分组内过滤,而不是跳回全局结果
+ assert.match(source, /isFlatMode = computed\(\(\) => !currentGroupType\.value && trimmedQuery\.value\.length > 0\)/)
+})
+
+test('mention menu follows the shared popover look of the other input selectors', () => {
+ assert.match(source, /border-radius: var\(--app-radius-lg\)/)
+ assert.match(source, /box-shadow: var\(--td-shadow-2\)/)
+ assert.doesNotMatch(source, /label: '标签'/)
+})
diff --git a/frontend/src/components/MentionSelector.vue b/frontend/src/components/MentionSelector.vue
index 3ead6a8ba..3b27fdaf8 100644
--- a/frontend/src/components/MentionSelector.vue
+++ b/frontend/src/components/MentionSelector.vue
@@ -1,276 +1,256 @@
<template>
- <div v-if="visible" class="mention-menu" :style="style" ref="menuRef" @click.stop>
+ <div v-if="visible" class="mention-menu" :style="[style, stableHeightStyle]" ref="menuRef" @click.stop>
+ <div class="mention-search">
+ <div class="mention-search__box" :class="{ 'is-readonly': !searchable }">
+ <span class="mention-search__icon">
+ <t-loading v-if="loading" size="12px" />
+ <t-icon v-else name="search" />
+ </span>
+ <button
+ v-if="currentGroup"
+ type="button"
+ class="mention-search__crumb"
+ :title="$t('mentionDetail.back')"
+ @mousedown.prevent
+ @click.stop="leaveGroup"
+ >
+ <t-icon name="chevron-left" />
+ <span>{{ currentGroup.label }}</span>
+ </button>
+ <input
+ ref="searchInputRef"
+ class="mention-search__input"
+ type="text"
+ :value="query ?? ''"
+ :readonly="!searchable"
+ :tabindex="searchable ? 0 : -1"
+ :placeholder="searchPlaceholder"
+ autocomplete="off"
+ spellcheck="false"
+ @mousedown="!searchable && $event.preventDefault()"
+ @input="onSearchInput"
+ @compositionstart="isComposing = true"
+ @compositionend="onCompositionEnd"
+ @keydown="onSearchKeydown"
+ />
+ </div>
+ </div>
+
<div class="mention-list" ref="listRef" @scroll="onScroll">
- <template v-if="!currentGroupType && !isFlatMode">
+ <!-- 根层级:分组入口 -->
+ <template v-if="isRootView">
<button
v-for="(group, index) in groupRows"
:key="group.type"
type="button"
- class="mention-group-entry"
+ class="mention-row mention-group-entry"
:class="{ active: index === groupActiveIndex }"
@click.stop="enterGroup(group.type)"
@mouseenter="groupActiveIndex = index"
>
- <span class="mention-group-entry__icon">
+ <span class="mention-row__icon">
<t-icon :name="group.icon" />
</span>
- <span class="mention-group-entry__label">{{ group.label }}</span>
- <span class="mention-group-entry__count">{{ formatGroupCount(group) }}</span>
- <t-icon class="mention-group-entry__arrow" name="chevron-right" />
+ <span class="mention-row__name">{{ group.label }}</span>
+ <span class="mention-row__meta">{{ formatGroupCount(group) }}</span>
+ <t-icon class="mention-row__arrow" name="chevron-right" />
</button>
<div v-if="groupRows.length === 0 && !loading" class="empty">
{{ emptyHint || $t('common.noResult') }}
</div>
</template>
+ <!-- 全局搜索结果 / 分组内列表 -->
<template v-else>
- <button v-if="!isFlatMode" type="button" class="mention-back-row" @click.stop="leaveGroup">
- <t-icon name="chevron-left" />
- <span>{{ currentGroup?.label }}</span>
- </button>
-
- <div
- v-if="isFlatMode && groupTabs.length > 1 && kbItems.length > 0"
- class="mention-group-header"
- >
- {{ $t('common.knowledgeBase') }}
- </div>
- <!-- Knowledge Bases Group -->
- <div v-if="(isFlatMode || currentGroupType === 'kb') && kbItems.length > 0" class="mention-group" data-group-type="kb">
- <t-popup
- v-for="(item, index) in kbItems"
- :key="item.id"
- placement="right-start"
- trigger="hover"
- :show-arrow="false"
- :delay="[320, 80]"
- :disabled="isScrolling"
- :overlay-class-name="'mention-detail-popup'"
- :overlay-inner-class-name="'mention-detail-popup-wrap'"
- @visible-change="(v: boolean) => v && fetchKbDetail(item)"
- >
- <div
- class="mention-item"
- :class="{ active: index === activeIndex }"
- @click="$emit('select', item)"
- @mouseenter="$emit('update:activeIndex', index)"
- >
- <div class="icon-wrap">
- <div class="icon" :class="item.kbType === 'faq' ? 'faq-icon' : 'kb-icon'">
- <t-icon :name="item.kbType === 'faq' ? 'chat-bubble-help' : 'folder'" />
- </div>
- </div>
- <div class="item-main">
- <span class="name">{{ item.name }}</span>
- <span class="count">{{ item.count || 0 }}</span>
- </div>
- </div>
- <template #content>
- <div class="mention-detail-content">
- <template v-if="detailCache[item.id]?.loading">
- <div class="detail-loading"><t-loading size="small" /></div>
- </template>
- <template v-else-if="detailCache[item.id]?.error">
- <div class="detail-error">{{ detailCache[item.id].error }}</div>
- </template>
- <template v-else-if="detailCache[item.id]?.data">
- <div class="detail-header">
- <span class="detail-name">{{ detailCache[item.id].data.name }}</span>
- <span class="detail-type-badge" :class="detailCache[item.id].data.type === 'faq' ? 'faq' : 'doc'">
- {{ detailCache[item.id].data.type === 'faq' ? $t('knowledgeEditor.basic.typeFAQ') : $t('knowledgeEditor.basic.typeDocument') }}
- </span>
- </div>
- <p v-if="detailCache[item.id].data.description" class="detail-desc">{{ detailCache[item.id].data.description }}</p>
- <div class="detail-meta">
- <span v-if="detailCache[item.id].data.type === 'faq'">
- {{ $t('mentionDetail.faqCount', { count: detailCache[item.id].data.chunk_count ?? detailCache[item.id].data.count ?? 0 }) }}
- </span>
- <span v-else>
- {{ $t('mentionDetail.kbCount', { count: detailCache[item.id].data.knowledge_count ?? detailCache[item.id].data.count ?? 0 }) }}
- </span>
- <span v-if="detailCache[item.id].data.org_name || item.orgName" class="detail-org">
- <img src="@/assets/img/organization-green.svg" class="detail-icon-img" alt="" aria-hidden="true" />
- <span class="detail-label">{{ $t('mentionDetail.belongsToOrg') }}</span>
- <span
- class="detail-value clickable"
- @click.stop="handleOrgClick(detailCache[item.id].data.org_name || item.orgName)"
- >
- {{ detailCache[item.id].data.org_name || item.orgName }}
- </span>
- </span>
- <span v-if="agentIdForDetail && (detailCache[item.id].data.org_name || item.orgName)" class="detail-readonly-hint">
- {{ $t('mentionDetail.readOnlyFromAgent') }}
- </span>
- </div>
- </template>
- </div>
- </template>
- </t-popup>
- </div>
-
- <template v-for="group in activeExtraGroups" :key="group.type">
- <div
- v-if="isFlatMode && groupTabs.length > 1"
- class="mention-group-header"
- >
- {{ group.label }}
- </div>
- <div class="mention-group" :data-group-type="group.type">
- <t-popup
- v-for="(item, index) in group.items"
- :key="`${item.type}:${item.id}`"
- placement="right-start"
- trigger="hover"
- :show-arrow="false"
- :delay="[320, 80]"
- :disabled="isScrolling"
- :overlay-class-name="'mention-detail-popup'"
- :overlay-inner-class-name="'mention-detail-popup-wrap'"
- >
- <div
- class="mention-item"
- :class="{ active: group.offset + index === activeIndex }"
- @click="$emit('select', item)"
- @mouseenter="$emit('update:activeIndex', group.offset + index)"
- >
- <div class="icon-wrap">
- <div class="icon" :class="`${item.type}-icon`">
- <t-icon :name="group.icon" />
- </div>
- </div>
- <div class="item-main">
- <span class="name">{{ item.name }}</span>
- <span
- v-if="item.type === 'mcp' && item.catalogSynced"
- class="count"
- :class="{ 'is-stale': item.catalogStale }"
- >{{ item.toolCount ?? 0 }}</span>
- </div>
+ <template v-for="group in visibleGroups" :key="group.type">
+ <div v-if="isFlatMode" class="mention-section-header">
+ <span class="mention-section-header__label">{{ group.label }}</span>
+ <span class="mention-section-header__count">{{ formatGroupCount(group) }}</span>
+ <button
+ v-if="group.hasHidden"
+ type="button"
+ class="mention-section-header__more"
+ @mousedown.prevent
+ @click.stop="enterGroup(group.type)"
+ >
+ {{ $t('mentionDetail.viewAll') }}
+ <t-icon name="chevron-right" />
+ </button>
</div>
- <template #content>
- <div class="mention-detail-content">
- <div class="detail-header">
- <span class="detail-name">{{ item.name }}</span>
- </div>
- <p v-if="item.description" class="detail-desc">{{ item.description }}</p>
- <div v-if="item.type === 'mcp'" class="detail-meta">
- <span class="detail-kb">
- <t-icon name="tools" class="detail-icon" />
- <span v-if="item.catalogSynced" class="detail-value">
- {{ $t('mentionDetail.mcpToolCount', { count: item.toolCount ?? 0 }) }}
- </span>
- <span v-else class="detail-value">{{ $t('mentionDetail.mcpNotSynced') }}</span>
- </span>
- <span v-if="item.catalogSynced && item.catalogStale" class="detail-stale">
- {{ $t('mentionDetail.mcpStale') }}
- </span>
- </div>
- <div v-else-if="item.kbName || item.serviceName" class="detail-meta">
- <span v-if="item.kbName" class="detail-kb">
- <t-icon name="folder" class="detail-icon" />
- <span class="detail-label">{{ $t('mentionDetail.belongsToKb') }}</span>
- <span
- class="detail-value clickable"
- @click.stop="handleKbClick(item.kbId)"
- >
- {{ item.kbName }}
- </span>
+ <div class="mention-group" :data-group-type="group.type">
+ <t-popup
+ v-for="(item, index) in group.visibleItems"
+ :key="`${item.type}:${item.id}`"
+ placement="right-start"
+ trigger="hover"
+ :show-arrow="false"
+ :delay="[320, 80]"
+ :disabled="isScrolling"
+ :overlay-class-name="'mention-detail-popup'"
+ :overlay-inner-class-name="'mention-detail-popup-wrap'"
+ @visible-change="(v: boolean) => v && fetchDetail(item)"
+ >
+ <div
+ class="mention-row mention-item"
+ :class="{ active: group.offset + index === activeIndex }"
+ @click="$emit('select', item)"
+ @mouseenter="$emit('update:activeIndex', group.offset + index)"
+ >
+ <span class="mention-row__icon" :class="item.type === 'kb' && item.kbType === 'faq' ? 'faq-icon' : `${item.type}-icon`">
+ <t-icon :name="itemIcon(item)" />
</span>
- <span v-if="item.serviceName" class="detail-kb">
- <t-icon name="tools" class="detail-icon" />
- <span class="detail-label">MCP:</span>
- <span class="detail-value">{{ item.serviceName }}</span>
+ <span class="mention-row__name">
+ <template v-for="(part, pi) in highlightParts(item.name)" :key="pi">
+ <mark v-if="part.hit" class="mention-hit">{{ part.text }}</mark>
+ <template v-else>{{ part.text }}</template>
+ </template>
</span>
+ <span
+ v-if="item.type === 'kb'"
+ class="mention-row__meta"
+ >{{ item.count || 0 }}</span>
+ <span
+ v-else-if="item.type === 'mcp' && item.catalogSynced"
+ class="mention-row__meta"
+ :class="{ 'is-stale': item.catalogStale }"
+ >{{ item.toolCount ?? 0 }}</span>
+ <span
+ v-else-if="(item.type === 'file' || item.type === 'tag') && item.kbName"
+ class="mention-row__meta mention-row__meta--text"
+ >{{ item.kbName }}</span>
</div>
- </div>
- </template>
- </t-popup>
- </div>
- </template>
-
- <div
- v-if="isFlatMode && groupTabs.length > 1 && fileItems.length > 0"
- class="mention-group-header"
- >
- {{ $t('common.file') }}
- </div>
- <!-- Files Group -->
- <div v-if="(isFlatMode || currentGroupType === 'file') && fileItems.length > 0" class="mention-group" data-group-type="file">
- <t-popup
- v-for="(item, index) in fileItems"
- :key="item.id"
- placement="right-start"
- trigger="hover"
- :show-arrow="false"
- :delay="[320, 80]"
- :disabled="isScrolling"
- :overlay-class-name="'mention-detail-popup'"
- :overlay-inner-class-name="'mention-detail-popup-wrap'"
- @visible-change="(v: boolean) => v && fetchFileDetail(item)"
- >
- <div
- class="mention-item"
- :class="{ active: (fileGroupOffset + index) === activeIndex }"
- @click="$emit('select', item)"
- @mouseenter="$emit('update:activeIndex', fileGroupOffset + index)"
- >
- <div class="icon-wrap">
- <div class="icon file-icon">
- <t-icon name="file" />
- </div>
- </div>
- <span class="name">{{ item.name }}</span>
- </div>
- <template #content>
- <div class="mention-detail-content">
- <template v-if="detailCache[item.id]?.loading">
- <div class="detail-loading"><t-loading size="small" /></div>
- </template>
- <template v-else-if="detailCache[item.id]?.error">
- <div class="detail-error">{{ detailCache[item.id].error }}</div>
- </template>
- <template v-else-if="detailCache[item.id]?.data">
- <div class="detail-header">
- <span class="detail-name">{{ detailCache[item.id].data.title || detailCache[item.id].data.file_name || item.name }}</span>
- </div>
- <p v-if="detailCache[item.id].data.description" class="detail-desc">{{ detailCache[item.id].data.description }}</p>
- <div class="detail-meta">
- <span v-if="detailCache[item.id].data.knowledge_base_name || item.kbName" class="detail-kb">
- <t-icon name="folder" class="detail-icon" />
- <span class="detail-label">{{ $t('mentionDetail.belongsToKb') }}</span>
- <span
- class="detail-value clickable"
- @click.stop="handleKbClick(detailCache[item.id].data.knowledge_base_id || (item as any).kbId)"
- >
- {{ detailCache[item.id].data.knowledge_base_name || item.kbName }}
- </span>
- </span>
- <span v-if="item.orgName" class="detail-org">
- <img src="@/assets/img/organization-green.svg" class="detail-icon-img" alt="" aria-hidden="true" />
- <span class="detail-label">{{ $t('mentionDetail.belongsToOrg') }}</span>
- <span
- class="detail-value clickable"
- @click.stop="handleOrgClick(item.orgName)"
- >
- {{ item.orgName }}
- </span>
- </span>
+ <template #content>
+ <div class="mention-detail-content">
+ <!-- 知识库详情 -->
+ <template v-if="item.type === 'kb'">
+ <template v-if="detailCache[item.id]?.loading">
+ <div class="detail-loading"><t-loading size="small" /></div>
+ </template>
+ <template v-else-if="detailCache[item.id]?.error">
+ <div class="detail-error">{{ detailCache[item.id].error }}</div>
+ </template>
+ <template v-else-if="detailCache[item.id]?.data">
+ <div class="detail-header">
+ <span class="detail-name">{{ detailCache[item.id].data.name }}</span>
+ <span class="detail-type-badge" :class="detailCache[item.id].data.type === 'faq' ? 'faq' : 'doc'">
+ {{ detailCache[item.id].data.type === 'faq' ? $t('knowledgeEditor.basic.typeFAQ') : $t('knowledgeEditor.basic.typeDocument') }}
+ </span>
+ </div>
+ <p v-if="detailCache[item.id].data.description" class="detail-desc">{{ detailCache[item.id].data.description }}</p>
+ <div class="detail-meta">
+ <span v-if="detailCache[item.id].data.type === 'faq'">
+ {{ $t('mentionDetail.faqCount', { count: detailCache[item.id].data.chunk_count ?? detailCache[item.id].data.count ?? 0 }) }}
+ </span>
+ <span v-else>
+ {{ $t('mentionDetail.kbCount', { count: detailCache[item.id].data.knowledge_count ?? detailCache[item.id].data.count ?? 0 }) }}
+ </span>
+ <span v-if="detailCache[item.id].data.org_name || item.orgName" class="detail-org">
+ <img src="@/assets/img/organization-green.svg" class="detail-icon-img" alt="" aria-hidden="true" />
+ <span class="detail-label">{{ $t('mentionDetail.belongsToOrg') }}</span>
+ <span
+ class="detail-value clickable"
+ @click.stop="handleOrgClick(detailCache[item.id].data.org_name || item.orgName)"
+ >
+ {{ detailCache[item.id].data.org_name || item.orgName }}
+ </span>
+ </span>
+ <span v-if="agentIdForDetail && (detailCache[item.id].data.org_name || item.orgName)" class="detail-readonly-hint">
+ {{ $t('mentionDetail.readOnlyFromAgent') }}
+ </span>
+ </div>
+ </template>
+ </template>
+
+ <!-- 文件详情 -->
+ <template v-else-if="item.type === 'file'">
+ <template v-if="detailCache[item.id]?.loading">
+ <div class="detail-loading"><t-loading size="small" /></div>
+ </template>
+ <template v-else-if="detailCache[item.id]?.error">
+ <div class="detail-error">{{ detailCache[item.id].error }}</div>
+ </template>
+ <template v-else-if="detailCache[item.id]?.data">
+ <div class="detail-header">
+ <span class="detail-name">{{ detailCache[item.id].data.title || detailCache[item.id].data.file_name || item.name }}</span>
+ </div>
+ <p v-if="detailCache[item.id].data.description" class="detail-desc">{{ detailCache[item.id].data.description }}</p>
+ <div class="detail-meta">
+ <span v-if="detailCache[item.id].data.knowledge_base_name || item.kbName" class="detail-kb">
+ <t-icon name="folder" class="detail-icon" />
+ <span class="detail-label">{{ $t('mentionDetail.belongsToKb') }}</span>
+ <span
+ class="detail-value clickable"
+ @click.stop="handleKbClick(detailCache[item.id].data.knowledge_base_id || item.kbId)"
+ >
+ {{ detailCache[item.id].data.knowledge_base_name || item.kbName }}
+ </span>
+ </span>
+ <span v-if="item.orgName" class="detail-org">
+ <img src="@/assets/img/organization-green.svg" class="detail-icon-img" alt="" aria-hidden="true" />
+ <span class="detail-label">{{ $t('mentionDetail.belongsToOrg') }}</span>
+ <span
+ class="detail-value clickable"
+ @click.stop="handleOrgClick(item.orgName)"
+ >
+ {{ item.orgName }}
+ </span>
+ </span>
+ </div>
+ </template>
+ </template>
+
+ <!-- 标签 / MCP / 技能 -->
+ <template v-else>
+ <div class="detail-header">
+ <span class="detail-name">{{ item.name }}</span>
+ </div>
+ <p v-if="item.description" class="detail-desc">{{ item.description }}</p>
+ <div v-if="item.type === 'mcp'" class="detail-meta">
+ <span class="detail-kb">
+ <t-icon name="tools" class="detail-icon" />
+ <span v-if="item.catalogSynced" class="detail-value">
+ {{ $t('mentionDetail.mcpToolCount', { count: item.toolCount ?? 0 }) }}
+ </span>
+ <span v-else class="detail-value">{{ $t('mentionDetail.mcpNotSynced') }}</span>
+ </span>
+ <span v-if="item.catalogSynced && item.catalogStale" class="detail-stale">
+ {{ $t('mentionDetail.mcpStale') }}
+ </span>
+ </div>
+ <div v-else-if="item.kbName || item.serviceName" class="detail-meta">
+ <span v-if="item.kbName" class="detail-kb">
+ <t-icon name="folder" class="detail-icon" />
+ <span class="detail-label">{{ $t('mentionDetail.belongsToKb') }}</span>
+ <span
+ class="detail-value clickable"
+ @click.stop="handleKbClick(item.kbId)"
+ >
+ {{ item.kbName }}
+ </span>
+ </span>
+ <span v-if="item.serviceName" class="detail-kb">
+ <t-icon name="tools" class="detail-icon" />
+ <span class="detail-label">MCP:</span>
+ <span class="detail-value">{{ item.serviceName }}</span>
+ </span>
+ </div>
+ </template>
</div>
</template>
- </div>
- </template>
- </t-popup>
- <!-- Loading indicator -->
- <div v-if="loading" class="loading-more">
+ </t-popup>
+ </div>
+ </template>
+
+ <div v-if="loading && currentGroupType === 'file' && visibleItems.length > 0" class="loading-more">
<t-loading size="small" />
</div>
- </div>
- <div v-if="items.length === 0 && !loading" class="empty">
- {{ emptyHint || $t('common.noResult') }}
- </div>
+ <div v-if="visibleItems.length === 0" class="empty">
+ <template v-if="!loading">{{ emptyHint || $t('common.noResult') }}</template>
+ </div>
</template>
</div>
+
</div>
</template>
@@ -280,7 +260,6 @@ import { useRouter } from 'vue-router';
import { useI18n } from 'vue-i18n';
import { getKnowledgeBaseById } from '@/api/knowledge-base';
import { getKnowledgeDetails } from '@/api/knowledge-base';
-import { useOrganizationStore } from '@/stores/organization';
import { useSettingsStore } from '@/stores/settings';
import { SKILL_ICON, type MentionItem, type MentionItemType } from '@/types/mention';
@@ -290,27 +269,33 @@ const props = defineProps<{
visible: boolean;
style: any;
items: MentionItem[];
+ /** 当前可见列表(全局搜索结果或分组内列表)中的高亮下标 */
activeIndex: number;
hasMore?: boolean;
loading?: boolean;
// 空态下替换默认 "无结果" 文案,用于给上游(如"被智能体工具兼容性过滤掉了")透传具体原因
emptyHint?: string;
- // 输入 @ 后的筛选关键词;非空时平铺展示匹配项,不再要求进入二级目录
+ // 搜索关键词;在根层级非空时做跨分组的全局搜索,在分组内则只过滤该分组
query?: string;
+ // 为 true 时顶部搜索框可编辑并自动聚焦(按钮触发);否则关键词来自输入框中 @ 之后的文本
+ searchable?: boolean;
// 分组入口展示用的总数(如文件搜索的 total),避免仅用首屏已加载条数
groupCounts?: Partial<Record<MentionItemType, number>>;
}>();
-const emit = defineEmits(['select', 'update:activeIndex', 'loadMore']);
+const emit = defineEmits(['select', 'update:activeIndex', 'update:query', 'loadMore', 'close']);
+
+const FLAT_GROUP_LIMIT = 5;
const router = useRouter();
const { t } = useI18n();
-const orgStore = useOrganizationStore();
const settingsStore = useSettingsStore();
const menuRef = ref<HTMLElement | null>(null);
const listRef = ref<HTMLElement | null>(null);
+const searchInputRef = ref<HTMLInputElement | null>(null);
const detailCache = ref<Record<string, DetailState>>({});
const isScrolling = ref(false);
+const isComposing = ref(false);
const currentGroupType = ref<MentionItemType | null>(null);
const groupActiveIndex = ref(0);
let scrollTimer: ReturnType<typeof setTimeout> | null = null;
@@ -327,29 +312,71 @@ const agentIdForDetail = computed(() => {
});
const agentSourceTenantIdForDetail = computed(() => settingsStore.selectedAgentSourceTenantId ?? undefined);
-const kbItems = computed(() => props.items.filter(item => item.type === 'kb'));
-const fileItems = computed(() => props.items.filter(item => item.type === 'file'));
-
const mentionGroupDefs = computed<Array<{ type: MentionItemType; label: string; icon: string }>>(() => [
{ type: 'kb', label: t('common.knowledgeBase'), icon: 'folder' },
- { type: 'tag', label: '标签', icon: 'tag' },
+ { type: 'tag', label: t('mentionDetail.tag'), icon: 'tag' },
{ type: 'mcp', label: 'MCP', icon: 'tools' },
{ type: 'skill', label: t('common.skill'), icon: SKILL_ICON },
{ type: 'file', label: t('common.file'), icon: 'file' },
]);
-const mentionGroups = computed(() => {
+const mentionGroups = computed(() => mentionGroupDefs.value.map(def => {
+ const items = props.items.filter(item => item.type === def.type);
+ const loadedCount = items.length;
+ const count = props.groupCounts?.[def.type] ?? loadedCount;
+ return { ...def, items, count, loadedCount };
+}));
+
+type MentionGroup = (typeof mentionGroups.value)[number];
+
+const trimmedQuery = computed(() => (props.query ?? '').trim());
+const currentGroup = computed(() => mentionGroups.value.find(group => group.type === currentGroupType.value) || null);
+const isFlatMode = computed(() => !currentGroupType.value && trimmedQuery.value.length > 0);
+const isRootView = computed(() => !currentGroupType.value && !isFlatMode.value);
+const groupRows = computed(() => mentionGroups.value.filter(group => group.count > 0));
+
+const visibleGroups = computed(() => {
+ const source: MentionGroup[] = currentGroup.value
+ ? [currentGroup.value]
+ : isFlatMode.value
+ ? mentionGroups.value.filter(group => group.loadedCount > 0)
+ : [];
let offset = 0;
- return mentionGroupDefs.value.map(def => {
- const items = props.items.filter(item => item.type === def.type);
- const loadedCount = items.length;
- const count = props.groupCounts?.[def.type] ?? loadedCount;
- const group = { ...def, items, offset, count, loadedCount };
- offset += items.length;
- return group;
+ return source.map(group => {
+ const visibleItems = isFlatMode.value ? group.items.slice(0, FLAT_GROUP_LIMIT) : group.items;
+ const hasHidden = isFlatMode.value && (group.loadedCount > visibleItems.length || group.count > visibleItems.length);
+ const row = { ...group, visibleItems, hasHidden, offset };
+ offset += visibleItems.length;
+ return row;
});
});
+const visibleItems = computed(() => visibleGroups.value.flatMap(group => group.visibleItems));
+
+// 菜单贴着输入框向上展开,结果条数变化会让顶边上下跳;搜索期间高度只增不减
+const stableMinHeight = ref(0);
+const stableHeightStyle = computed(() => (
+ !isRootView.value && stableMinHeight.value ? { minHeight: `${stableMinHeight.value}px` } : undefined
+));
+
+watch(
+ [() => visibleItems.value.length, () => props.loading, isRootView],
+ () => {
+ if (isRootView.value) {
+ stableMinHeight.value = 0;
+ return;
+ }
+ const height = menuRef.value?.offsetHeight ?? 0;
+ if (height > stableMinHeight.value) stableMinHeight.value = height;
+ },
+ { flush: 'post' },
+);
+
+const searchPlaceholder = computed(() => {
+ if (currentGroup.value) return t('mentionDetail.searchInGroup', { group: currentGroup.value.label });
+ return props.searchable ? t('mentionDetail.searchPlaceholder') : t('mentionDetail.typeToSearch');
+});
+
const formatGroupCount = (group: { type: MentionItemType; count: number; loadedCount: number }) => {
if (props.groupCounts?.[group.type] != null) {
return props.groupCounts[group.type]!;
@@ -360,105 +387,157 @@ const formatGroupCount = (group: { type: MentionItemType; count: number; loadedC
return group.count;
};
-const groupTabs = computed(() => mentionGroups.value.filter(group => group.count > 0));
-const groupRows = computed(() => groupTabs.value);
-const isFlatMode = computed(() => (props.query ?? '').trim().length > 0);
-const currentGroup = computed(() => mentionGroups.value.find(group => group.type === currentGroupType.value));
-const extraGroups = computed(() => mentionGroups.value.filter(group =>
- group.type !== 'kb' && group.type !== 'file' && group.count > 0
-));
-const activeExtraGroups = computed(() => {
- if (isFlatMode.value) return extraGroups.value;
- return extraGroups.value.filter(group => group.type === currentGroupType.value);
-});
-const fileGroupOffset = computed(() => mentionGroups.value.find(group => group.type === 'file')?.offset || 0);
-
-const enterGroup = (type: MentionItemType) => {
- const group = mentionGroups.value.find(item => item.type === type && item.count > 0);
- if (!group || !listRef.value) return;
+const itemIcon = (item: MentionItem) => {
+ if (item.type === 'kb') return item.kbType === 'faq' ? 'chat-bubble-help' : 'folder';
+ return mentionGroupDefs.value.find(def => def.type === item.type)?.icon || 'file';
+};
- currentGroupType.value = type;
- emit('update:activeIndex', group.offset);
+const highlightParts = (name: string) => {
+ const q = trimmedQuery.value;
+ if (!q || !name) return [{ text: name, hit: false }];
+ const idx = name.toLowerCase().indexOf(q.toLowerCase());
+ if (idx < 0) return [{ text: name, hit: false }];
+ return [
+ { text: name.slice(0, idx), hit: false },
+ { text: name.slice(idx, idx + q.length), hit: true },
+ { text: name.slice(idx + q.length), hit: false },
+ ].filter(part => part.text);
+};
+const resetListScroll = () => {
nextTick(() => {
- if (!listRef.value) return;
- listRef.value.scrollTo({
- top: 0,
- });
+ if (listRef.value) listRef.value.scrollTop = 0;
});
};
+const enterGroup = (type: MentionItemType) => {
+ const group = mentionGroups.value.find(item => item.type === type && item.count > 0);
+ if (!group) return;
+ currentGroupType.value = type;
+ emit('update:activeIndex', 0);
+ resetListScroll();
+ focusSearch();
+};
+
const leaveGroup = () => {
- if (isFlatMode.value) return false;
if (!currentGroupType.value) return false;
const rowIndex = groupRows.value.findIndex(group => group.type === currentGroupType.value);
groupActiveIndex.value = Math.max(0, rowIndex);
currentGroupType.value = null;
- nextTick(() => {
- if (listRef.value) listRef.value.scrollTop = 0;
- });
+ emit('update:activeIndex', 0);
+ resetListScroll();
+ focusSearch();
return true;
};
-const updateActiveGroupFromIndex = (index: number) => {
- const group = groupTabs.value.find(item => index >= item.offset && index < item.offset + item.count);
- if (group) currentGroupType.value = group.type;
+/** 全局搜索结果中,从当前高亮项进入其所在分组查看全部 */
+const enterActiveGroup = () => {
+ if (isRootView.value) {
+ confirmActive();
+ return true;
+ }
+ if (!isFlatMode.value) return false;
+ const group = visibleGroups.value.find(g => props.activeIndex >= g.offset && props.activeIndex < g.offset + g.visibleItems.length);
+ if (!group) return false;
+ enterGroup(group.type);
+ return true;
};
-watch(groupTabs, (groups) => {
+watch(groupRows, (groups) => {
if (groupActiveIndex.value >= groups.length) {
groupActiveIndex.value = Math.max(0, groups.length - 1);
}
});
-const moveActive = (delta: number) => {
- if (isFlatMode.value) {
- const next = Math.min(props.items.length - 1, Math.max(0, props.activeIndex + delta));
- emit('update:activeIndex', next);
- scrollToItem(next);
- return;
+watch(() => visibleItems.value.length, (len) => {
+ if (!isRootView.value && props.activeIndex >= len) {
+ emit('update:activeIndex', Math.max(0, len - 1));
}
+});
- if (!currentGroupType.value) {
+const moveActive = (delta: number) => {
+ if (isRootView.value) {
const maxIndex = Math.max(0, groupRows.value.length - 1);
groupActiveIndex.value = Math.min(maxIndex, Math.max(0, groupActiveIndex.value + delta));
+ scrollToRow(groupActiveIndex.value);
return;
}
-
- const group = currentGroup.value;
- if (!group) return;
- const currentLocalIndex = props.activeIndex - group.offset;
- const nextLocalIndex = Math.min(group.count - 1, Math.max(0, currentLocalIndex + delta));
- emit('update:activeIndex', group.offset + nextLocalIndex);
- scrollToItem(nextLocalIndex);
+ const len = visibleItems.value.length;
+ if (!len) return;
+ const next = Math.min(len - 1, Math.max(0, props.activeIndex + delta));
+ emit('update:activeIndex', next);
+ scrollToRow(next);
+ if (currentGroupType.value === 'file' && next >= len - 3 && props.hasMore && !props.loading) {
+ emit('loadMore');
+ }
};
const confirmActive = () => {
- if (isFlatMode.value) {
- const item = props.items[props.activeIndex];
- if (item) emit('select', item);
- return;
- }
-
- if (!currentGroupType.value) {
+ if (isRootView.value) {
const group = groupRows.value[groupActiveIndex.value];
if (group) enterGroup(group.type);
return;
}
-
- const group = currentGroup.value;
- if (!group) return;
- const localIndex = props.activeIndex - group.offset;
- const item = group.items[localIndex];
+ const item = visibleItems.value[props.activeIndex];
if (item) emit('select', item);
};
+const focusSearch = () => {
+ if (!props.searchable) return;
+ nextTick(() => searchInputRef.value?.focus({ preventScroll: true }));
+};
+
+const onSearchInput = (e: Event) => {
+ if (isComposing.value) return;
+ emit('update:query', (e.target as HTMLInputElement).value);
+};
+
+const onCompositionEnd = (e: CompositionEvent) => {
+ isComposing.value = false;
+ emit('update:query', (e.target as HTMLInputElement).value);
+};
+
+const onSearchKeydown = (e: KeyboardEvent) => {
+ if (!props.searchable) return;
+ if (isComposing.value || e.isComposing || e.keyCode === 229) return;
+ switch (e.key) {
+ case 'ArrowUp':
+ e.preventDefault();
+ moveActive(-1);
+ break;
+ case 'ArrowDown':
+ e.preventDefault();
+ moveActive(1);
+ break;
+ case 'Enter':
+ e.preventDefault();
+ confirmActive();
+ break;
+ case 'Tab':
+ if (enterActiveGroup()) e.preventDefault();
+ break;
+ case 'Escape':
+ e.preventDefault();
+ if (!leaveGroup()) emit('close');
+ break;
+ case 'Backspace':
+ if (!(props.query ?? '') && leaveGroup()) e.preventDefault();
+ break;
+ }
+};
+
defineExpose({
moveActive,
confirmActive,
leaveGroup,
+ enterActiveGroup,
});
+const fetchDetail = (item: MentionItem) => {
+ if (item.type === 'kb') return fetchKbDetail(item);
+ if (item.type === 'file') return fetchFileDetail(item);
+};
+
async function fetchKbDetail(item: { id: string }) {
if (detailCache.value[item.id]?.data || detailCache.value[item.id]?.loading) return;
detailCache.value = { ...detailCache.value, [item.id]: { loading: true } };
@@ -494,19 +573,10 @@ function handleKbClick(kbId: string | undefined) {
router.push(`/platform/knowledge-bases/${kbId}`);
}
-function handleOrgClick(orgName: string) {
+function handleOrgClick(orgName: string | undefined) {
if (!orgName) return;
- // 从共享知识库列表中找到对应的组织 ID
- const sharedKb = orgStore.sharedKnowledgeBases.find(
- (s: any) => s.org_name === orgName
- );
- if (sharedKb?.organization_id) {
- // 跳转到组织列表页(目前组织详情页可能不存在,先跳转到列表页)
- router.push('/platform/organizations');
- } else {
- // 如果找不到组织 ID,也跳转到组织列表页
- router.push('/platform/organizations');
- }
+ // 目前组织详情页可能不存在,统一跳转到组织列表页
+ router.push('/platform/organizations');
}
const onScroll = (e: Event) => {
@@ -518,336 +588,312 @@ const onScroll = (e: Event) => {
const target = e.target as HTMLElement;
const { scrollTop, scrollHeight, clientHeight } = target;
- if ((currentGroupType.value === 'file' || isFlatMode.value) && scrollHeight - scrollTop - clientHeight < 50 && props.hasMore && !props.loading) {
+ if (currentGroupType.value === 'file' && scrollHeight - scrollTop - clientHeight < 50 && props.hasMore && !props.loading) {
emit('loadMore');
}
};
watch(() => props.activeIndex, (newIndex) => {
- if (isFlatMode.value) {
- scrollToItem(newIndex);
- return;
- }
- if (currentGroupType.value) {
- updateActiveGroupFromIndex(newIndex);
- const group = currentGroup.value;
- if (group) scrollToItem(newIndex - group.offset);
- }
-});
-
-watch(isFlatMode, (flat) => {
- if (flat) {
- currentGroupType.value = null;
- nextTick(() => {
- if (listRef.value) listRef.value.scrollTop = 0;
- });
- }
+ if (!isRootView.value) scrollToRow(newIndex);
});
watch(() => props.visible, (newVisible) => {
if (newVisible) {
- nextTick(() => {
- if (listRef.value) listRef.value.scrollTop = 0;
- currentGroupType.value = null;
- groupActiveIndex.value = 0;
- });
+ stableMinHeight.value = 0;
+ currentGroupType.value = null;
+ groupActiveIndex.value = 0;
+ resetListScroll();
+ focusSearch();
}
});
-const scrollToItem = (index: number) => {
+const scrollToRow = (index: number) => {
nextTick(() => {
- if (!listRef.value) return;
-
- const items = listRef.value.querySelectorAll('.mention-item');
- if (!items || items.length <= index) return;
-
- const activeItem = items[index] as HTMLElement;
- const menu = listRef.value;
-
- if (activeItem) {
- const menuRect = menu.getBoundingClientRect();
- const itemRect = activeItem.getBoundingClientRect();
-
- // 检查是否在上方被遮挡
- if (itemRect.top < menuRect.top) {
- menu.scrollTop -= (menuRect.top - itemRect.top);
- }
- // 检查是否在下方被遮挡
- else if (itemRect.bottom > menuRect.bottom) {
- menu.scrollTop += (itemRect.bottom - menuRect.bottom);
- }
+ const list = listRef.value;
+ if (!list) return;
+ const rows = list.querySelectorAll<HTMLElement>(isRootView.value ? '.mention-group-entry' : '.mention-item');
+ const row = rows[index];
+ if (!row) return;
+ const listRect = list.getBoundingClientRect();
+ const rowRect = row.getBoundingClientRect();
+ if (rowRect.top < listRect.top) {
+ list.scrollTop -= (listRect.top - rowRect.top);
+ } else if (rowRect.bottom > listRect.bottom) {
+ list.scrollTop += (rowRect.bottom - listRect.bottom);
}
});
};
</script>
<style scoped>
+/* 与输入框内其他下拉(推理强度、模型选择)保持同一套尺寸 */
.mention-menu {
position: fixed;
z-index: 10000;
+ width: 260px;
+ max-height: 360px;
+ padding: 4px;
+ box-sizing: border-box;
background: var(--td-bg-color-container);
- border: 1px solid var(--td-component-stroke);
- border-radius: var(--td-radius-extraLarge);
- box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1), 0 2px 8px rgba(0, 0, 0, 0.04);
- width: 220px;
- max-height: 388px;
+ border: .5px solid var(--td-component-border);
+ border-radius: var(--app-radius-lg);
+ box-shadow: var(--td-shadow-2);
overflow: hidden;
display: flex;
flex-direction: column;
+ font-family: var(--app-font-family);
+ animation: mentionMenuFadeIn 0.15s ease-out;
}
-.mention-list {
- flex: 1 1 auto;
- min-height: 0;
- overflow-y: auto;
- padding: 4px 0;
+@keyframes mentionMenuFadeIn {
+ from {
+ opacity: 0;
+ transform: scale(0.98);
+ }
+ to {
+ opacity: 1;
+ transform: scale(1);
+ }
}
-.mention-group-entry,
-.mention-back-row {
- width: calc(100% - 12px);
- min-height: 32px;
- margin: 1px 6px;
- padding: 0 8px;
- border: 0;
- border-radius: var(--td-radius-medium);
- background: transparent;
- color: var(--td-text-color-primary);
- font-family: var(--app-font-family);
- font-size: var(--td-font-size-body-medium);
- font-weight: 400;
- line-height: 20px;
- cursor: pointer;
- box-sizing: border-box;
+.mention-search {
+ flex-shrink: 0;
+ margin-bottom: 2px;
+ border-bottom: .5px solid var(--td-component-stroke);
+}
+
+.mention-search__box {
display: flex;
align-items: center;
- gap: 8px;
- transition: background var(--app-motion-fast) ease;
+ gap: 6px;
+ padding: 6px 8px;
}
-.mention-group-entry:hover,
-.mention-group-entry.active,
-.mention-back-row:hover {
- background: var(--td-bg-color-secondarycontainer);
+.mention-search__icon {
+ width: 14px;
+ height: 14px;
+ flex-shrink: 0;
+ display: inline-flex;
+ align-items: center;
+ justify-content: center;
+ font-size: var(--app-text-md);
+ color: var(--td-text-color-placeholder);
}
-.mention-group-entry__icon {
- width: 18px;
- height: 18px;
+.mention-search__crumb {
flex-shrink: 0;
+ max-width: 88px;
+ height: 20px;
display: inline-flex;
align-items: center;
- justify-content: center;
+ gap: 2px;
+ padding: 0 6px 0 2px;
+ border: 0;
+ border-radius: var(--app-radius-sm);
+ background: var(--td-bg-color-secondarycontainer);
color: var(--td-text-color-secondary);
- font-size: var(--app-text-xl);
+ font: inherit;
+ font-size: var(--app-text-sm);
+ font-weight: 500;
+ cursor: pointer;
+ transition: background var(--app-motion-instant), color var(--app-motion-instant);
}
-.mention-group-entry__label,
-.mention-back-row span {
- min-width: 0;
- flex: 1;
+.mention-search__crumb:hover {
+ background: var(--td-bg-color-secondarycontainer-hover);
+ color: var(--td-text-color-primary);
+}
+
+.mention-search__crumb span {
overflow: hidden;
- text-align: left;
text-overflow: ellipsis;
white-space: nowrap;
- font-size: inherit;
- font-weight: inherit;
}
-.mention-group-entry__count {
- flex-shrink: 0;
- min-width: 18px;
- padding: 0 6px;
- border-radius: var(--app-radius-pill);
- background: var(--td-bg-color-secondarycontainer);
- color: var(--td-text-color-placeholder);
- font-size: var(--td-font-size-mark-small);
- line-height: 18px;
- text-align: center;
- font-variant-numeric: tabular-nums;
+.mention-search__input {
+ flex: 1;
+ min-width: 0;
+ height: 20px;
+ padding: 0;
+ border: 0;
+ outline: none;
+ text-overflow: ellipsis;
+ background: transparent;
+ color: var(--td-text-color-primary);
+ font: inherit;
+ font-size: var(--app-text-md);
+ line-height: 20px;
}
-.mention-group-entry__arrow {
- flex-shrink: 0;
+.mention-search__input::placeholder {
color: var(--td-text-color-placeholder);
- font-size: var(--app-text-xl);
}
-.mention-back-row {
- min-height: 30px;
- margin-bottom: 4px;
- color: var(--td-text-color-secondary);
- border-bottom: 1px solid var(--td-component-stroke);
- border-radius: 0;
+.mention-search__box.is-readonly .mention-search__input {
+ cursor: default;
}
-.mention-back-row span {
- font-size: var(--td-font-size-body-medium);
+.mention-list {
+ flex: 1 1 auto;
+ min-height: 0;
+ overflow-y: auto;
+ overscroll-behavior: contain;
+ display: flex;
+ flex-direction: column;
+ gap: 2px;
}
.mention-group {
- padding: 2px 0 5px;
-}
-
-.mention-group:not(:last-child) {
- border-bottom: 1px solid var(--td-component-stroke);
-}
-
-.mention-group-header {
- padding: 7px 14px 5px;
- font-size: var(--td-font-size-mark-small);
- font-weight: 600;
- line-height: 18px;
- color: var(--td-text-color-placeholder);
+ display: flex;
+ flex-direction: column;
+ gap: 2px;
}
-.mention-item {
+.mention-row {
+ width: 100%;
+ min-height: 30px;
display: flex;
align-items: center;
gap: 8px;
- min-height: 32px;
padding: 4px 8px;
- margin: 1px 6px;
+ margin: 0;
+ border: 0;
+ border-radius: var(--app-radius-sm);
+ background: transparent;
box-sizing: border-box;
+ color: var(--td-text-color-secondary);
+ font: inherit;
+ font-size: var(--app-text-md);
+ line-height: 20px;
+ text-align: left;
cursor: pointer;
- border-radius: var(--td-radius-medium);
- color: var(--td-text-color-primary);
- font-size: var(--td-font-size-body-medium);
- font-family: var(--app-font-family);
- transition: background var(--app-motion-fast) ease;
+ transition: background var(--app-motion-instant), color var(--app-motion-instant);
}
-.mention-item:hover {
- background: var(--td-bg-color-secondarycontainer);
+.mention-row:hover {
+ background: var(--td-bg-color-secondarycontainer-hover);
}
-.mention-item.active {
+.mention-row.active {
background: var(--td-bg-color-secondarycontainer);
color: var(--td-text-color-primary);
}
-.icon-wrap {
- position: relative;
- width: 18px;
- height: 18px;
- flex-shrink: 0;
-}
-
-.icon {
- display: flex;
- align-items: center;
- justify-content: center;
- width: 18px;
- height: 18px;
+.mention-row__icon {
+ width: 14px;
+ height: 14px;
flex-shrink: 0;
- font-size: var(--app-text-xl);
-}
-
-/* 右下角组织角标:柔和小圆 + 绿色/灰色 icon,不刺眼 */
-.org-badge-wrap {
- position: absolute;
- right: 0;
- bottom: 0;
- width: 10px;
- height: 10px;
- border-radius: 50%;
- background: var(--td-bg-color-secondarycontainer);
- box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.05);
- display: flex;
+ display: inline-flex;
align-items: center;
justify-content: center;
- pointer-events: none;
-}
-
-.org-badge-wrap .org-badge {
- width: 6px;
- height: 6px;
- object-fit: contain;
-}
-
-/* 知识库 / 文件 - 无背景,与整体一致 */
-.kb-icon,
-.faq-icon,
-.file-icon,
-.mcp-icon,
-.skill-icon,
-.tag-icon {
- background: transparent;
- color: var(--td-text-color-secondary);
+ font-size: var(--app-text-md);
+ color: var(--td-text-color-placeholder);
+ transition: color var(--app-motion-instant);
}
-.mention-item.active .icon {
+.mention-row.active .mention-row__icon {
color: var(--td-brand-color);
}
-.mention-item.active .faq-icon {
+.mention-row.active .mention-row__icon.faq-icon {
color: var(--weknora-faq-color, #0052d9);
}
-.item-main {
+.mention-row__name {
flex: 1;
min-width: 0;
- display: flex;
- align-items: center;
- gap: 4px;
-}
-
-.name {
- font-weight: 400;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
-/* 文件项中的 name 需要占据剩余空间,将 kb-name 推到右边 */
-.mention-item > .name {
- flex: 1;
- min-width: 0;
+.mention-hit {
+ padding: 0;
+ background: transparent;
+ color: var(--td-brand-color);
+ font-weight: 500;
}
-.count {
- margin-left: auto;
+.mention-row__meta {
flex-shrink: 0;
- font-size: var(--td-font-size-mark-small);
- font-variant-numeric: tabular-nums;
color: var(--td-text-color-placeholder);
+ font-size: var(--app-text-sm);
+ font-variant-numeric: tabular-nums;
+}
+
+.mention-row__meta--text {
+ max-width: 96px;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
}
-.count.is-stale {
+.mention-row__meta.is-stale {
color: var(--td-warning-color);
}
-.org-name {
+.mention-row__arrow {
flex-shrink: 0;
- max-width: 72px;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- font-size: var(--td-font-size-mark-small);
+ margin-right: -4px;
+ font-size: var(--app-text-md);
color: var(--td-text-color-placeholder);
}
-.kb-name {
- flex-shrink: 0;
- max-width: 80px;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- font-size: var(--td-font-size-mark-small);
+/* 全局搜索结果中的分组标题 */
+.mention-section-header {
+ display: flex;
+ align-items: center;
+ gap: 4px;
+ height: 24px;
+ padding: 0 8px;
+ color: var(--td-text-color-placeholder);
+ font-size: var(--app-text-sm);
+ line-height: 18px;
+}
+
+.mention-group + .mention-section-header {
+ margin-top: 2px;
+ padding-top: 4px;
+ height: 28px;
+ border-top: .5px solid var(--td-component-stroke);
+}
+
+.mention-section-header__count {
+ font-variant-numeric: tabular-nums;
+}
+
+.mention-section-header__more {
+ margin-left: auto;
+ display: inline-flex;
+ align-items: center;
+ padding: 0 0 0 4px;
+ border: 0;
+ background: transparent;
color: var(--td-text-color-secondary);
+ font: inherit;
+ font-size: var(--app-text-sm);
+ cursor: pointer;
+ transition: color var(--app-motion-instant);
+}
+
+.mention-section-header__more:hover {
+ color: var(--td-brand-color);
}
.empty {
- padding: 28px 16px;
+ min-height: 52px;
+ padding: 16px 8px;
+ box-sizing: border-box;
text-align: center;
color: var(--td-text-color-placeholder);
- font-size: var(--td-font-size-body-medium);
+ font-size: var(--app-text-md);
+ line-height: 20px;
}
.loading-more {
display: flex;
justify-content: center;
- padding: 8px 12px;
+ padding: 4px 8px;
}
</style>
@@ -856,11 +902,11 @@ const scrollToItem = (index: number) => {
.mention-detail-popup-wrap.t-popup__content {
min-width: 220px;
max-width: 280px;
- padding: 13px 14px;
- border: 1px solid var(--td-component-stroke);
- border-radius: var(--td-radius-large);
+ padding: 10px 12px;
+ border: .5px solid var(--td-component-border);
+ border-radius: var(--app-radius-lg);
background: var(--td-bg-color-container);
- box-shadow: 0 10px 28px rgba(0, 0, 0, 0.1), 0 2px 8px rgba(0, 0, 0, 0.04);
+ box-shadow: var(--td-shadow-2);
}
.mention-detail-content {
font-size: var(--td-font-size-body-small);
@@ -892,8 +938,8 @@ const scrollToItem = (index: number) => {
.mention-detail-content .detail-type-badge {
flex-shrink: 0;
padding: 1px 6px;
- border: 1px solid var(--td-component-stroke);
- border-radius: var(--td-radius-medium);
+ border: .5px solid var(--td-component-stroke);
+ border-radius: var(--app-radius-xs);
font-size: var(--td-font-size-mark-small);
line-height: 18px;
}
diff --git a/frontend/src/i18n/locales/en-US.ts b/frontend/src/i18n/locales/en-US.ts
index b3a81dc79..bafb398c7 100755
--- a/frontend/src/i18n/locales/en-US.ts
+++ b/frontend/src/i18n/locales/en-US.ts
@@ -2807,7 +2807,13 @@ export default {
mcpStale: 'Needs resync',
belongsToKb: 'Knowledge base: ',
belongsToOrg: 'Space: ',
- noCompatibleKbForAgent: 'This agent\'s tools don\'t match any knowledge base\'s capabilities in scope, so nothing can be referenced.'
+ noCompatibleKbForAgent: 'This agent\'s tools don\'t match any knowledge base\'s capabilities in scope, so nothing can be referenced.',
+ tag: 'Tags',
+ searchPlaceholder: 'Search KBs, files, skills…',
+ searchInGroup: 'Search in {group}…',
+ typeToSearch: "Keep typing after {'@'} to search…",
+ viewAll: 'View all',
+ back: 'Back'
},
file: {
upload: 'Upload File'
diff --git a/frontend/src/i18n/locales/ja-JP.ts b/frontend/src/i18n/locales/ja-JP.ts
index 83e2ff0e0..f269ff18c 100644
--- a/frontend/src/i18n/locales/ja-JP.ts
+++ b/frontend/src/i18n/locales/ja-JP.ts
@@ -2807,7 +2807,13 @@ export default {
mcpStale: '再同期が必要',
belongsToKb: 'ナレッジベース: ',
belongsToOrg: '共有スペース: ',
- noCompatibleKbForAgent: 'このエージェントのツールはスコープ内のナレッジベースの機能と一致しないため、参照できるナレッジベースがありません。'
+ noCompatibleKbForAgent: 'このエージェントのツールはスコープ内のナレッジベースの機能と一致しないため、参照できるナレッジベースがありません。',
+ tag: 'タグ',
+ searchPlaceholder: 'ナレッジ・ファイル等を検索',
+ searchInGroup: '{group}内を検索…',
+ typeToSearch: "{'@'} の後に入力して検索…",
+ viewAll: 'すべて表示',
+ back: '戻る'
},
file: {
upload: 'ファイルをアップロード'
diff --git a/frontend/src/i18n/locales/ko-KR.ts b/frontend/src/i18n/locales/ko-KR.ts
index 86edccbb1..6ca61b063 100755
--- a/frontend/src/i18n/locales/ko-KR.ts
+++ b/frontend/src/i18n/locales/ko-KR.ts
@@ -5342,7 +5342,13 @@ export default {
mcpStale: '다시 동기화 필요',
belongsToKb: '지식베이스: ',
belongsToOrg: '스페이스: ',
- noCompatibleKbForAgent: '현재 에이전트의 도구와 범위 내 지식베이스의 기능이 일치하지 않아 참조할 수 있는 지식베이스가 없습니다.'
+ noCompatibleKbForAgent: '현재 에이전트의 도구와 범위 내 지식베이스의 기능이 일치하지 않아 참조할 수 있는 지식베이스가 없습니다.',
+ tag: '태그',
+ searchPlaceholder: '지식베이스, 파일 등 검색',
+ searchInGroup: '{group}에서 검색…',
+ typeToSearch: "{'@'} 뒤에 계속 입력하여 검색…",
+ viewAll: '모두 보기',
+ back: '뒤로'
},
common: {
add: '추가',
diff --git a/frontend/src/i18n/locales/ru-RU.ts b/frontend/src/i18n/locales/ru-RU.ts
index c4aab3bde..43ff93d55 100755
--- a/frontend/src/i18n/locales/ru-RU.ts
+++ b/frontend/src/i18n/locales/ru-RU.ts
@@ -5342,7 +5342,13 @@ export default {
mcpStale: 'Нужна повторная синхронизация',
belongsToKb: 'База знаний: ',
belongsToOrg: 'Пространство: ',
- noCompatibleKbForAgent: 'Инструменты текущего агента не соответствуют возможностям ни одной базы знаний в области видимости — нечего упомянуть.'
+ noCompatibleKbForAgent: 'Инструменты текущего агента не соответствуют возможностям ни одной базы знаний в области видимости — нечего упомянуть.',
+ tag: 'Теги',
+ searchPlaceholder: 'Поиск баз, файлов, навыков…',
+ searchInGroup: 'Поиск в разделе «{group}»…',
+ typeToSearch: "Продолжайте ввод после {'@'} для поиска…",
+ viewAll: 'Показать все',
+ back: 'Назад'
},
common: {
add: 'Добавить',
diff --git a/frontend/src/i18n/locales/zh-CN.ts b/frontend/src/i18n/locales/zh-CN.ts
index 2438463ea..ff894cf2e 100755
--- a/frontend/src/i18n/locales/zh-CN.ts
+++ b/frontend/src/i18n/locales/zh-CN.ts
@@ -5344,7 +5344,13 @@ export default {
mcpStale: '需重新同步',
belongsToKb: '所属知识库:',
belongsToOrg: '所属空间:',
- noCompatibleKbForAgent: '当前智能体的工具与作用域内知识库的能力不匹配,暂无可引用的知识库。'
+ noCompatibleKbForAgent: '当前智能体的工具与作用域内知识库的能力不匹配,暂无可引用的知识库。',
+ tag: '标签',
+ searchPlaceholder: '搜索知识库、文件、技能等',
+ searchInGroup: '在{group}中搜索…',
+ typeToSearch: "在 {'@'} 后继续输入以搜索…",
+ viewAll: '查看全部',
+ back: '返回'
},
common: {
add: '添加',
diff --git a/frontend/src/i18n/locales/zh-TW.ts b/frontend/src/i18n/locales/zh-TW.ts
index 44157bf4f..7f31ffaeb 100644
--- a/frontend/src/i18n/locales/zh-TW.ts
+++ b/frontend/src/i18n/locales/zh-TW.ts
@@ -5344,7 +5344,13 @@ export default {
mcpStale: '需重新同步',
belongsToKb: '所屬知識庫:',
belongsToOrg: '所屬空間:',
- noCompatibleKbForAgent: '當前智慧代理的工具與作用域內知識庫的能力不比對,暫無可引用的知識庫。'
+ noCompatibleKbForAgent: '當前智慧代理的工具與作用域內知識庫的能力不比對,暫無可引用的知識庫。',
+ tag: '標籤',
+ searchPlaceholder: '搜尋知識庫、檔案、技能等',
+ searchInGroup: '在{group}中搜尋…',
+ typeToSearch: "在 {'@'} 後繼續輸入以搜尋…",
+ viewAll: '檢視全部',
+ back: '返回'
},
common: {
add: '新增',