feat: expose KB ↔ vector store binding in list, editor, and detail UI
Backend ------- ListKnowledgeBases now enriches each row with the resolved vector_store metadata (name / source / engine_type / status) via a new buildKBListResponse helper. Store views are batch-resolved once per request through BatchResolveStoreView so an N-KB list costs one vector-store service call rather than N — closing the N+1 limitation flagged in #1372's known-limitations section. Cross-tenant shared KBs continue to render via SharedStoreDisplay so the owning tenant's store inventory cannot be correlated across rows; the underlying vector_store_id UUID is stripped from those responses. Resolver failures degrade gracefully: bound KBs render as unavailable instead of breaking the list. Test coverage pins the env / bound / shared distinction, the batch-call-count invariant, and the graceful-failure path. Frontend -------- KB editor modal gains a new "Vector Store" section. Create mode shows a dropdown that combines the system default (env store) and the tenant's configured user stores, fetched once at mount via the existing listVectorStores API. Edit mode shows the bound store read-only via a new VectorStoreBadge component with an explicit immutability hint — matching the backend's `<-:create` GORM tag and the service-layer UpdateKnowledgeBaseRequest DTO that already omit the field. KB list cards surface a small engine-type badge for own-tenant bound KBs, and a warning badge when the bound store is unavailable. Env-bound and shared KBs render no badge (visual noise control). KB detail header shows the bound store via the same VectorStoreBadge component; shared KBs fall through to the badge's internal "shared" branch with no name / engine / id rendered. The KB editor's create-time error handler translates the typed ErrVectorStoreBindingInvalid (2200) and ErrVectorStoreUnavailable (2201) into localized messages and jumps the user back to the VectorStore section so they can pick a different store or fall back to the system default. The KB row type gains five optional fields (vector_store_id / name / engine_type / source / status). i18n: 18 new keys added to en-US, ko-KR, zh-CN; ru-RU receives English placeholders pending translation (consistent with prior PRs in this locale). Part of #993 (Phase 2: Per-KB VectorStore Binding). Phase 2 roadmap item: PR 5 (KB binding UI + list-response enrichment). Depends on #994, #1310, #1372, #1386 (all backend in the Phase 2 series).
This commit is contained in:
@@ -0,0 +1,114 @@
|
||||
<template>
|
||||
<span :class="['vs-badge', `vs-badge-${effectiveSource}`, isUnavailable && 'vs-badge-warn']">
|
||||
<t-icon :name="iconName" class="vs-badge-icon" />
|
||||
<span class="vs-badge-name">{{ displayName }}</span>
|
||||
<span
|
||||
v-if="engineType && (effectiveSource === 'user' || effectiveSource === 'env')"
|
||||
class="vs-badge-engine"
|
||||
>
|
||||
({{ engineType }})
|
||||
</span>
|
||||
<t-tag
|
||||
v-if="isUnavailable"
|
||||
theme="danger"
|
||||
variant="light"
|
||||
size="small"
|
||||
class="vs-badge-warn-tag"
|
||||
>
|
||||
{{ $t('vectorStoreBadge.unavailable') }}
|
||||
</t-tag>
|
||||
</span>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import type { VectorStoreSource, VectorStoreStatus } from '@/api/knowledge-base'
|
||||
|
||||
const props = defineProps<{
|
||||
source?: VectorStoreSource
|
||||
name?: string
|
||||
engineType?: string
|
||||
status?: VectorStoreStatus
|
||||
}>()
|
||||
|
||||
const { t } = useI18n()
|
||||
|
||||
// When backend omits the source (e.g. legacy KB row from a cached list
|
||||
// endpoint that does not enrich), treat it as env so the badge renders
|
||||
// gracefully instead of going blank.
|
||||
const effectiveSource = computed<VectorStoreSource>(() => props.source || 'env')
|
||||
|
||||
const isUnavailable = computed(
|
||||
() => props.status === 'unavailable' || effectiveSource.value === 'unavailable',
|
||||
)
|
||||
|
||||
const iconName = computed(() => {
|
||||
switch (effectiveSource.value) {
|
||||
case 'env':
|
||||
case 'user':
|
||||
// Both env- and user-bound KBs sit on top of a vector store; the
|
||||
// distinction is purely organizational (configured at process
|
||||
// start vs. created in the UI), so they share the same icon.
|
||||
return 'data-base'
|
||||
case 'shared':
|
||||
return 'share'
|
||||
case 'unavailable':
|
||||
default:
|
||||
return 'help-circle'
|
||||
}
|
||||
})
|
||||
|
||||
const displayName = computed(() => {
|
||||
if (effectiveSource.value === 'env') return t('vectorStoreBadge.systemDefault')
|
||||
if (effectiveSource.value === 'shared') return t('vectorStoreBadge.sharedFromOrg')
|
||||
return props.name || t('vectorStoreBadge.unknownStore')
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.vs-badge {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
padding: 2px 8px;
|
||||
border-radius: 4px;
|
||||
font-size: 12px;
|
||||
line-height: 1.4;
|
||||
background: var(--td-bg-color-component, #f5f7fa);
|
||||
color: var(--td-text-color-primary, #1d2129);
|
||||
}
|
||||
|
||||
.vs-badge-env {
|
||||
background: var(--td-brand-color-1, #ecf2fe);
|
||||
color: var(--td-brand-color-7, #0052d9);
|
||||
}
|
||||
|
||||
.vs-badge-user {
|
||||
background: var(--td-success-color-1, #e8f8f2);
|
||||
color: var(--td-success-color-7, #00754a);
|
||||
}
|
||||
|
||||
.vs-badge-shared {
|
||||
background: var(--td-warning-color-1, #fff1e9);
|
||||
color: var(--td-warning-color-7, #b85b00);
|
||||
}
|
||||
|
||||
.vs-badge-warn {
|
||||
background: var(--td-error-color-1, #fde9e6);
|
||||
color: var(--td-error-color-7, #b32700);
|
||||
}
|
||||
|
||||
.vs-badge-icon {
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.vs-badge-engine {
|
||||
opacity: 0.7;
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
.vs-badge-warn-tag {
|
||||
margin-left: 4px;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user