Skip Pinia getters when syncing state from Vuex

What does this MR do and why?

The Pinia sync plugin copies every Vuex state key onto the Pinia store on boot. The legacy notes Vuex state has a discussions key, but the Pinia legacyNotes store exposes discussions as a getter backed by useDiscussions. Assigning to a Pinia getter writes to a readonly computed. The reset mutation also tries to assign to discussions through Object.assign(this, createState()).

The warning is [Vue warn]: Write operation failed: computed value is readonly. This appears when visiting incident detail pages that render a notes thread.

Fix: the sync plugin now only copies keys that exist in the Pinia $state, skipping getters. The reset mutation strips discussions from the copied state and writes it to useDiscussions separately. Add a spec case where Vuex state has a key that is a Pinia getter; without the fix, the test fails with that exact warning.

Changes made:

  • app/assets/javascripts/pinia/plugins.js
  • app/assets/javascripts/notes/store/legacy_notes/mutations.js
  • spec/frontend/pinia/plugins_spec.js

How to set up and validate locally

  1. Go to Monitor > Incidents.
  2. Open an incident.
  3. Add a comment in the notes thread.
  4. Reload the page.
  5. Check the browser console shows no [Vue warn] line for this warning.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

References

🤖 Generated with Claude Code

Edited by Miguel Rincon

Merge request reports

Loading
Loading