Skip to content

refactor: Vuex state factory export - #1952

Merged
pedrolamas merged 2 commits into
fluidd-core:developfrom
pedrolamas:pedrolamas/simplify-state
Sep 4, 2026
Merged

refactor: Vuex state factory export#1952
pedrolamas merged 2 commits into
fluidd-core:developfrom
pedrolamas:pedrolamas/simplify-state

Conversation

@pedrolamas

Copy link
Copy Markdown
Member

Refactor Vuex state to always use a factory instead of static value.

Signed-off-by: Pedro Lamas <pedrolamas@gmail.com>
@pedrolamas pedrolamas added this to the 1.37.5 milestone Sep 4, 2026
@pedrolamas
pedrolamas requested a lite review from Copilot September 4, 2026 17:32
@pedrolamas pedrolamas added the Code - Optimizations Everything that relates to code optimizations! label Sep 4, 2026
@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown

Bundle size report (gzip)

Chunk Base Head Δ
assets/index-*.js 161.0 kB 160.9 kB -116 B
assets/Diagnostics-*.js 16.0 kB 15.9 kB -18 B
assets/GcodePreview-*.js 369 B 364 B -5 B
assets/Dashboard-*.js 63.2 kB 63.2 kB +3 B
assets/Configure-*.js 777 B 779 B +2 B
assets/Icons-*.js 529 B 527 B -2 B
assets/System-*.js 2.3 kB 2.3 kB +2 B
assets/Timelapse-*.js 1.9 kB 1.9 kB -2 B
sw.js 11.2 kB 11.2 kB +2 B
assets/AfcPrintStartDialogTool-*.js 2.4 kB 2.4 kB -1 B
assets/Console-*.js 365 B 366 B +1 B
assets/Diagnostics-*.css 425 B 424 B -1 B
assets/DiskUsageCard-*.js 3.2 kB 3.2 kB +1 B
assets/FileSystem-*.js 31.2 kB 31.2 kB +1 B
assets/History-*.js 3.8 kB 3.8 kB +1 B
assets/JobHistoryItemStatus-*.js 1.2 kB 1.2 kB -1 B
assets/JobQueueCard-*.js 4.5 kB 4.5 kB -1 B
assets/MacroCategorySettings-*.js 2.0 kB 2.0 kB +1 B
assets/NotFound-*.js 439 B 438 B -1 B
assets/Settings-*.js 23.3 kB 23.3 kB +1 B
assets/TimelapseRenderSettingsDialog-*.js 1.8 kB 1.8 kB -1 B
Total 2.9 MB 2.9 MB -134 B

119 chunks compared, 21 changed. Sizes are gzip, matching what nginx serves.

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.

🟢 Approval recommended

The refactor consistently updates state exports, resets, and consumers to use state factories, and the RootState typing change aligns with the new convention.

Pull request overview

Refactors Vuex module state exports to consistently use factory functions (instead of exporting a shared static state object), and updates call sites/types accordingly to keep module state initialization/reset behavior consistent across the app.

Changes:

  • Convert many src/store/**/state.ts exports from defaultState()/state = defaultState() to export const state = () => ({ ... }).
  • Update mutations and UI call sites to import the factory ({ state as defaultState }) and invoke it when cloning defaults or resetting state.
  • Update RootState type derivation to use ReturnType<module['state']> now that state is consistently a function.
File summaries
File Description
src/views/Diagnostics.vue Switch layout defaults import to state factory for cloning default diagnostics card config.
src/store/webcams/state.ts Export webcams Vuex state as a factory function.
src/store/webcams/mutations.ts Update reset/default import to use state factory.
src/store/wait/state.ts Export wait Vuex state as a factory function.
src/store/wait/mutations.ts Update reset/default import to use state factory.
src/store/version/state.ts Export version Vuex state as a factory function.
src/store/version/mutations.ts Update reset/default import to use state factory.
src/store/types.ts Derive RootState via ReturnType<module['state']> to match state-as-factory convention.
src/store/timelapse/state.ts Export timelapse Vuex state as a factory function.
src/store/timelapse/mutations.ts Update reset/default import to use state factory.
src/store/spoolman/state.ts Export spoolman Vuex state as a factory function.
src/store/spoolman/mutations.ts Update reset/default import to use state factory.
src/store/socket/state.ts Export socket Vuex state as a factory function.
src/store/socket/mutations.ts Update reset/default import to use state factory.
src/store/server/state.ts Export server Vuex state as a factory function.
src/store/server/mutations.ts Update reset/default import to use state factory.
src/store/sensors/state.ts Export sensors Vuex state as a factory function.
src/store/sensors/mutations.ts Update reset/default import to use state factory.
src/store/printer/state.ts Export printer Vuex state as a factory function.
src/store/printer/mutations.ts Update reset/default import to use state factory.
src/store/power/state.ts Export power Vuex state as a factory function.
src/store/power/mutations.ts Update reset/default import to use state factory.
src/store/notifications/state.ts Export notifications Vuex state as a factory function.
src/store/notifications/mutations.ts Update reset/default import to use state factory.
src/store/mmu/state.ts Export mmu Vuex state as a factory function.
src/store/mmu/mutations.ts Update reset/default import to use state factory.
src/store/mesh/state.ts Export mesh Vuex state as a factory function.
src/store/mesh/mutations.ts Update reset/default import to use state factory.
src/store/macros/state.ts Export macros Vuex state as a factory function.
src/store/macros/mutations.ts Update reset/default import to use state factory.
src/store/layout/state.ts Export layout Vuex state as a factory function.
src/store/layout/mutations.ts Update reset/init logic to use state factory (and its layouts) for defaults/migration.
src/store/jobQueue/state.ts Export jobQueue Vuex state as a factory function.
src/store/jobQueue/mutations.ts Update reset/default import to use state factory.
src/store/history/state.ts Export history Vuex state as a factory function.
src/store/history/mutations.ts Update reset/default import to use state factory.
src/store/gcodePreview/state.ts Export gcodePreview Vuex state as a factory function.
src/store/gcodePreview/mutations.ts Update reset/default import to use state factory.
src/store/files/state.ts Export files Vuex state as a factory function.
src/store/files/mutations.ts Update reset/default import to use state factory.
src/store/database/state.ts Export database Vuex state as a factory function.
src/store/database/mutations.ts Update reset/default import to use state factory.
src/store/console/state.ts Export console Vuex state as a factory function.
src/store/console/mutations.ts Update reset/default import to use state factory.
src/store/config/state.ts Export config Vuex state as a factory function.
src/store/config/mutations.ts Update reset/default import to use state factory.
src/store/charts/state.ts Export charts Vuex state as a factory function.
src/store/charts/mutations.ts Update reset/default import to use state factory.
src/store/auth/state.ts Export auth Vuex state as a factory function.
src/store/auth/mutations.ts Update reset/default import to use state factory.
src/store/announcements/state.ts Export announcements Vuex state as a factory function.
src/store/announcements/mutations.ts Update reset/default import to use state factory.
src/store/analysis/state.ts Export analysis Vuex state as a factory function.
src/store/analysis/mutations.ts Update reset/default import to use state factory.
src/store/afc/state.ts Export afc Vuex state as a factory function.
src/store/afc/mutations.ts Update reset/default import to use state factory.
src/components/widgets/diagnostics/config/MetricsConfigStep.vue Switch layout defaults import to state factory for deriving the default diagnostics card config.
src/components/settings/WarningsSettings.vue Switch config defaults import to state factory for default UI settings values.
src/components/settings/ToolheadSettings.vue Switch config defaults import to state factory for default general/toolhead UI settings values.
src/components/settings/SpoolmanSettings.vue Switch config defaults import to state factory for default spoolman UI settings values.
src/components/settings/MmuSettings.vue Switch config defaults import to state factory for default mmu UI settings values.
src/components/settings/GcodePreviewSettings.vue Switch config defaults import to state factory for default gcode preview UI settings values.
src/components/settings/FileEditorSettings.vue Switch config defaults import to state factory for default editor UI settings values.
src/components/layout/AppBar.vue Switch layout defaults import to state factory for default layout data used by UI actions.
Review details
  • Files reviewed: 64/64 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

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.

🟢 Approval recommended

The refactor is consistent across modules/callers and correctly switches Vuex module state to factory functions without leaving stale defaultState/static state usages.

Review details
  • Files reviewed: 91/91 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

@pedrolamas
pedrolamas merged commit debecbb into fluidd-core:develop Sep 4, 2026
6 checks passed
@pedrolamas
pedrolamas deleted the pedrolamas/simplify-state branch September 4, 2026 21:12
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