Skip to content

feat: add data correction section to settings page#3039

Open
Hui-Hwoo wants to merge 7 commits into
npmx-dev:mainfrom
Hui-Hwoo:feat/settings-data-correction
Open

feat: add data correction section to settings page#3039
Hui-Hwoo wants to merge 7 commits into
npmx-dev:mainfrom
Hui-Hwoo:feat/settings-data-correction

Conversation

@Hui-Hwoo

@Hui-Hwoo Hui-Hwoo commented Jul 13, 2026

Copy link
Copy Markdown

🔗 Linked issue

Closes #2536

🧭 Context

The download chart's data correction parameters (averageWindow, smoothingTau, anomaliesFixed, predictionPoints) persist in localStorage but are only accessible from the chart modal on package pages. Users who modified these settings may forget they did so, leading to confusing download number discrepancies (see #2510).

📚 Description

Adds a new Data Correction section to the Settings page (/settings) that displays the current values of all four chartFilter parameters and provides a "Reset to defaults" button.

Changes:

  • app/composables/useSettings.ts — Exports a DEFAULT_CHART_FILTER constant (single source of truth for defaults), referenced by DEFAULT_SETTINGS
  • app/pages/settings.vue — Adds the Data Correction section with a computed isDefaultChartFilter check and a resetChartFilter() function. The reset button is disabled when all values are already at defaults
  • i18n/locales/en.json — Adds settings.sections.data_correction, settings.data_correction_reset, and settings.data_correction_description
  • i18n/locales/*.json — Propagates the three new keys to all locale files with English placeholders

@vercel

vercel Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
npmx.dev Ready Ready Preview, Comment Jul 13, 2026 8:06pm
2 Skipped Deployments
Project Deployment Actions Updated (UTC)
docs.npmx.dev Ignored Ignored Preview Jul 13, 2026 8:06pm
npmx-lunaria Ignored Ignored Jul 13, 2026 8:06pm

Request Review

@github-actions

Copy link
Copy Markdown

Hello! Thank you for opening your first PR to npmx, @Hui-Hwoo! 🚀

Here’s what will happen next:

  1. Our GitHub bots will run to check your changes.
    If they spot any issues you will see some error messages on this PR.
    Don’t hesitate to ask any questions if you’re not sure what these mean!

  2. In a few minutes, you’ll be able to see a preview of your changes on Vercel

  3. One or more of our maintainers will take a look and may ask you to make changes.
    We try to be responsive, but don’t worry if this takes a few days.

@github-actions

github-actions Bot commented Jul 13, 2026

Copy link
Copy Markdown

Lunaria Status Overview

🌕 This pull request will trigger status changes.

Learn more

By default, every PR changing files present in the Lunaria configuration's files property will be considered and trigger status changes accordingly.

You can change this by adding one of the keywords present in the ignoreKeywords property in your Lunaria configuration file in the PR's title (ignoring all files) or by including a tracker directive in the merged commit's description.

Tracked Files

File Note
i18n/locales/en.json Source changed, localizations will be marked as outdated.
Warnings reference
Icon Description
🔄️ The source for this localization has been updated since the creation of this pull request, make sure all changes in the source have been applied.

@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Chart-filter defaults are centralised and reset support is exposed in settings. A new data-correction section displays filter values, provides a conditional reset button, adds localisation and schema keys, and includes composable tests.

Changes

Chart filter reset

Layer / File(s) Summary
Shared defaults and reset UI
app/composables/useSettings.ts, app/pages/settings.vue
Chart-filter defaults are exported and reused by useChartFilter(), while the settings page displays current values and enables reset only when values differ from defaults.
Chart-filter reset validation
test/nuxt/composables/use-settings.spec.ts
Tests cover default values, modified-state detection, reset behaviour, and restoration of the default state.
Data-correction locale coverage
i18n/locales/en.json, i18n/schema.json
English locale strings and schema properties are added for the data-correction section, controls, description, and reset action.

Sequence Diagram(s)

sequenceDiagram
  participant SettingsPage
  participant useChartFilter
  participant SettingsState
  SettingsPage->>useChartFilter: read filter state
  useChartFilter->>SettingsState: compare chartFilter with DEFAULT_CHART_FILTER
  SettingsPage->>useChartFilter: click reset
  useChartFilter->>SettingsState: assign default chart-filter copy
  SettingsState-->>SettingsPage: update values and button state
Loading

Possibly related PRs

Suggested reviewers: matteogabriele, mvanhorn, 43081j, alexdln, bittubarnwal7479

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: adding a data correction section to the settings page.
Description check ✅ Passed The description is directly related to the implemented settings-page data correction work and matches the change set.
Linked Issues check ✅ Passed The PR adds the Data Correction section, reset-to-defaults logic, and the required default chartFilter values from #2536.
Out of Scope Changes check ✅ Passed The added tests and localisation/schema updates support the new settings feature and do not appear unrelated to the issue.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot added the 007 This PR *may* not follow our code of conduct regarding AI usage. label Jul 13, 2026

@gameroman gameroman left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please use the Pull Request template and resolve the conflicts

@Hui-Hwoo
Hui-Hwoo force-pushed the feat/settings-data-correction branch from 447a187 to 07f0dd5 Compare July 13, 2026 16:47
@codecov

codecov Bot commented Jul 13, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.86207% with 7 lines in your changes missing coverage. Please review.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
app/pages/settings.vue 73.91% 2 Missing and 4 partials ⚠️
app/composables/useSettings.ts 83.33% 0 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@gameroman
gameroman self-requested a review July 13, 2026 16:51
@gameroman gameroman removed the 007 This PR *may* not follow our code of conduct regarding AI usage. label Jul 13, 2026
Comment thread i18n/locales/ar.json Outdated

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 2

🧹 Nitpick comments (1)
i18n/locales/es-419.json (1)

15-16: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Keep the regional overlay limited to genuine differences.

After i18n/locales/es.json has final translations, omit these keys from es-419.json unless the Latin-American wording intentionally differs, so the variant inherits the base Spanish values.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@i18n/locales/es-419.json` around lines 15 - 16, Remove data_correction_reset
and data_correction_description from the es-419 locale unless their
Latin-American translations intentionally differ from the finalized es.json
values, allowing the regional locale to inherit the base Spanish translations.

Source: Learnings

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@i18n/locales/ar-EG.json`:
- Line 50: Replace every literal “EN TEXT TO REPLACE:” placeholder with accurate
localized translations for the relevant Settings strings. Update
i18n/locales/ar-EG.json at 50 and 74-75, ar.json at 93 and 122-123, az-AZ.json
at 140 and 173-174, bg-BG.json at 111 and 142-143, sr-Latn-RS.json at 144 and
191-192, ta-IN.json at 92 and 121-122, and te-IN.json at 69 and 89-90; preserve
the existing locale structure and ensure no English placeholders remain.

In `@i18n/locales/en-GB.json`:
- Around line 6-7: Replace every “EN TEXT TO REPLACE:” marker with finalized
localized copy: add English text for data_correction_reset and
data_correction_description in i18n/locales/en-GB.json; add Latin-American
Spanish or inherit the base locale in i18n/locales/es-419.json; add Austrian
German in i18n/locales/de-AT.json; and translate the section label plus reset
action and description at the specified locations in i18n/locales/de.json,
i18n/locales/es.json, i18n/locales/fr-FR.json, and i18n/locales/nl.json. Ensure
no unfinished marker remains.

---

Nitpick comments:
In `@i18n/locales/es-419.json`:
- Around line 15-16: Remove data_correction_reset and
data_correction_description from the es-419 locale unless their Latin-American
translations intentionally differ from the finalized es.json values, allowing
the regional locale to inherit the base Spanish translations.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 60af86c3-126b-408c-a940-db5c39f485f9

📥 Commits

Reviewing files that changed from the base of the PR and between 447a187 and 07f0dd5.

📒 Files selected for processing (38)
  • app/composables/useSettings.ts
  • app/pages/settings.vue
  • i18n/locales/ar-EG.json
  • i18n/locales/ar.json
  • i18n/locales/az-AZ.json
  • i18n/locales/bg-BG.json
  • i18n/locales/bn-IN.json
  • i18n/locales/cs-CZ.json
  • i18n/locales/de-AT.json
  • i18n/locales/de.json
  • i18n/locales/en-GB.json
  • i18n/locales/en.json
  • i18n/locales/es-419.json
  • i18n/locales/es.json
  • i18n/locales/fr-FR.json
  • i18n/locales/hi-IN.json
  • i18n/locales/hu-HU.json
  • i18n/locales/id-ID.json
  • i18n/locales/it-IT.json
  • i18n/locales/ja-JP.json
  • i18n/locales/kn-IN.json
  • i18n/locales/mr-IN.json
  • i18n/locales/nb-NO.json
  • i18n/locales/ne-NP.json
  • i18n/locales/nl.json
  • i18n/locales/pl-PL.json
  • i18n/locales/pt-BR.json
  • i18n/locales/pt-PT.json
  • i18n/locales/ro-RO.json
  • i18n/locales/ru-RU.json
  • i18n/locales/sr-Latn-RS.json
  • i18n/locales/ta-IN.json
  • i18n/locales/te-IN.json
  • i18n/locales/tr-TR.json
  • i18n/locales/uk-UA.json
  • i18n/locales/vi-VN.json
  • i18n/locales/zh-CN.json
  • i18n/locales/zh-TW.json
🚧 Files skipped from review as they are similar to previous changes (3)
  • i18n/locales/en.json
  • app/pages/settings.vue
  • app/composables/useSettings.ts

Comment thread i18n/locales/ar-EG.json Outdated
Comment thread i18n/locales/en-GB.json Outdated

@coderabbitai coderabbitai Bot 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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
app/pages/settings.vue (1)

353-356: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Localise the anomaliesFixed label. {{ settings.chartFilter.anomaliesFixed }} will render true/false directly; use a translated label here instead of the raw boolean.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@app/pages/settings.vue` around lines 353 - 356, Update the anomaliesFixed
display in the settings template to render a localized true/false label rather
than the raw boolean value, using the existing translation helper and
established translation keys.
🧹 Nitpick comments (1)
app/composables/useSettings.ts (1)

263-269: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Consider iterating over DEFAULT_CHART_FILTER keys for isDefault.

The manual field-by-field comparison works correctly today, but if a new field is added to chartFilter in the future, isDefault must be updated in lockstep — otherwise the reset button could be incorrectly enabled or disabled. Iterating over DEFAULT_CHART_FILTER keys auto-includes future fields.

♻️ Optional refactor
   const isDefault = computed(
-    () =>
-      settings.value.chartFilter.averageWindow === DEFAULT_CHART_FILTER.averageWindow &&
-      settings.value.chartFilter.smoothingTau === DEFAULT_CHART_FILTER.smoothingTau &&
-      settings.value.chartFilter.anomaliesFixed === DEFAULT_CHART_FILTER.anomaliesFixed &&
-      settings.value.chartFilter.predictionPoints === DEFAULT_CHART_FILTER.predictionPoints,
+    () =>
+      (Object.keys(DEFAULT_CHART_FILTER) as (keyof typeof DEFAULT_CHART_FILTER)[]).every(
+        key => settings.value.chartFilter[key] === DEFAULT_CHART_FILTER[key]
+      ),
   )
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@app/composables/useSettings.ts` around lines 263 - 269, Update the isDefault
computed property to iterate over the keys of DEFAULT_CHART_FILTER and compare
each corresponding value in settings.value.chartFilter, replacing the manual
field-by-field checks while preserving the current boolean result.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@app/pages/settings.vue`:
- Around line 353-356: Update the anomaliesFixed display in the settings
template to render a localized true/false label rather than the raw boolean
value, using the existing translation helper and established translation keys.

---

Nitpick comments:
In `@app/composables/useSettings.ts`:
- Around line 263-269: Update the isDefault computed property to iterate over
the keys of DEFAULT_CHART_FILTER and compare each corresponding value in
settings.value.chartFilter, replacing the manual field-by-field checks while
preserving the current boolean result.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 8d24ecf0-9d7c-40d0-a6a9-bfa5d3252021

📥 Commits

Reviewing files that changed from the base of the PR and between 07f0dd5 and 2b974ab.

📒 Files selected for processing (3)
  • app/composables/useSettings.ts
  • app/pages/settings.vue
  • test/nuxt/composables/use-settings.spec.ts

@graphieros graphieros left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@Hui-Hwoo thanks for your PR :)

A few remarks:

  • there is no chart modal anymore. Download charts are visible on the stats and compare pages
  • for each correction variable, a tooltip should be used to explain what the variables are about (tooltip visible on hover of a i icon)
  • values should have units when applicable (for example: average window is in days)
  • I would replace "known anomalies true" with "Known anomalies correction enabled/disabled)
  • The styles of the reset button need to match the application standards

- Update description to reference stats/compare pages instead of chart modal
- Add info icon tooltips explaining each correction variable
- Show units (points) for average window and prediction values
- Display "Enabled"/"Disabled" instead of raw boolean for anomalies
- Use size="sm" on reset button to match application standards
Fixes HTML validation error where div elements (from TooltipApp) were
nested inside span elements, which is not permitted per HTML spec.
@graphieros graphieros added the 007 This PR *may* not follow our code of conduct regarding AI usage. label Jul 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

007 This PR *may* not follow our code of conduct regarding AI usage.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Download charts: facilitate access to data correction settings

3 participants