Skip to content

Conversation

@pedrolamas
Copy link
Member

Major refactor to allow:

  • awaitable socket calls
  • Moonraker and Klipper related typings isolation

@pedrolamas pedrolamas added this to the 1.36.1 milestone Dec 12, 2025
@pedrolamas pedrolamas requested a review from Copilot December 12, 2025 16:24
@pedrolamas pedrolamas added the Code - Optimizations Everything that relates to code optimizations! label Dec 12, 2025
Copy link
Contributor

Copilot AI left a comment

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 refactors the codebase to support awaitable socket operations and isolates Moonraker and Klipper type definitions into dedicated namespaces, improving type safety and enabling promise-based WebSocket communication.

  • Introduces Moonraker and Klipper global namespaces for API-related types
  • Refactors socketClient.ts to return promises from emit() method for awaitable socket calls
  • Migrates store types from local definitions to centralized namespace types
  • Adds comprehensive type definitions for Moonraker API responses and Klipper printer state

Reviewed changes

Copilot reviewed 133 out of 161 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tshelpers.d.ts Adds DeepReadonly utility type
src/typings/moonraker.*.d.ts New type definitions for all Moonraker API endpoints and responses
src/typings/klipper.d.ts Comprehensive Klipper printer state and settings types (1759 lines)
src/typings/vuetify.d.ts Component interface definitions for Vuetify components
src/typings/vue-*.d.ts Type declarations for third-party Vue libraries
src/views/*.vue Updated to use new namespace types (Moonraker.Webcam.Entry, Klipper.SettingsState)
src/util/transform-mesh.ts Updated to use Klipper.BedMeshState
src/store/*/types.ts Migrated from local types to centralized namespace types
src/store/*/mutations.ts Updated with proper type annotations using namespace types
src/store/*/actions.ts Updated action parameters to use namespace types, replaced SocketActions.serverWrite with serverDatabasePostItem
src/plugins/socketClient.ts Refactored emit() to return Promise, added request tracking with callbacks, improved error handling
src/mixins/*.ts Updated type imports to use namespace types
src/components/widgets/toolhead/*.vue Updated to use Klipper.SettingsState

Copy link
Contributor

Copilot AI left a comment

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 154 out of 182 changed files in this pull request and generated 2 comments.

Comment on lines +78 to +112
const bounds: BBox = {
x: {
min: NaN,
max: NaN
min: Number.POSITIVE_INFINITY,
max: Number.NEGATIVE_INFINITY
},
y: {
min: NaN,
max: NaN
}
}

const isFinite = (x: unknown): x is number => Number.isFinite(x)
let index = 0

for (; index < moves.length && !Object.values(bounds).every(isFinite); index++) {
const move = moves[index]

if (isFinite(move.x)) {
bounds.x.min = isFinite(bounds.x.min) ? Math.min(bounds.x.min, move.x) : move.x
bounds.x.max = isFinite(bounds.x.max) ? Math.max(bounds.x.max, move.x) : move.x
}

if (isFinite(move.y)) {
bounds.y.min = isFinite(bounds.y.min) ? Math.min(bounds.y.min, move.y) : move.y
bounds.y.max = isFinite(bounds.y.max) ? Math.max(bounds.y.max, move.y) : move.y
min: Number.POSITIVE_INFINITY,
max: Number.NEGATIVE_INFINITY
}
}

for (; index < moves.length; index++) {
for (let index = 0; index < moves.length; index++) {
const move = moves[index]

if (isFinite(move.x)) {
if (move.x != null) {
bounds.x.min = Math.min(bounds.x.min, move.x)
bounds.x.max = Math.max(bounds.x.max, move.x)
}

if (isFinite(move.y)) {
if (move.y != null) {
bounds.y.min = Math.min(bounds.y.min, move.y)
bounds.y.max = Math.max(bounds.y.max, move.y)
}
}

return {
return Object.freeze({
x: {
min: isFinite(bounds.x.min) ? bounds.x.min : 0,
max: isFinite(bounds.x.max) ? bounds.x.max : 0
min: Number.isFinite(bounds.x.min) ? bounds.x.min : 0,
max: Number.isFinite(bounds.x.max) ? bounds.x.max : 0
},
y: {
min: isFinite(bounds.y.min) ? bounds.y.min : 0,
max: isFinite(bounds.y.max) ? bounds.y.max : 0
min: Number.isFinite(bounds.y.min) ? bounds.y.min : 0,
max: Number.isFinite(bounds.y.max) ? bounds.y.max : 0
}
}
})
Copy link

Copilot AI Dec 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic has changed significantly. Previously, the code would initialize the bounds values with the first valid move coordinates, then continue from that point. Now it initializes with Infinity/-Infinity and processes all moves. While this approach works, it may be less efficient and the fallback logic at lines 105-111 handles the case where no valid coordinates are found. Verify this is the intended behavior change.

Copilot uses AI. Check for mistakes.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is correct, keep as is.

Signed-off-by: Pedro Lamas <[email protected]>
Copy link
Contributor

Copilot AI left a comment

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 154 out of 182 changed files in this pull request and generated no new comments.

@pedrolamas pedrolamas merged commit 4e6f7aa into fluidd-core:develop Dec 13, 2025
10 checks passed
@pedrolamas pedrolamas deleted the pedrolamas/namespaced-typings branch December 13, 2025 19:15
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.

1 participant