WeKnora/internal/application
tayadwx 98362dd296
feat(gallery): filter images by source document (#4159)
* feat(gallery): filter images by source document

Add a gallery toolbar button that opens a paginated, keyword-searchable
document picker; confirming restricts the listing to images owned by
the selected documents. The backend gallery endpoint accepts a
knowledge_ids query param (capped at 50) narrowing chunk_images by the
owning document before de-duplication, so the count query stays index
served.

* feat(gallery): lift knowledge_ids cap via POST body, sortable doc picker

Add POST /knowledge-bases/:id/images accepting the gallery filter as a
JSON body so knowledge_ids escapes the URL-length cap (50 -> 1000, an
abuse guard rather than a transport limit); the GET variant keeps its
cap and both share the contract-constrain logic. The source picker
gains sortable column headers (file name / upload time, newest first
by default), a header select-all that unions and removes whole hit
lists across keyword searches, overflow guards capping the no-keyword
view at the 500 most recent documents, and a wider dialog.

* style(gallery): replace td-token fallbacks and font-size literals with design tokens

styleGuard.test.mjs enforces ratchets: --td-* vars must not carry
fallbacks (theme.css guarantees them) and font sizes must use
--app-text-* tokens. GallerySourcePicker.vue added 4 of each,
pushing the ratchets over baseline.

* fix(gallery): keep shared images in source filter and align picker UI

- Scope the de-duplication probe to the selected documents, so an image
  whose newer copy lives in an unselected document is no longer hidden.
- Reset the source filter when the gallery switches knowledge bases.
- Accept an empty POST /images body; drop pruned attribute maps to nil.
- Keep the source filter out of the filter panel's count and clear action;
  the empty state's clear still resets it.
- Rework the picker dialog to the BatchTagDialog shell: heading with
  subtitle, footer with selection count, clickable rows, debounced search,
  select-all toggling against every hit, stale select-all responses dropped.
- Remove the unreachable GET knowledge_ids branch in the API client.

---------

Co-authored-by: tayadwx <tayadwx@users.noreply.github.com>
Co-authored-by: wizardchen <wizardchen@tencent.com>
2026-10-12 15:43:28 +08:00
..
access feat(wiki): 增加跨知识库 Wiki 搜索 POST /wiki-search (#3535) 2026-09-25 22:22:58 +08:00
repository feat(gallery): filter images by source document (#4159) 2026-10-12 15:43:28 +08:00
service feat(gallery): filter images by source document (#4159) 2026-10-12 15:43:28 +08:00