Skip to content

RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.

Fix: Knowledge Compilation - Graph - Entity count remains unchanged after search. (#19652)

balibabuf872f55db43f
diff --git a/web/src/components/originui/select-with-search.tsx b/web/src/components/originui/select-with-search.tsx
index 3c7e068d94..87df74230a 100644
--- a/web/src/components/originui/select-with-search.tsx
+++ b/web/src/components/originui/select-with-search.tsx
@@ -55,6 +55,8 @@ export type SelectWithSearchFlagProps = {
placeholder?: string;
emptyData?: string;
allowCustomValue?: boolean;
+ // Always show the search input even with few options
+ alwaysShowSearch?: boolean;
// Return false to veto selecting the custom value on Enter
onNoMatchEnter?(searchValue: string): boolean | void;
disableAutoSelectOnEnter?: boolean;
@@ -130,6 +132,7 @@ export const SelectWithSearch = forwardRef<
placeholder,
emptyData,
allowCustomValue = false,
+ alwaysShowSearch = false,
onNoMatchEnter,
disableAutoSelectOnEnter = false,
testId,
@@ -168,7 +171,7 @@ export const SelectWithSearch = forwardRef<
}, [options, value]);
const showSearch = useMemo(() => {
- if (allowCustomValue) {
+ if (allowCustomValue || alwaysShowSearch) {
return true;
}
if (Array.isArray(options) && options.length > 5) {
@@ -181,7 +184,7 @@ export const SelectWithSearch = forwardRef<
return optionsNum > 5;
}
return false;
- }, [allowCustomValue, options]);
+ }, [allowCustomValue, alwaysShowSearch, options]);
const hasCustomSearchValue = useMemo(() => {
const customValue = searchValue.trim();
diff --git a/web/src/pages/dataset/compilation/dataset-structure-view.tsx b/web/src/pages/dataset/compilation/dataset-structure-view.tsx
index 4bb2ed105c..4bd28d2b44 100644
--- a/web/src/pages/dataset/compilation/dataset-structure-view.tsx
+++ b/web/src/pages/dataset/compilation/dataset-structure-view.tsx
@@ -109,20 +109,17 @@ export function DatasetStructureView({ kind }: DatasetStructureViewProps) {
: '';
const handleSelectEntity = useCallback((name: string) => {
- if (!name) {
- setGraphKeywords('');
- setSelectedNodeId('');
- return;
- }
+ // Picking an option behaves like an Enter search: refetch the server-side
+ // keyword subgraph for that entity and keep the node highlighted.
setSelectedNodeId(name);
+ setGraphKeywords(name);
}, []);
const handleNoMatchEnter = useCallback(
(keywords: string) => {
// Enter on a keyword that exactly names an entity must behave like
- // picking it from the dropdown: highlight that node and its neighbors
- // and dim the rest. Only unmatched text falls back to the server-side
- // keyword subgraph, which renders fully bright.
+ // picking it from the dropdown. Only unmatched text falls back to the
+ // raw keyword subgraph with no highlighted node.
const entityName = findEntityDisplayNameByKeyword(
template?.entities ?? [],
keywords,
@@ -208,7 +205,8 @@ export function DatasetStructureView({ kind }: DatasetStructureViewProps) {
onChange={handleSelectEntity}
placeholder={t('knowledgeCompilation.searchEntity')}
allowClear
- triggerClassName="w-96 max-w-full"
+ alwaysShowSearch
+ triggerClassName="ml-auto w-96 max-w-full"
onNoMatchEnter={handleNoMatchEnter}
disableAutoSelectOnEnter
/>