Files
Enterprise-Knowledge-Base/frontend/src/components/GlobalCommandPalette/ResultGroup.vue
T
wizardchen 2d3f32de5c 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.
2026-05-06 16:26:22 +08:00

90 lines
1.6 KiB
Vue

<template>
<div class="cmdk-group" v-if="$slots.default">
<div class="cmdk-group__header">
<span class="cmdk-group__label">{{ label }}</span>
<span v-if="count != null" class="cmdk-group__count">({{ count }})</span>
<span v-if="action" class="cmdk-group__spacer" />
<button
v-if="action"
type="button"
class="cmdk-group__action"
@click="$emit('action')"
>
{{ action }}
</button>
</div>
<div class="cmdk-group__body">
<slot />
</div>
</div>
</template>
<script setup lang="ts">
defineProps<{
label: string
count?: number
action?: string
}>()
defineEmits<{
(e: 'action'): void
}>()
</script>
<style lang="less" scoped>
.cmdk-group {
display: flex;
flex-direction: column;
gap: 2px;
padding: 4px 0;
& + & {
border-top: 1px solid var(--td-component-stroke);
margin-top: 4px;
padding-top: 8px;
}
}
.cmdk-group__header {
display: flex;
align-items: center;
gap: 6px;
padding: 4px 12px 2px;
font-size: 11px;
font-weight: 500;
letter-spacing: 0.3px;
color: var(--td-text-color-placeholder);
text-transform: uppercase;
}
.cmdk-group__count {
color: var(--td-text-color-disabled);
font-weight: 400;
}
.cmdk-group__spacer {
flex: 1;
}
.cmdk-group__action {
border: none;
background: transparent;
padding: 2px 6px;
border-radius: 4px;
font-size: 11px;
color: var(--td-brand-color);
cursor: pointer;
text-transform: none;
letter-spacing: normal;
&:hover {
background: rgba(7, 192, 95, 0.08);
}
}
.cmdk-group__body {
display: flex;
flex-direction: column;
}
</style>