Extract Vue.observable state from constants to prevent Vue 3 duplication
What does this MR do and why?
Moves Vue.observable reactive state (portalState, sidebarState, duoChatGlobalState) from constants.js to a dedicated state.js file in the super_sidebar directory.
This change is needed to enable Vue 3 compatibility. When these reactive state objects are imported from a Vue 3 dependency tree, they get wrongly duplicated, causing state to be out of sync across the application. By extracting them into a separate file and adding it to the INFECTION_BLOCKLIST in context_aliases_shared.js, we ensure a single instance is shared.
This also improves code organization: Vue.observable objects are mutable reactive state, not constants, and should not live in a constants file.
Changes
- New file:
app/assets/javascripts/super_sidebar/state.jscontaining allVue.observablestate objects - Updated:
constants.jsto remove reactive state (keeps only true constants) - Updated:
config/helpers/context_aliases_shared.jsto addstate.jsto theINFECTION_BLOCKLIST - Updated: All imports across components, utilities, specs, and documentation to reference
state.js - Removed: Unnecessary
jest.mock('~/super_sidebar/constants')innew_namespace_page_spec.js