Refact: Auto-refresh of Popular Labels When Pipeline Completes #2291
+82
−4
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Refact: Auto-refresh of Popular Labels When Pipeline Completes
Summary
This PR implements automatic refresh of popular labels in the graph viewer when the document processing pipeline transitions from busy to idle state. This ensures users always see the most up-to-date entity labels without manual intervention.
Problem Statement
Previously, after uploading and processing new documents, the popular labels dropdown would still show outdated labels until users manually refreshed. This created a disconnect between the newly processed knowledge graph and the available label suggestions.
Solution
Implemented pipeline state monitoring with automatic label refresh:
pipelineBusystate using refs to detect transitions from busy → idleshouldRefreshPopularLabelsRefto mark when refresh is neededonBeforeOpencallback support for async operations before dropdown opensTechnical Details
GraphLabels.tsx Changes:
useBackendStatehook to monitor pipeline statusreloadPopularLabels()helper functionhandleDropdownBeforeOpen()callback for pre-open refreshAsyncSelect.tsx Changes:
onBeforeOpen?: () => void | Promise<void>prophandleOpenChange()to trigger callback before openingBenefits
Testing Suggestions
*label → should reload popular labels