Skip to content

refactor(imports): Improving imports pass #1 - #886

Merged
thostetler merged 3 commits into
adsabs:masterfrom
thostetler:refactor/import-cycles
Jun 18, 2026
Merged

refactor(imports): Improving imports pass #1#886
thostetler merged 3 commits into
adsabs:masterfrom
thostetler:refactor/import-cycles

Conversation

@thostetler

@thostetler thostetler commented Jun 11, 2026

Copy link
Copy Markdown
Member

madge reports 46 circular dependencies in src. This breaks 34 of them with no behavior change.

  • Replaces runtime-relevant barrel cycles with direct imports
  • Moves shared type definitions out of modules that were creating cycles
  • Leaves the remaining type-only cycles for a focused follow-up

madge --circular reports 46 circular dependencies in src/ (an earlier graphify
pass undercounted at 19). This removes 34 of them with no behavior change: all
the runtime-relevant barrel-incest cycles plus several type-only ones. The
remaining 12 are benign type-only cycles (store slices, SearchFacet,
CitationExporter) and are deferred to a follow-up.

- Redirect Visualizations container/pane imports off the @/components/Visualizations
  barrel to direct module paths
- Extract NetworkDetails node/link types and the AuthorNetworkGraph/BubblePlot
  hook-component type pairs into leaf *.types.ts files
- Redirect FeedbackForms, Settings/Export, HistogramSlider and useExportFormats
  barrel imports to direct paths
- Drop api/metrics/model's dependency on metrics by typing bibcodes as Bibcode[]
- Move ApiRequestConfig into api/types.ts; api.ts re-exports it
- Extract AffTableState/AffTableAction into AuthorAffiliations/types.ts
- Move UserDataSetterEvent out of the settings/export page into
  components/Settings/Export/types.ts (it was imported by four components)
@codecov

codecov Bot commented Jun 11, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.36957% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 65.9%. Comparing base (4d21fec) to head (1db2e2f).
⚠️ Report is 8 commits behind head on master.

Files with missing lines Patch % Lines
...nents/Visualizations/Graphs/AuthorNetworkGraph.tsx 50.0% 2 Missing ⚠️
src/components/Metatags/Metatags.tsx 98.6% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##           master    #886     +/-   ##
========================================
+ Coverage    61.2%   65.9%   +4.7%     
========================================
  Files         349     335     -14     
  Lines       41439   39811   -1628     
  Branches     1836    2006    +170     
========================================
+ Hits        25359   26211    +852     
+ Misses      16037   13557   -2480     
  Partials       43      43             
Files with missing lines Coverage Δ
src/api/api.ts 84.3% <100.0%> (+0.1%) ⬆️
src/api/metrics/model.ts 75.0% <100.0%> (+10.8%) ⬆️
src/auth-utils.ts 65.6% <100.0%> (ø)
...orms/AssociatedArticles/AssociatedArticlesForm.tsx 67.6% <100.0%> (ø)
src/components/HistogramSlider/HistogramSlider.tsx 19.0% <100.0%> (+1.1%) ⬆️
src/components/Metatags/scholarDoctypes.ts 100.0% <100.0%> (ø)
...izations/Containers/AuthorNetworkPageContainer.tsx 21.4% <100.0%> (-0.5%) ⬇️
...lizations/Containers/ConceptCloudPageContainer.tsx 27.3% <100.0%> (ø)
...Visualizations/Containers/MetricsPageContainer.tsx 27.2% <100.0%> (ø)
...isualizations/Containers/OverviewPageContainer.tsx 23.4% <100.0%> (+0.5%) ⬆️
... and 19 more

... and 35 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 changed the title refactor(imports): break 34 of 46 src import cycles refactor(imports): break 34 of 46 import cycles Jun 11, 2026
@thostetler thostetler changed the title refactor(imports): break 34 of 46 import cycles refactor(imports): Improving imports pass #1 Jun 11, 2026
@thostetler
thostetler requested a review from shinyichen June 11, 2026 23:04
@thostetler
thostetler marked this pull request as ready for review June 11, 2026 23:04
Copilot AI review requested due to automatic review settings June 11, 2026 23:04

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Refactors imports and colocates shared types to reduce circular dependencies in src/ (per madge), aiming for no behavior change while removing runtime-relevant barrel cycles.

Changes:

  • Replaced several barrel imports (notably @/components/Visualizations, @/components/Settings, @/components/FeedbackForms) with direct/relative imports.
  • Extracted shared type definitions into dedicated *.types.ts / types.ts modules (Visualizations, Settings Export, Author Affiliations) to avoid cross-module cycles.
  • Centralized ApiRequestConfig type in src/api/types.ts and re-exported it from src/api/api.ts.

Risk summary

Medium risk: broad import-path churn across many modules (regression risk from missed/incorrect import semantics), plus a few places where type-only dependencies should be made explicit to avoid reintroducing runtime edges.

Findings (priority order)

blocker

  • None.

high

  • None.

medium

  • Type-only imports should consistently use import type in several newly introduced/updated type modules and consumers to ensure these refactors don’t accidentally preserve runtime dependency edges (especially relevant to a circular-dependency cleanup).
    Locations include: src/api/types.ts, src/auth-utils.ts, src/components/Settings/Export/types.ts, src/components/Visualizations/**/(types|*.types).ts(x), and several updated Visualizations components/hooks/utils.

low

  • None.

Reviewed changes

Copilot reviewed 44 out of 44 changed files in this pull request and generated 12 comments.

Show a summary per file
File Description
src/pages/user/settings/export.tsx Stops exporting reducer event types from a page module; imports shared event type from a component types file.
src/lib/useExportFormats.ts Switches DEFAULT_EXPORT_FORMATS import to a direct models module to avoid barrel cycles.
src/components/Visualizations/utils/graphUtils.ts Replaces Visualizations barrel type imports with direct NetworkDetails type imports.
src/components/Visualizations/Panes/NetworkDetails/types.ts New shared types module for network details panes.
src/components/Visualizations/Panes/NetworkDetails/SummaryPane.tsx Replaces Visualizations barrel imports with direct relative imports (types + graph component).
src/components/Visualizations/Panes/NetworkDetails/PaperNetworkDetailsPane.tsx Moves inline interface definitions to shared types.ts.
src/components/Visualizations/Panes/NetworkDetails/index.ts Re-exports shared NetworkDetails types from the pane index.
src/components/Visualizations/Panes/NetworkDetails/AuthorNetworkDetailsPane.tsx Uses shared types.ts for Paper/NodeDetails types.
src/components/Visualizations/Graphs/useBubblePlot.tsx Imports BubblePlot types from a dedicated BubblePlot.types.ts module.
src/components/Visualizations/Graphs/useAuthorNetworkGraph.tsx Imports shared graph types from AuthorNetworkGraph.types.ts.
src/components/Visualizations/Graphs/BubblePlot.types.ts New extracted type module for BubblePlot props/config.
src/components/Visualizations/Graphs/BubblePlot.tsx Removes inline types in favor of BubblePlot.types.ts.
src/components/Visualizations/Graphs/AuthorNetworkGraph.types.ts New extracted type module for AuthorNetworkGraph shared types.
src/components/Visualizations/Graphs/AuthorNetworkGraph.tsx Moves shared interfaces out to AuthorNetworkGraph.types.ts and trims d3 imports.
src/components/Visualizations/GraphPanes/YearsGraphPane.tsx Replaces Visualizations barrel import with direct BarGraph import.
src/components/Visualizations/GraphPanes/MetricsPane.tsx Replaces Visualizations barrel imports with direct Graph/Table imports.
src/components/Visualizations/GraphPanes/HIndexGraphPane.tsx Replaces Visualizations barrel import with direct LineGraph import.
src/components/Visualizations/GraphPanes/BubblePlotPane.tsx Splits BubblePlot component import from BubblePlot config type import.
src/components/Visualizations/GraphPanes/AuthorNetworkGraphPane.tsx Replaces Visualizations barrel import with direct AuthorNetworkGraph import.
src/components/Visualizations/Containers/ResultsGraphPageContainer.tsx Imports IBubblePlotNodeData directly from local Visualizations types.
src/components/Visualizations/Containers/PaperNetworkPageContainer.tsx Imports PaperNetwork pane/components/types directly instead of via barrel.
src/components/Visualizations/Containers/OverviewPageContainer.tsx Imports graph panes directly instead of via Visualizations barrel.
src/components/Visualizations/Containers/MetricsPageContainer.tsx Imports MetricsPane directly instead of via Visualizations barrel.
src/components/Visualizations/Containers/ConceptCloudPageContainer.tsx Imports WordCloudPane directly instead of via Visualizations barrel.
src/components/Visualizations/Containers/AuthorNetworkPageContainer.tsx Imports network panes/types directly instead of via Visualizations barrel.
src/components/Settings/Export/types.ts New extracted type module for Settings Export reducer events.
src/components/Settings/Export/Tabs/QuickExportFormatTabPane.tsx Uses new Settings Export types module instead of importing from a page.
src/components/Settings/Export/Tabs/GeneralTabPanel.tsx Uses new Settings Export types module; replaces Settings barrel import with local SampleTextArea.
src/components/Settings/Export/Tabs/CustomFormatsTabPanel.tsx Uses new Settings Export types module; replaces Settings barrel import with local SampleTextArea.
src/components/Settings/Export/Tabs/BibtexTabPanel.tsx Uses new Settings Export types module; replaces Settings barrel imports with local components.
src/components/Settings/Export/ExportFormatSelect.tsx Replaces Settings barrel description import with local Description module.
src/components/Settings/Export/CustomFormatsTable.tsx Replaces Settings barrel description import with local Description module.
src/components/HistogramSlider/HistogramSlider.tsx Replaces Visualizations barrel imports with direct Histogram + HistogramDatum imports.
src/components/FeedbackForms/MissingRecord/RecordPanel.tsx Replaces FeedbackForms barrel import with direct PreviewModal import.
src/components/FeedbackForms/AssociatedArticles/AssociatedArticlesForm.tsx Replaces FeedbackForms barrel import with direct PreviewModal import.
src/components/AuthorAffiliations/types.ts Extracts table state/action types to shared types module.
src/components/AuthorAffiliations/hooks/UseSubCaption.tsx Imports AffTableState from shared types.ts instead of component module.
src/components/AuthorAffiliations/hooks/UseFetchAffData.tsx Imports AffTableState from shared types.ts instead of component module.
src/components/AuthorAffiliations/AuthorAffiliations.tsx Uses extracted AffTableState/AffTableAction from types.ts.
src/components/AuthorAffiliations/AffiliationControls.tsx Imports state/action types from shared types.ts instead of component module.
src/auth-utils.ts Switches ApiRequestConfig import source to @/api/types.
src/api/types.ts Introduces shared ApiRequestConfig type alias for request config typing.
src/api/metrics/model.ts Removes dependency on metricsKeys for typing; uses Bibcode[] directly.
src/api/api.ts Imports and re-exports ApiRequestConfig from src/api/types.ts to avoid cycles.

Comment thread src/components/Settings/Export/types.ts Outdated
Comment thread src/components/Visualizations/Panes/NetworkDetails/types.ts Outdated
Comment thread src/components/Visualizations/Graphs/BubblePlot.types.ts Outdated
Comment thread src/api/types.ts Outdated
Comment thread src/auth-utils.ts Outdated
Comment thread src/components/Visualizations/Graphs/AuthorNetworkGraph.tsx Outdated
Comment thread src/components/Visualizations/Panes/NetworkDetails/SummaryPane.tsx Outdated
Comment thread src/components/Visualizations/utils/graphUtils.ts Outdated
Comment thread src/components/Visualizations/Graphs/useAuthorNetworkGraph.tsx Outdated
Comment thread src/components/Visualizations/Graphs/AuthorNetworkGraph.types.ts Outdated
Only an allowed whitelist of doctypes emits Google Scholar-compatible
meta tags (Highwire citation_*, PRISM prism.*, Dublin Core dc.*) on the
abstract page. Other or unknown doctypes omit them; Schema.org JSON-LD,
Open Graph, Twitter, canonical, and description tags remain for all
records. Doctype comparisons are normalized to lowercase.
@thostetler
thostetler merged commit 0b8bc82 into adsabs:master Jun 18, 2026
5 checks passed
@thostetler
thostetler deleted the refactor/import-cycles branch June 18, 2026 21:48
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