Skip to content

refactor: freeze immutable entries#1875

Merged
pedrolamas merged 7 commits into
fluidd-core:developfrom
pedrolamas:pedrolamas/freeze-entries
Jun 11, 2026
Merged

refactor: freeze immutable entries#1875
pedrolamas merged 7 commits into
fluidd-core:developfrom
pedrolamas:pedrolamas/freeze-entries

Conversation

@pedrolamas

@pedrolamas pedrolamas commented Jun 11, 2026

Copy link
Copy Markdown
Member

Minor optimization by freezing immutable entries on Console and Sensors store.

Also includes:

  • Fix setSensorUpdate payload type from Record<string, Moonraker.Sensor.Entry> to Record<string, Moonraker.Sensor.Values>, matching what Moonraker actually sends in update notifications
  • Remove redundant Vue.set calls across store mutations where the property already exists in initial state (plain assignment is sufficient and clearer)
  • Replace Vue.set(state.currentPaths, root, undefined) with Vue.delete in files/mutations.ts (correct semantics for key removal)

pedrolamas and others added 2 commits June 11, 2026 14:31
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>
@pedrolamas pedrolamas added this to the 1.37.2 milestone Jun 11, 2026
@pedrolamas pedrolamas requested a review from Copilot June 11, 2026 13:35
@pedrolamas pedrolamas added the Code - Optimizations Everything that relates to code optimizations! label Jun 11, 2026

Copilot AI 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.

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.values objects 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.

Comment thread src/store/sensors/mutations.ts Outdated
Comment thread src/store/sensors/mutations.ts Outdated
Comment thread src/store/console/mutations.ts
Comment thread src/store/console/mutations.ts
pedrolamas and others added 2 commits June 11, 2026 15:16
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>

Copilot AI 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.

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.

Comment thread src/store/sensors/mutations.ts
Comment thread src/store/files/mutations.ts
Comment thread src/store/sensors/mutations.ts Outdated
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>

Copilot AI 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.

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.

Comment thread src/store/sensors/actions.ts
Comment thread src/store/notifications/mutations.ts Outdated
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Pedro Lamas <pedrolamas@gmail.com>

Copilot AI 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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copilot AI 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.

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated no new comments.

@pedrolamas pedrolamas merged commit f2c6c8b into fluidd-core:develop Jun 11, 2026
4 checks passed
@pedrolamas pedrolamas deleted the pedrolamas/freeze-entries branch June 11, 2026 17:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Code - Optimizations Everything that relates to code optimizations!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants