Skip to content

Reduce flickering on pageload and plot controls changes#99

Merged
david-mears-2 merged 5 commits into
mainfrom
fix-alert-on-pageload-2
Jun 5, 2026
Merged

Reduce flickering on pageload and plot controls changes#99
david-mears-2 merged 5 commits into
mainfrom
fix-alert-on-pageload-2

Conversation

@david-mears-2

@david-mears-2 david-mears-2 commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

To see what I mean by flickering, go to https://vaxviz.vaccineimpact.org/ and click 'disable cache' in developer tools. Then pay attention to the plot area when you (a) initially load/reload the page (you'll likely see the 'no data' alert flash up for a fraction of a second) and (b) when you first switch focus from 'Geography' to 'Disease' (you might see that alert again, and also, what's worse, an updated version of the plot that has only one plot row, which is then instantly replaced with a correct plot).

The degree of noticeability of flicker probably depends on your own computer's speed.

I reduce the flickering of plot updates in two ways in this PR.

First: the commit Don't show 'no data' alert if data is still loading. We had needlessly been displaying the 'no data' alert for fractions of a second while data was still loading. There is already a dataStore.isLoading flag we can trivially look at to prevent his.

Secondly: the commit Increase debounce duration to reduce flickering papers over the rapid plot updates. 25ms was not enough, since the constructLines function can sometimes take up to around 100ms (at least on my laptop).

A general solution to the issue would involve trying to make sure that individual changes to the plot controls ultimately trigger only one call to constructLines and only one call to updateChart (removing the need for debouncing). But this would be a deep refactor that isn't currently justified given we don't know how much future development vaxviz will see. https://mrc-ide.myjetbrains.com/youtrack/issue/mrc-6857/Reduce-number-of-watchers

@coderabbitai

coderabbitai Bot commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 671198f8-d32e-4b00-92c5-180659d8c42c

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

RidgelinePlot component refines its "no data" display condition to require both empty selections and completion of data loading, removes immediate watcher execution, and expands test coverage with categorical-scale assertions and deterministic loading-state timing tests.

Changes

RidgelinePlot component and tests

Layer / File(s) Summary
No-data state logic and watcher setup
src/components/RidgelinePlot.vue
noDataToDisplay becomes true only when there are no selectedLines and dataStore.isLoading is false; the watcher triggering updateChart removes immediate: true so updates run on dependency changes only, not on component initialisation.
No-data scenario test assertions
tests/unit/components/RidgelinePlot.spec.ts
Tests for partial no-data and complete no-data scenarios add categorical-scale assertions; the "passes correct options to Chart" test removes an explanatory comment and uses the categorical-scale helper to validate the non-normalised render.
Loading spinner test with fake timers
tests/unit/components/RidgelinePlot.spec.ts
Loading-spinner test adopts fake timers and MSW delay handler to establish a deterministic loading window; timers are advanced in two phases to assert dataStore.isLoading, spinner visibility, and #chartWrapper presence before and after the delayed response, then real timers are restored.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 A chart that waits for data's call,
No eager updates one and all!
With timers fake and scales so true,
The loading states shine bold and new.
Ridge upon ridge, now wisely told! 🗻✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarises the main objective of the changeset: reducing visual flickering on initial page load and when plot controls change.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description check ✅ Passed The pull request description clearly relates to the changeset, describing the specific problem of UI flickering and how the changes address it.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-alert-on-pageload-2

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 and usage tips.

@codecov

codecov Bot commented Jun 4, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.32%. Comparing base (ce406da) to head (9f20a97).

Additional details and impacted files
@@           Coverage Diff           @@
##            types      #99   +/-   ##
=======================================
  Coverage   98.32%   98.32%           
=======================================
  Files          39       39           
  Lines         897      897           
  Branches      256      257    +1     
=======================================
  Hits          882      882           
  Misses         10       10           
  Partials        5        5           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 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.

@david-mears-2 david-mears-2 force-pushed the fix-alert-on-pageload-2 branch from 37ddc35 to def2d48 Compare June 4, 2026 13:07
@david-mears-2 david-mears-2 marked this pull request as ready for review June 4, 2026 13:10
@david-mears-2

Copy link
Copy Markdown
Contributor Author

@CodeRabbit review

@coderabbitai

coderabbitai Bot commented Jun 4, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@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: 1

🤖 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 `@src/components/RidgelinePlot.vue`:
- Line 146: The legend stays visible during data fetches because noDataToDisplay
is set false while loading; update the logic so loading counts as "no data" — in
RidgelinePlot.vue change the assignment for noDataToDisplay to include
dataStore.isLoading (e.g., set noDataToDisplay = selectedLines.length === 0 ||
dataStore.isLoading) so LegendContainer (which is rendered when
!noDataToDisplay) is hidden during fetches; ensure you update the reactive/noRef
usage consistent with existing selectedLines and dataStore access.
🪄 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: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 1fc6fea5-2f5b-4ebb-83a8-a442e8440f07

📥 Commits

Reviewing files that changed from the base of the PR and between dd757bd and def2d48.

📒 Files selected for processing (2)
  • src/components/RidgelinePlot.vue
  • tests/unit/components/RidgelinePlot.spec.ts

Comment thread src/components/RidgelinePlot.vue

@EmmaLRussell EmmaLRussell 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.

I struggled to see any flickering with the deployed vaxviz from my desktop, but did see some issues from my laptop and when looking at vaxviz running locally (in dev mode, which may cause other issues). This definitely seems smoother!

So during all the time when loading is still going on, the loading spinner will be displayed rather than the momentary "No data" message..?

},
}));

// Assert that all diseases (the current data dimension for the plot-rows) are in the correct order,

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.

Did you remove this comment because you've added some previously missing, similar assertions above? This could still be a useful comments, so could move and edit it to the first such assertion.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It duplicates a comment at the definition of the function called here.

@david-mears-2

Copy link
Copy Markdown
Contributor Author

So during all the time when loading is still going on, the loading spinner will be displayed rather than the momentary "No data" message..?

Yes

@david-mears-2 david-mears-2 changed the base branch from types to main June 5, 2026 11:11
@david-mears-2 david-mears-2 merged commit 69419f3 into main Jun 5, 2026
6 checks passed
@david-mears-2 david-mears-2 deleted the fix-alert-on-pageload-2 branch June 5, 2026 11:11
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.

2 participants