@ihyeon/flow-qa 0.10.11 → 0.10.12

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.
@@ -5,6 +5,9 @@
5
5
  const t = i18n.t;
6
6
  const names = { scenario: 'nav.scenario', library: 'nav.library', history: 'nav.history', settings: 'nav.settings' };
7
7
  const defaultReportFilter = () => ({ search: '', status: 'all', sort: 'recorded', repeatedOnly: false });
8
+ let refreshRequest = 0;
9
+ let appliedRefreshRequest = 0;
10
+ let pendingSettingsRefresh = 0;
8
11
  const app = { state: null, connected: false, displayTargets: [], draft: null, selectedCaseIds: new Set(), script: '', neutralScript: '', scriptRevision: 0, savedFile: '', savedHash: '', origin: 'none', sourceFlow: '', boundSource: null, stale: false, dirty: false, busy: false, planning: false, planRequest: 0, stopping: false, report: null, reportParent: null, reportMarkdown: '', selectedRun: '', reportRequest: 0, reportLoading: false, reportFilter: defaultReportFilter(), rerunOrigin: null, rerunTargetMismatch: false, navigationVersion: 0, comparison: null, comparisonRequest: 0, comparisonBusy: false, comparisonStatus: 'comparison.selectBoth', comparisonPins: { baseline: null, current: null }, comparisonSelectionGeneration: 0, comparisonValidation: null, history: { runs: [], nextCursor: null, pagesLoaded: 0, loaded: false, loading: false, request: 0, debounce: null, kind: null, error: null, updatesAvailable: false, pendingRecentUpdate: false, parentRunId: '' }, view: 'scenario' };
9
12
 
10
13
  function el(tag, className, value) {
@@ -627,15 +630,29 @@
627
630
  readiness();
628
631
  }
629
632
  async function refresh(full = false) {
630
- const previousActive = app.state?.active;
633
+ const request = ++refreshRequest;
634
+ if (full) pendingSettingsRefresh = request;
631
635
  let state;
632
- try { state = await api('/api/state'); } catch (error) { app.connected = false; renderActive(); throw error; }
636
+ try { state = await api('/api/state'); }
637
+ catch (error) {
638
+ if (request !== refreshRequest) return;
639
+ appliedRefreshRequest = request;
640
+ app.connected = false;
641
+ renderActive();
642
+ throw error;
643
+ }
644
+ if (request < appliedRefreshRequest) return;
645
+ appliedRefreshRequest = request;
646
+ const previousActive = app.state?.active;
633
647
  const initialize = !app.state;
634
648
  const libraryChanged = JSON.stringify(app.state?.suites) !== JSON.stringify(state.suites);
635
649
  const historyChanged = JSON.stringify(app.state?.runs) !== JSON.stringify(state.runs);
636
650
  app.state = state; app.connected = true;
637
651
  renderActive(); if (libraryChanged) renderLibrary(); if (historyChanged) { recentRunsChanged(); renderComparisonOptions(); }
638
- if (full || initialize) { targetOptions(); modelForms(); }
652
+ // A newer poll can satisfy the pending settings refresh.
653
+ const refreshSettings = pendingSettingsRefresh !== 0 && request >= pendingSettingsRefresh;
654
+ if (refreshSettings) pendingSettingsRefresh = 0;
655
+ if (refreshSettings || initialize) { targetOptions(); modelForms(); }
639
656
  if (previousActive?.kind === 'run' && !state.active) { if (state.lastError) notice(state.lastError, true); else noticeKey('app.runEnded'); }
640
657
  if (state.lastError && state.lastError !== app.lastError) { app.lastError = state.lastError; notice(state.lastError, true); }
641
658
  await validateComparisonSelection(state);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ihyeon/flow-qa",
3
- "version": "0.10.11",
3
+ "version": "0.10.12",
4
4
  "license": "MIT",
5
5
  "author": "Hyeonse Im",
6
6
  "repository": {