Skip to content

fix(export): prevent prop-sync effects from reverting user format change#874

Merged
thostetler merged 1 commit into
adsabs:masterfrom
thostetler:fix/export-format-revert
Jun 1, 2026
Merged

fix(export): prevent prop-sync effects from reverting user format change#874
thostetler merged 1 commit into
adsabs:masterfrom
thostetler:fix/export-format-revert

Conversation

@thostetler
Copy link
Copy Markdown
Member

@thostetler thostetler commented May 28, 2026

Fix small export bug introduced by the sentry telemetry PR

The format/records/sort sync effects in useCitationExporter widened their
dep arrays to include derived machine state during the telemetry PR's
exhaustive-deps cleanup. After a user-initiated SET_FORMAT, params.format
changed, the effect re-ran, saw format (prop) !== params.format (machine),
and dispatched the original prop value back — instantly reverting the
chosen export format.

- Narrow dep arrays back to props only on the three one-way sync effects
- Match the eslint-disable-line precedent used by the mount-only effect
- Add useCitationExporter regression test covering SET_FORMAT persistence
  and prop -> machine sync
@codecov
Copy link
Copy Markdown

codecov Bot commented May 28, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 62.7%. Comparing base (16840c8) to head (7c7c84f).

Additional details and impacted files
@@           Coverage Diff            @@
##           master    #874     +/-   ##
========================================
+ Coverage    62.6%   62.7%   +0.1%     
========================================
  Files         324     324             
  Lines       38203   38205      +2     
  Branches     1733    1741      +8     
========================================
+ Hits        23903   23918     +15     
+ Misses      14259   14247     -12     
+ Partials       41      40      -1     
Files with missing lines Coverage Δ
...components/CitationExporter/useCitationExporter.ts 93.2% <100.0%> (+2.2%) ⬆️

... and 5 files with indirect coverage changes

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@thostetler thostetler marked this pull request as ready for review May 28, 2026 16:43
@thostetler thostetler requested review from Copilot and shinyichen May 28, 2026 16:43
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Risk summary: Low regression risk; change is localized to prop→state-machine sync behavior in the citation exporter hook, with targeted test coverage added.

Findings (priority order):

  • medium: useCitationExporter’s format prop-sync effect still requires an exhaustive-deps suppression; it can be rewritten to depend only on the format prop (and dispatch) without reading derived machine state. (Location: src/components/CitationExporter/useCitationExporter.ts, format sync effect; confidence: high)

Purpose: Prevent the citation export “prop-sync” effects from undoing a user-driven format change (regression introduced by prior telemetry-related changes), while ensuring prop changes still synchronize into the XState FSM.

Changes:

  • Make prop→machine sync effects one-way by removing derived machine values from effect dependency arrays (prevents re-firing after user dispatches).
  • Add hook-level tests to verify user-initiated SET_FORMAT persists and prop changes still sync.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/components/CitationExporter/useCitationExporter.ts Adjusts prop→FSM synchronization effects to avoid reverting user-initiated format changes.
src/components/CitationExporter/useCitationExporter.test.tsx Adds regression tests for format sync behavior between props and the FSM.

Comment on lines 88 to +92
useEffect(() => {
if (format !== params.format) {
dispatch({ type: 'SET_FORMAT', payload: format });
}
}, [format, params.format, dispatch]);
}, [format]); // eslint-disable-line react-hooks/exhaustive-deps
@thostetler thostetler merged commit 6a15785 into adsabs:master Jun 1, 2026
5 checks passed
@thostetler thostetler deleted the fix/export-format-revert branch June 1, 2026 21:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants