use same state accross app for nlq search#29165
Conversation
❌ PR checklist incompleteThis PR cannot be merged until the following are addressed on its linked issue:
The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically. Maintainers can bypass this check by adding the |
|
Hi there 👋 Thanks for your contribution! The OpenMetadata team will review the PR shortly! Once it has been labeled as Let us know if you need any help! |
|
Hi there 👋 Thanks for your contribution! The OpenMetadata team will review the PR shortly! Once it has been labeled as Let us know if you need any help! |
…data/OpenMetadata into marketplace-nlq-search
|
Hi there 👋 Thanks for your contribution! The OpenMetadata team will review the PR shortly! Once it has been labeled as Let us know if you need any help! |
| if (!isNLPEnabled) { | ||
| getNLPEnabledStatus() | ||
| .then(setNLPEnabled) | ||
| .catch(() => setNLPEnabled(false)); | ||
| } |
There was a problem hiding this comment.
Is there a primitive in store that calls this directly?
There was a problem hiding this comment.
No. The fetch and set logic lives in the components themselves.
…data/OpenMetadata into marketplace-nlq-search
…data/OpenMetadata into marketplace-nlq-search
…data/OpenMetadata into marketplace-nlq-search
Code Review ✅ Approved 2 resolved / 2 findingsCentralizes NLQ search state into a shared Zustand store to resolve sync issues, though the initNLP guard needs refinement to fully eliminate redundant API calls when NLP is disabled. ✅ 2 resolved✅ Bug: NLQ toggle won't render on marketplace pages (isNLPEnabled never populated)
✅ Bug: initNLP race: concurrent callers still fire duplicate API calls
OptionsDisplay: compact → Showing less information. Comment with these commands to change:
Was this helpful? React with 👍 / 👎 | Gitar |
|
🟡 Playwright Results — all passed (15 flaky)✅ 4299 passed · ❌ 0 failed · 🟡 15 flaky · ⏭️ 88 skipped
🟡 15 flaky test(s) (passed on retry)
How to debug locally# Download playwright-test-results-<shard> artifact and unzip
npx playwright show-trace path/to/trace.zip # view trace |



Describe your changes:
Problem:
The Data Marketplace search bar maintained its own local isNLPEnabled/isNLQActive state and made a redundant GET /api/v1/system/search/nlq call on every marketplace page load. NLQ active state was also siloed — toggling it on the explore or home page had no effect in the marketplace and vice versa.
Fix:
Replace local state and the useEffect API call in MarketplaceSearchBar with useSearchStore (the existing Zustand store already used by GlobalSearchBar and ExplorePageV1). isNLPEnabled is now populated once (when the global search bar mounts) and shared app-wide. isNLPActive toggled anywhere persists everywhere.
Tests:
Updated MarketplaceSearchBar.test.tsx to remove the getNLPEnabledStatus mock and seed NLQ state via useSearchStore.setState(...) instead, matching how the component actually reads it.
Fixes #
I worked on ... because ...
Type of change:
High-level design:
N/A — small change.
Tests:
Use cases covered
Unit tests
Backend integration tests
Ingestion integration tests
Playwright (UI) tests
Manual testing performed
UI screen recording / screenshots:
Not applicable.
Checklist:
Fixes <issue-number>: <short explanation>Fixes #<issue-number>above.Greptile Summary
This PR consolidates NLQ/NLP state into the existing
useSearchStoreZustand store so thatisNLPEnabledandisNLPActiveare shared across the GlobalSearchBar, CustomiseSearchBar, and MarketplaceSearchBar — eliminating a redundant per-component API call and the siloed local state in the marketplace.useSearchStoregains anisNLPInitializedguard and aninitNLP()async action that replaces the previoussetNLPEnabledaction; each consumer now callsinitNLP()on mount, and the guard short-circuits if the store is already hydrated.MarketplaceSearchBardrops its localisNLPEnabled/isNLQActivestate anduseEffectAPI call, reading from the shared store instead; toggling NLQ in the marketplace now propagates app-wide.useSearchStore.setStateand a new test verifies the cold-store bootstrap path (direct marketplace navigation before the global nav mounts).Confidence Score: 5/5
Safe to merge — the change is a straightforward state consolidation with no new API surface and well-updated tests.
The core logic is a clean refactor: local component state and a redundant API call replaced by a shared Zustand store with a one-time-init guard. The guard has a theoretical concurrent-call edge case but the consequence is a single duplicate API request at startup — the same outcome as the code being replaced. Tests cover the cold-store bootstrap and skip-when-initialized paths. No data correctness or security concerns.
GlobalSearchBar.tsx and CustomiseSearchBar.tsx —
initNLPis omitted from theiruseEffectdependency arrays, which may trigger a lint warning.Important Files Changed
isNLPInitializedflag and aninitNLPasync action; replacessetNLPEnabled. Guard is not atomic so concurrent callers can race past it, but the outcome is benign.useSearchStore; correctly callsinitNLP()on mount with[initNLP]in deps.initNLP()directly;initNLPis missing from theuseEffectdependency array (potential lint violation).GlobalSearchBar; same missinginitNLPdep in theuseEffectdependency array.useSearchStore.setState; new test for cold-store bootstrap path added;getNLPEnabledStatusmock retained for the bootstrap test.Sequence Diagram
%%{init: {'theme': 'neutral'}}%% sequenceDiagram participant GSB as GlobalSearchBar participant MSB as MarketplaceSearchBar participant Store as useSearchStore participant API as GET /api/v1/system/search/nlq Note over GSB,MSB: Normal flow (nav includes GlobalSearchBar) GSB->>Store: "initNLP() isNLPInitialized=false fetch" Store->>API: getNLPEnabledStatus() API-->>Store: true Store->>Store: "set isNLPEnabled=true, isNLPInitialized=true" MSB->>Store: "initNLP() isNLPInitialized=true skip" Note over MSB,Store: Direct deep-link to marketplace (no GSB) MSB->>Store: "initNLP() isNLPInitialized=false fetch" Store->>API: getNLPEnabledStatus() API-->>Store: true Store->>Store: "set isNLPEnabled=true, isNLPInitialized=true" Note over GSB,MSB: NLQ toggle shared state GSB->>Store: setNLPActive(true) Store-->>MSB: "isNLPActive=true re-render" MSB->>Store: setNLPActive(false) Store-->>GSB: "isNLPActive=false re-render"%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%% sequenceDiagram participant GSB as GlobalSearchBar participant MSB as MarketplaceSearchBar participant Store as useSearchStore participant API as GET /api/v1/system/search/nlq Note over GSB,MSB: Normal flow (nav includes GlobalSearchBar) GSB->>Store: "initNLP() isNLPInitialized=false fetch" Store->>API: getNLPEnabledStatus() API-->>Store: true Store->>Store: "set isNLPEnabled=true, isNLPInitialized=true" MSB->>Store: "initNLP() isNLPInitialized=true skip" Note over MSB,Store: Direct deep-link to marketplace (no GSB) MSB->>Store: "initNLP() isNLPInitialized=false fetch" Store->>API: getNLPEnabledStatus() API-->>Store: true Store->>Store: "set isNLPEnabled=true, isNLPInitialized=true" Note over GSB,MSB: NLQ toggle shared state GSB->>Store: setNLPActive(true) Store-->>MSB: "isNLPActive=true re-render" MSB->>Store: setNLPActive(false) Store-->>GSB: "isNLPActive=false re-render"Reviews (9): Last reviewed commit: "fix lint issues" | Re-trigger Greptile