feat(knowledge-base): document list filters and explicit batch-management UX

Add three new optional filters to the document list under a knowledge base
detail page — parse status, source/channel, and updated time range — and
rework multi-select to no longer cause the card title to jitter on hover.

Backend
- Introduce types.KnowledgeListFilter to aggregate optional filter dimensions
  (tag, keyword, file_type, parse_status, source, updated_from/to) and switch
  ListPagedKnowledgeByKnowledgeBaseID (repository/service/interface) to accept
  it instead of a growing positional parameter list.
- The ListKnowledge HTTP handler accepts new parse_status, source, start_time
  and end_time query params; time params accept RFC3339, "YYYY-MM-DD HH:MM:SS"
  and "YYYY-MM-DD". The repository routes source="manual"/"url" onto the type
  column to stay consistent with file_type semantics; other source values match
  the channel column.
- Update the four other callers (agent_service, initialization) to pass an
  empty filter struct, preserving prior behavior.

Frontend
- Add three controls in the doc-filter-bar (status select, source select,
  date-range picker with future-date disabled) wired through getKnowled /
  listKnowledgeFiles into the new backend params.
- Replace the hover-triggered card checkbox with an explicit "批量管理" mode
  (mirrors the session list UX): in card view the checkbox only renders while
  batch mode is on, entered via the per-card "..." menu; the list view keeps
  its leading checkbox column. Switching from list to grid auto-enables batch
  mode when something is already selected, so the selection stays visible.
- DocumentBatchBar now stays open whenever batch mode or selection > 0, and
  its "取消选择" button both clears the selection and exits batch mode.

API surface sync
- Regenerate Swagger artifacts (docs/docs.go / swagger.json / swagger.yaml).
- Update docs/api/knowledge.md with the new query parameters.
- Add backward-compatible ListKnowledgeWithFilter + KnowledgeListFilter to the
  Go SDK; the existing ListKnowledge keeps its signature.

i18n
- New filter labels in zh-CN / en-US / ko-KR / ru-RU; reuse existing
  menu.batchManage / batchManage.cancel for the multi-select strings.
This commit is contained in:
wizardchen
2026-05-12 18:16:34 +08:00
committed by lyingbug
parent f635eaf466
commit cacca049d9
20 changed files with 596 additions and 174 deletions
+10 -12
View File
@@ -61,17 +61,15 @@ type KnowledgeService interface {
GetKnowledgeBatchWithSharedAccess(ctx context.Context, tenantID uint64, ids []string) ([]*types.Knowledge, error)
// ListKnowledgeByKnowledgeBaseID lists all knowledge under a knowledge base.
ListKnowledgeByKnowledgeBaseID(ctx context.Context, kbID string) ([]*types.Knowledge, error)
// ListPagedKnowledgeByKnowledgeBaseID lists all knowledge under a knowledge base with pagination.
// When tagID is non-empty, results are filtered by tag_id.
// When keyword is non-empty, results are filtered by file_name.
// When fileType is non-empty, results are filtered by file_type or type.
// ListPagedKnowledgeByKnowledgeBaseID lists all knowledge under a knowledge base
// with pagination. The filter struct controls optional dimensions (tag, keyword,
// file type, parse status, source channel, updated time range); pass a zero
// struct to disable all filters.
ListPagedKnowledgeByKnowledgeBaseID(
ctx context.Context,
kbID string,
page *types.Pagination,
tagID string,
keyword string,
fileType string,
filter types.KnowledgeListFilter,
) (*types.PageResult, error)
// DeleteKnowledge deletes knowledge by ID.
DeleteKnowledge(ctx context.Context, id string) error
@@ -178,12 +176,12 @@ type KnowledgeRepository interface {
// GetKnowledgeByIDOnly returns knowledge by ID without tenant filter (for permission resolution).
GetKnowledgeByIDOnly(ctx context.Context, id string) (*types.Knowledge, error)
ListKnowledgeByKnowledgeBaseID(ctx context.Context, tenantID uint64, kbID string) ([]*types.Knowledge, error)
// ListPagedKnowledgeByKnowledgeBaseID lists all knowledge in a knowledge base with pagination.
// When tagID is non-empty, results are filtered by tag_id.
// When keyword is non-empty, results are filtered by file_name.
// When fileType is non-empty, results are filtered by file_type or type.
// ListPagedKnowledgeByKnowledgeBaseID lists all knowledge in a knowledge base
// with pagination. The filter struct controls optional dimensions (tag, keyword,
// file type, parse status, source channel, updated time range); pass a zero
// struct to disable all filters.
ListPagedKnowledgeByKnowledgeBaseID(ctx context.Context,
tenantID uint64, kbID string, page *types.Pagination, tagID string, keyword string, fileType string,
tenantID uint64, kbID string, page *types.Pagination, filter types.KnowledgeListFilter,
) ([]*types.Knowledge, int64, error)
UpdateKnowledge(ctx context.Context, knowledge *types.Knowledge) error
// UpdateKnowledgeBatch updates knowledge items in batch
+21
View File
@@ -67,6 +67,27 @@ const (
ManualKnowledgeStatusPublish = "publish"
)
// KnowledgeListFilter aggregates optional filters for listing knowledge entries
// under a knowledge base. Empty / zero fields mean "no filter on that dimension".
type KnowledgeListFilter struct {
// TagID filters by tag_id when non-empty.
TagID string
// Keyword performs a LIKE match on file_name / title when non-empty.
Keyword string
// FileType filters by file_type, or by type for the special values "manual" / "url".
FileType string
// ParseStatus filters by parse_status when non-empty (e.g. pending, processing, completed, failed).
ParseStatus string
// Source filters by ingestion channel when non-empty (web, api, feishu, notion, wechat, ...).
// The special values "manual" and "url" are routed to the `type` column to match
// FileType semantics, so callers can filter "manually created" / "URL imported" entries.
Source string
// UpdatedFrom, when non-zero, keeps rows with updated_at >= UpdatedFrom.
UpdatedFrom time.Time
// UpdatedTo, when non-zero, keeps rows with updated_at <= UpdatedTo.
UpdatedTo time.Time
}
// Knowledge represents a knowledge entity in the system.
// It contains metadata about the knowledge source, its processing status,
// and references to the physical file if applicable.