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:
@@ -277,6 +277,32 @@
|
||||
<t-icon name="share" size="14px" />
|
||||
</div>
|
||||
</t-tooltip>
|
||||
<!-- Vector-store badge: shows the underlying engine
|
||||
type (e.g. "postgres", "qdrant") for any KB whose
|
||||
binding is currently reachable. Cross-tenant
|
||||
shared KBs are filtered out upstream (their
|
||||
engine_type is stripped from the response).
|
||||
Unreachable bindings surface a red warning so
|
||||
operators can self-recover from the badge alone. -->
|
||||
<t-tooltip
|
||||
v-if="kb.vector_store_engine_type && kb.vector_store_status === 'available'"
|
||||
:content="kb.vector_store_name || ''"
|
||||
placement="top"
|
||||
>
|
||||
<div class="feature-badge store">
|
||||
<t-icon name="data-base" size="14px" />
|
||||
<span class="badge-count">{{ kb.vector_store_engine_type }}</span>
|
||||
</div>
|
||||
</t-tooltip>
|
||||
<t-tooltip
|
||||
v-else-if="kb.vector_store_status === 'unavailable'"
|
||||
:content="$t('kbSettings.vectorStore.unavailableHint')"
|
||||
placement="top"
|
||||
>
|
||||
<div class="feature-badge store-warn">
|
||||
<t-icon name="error-circle" size="14px" />
|
||||
</div>
|
||||
</t-tooltip>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="!authStore.isLiteMode" class="bottom-right">
|
||||
@@ -502,6 +528,29 @@
|
||||
<t-icon name="share" size="14px" />
|
||||
</div>
|
||||
</t-tooltip>
|
||||
<!-- Vector-store badge: identical rendering rule to
|
||||
the badge in the other card variant above; kept
|
||||
in sync so users see the same engine indicator
|
||||
regardless of which filter scope they browse. -->
|
||||
<t-tooltip
|
||||
v-if="kb.vector_store_engine_type && kb.vector_store_status === 'available'"
|
||||
:content="kb.vector_store_name || ''"
|
||||
placement="top"
|
||||
>
|
||||
<div class="feature-badge store">
|
||||
<t-icon name="data-base" size="14px" />
|
||||
<span class="badge-count">{{ kb.vector_store_engine_type }}</span>
|
||||
</div>
|
||||
</t-tooltip>
|
||||
<t-tooltip
|
||||
v-else-if="kb.vector_store_status === 'unavailable'"
|
||||
:content="$t('kbSettings.vectorStore.unavailableHint')"
|
||||
placement="top"
|
||||
>
|
||||
<div class="feature-badge store-warn">
|
||||
<t-icon name="error-circle" size="14px" />
|
||||
</div>
|
||||
</t-tooltip>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="!authStore.isLiteMode" class="bottom-right">
|
||||
@@ -843,6 +892,17 @@ interface KB {
|
||||
creator_id?: string;
|
||||
// creator_name 由后端 list 接口回填,仅用于卡片右下角来源徽章的 tooltip。
|
||||
creator_name?: string;
|
||||
// Resolved vector-store binding metadata, populated by the list and
|
||||
// detail endpoints. Fields are optional so callers that don't request
|
||||
// (or that receive a stripped cross-tenant response) still type-check.
|
||||
// vector_store_engine_type is the canonical render trigger — env-bound
|
||||
// and user-bound KBs both carry it; shared KBs and unreachable
|
||||
// bindings leave it unset.
|
||||
vector_store_id?: string | null;
|
||||
vector_store_name?: string;
|
||||
vector_store_engine_type?: string;
|
||||
vector_store_source?: 'env' | 'user' | 'shared' | 'unavailable';
|
||||
vector_store_status?: 'available' | 'unavailable';
|
||||
}
|
||||
|
||||
const kbs = ref<KB[]>([])
|
||||
@@ -2631,6 +2691,37 @@ const handleUploadFinishedEvent = (event: Event) => {
|
||||
}
|
||||
}
|
||||
|
||||
/* Vector-store engine badge. Shares the green palette used by the
|
||||
document/FAQ "type" badges so the card-bottom feature row reads as
|
||||
one consistent visual group. The badge-count slot carries the
|
||||
engine name (e.g. "qdrant"), so the badge uses the same
|
||||
variable-width treatment as the type badges. */
|
||||
&.store {
|
||||
background: rgba(7, 192, 95, 0.08);
|
||||
color: var(--td-brand-color-active);
|
||||
width: auto;
|
||||
padding: 0 6px;
|
||||
gap: 3px;
|
||||
|
||||
&:hover {
|
||||
background: rgba(7, 192, 95, 0.12);
|
||||
}
|
||||
|
||||
.badge-count {
|
||||
font-size: 11px;
|
||||
font-weight: 500;
|
||||
}
|
||||
}
|
||||
|
||||
&.store-warn {
|
||||
background: rgba(229, 57, 53, 0.08);
|
||||
color: var(--td-error-color);
|
||||
|
||||
&:hover {
|
||||
background: rgba(229, 57, 53, 0.14);
|
||||
}
|
||||
}
|
||||
|
||||
&.role-admin {
|
||||
background: rgba(7, 192, 95, 0.1);
|
||||
color: var(--td-brand-color-active);
|
||||
|
||||
Reference in New Issue
Block a user