refactor: freeze immutable entries#1875
Merged
pedrolamas merged 7 commits intoJun 11, 2026
Merged
Conversation
Console entries are append-only and never mutated after creation. Freezing them on insert and bulk init makes Vue 2.7's observe() skip deep reactive conversion of each entry and of the retained backlog (up to CONSOLE_HISTORY_RETENTION), matching the charts/printer stores. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: Pedro Lamas <pedrolamas@gmail.com>
Sensor values are replaced wholesale on each update and never mutated in place, so freezing them lets Vue 2.7 skip deep reactive conversion on every sensor notification, as well as on the one-time list load. Also drop Vue.set in favour of a plain assignment, since 'values' is always an existing reactive property on the entry. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: Pedro Lamas <pedrolamas@gmail.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR aims to reduce accidental mutations (and potentially improve performance) by freezing store data that is treated as immutable in the Console and Sensors Vuex modules.
Changes:
- Freeze console entries when appended and when bulk-loaded.
- Freeze
Moonraker.Sensor.Entry.valuesobjects when the sensors list is loaded and when updates arrive. - Remove the
Vue.set(..., 'values', ...)path in sensors updates in favor of direct assignment.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| src/store/sensors/mutations.ts | Freezes sensor values on list + update mutations; removes Vue import/Vue.set usage. |
| src/store/console/mutations.ts | Freezes console entry objects when adding a single entry and when setting all entries. |
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: Pedro Lamas <pedrolamas@gmail.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: Pedro Lamas <pedrolamas@gmail.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: Pedro Lamas <pedrolamas@gmail.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: Pedro Lamas <pedrolamas@gmail.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: Pedro Lamas <pedrolamas@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Minor optimization by freezing immutable entries on Console and Sensors store.
Also includes:
setSensorUpdatepayload type fromRecord<string, Moonraker.Sensor.Entry>toRecord<string, Moonraker.Sensor.Values>, matching what Moonraker actually sends in update notificationsVue.setcalls across store mutations where the property already exists in initial state (plain assignment is sufficient and clearer)Vue.set(state.currentPaths, root, undefined)withVue.deleteinfiles/mutations.ts(correct semantics for key removal)