Skip to content

chore(web): simplification sweep — dead exports, shared media-query hook - #988

Merged
andy-esch merged 2 commits into
mainfrom
chore/simplify-sweep-web
Sep 1, 2026
Merged

chore(web): simplification sweep — dead exports, shared media-query hook#988
andy-esch merged 2 commits into
mainfrom
chore/simplify-sweep-web

Conversation

@andy-esch

Copy link
Copy Markdown
Owner

Behaviour-preserving cleanup of 7 findings from the 2026-08-12 and 2026-08-17 simplify-web audits. No production behaviour changes.

Deletions (each verified to have zero references first):

  • AvailableYear type export (constants/sidebar.ts)
  • MultiDailySportData, FirebaseConfig, EmulatorConfig types
  • the speculative _userPrefs parameter on getPrimaryMetric, its @PARAM doc and its commented-out implementation

AppConfig sat inside the same finding's line range but has three live uses, so it was left alone. The _userPrefs test went with the parameter: it only asserted the argument was ignored, and no production caller ever passed one.

Extractions:

  • useMediaQueryuseIsMobile and useReducedMotion were byte-identical apart from the query string and state name; both are now thin wrappers
  • goalToDisplayValue in dashboardUtils — the target and impact goals each ran their own copy of the isDistance/isTime/else chain

Idiom:

  • filterActualActivityData uses .filter() instead of an index loop
  • Object.fromEntries for the demo-goals map; redundant .toString() dropped inside a template literal

useMediaQuery is deliberately a byte-for-byte port, including the gap where a change between the useState initializer and the effect subscribing is missed. Closing that is a behaviour change and belongs in its own commit; the reasoning is recorded in the new file.

Two findings from these audits are intentionally not included:

  • collapsing useSportConfig / usePublicSportConfig: the two hooks differ in auth posture (one attaches a Firebase ID token, one must never), so merging them risks attaching a token to a non-internal request. Needs a deliberate decision, not a sweep.
  • consolidating the chart-tooltip surface style: gated on the tooltip-converge work, which will delete one of the duplicate copies outright.

web-test 1650 passed, web-lint and web-typecheck clean.

@codecov

codecov Bot commented Sep 1, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 88.00000% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 71.62%. Comparing base (c7d6930) to head (beccbd8).

Files with missing lines Patch % Lines
packages/web/src/utils/dashboardUtils.ts 66.66% 2 Missing ⚠️
packages/web/src/utils/units.ts 0.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #988      +/-   ##
==========================================
- Coverage   71.62%   71.62%   -0.01%     
==========================================
  Files         310      311       +1     
  Lines       15833    15807      -26     
  Branches     3216     3383     +167     
==========================================
- Hits        11341    11322      -19     
+ Misses       4298     4291       -7     
  Partials      194      194              
Flag Coverage Δ
go-apigateway 63.93% <ø> (ø)
go-apigateway-integration 91.63% <ø> (ø)
go-dispatcher 77.33% <ø> (ø)
go-firestore-integration 22.11% <ø> (ø)
go-shared 87.35% <ø> (ø)
python-integration 44.32% <ø> (ø)
web 81.56% <88.00%> (+0.02%) ⬆️
web-integration 27.71% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
packages/web/src/constants/sidebar.ts 100.00% <ø> (ø)
packages/web/src/hooks/useDailySportData.ts 2.85% <ø> (ø)
packages/web/src/hooks/useIsMobile.ts 100.00% <ø> (ø)
packages/web/src/hooks/useMediaQuery.ts 100.00% <100.00%> (ø)
packages/web/src/hooks/useReducedMotion.ts 100.00% <ø> (ø)
packages/web/src/hooks/useWeeklySummary.ts 81.17% <100.00%> (+0.27%) ⬆️
packages/web/src/lib/config.ts 71.42% <ø> (ø)
packages/web/src/utils/sportConfig.ts 100.00% <100.00%> (ø)
packages/web/src/utils/trainingMomentum.ts 95.31% <100.00%> (-0.41%) ⬇️
packages/web/src/utils/units.ts 76.80% <0.00%> (ø)
... and 1 more
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Behaviour-preserving cleanup of 7 findings from the 2026-08-12 and 2026-08-17
simplify-web audits. No production behaviour changes.

Deletions (each verified to have zero references first):
- `AvailableYear` type export (constants/sidebar.ts)
- `MultiDailySportData`, `FirebaseConfig`, `EmulatorConfig` types
- the speculative `_userPrefs` parameter on `getPrimaryMetric`, its @PARAM doc
  and its commented-out implementation

`AppConfig` sat inside the same finding's line range but has three live uses,
so it was left alone. The `_userPrefs` test went with the parameter: it only
asserted the argument was ignored, and no production caller ever passed one.

Extractions:
- `useMediaQuery` — `useIsMobile` and `useReducedMotion` were byte-identical
  apart from the query string and state name; both are now thin wrappers
- `goalToDisplayValue` in dashboardUtils — the target and impact goals each ran
  their own copy of the isDistance/isTime/else chain

Idiom:
- `filterActualActivityData` uses `.filter()` instead of an index loop
- `Object.fromEntries` for the demo-goals map; redundant `.toString()` dropped
  inside a template literal

`useMediaQuery` is deliberately a byte-for-byte port, including the gap where a
change between the `useState` initializer and the effect subscribing is missed.
Closing that is a behaviour change and belongs in its own commit; the reasoning
is recorded in the new file.

Two findings from these audits are intentionally not included:
- collapsing `useSportConfig` / `usePublicSportConfig`: the two hooks differ in
  auth posture (one attaches a Firebase ID token, one must never), so merging
  them risks attaching a token to a non-internal request. Needs a deliberate
  decision, not a sweep.
- consolidating the chart-tooltip surface style: gated on the tooltip-converge
  work, which will delete one of the duplicate copies outright.

web-test 1650 passed, web-lint and web-typecheck clean.
@andy-esch
andy-esch force-pushed the chore/simplify-sweep-web branch from 29c7cfe to beccbd8 Compare September 1, 2026 10:49
@andy-esch
andy-esch merged commit 3a19356 into main Sep 1, 2026
21 checks passed
@andy-esch
andy-esch deleted the chore/simplify-sweep-web branch September 1, 2026 10:56
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