feat(frontend): replace standalone search page with global command palette
Reworks search from a siloed /platform/knowledge-search page into a universal ⌘K palette plus natural, in-context entry points. Why the old page felt out of place: - "Search" was an action pinned next to entity routes (knowledge base, agent, organization), mixing noun- and verb-level navigation items. - Its two tabs (knowledge vs. chat messages) forced users to pick a mental model before they knew what they wanted. - It was also the only way to search at all — no global shortcut, no context-aware entry. What this replaces it with: - A new ⌘K/Ctrl+K command palette (GlobalCommandPalette.vue) mounted once in views/platform/index.vue. Results are grouped by type (files, messages, knowledge bases, agents, chat titles, commands) so users never need to pre-filter. Debounced, identity-keyed selection survives async arrivals (slow KB results no longer yank the highlight off the user's current row). ⌘1-9 jump shortcuts are rendered inline on each row for discoverability. - Sidebar gets a visible "Search" entry at the top — clicking it opens the palette (no route change), with a platform-aware kbd hint (⌘K on Mac, Ctrl K elsewhere). - KB detail page: opening ⌘K there auto-scopes the search to the current KB via a removable chip (Backspace in empty input also clears it); no separate embedded search bar needed. - The legacy route /platform/knowledge-search now redirects to the KB list with ?cmdk= set, so existing bookmarks still work. - KnowledgeBase.vue now handles both route-query changes and a window event (weknora:open-knowledge) for intra-KB navigation, fixing the silent-no-op when the palette jumps to a chunk in the already-open KB. Dropped: - frontend/src/views/knowledge/KnowledgeSearch.vue (1163 lines). - The exploratory SessionSearchBar mode-switching widget in the chat submenu; ⌘K covers its use cases without a two-mode UI. i18n: zh-CN / en-US / ko-KR / ru-RU updated together — new commandPalette.*, kb.*, and menu.search keys; obsolete session.search.* and menu.knowledgeSearch removed.
This commit is contained in:
@@ -788,7 +788,12 @@ const handleOpenURLImportDialog = (event: CustomEvent) => {
|
||||
}
|
||||
};
|
||||
|
||||
// Auto-open document detail when navigated with ?knowledge_id=xxx
|
||||
// Auto-open document detail when navigated with ?knowledge_id=xxx.
|
||||
// Note: this runs both when the KB page mounts with a query param AND when a
|
||||
// subsequent in-page navigation (e.g. from the global command palette) only
|
||||
// changes the query without re-mounting the component — in that case kbId is
|
||||
// the same and cardList may already be populated, so relying solely on the
|
||||
// cardList watcher misses the trigger.
|
||||
const pendingKnowledgeId = ref<string | null>(
|
||||
(route.query.knowledge_id as string) || null
|
||||
);
|
||||
@@ -807,6 +812,29 @@ const tryAutoOpenDocument = () => {
|
||||
}
|
||||
};
|
||||
|
||||
// React to later ?knowledge_id= changes on the same KB route (no remount).
|
||||
watch(
|
||||
() => route.query.knowledge_id,
|
||||
(newId) => {
|
||||
if (typeof newId !== 'string' || !newId) return;
|
||||
pendingKnowledgeId.value = newId;
|
||||
// cardList is almost always already loaded at this point; if not, the
|
||||
// cardList watcher below will pick it up.
|
||||
tryAutoOpenDocument();
|
||||
},
|
||||
);
|
||||
|
||||
// Dispatched by the global command palette when the user picks a chunk that
|
||||
// lives in the KB they are already viewing — vue-router dedupes identical
|
||||
// navigations, so we rely on this event instead of a URL change.
|
||||
const handleOpenKnowledgeEvent = (e: Event) => {
|
||||
const detail = (e as CustomEvent<{ kbId: string; knowledgeId: string }>).detail;
|
||||
if (!detail || !detail.knowledgeId) return;
|
||||
if (detail.kbId && detail.kbId !== kbId.value) return;
|
||||
pendingKnowledgeId.value = detail.knowledgeId;
|
||||
tryAutoOpenDocument();
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
loadKnowledgeBaseInfo(kbId.value);
|
||||
loadKnowledgeList();
|
||||
@@ -818,11 +846,13 @@ onMounted(() => {
|
||||
|
||||
window.addEventListener('knowledgeFileUploaded', handleFileUploaded as EventListener);
|
||||
window.addEventListener('openURLImportDialog', handleOpenURLImportDialog as EventListener);
|
||||
window.addEventListener('weknora:open-knowledge', handleOpenKnowledgeEvent as EventListener);
|
||||
});
|
||||
|
||||
onUnmounted(() => {
|
||||
window.removeEventListener('knowledgeFileUploaded', handleFileUploaded as EventListener);
|
||||
window.removeEventListener('openURLImportDialog', handleOpenURLImportDialog as EventListener);
|
||||
window.removeEventListener('weknora:open-knowledge', handleOpenKnowledgeEvent as EventListener);
|
||||
stopMovePoll();
|
||||
if (timeout !== null) {
|
||||
clearTimeout(timeout);
|
||||
|
||||
Reference in New Issue
Block a user