Skip to content

fix: Document deletion now properly updates the stale knowledge filter source count#1936

Open
Vchen7629 wants to merge 9 commits into
release-0.5.1from
stale-knowledge-filter-source-count-fix-release-0.5.1
Open

fix: Document deletion now properly updates the stale knowledge filter source count#1936
Vchen7629 wants to merge 9 commits into
release-0.5.1from
stale-knowledge-filter-source-count-fix-release-0.5.1

Conversation

@Vchen7629

Copy link
Copy Markdown
Collaborator

Summary

Fixes #1254 . Knowledge filter containing specific documents used to show stale source counts even though the document was deleted and would show inflated counts if more sources are added even after the page was refreshed. This is because the source count was computed from query_data.filters.data_sources, a saved snapshot of filenames that's never pruned when a document is deleted.

Demo (Before)

screen-capture.5.webm

Demo (After)

screen-capture.3.webm

Changes

  • search_knowledge_filters now computes active_source_count per filter by checking which of its data_sources filenames still have indexed documents (one batched OpenSearch query via the admin client, so the count is consistent for every viewer of a shared filter)
  • Added build_existing_filenames_agg_body helper in opensearch_queries.py
  • knowledge-filter-list.tsx badge now uses active_source_count, falling back to the old .length if absent
  • knowledge-filter-panel.tsx source dropdown now filters its selected sources against the currently-active sources before display, so its count matches too
  • Added unit tests for search_knowledge_filters

@Vchen7629 Vchen7629 requested a review from lucaseduoli June 22, 2026 17:34
@coderabbitai

coderabbitai Bot commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 04d1ef88-92a3-4964-9207-f1dc91bf84c6

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Warning

.coderabbit.yaml has a parsing error

The CodeRabbit configuration file in this repository has a parsing error and default settings were used instead. Please fix the error(s) in the configuration file. You can initialize chat with CodeRabbit to get help with the configuration file.

💥 Parsing errors (1)
Validation error: Too big: expected number to be <=900000 at "reviews.tools.github-checks.timeout_ms"
⚙️ Configuration instructions
  • Please see the configuration documentation for more information.
  • You can also validate your configuration using the online YAML validator.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch stale-knowledge-filter-source-count-fix-release-0.5.1

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot added frontend 🟨 Issues related to the UI/UX backend 🔷 Issues related to backend services (OpenSearch, Langflow, APIs) tests bug 🔴 Something isn't working. labels Jun 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend 🔷 Issues related to backend services (OpenSearch, Langflow, APIs) bug 🔴 Something isn't working. frontend 🟨 Issues related to the UI/UX tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant