Skip to content

feat(citation): add a Copy Citation format override - #997

Open
thostetler wants to merge 11 commits into
adsabs:masterfrom
thostetler:feature/copy-citation-format-override
Open

thostetler wants to merge 11 commits into
adsabs:masterfrom
thostetler:feature/copy-citation-format-override

Conversation

@thostetler

@thostetler thostetler commented Dec 3, 2026 •

Copy link
Copy Markdown
Member

Copy Citation on the abstract page now follows its own format when the Export Settings checkbox under Default Format is turned on, instead of always matching the Default Export Format.

  • The override only covers formats the quick-copy modal supports, so custom export templates aren't selectable here.
  • Copying from the modal now closes it and shows a success toast.
image image

Reuses the unread defaultCitationFormat key with a copy: marker, so the three ways it was written on live accounts all read as linked. An override naming a format the manifest no longer offers relinks to the export format.
An opt-in checkbox under Default Format reveals a separate selector, initialised to the export format so opting in does not change what gets copied. Checked state comes from the stored marker, never from comparing the two formats.
Reset to defaults on the Default Format tab now clears the override. The default for the field becomes empty rather than a bare format id, which reset would otherwise stamp into accounts as a fresh ambiguous value.
Chakra forwards unknown props to the wrapper label, so the disclosure state goes through inputProps to reach the native input.
Gives the stub in-memory user data so a save can be read back, and asserts the stored marker directly rather than only the rendered state. STUB_PORT lets the stub run when 18080 is already taken.
A hardcoded gray.200 made the disclosure rule the brightest element on a dark page.
Three cases asserted through resolution could not fail, because an empty id and a missing marker both fall through to the same linked result. Asserting them on decodeCopyCitationOverride gives them teeth.
useCitationFormat is the shared resolver for copying and exporting, so putting the override inside it also redirected the Export Citation link, both Other Formats menus and the export page fallback. The hook now resolves the two separately and only copy surfaces read the override. The override is also restricted to the formats the quick-copy modal offers, which drops custom: picking a custom template reorders customFormats, so a copy:custom override silently changed template whenever the export template did.
Uses the existing onCopyComplete callback, which only fires on a resolved write, so a refused copy leaves the modal open with its failure notice visible.
…onfirm on

Closing the modal on a successful copy took the inline confirmation with it, since the label and the close fire in the same render. The toast names the format the reader selected rather than their default, and matches the split button's wording.
@thostetler
thostetler requested a review from shinyichen December 3, 2026 04:53
@github-actions

github-actions Bot commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Bundle size

Shared by all pages: 643.6 kB (-0.0 kB) ⚪

Route Base Head Change
/search/exportcitation/[format] 755.4 kB 759.4 kB +4.1 kB 🔴
/abs/[id]/exportcitation/[format] 804.5 kB 807.7 kB +3.2 kB 🔴
/user/settings/export 1024.2 kB 1025.9 kB +1.6 kB 🔴
/user/settings/orcid 1060.3 kB 1061.9 kB +1.6 kB 🔴
/search/paper_network 1022.9 kB 1024.5 kB +1.6 kB 🔴
/search/author_network 1022.9 kB 1024.5 kB +1.6 kB 🔴
/search/concept_cloud 1022.9 kB 1024.5 kB +1.6 kB 🔴
/search/metrics 1022.9 kB 1024.5 kB +1.6 kB 🔴
/search/results_graph 1022.9 kB 1024.5 kB +1.6 kB 🔴
/user/settings/delete 1023.9 kB 1025.5 kB +1.6 kB 🔴
/user/settings/email 1034.1 kB 1035.7 kB +1.6 kB 🔴
/user/settings/libraries 1023.4 kB 1025.0 kB +1.6 kB 🔴
/user/settings/librarylink 1025.1 kB 1026.7 kB +1.6 kB 🔴
/user/settings/password 1035.4 kB 1036.9 kB +1.6 kB 🔴
/user/settings/token 1025.9 kB 1027.4 kB +1.6 kB 🔴
/search/overview 1023.0 kB 1024.5 kB +1.6 kB 🔴

First load = polyfills + shared _app chunks + route chunks, gzipped.

@thostetler
thostetler marked this pull request as ready for review December 3, 2026 04:57
@codecov

codecov Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.72131% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 58.7%. Comparing base (8ea152a) to head (858d8a6).

Files with missing lines Patch % Lines
src/lib/citationFormat.ts 95.0% 0 Missing and 1 partial ⚠️
src/pages/user/settings/export.tsx 50.0% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##           master    #997     +/-   ##
========================================
+ Coverage    58.3%   58.7%   +0.5%     
========================================
  Files         407     408      +1     
  Lines       12768   12822     +54     
  Branches     2863    2875     +12     
========================================
+ Hits         7434    7520     +86     
+ Misses       4648    4612     -36     
- Partials      686     690      +4     
Files with missing lines Coverage Δ
src/api/user/models.ts 100.0% <100.0%> (ø)
...mponents/AbstractDetails/AbstractCitationModal.tsx 95.9% <100.0%> (+0.9%) ⬆️
.../components/AbstractDetails/CitationCopyButton.tsx 97.2% <100.0%> (ø)
...mponents/ResultList/Item/ItemResourceDropdowns.tsx 54.7% <100.0%> (ø)
...onents/Settings/Export/CopyCitationFormatField.tsx 100.0% <100.0%> (ø)
...omponents/Settings/Export/Tabs/GeneralTabPanel.tsx 63.0% <ø> (+59.3%) ⬆️
src/lib/useCitationFormat.ts 100.0% <100.0%> (ø)
src/lib/citationFormat.ts 98.4% <95.0%> (-1.6%) ⬇️
src/pages/user/settings/export.tsx 27.5% <50.0%> (-0.5%) ⬇️

... and 6 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.

This branch has not been deployed

No deployments
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.

1 participant