@seekora-ai/ui-sdk-core 0.2.24 → 0.2.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1395,6 +1395,8 @@ class SearchStateManager {
1395
1395
  this.listeners = [];
1396
1396
  this.debounceTimer = null;
1397
1397
  this.notifyScheduled = false;
1398
+ this.searchCoalesceTimer = null;
1399
+ this.searchCoalesceResolvers = [];
1398
1400
  this.client = config.client;
1399
1401
  this.autoSearch = config.autoSearch !== false;
1400
1402
  this.debounceMs = config.debounceMs || 300;
@@ -1539,13 +1541,27 @@ class SearchStateManager {
1539
1541
  this.debouncedSearch();
1540
1542
  }
1541
1543
  }
1542
- // Manual search trigger
1544
+ // Manual search trigger — coalesces rapid calls within 10ms into a single API request
1543
1545
  async search(additionalOptions) {
1544
1546
  // Clear debounce timer if exists
1545
1547
  if (this.debounceTimer) {
1546
1548
  clearTimeout(this.debounceTimer);
1547
1549
  this.debounceTimer = null;
1548
1550
  }
1551
+ return new Promise((resolve, reject) => {
1552
+ this.searchCoalesceResolvers.push({ resolve, reject });
1553
+ if (this.searchCoalesceTimer) {
1554
+ clearTimeout(this.searchCoalesceTimer);
1555
+ }
1556
+ this.searchCoalesceTimer = setTimeout(() => {
1557
+ this.searchCoalesceTimer = null;
1558
+ const resolvers = [...this.searchCoalesceResolvers];
1559
+ this.searchCoalesceResolvers = [];
1560
+ this._executeSearch(additionalOptions).then((result) => resolvers.forEach(r => r.resolve(result)), (err) => resolvers.forEach(r => r.reject(err)));
1561
+ }, 10);
1562
+ });
1563
+ }
1564
+ async _executeSearch(additionalOptions) {
1549
1565
  this.setState({ loading: true, error: null });
1550
1566
  try {
1551
1567
  const searchOptions = this.buildSearchOptions(additionalOptions);