Skip to content

Conversation

@andrew-welker
Copy link
Contributor

@andrew-welker andrew-welker commented Oct 15, 2025

This pull request introduces several improvements and refactors across the codebase, with a focus on WebSocket middleware architecture, API initialization, and UI consistency. The most significant changes include a comprehensive WebSocket middleware refactor (with detailed documentation), a refactor of the API initialization hook, and various UI and interface consistency updates.

WebSocket Middleware Refactor and Documentation:

  • Introduced a new Redux-based WebSocket middleware, centralizing connection logic, message routing, event handling, and state management. This resolves issues such as double initialization calls and provides a more testable, maintainable, and backward-compatible architecture. Detailed documentation (WEBSOCKET_REFACTOR_SUMMARY.md and AUTOMATIC_ROOM_STATUS_IMPLEMENTATION.md) explains the rationale, implementation, and migration steps. [1] [2]

API Initialization Refactor:

  • Moved the useInitialize hook to its own file (useInitialize.ts), improved type safety, and updated the export path. The previous implementation in apiService.ts was removed. This change clarifies the initialization process and aligns with better code organization practices. [1] [2] [3]

UI and Accessibility Improvements:

  • Updated UI components to use onPointerDown instead of onClick for better cross-device interaction in IconLibrary and DisconnectedMessage. Also improved formatting and consistency in the IconLibrary component. [1] [2] [3]

Interface and Hook Exports Consistency:

  • Expanded and alphabetized interface exports in src/lib/shared/hooks/interfaces/index.ts, adding missing hooks and ensuring all relevant interfaces are available for import. Added export for useStateIsSynced in the main hooks index. [1] [2]

Package Metadata and Distribution:

  • Fixed the style.css export in package.json to support both import and require syntaxes, and updated the repository URL for better compatibility with npm tooling. [1] [2]

WebSocket Middleware and Documentation

  • Added WEBSOCKET_REFACTOR_SUMMARY.md and AUTOMATIC_ROOM_STATUS_IMPLEMENTATION.md to document the new Redux middleware approach, automatic room status requests, and migration steps. [1] [2]

API Initialization Refactor

  • Moved and improved the useInitialize hook to useInitialize.ts, removed the old version from apiService.ts, and updated exports for cleaner code and better type safety. [1] [2] [3]

UI Consistency and Accessibility

  • Changed button event handlers to onPointerDown in IconLibrary and DisconnectedMessage for better device compatibility, and improved code formatting in IconLibrary. [1] [2] [3]

Interface and Hook Exports

  • Enhanced and alphabetized exports in src/lib/shared/hooks/interfaces/index.ts, adding missing hooks and ensuring consistency. Updated main hooks index to export useStateIsSynced. [1] [2]

Package Configuration

  • Fixed style.css export to support both import and require, and updated the repository URL in package.json for npm compatibility. [1] [2]

  • ci: publish new build on non-main branch

  • fix: /system/roomCombinationChanged handling override

  • fix: and useCameraBase to exports

  • fix: update cameraList type to CameraState[]

  • feat: add useIHasCameras hook and IHasCamerasState interface

  • fix: extend IHasSelectableItemsState interface to inherit from DeviceState

  • feat: add usb support & currentSources interface

  • fix: add currentSources/keys to DisplayState

  • fix: make currentSource{s} optional

  • fix: export actions for use with storybook

  • chore(force-patch): fix casing issues

  • chore(force-patch): update tsconfig.json

  • fix: export websocket context

  • fix: change export style for WebsocketContext

  • fix: use correct import in hook

  • feat: adds SecondaryAudio to SignalType

  • fix: put back missing type exports

  • fix: use correct types and message format for DSP Preset recall

  • chore(force-patch): go back to default style.css name

  • fix: update css file name and exports

  • fix: remove extra .css

  • build: use correct URL for git repo

  • fix: make styles export an object

  • fix: update InputSlot and OutputSlot interfaces for better type safety

  • fix: remove unnecessary import from IHasSelectableItemsState

  • fix: comment out deprecated state property in DeviceState interface

  • fix: add deviceInterfaceSupport to RoomData interface and initial state

  • fix: add selectDeviceInterfaceSupport selector and corresponding hook

  • feat: implement useStateIsSynced hook and related UI state management

  • fix: add missing export for useStateIsSynced hook in index.ts

  • fix: update syncState to use array instead of Set for consistency in state management

  • fix: standardize import quotes and replace onClick with onPointerDown for better performance

  • fix: clear all modals and sync state on websocket disconnection

  • fix: refactor websocket disconnection handling to use a dedicated function for clearing state

  • fix: remove dependency on serverIsRunningOnProcessorHardware

  • chore(force-patch): disable exhaustive deps

  • fix: remove dependency for getRoomData callback

  • fix: add dep on serverIsRunningOnProcessorHardware back in

  • fix: move check for websocket before getRoomData call

  • feat: websocket is now middleware instead of react component

  • docs: Copilot refactoring documentation

andrew-welker and others added 30 commits July 3, 2025 13:22
For some UIs, it is not necessary to reload the application when
the room combination state changes. In addition, the application may also
be able to update itself without restarting as well, by requesting the
correct room key from Essentials. The handler for the `/system/roomCombinationChanged` now
checks for any registered handlers. If no handlers are found, then the application
is reloaded, which is the existing behavior. If handlers are found, then the handlers
are executed, and the default behavior is not. This allows for customizing what happens
when the room combination state changes, while keeping the existing behavior in place for
backwards compatibility.
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

Refactors WebSocket handling into Redux middleware to prevent duplicate join calls, reorganizes and expands type/interface exports, and updates UI event handling and initialization logic for improved consistency and maintainability.

  • Introduces Redux WebSocket middleware with action-based API and removes previous in-component connection logic.
  • Adjusts numerous type interfaces (adds fields, makes fields optional, removes exports) and expands barrel exports.
  • Adds sync state tracking hook and UI state, switches UI event handlers to onPointerDown, and refactors initialization hook location.

Reviewed Changes

Copilot reviewed 51 out of 52 changed files in this pull request and generated 21 comments.

Show a summary per file
File Description
vite.config.ts Adds cssFileName and formatting updates to support new style export mapping.
src/lib/utils/useWebsocketContext.ts Switches to named import of WebsocketContext (potential API break).
src/lib/utils/index.ts Adds WebsocketContext to barrel exports.
src/lib/utils/WebsocketProvider.tsx Refactors provider to delegate all WebSocket operations to Redux middleware.
src/lib/utils/WebsocketContext.ts Converts default export to named export, expanding interface formatting.
src/lib/types/state/... Widespread interface changes (added/removed fields, optionality shifts, new types, documentation).
src/lib/store/**/* Adds WebSocket middleware, sync state tracking in UI slice, new selectors/hooks, and middleware wiring.
src/lib/shared/hooks/** Adds new hooks (useStateIsSynced, camera-related) and updates interface hook exports.
src/lib/shared/disconnectedMessage/DisconnectedMessage.tsx Uses onPointerDown for interaction consistency.
src/lib/shared/Icons/IconLibrary.tsx Uses onPointerDown and formatting improvements.
src/lib/services/** Moves initialization logic to new useInitialize hook file.
package.json Adjusts style.css export map and repository URL.
WEBSOCKET_REFACTOR_SUMMARY.md Adds documentation for WebSocket refactor.
AUTOMATIC_ROOM_STATUS_IMPLEMENTATION.md Documents automatic status request approach.

@github-actions
Copy link

🎉 This PR is included in version 1.21.0-fix-double-join-call.6 🎉

The release is available on:

Your semantic-release bot 📦🚀

@github-actions
Copy link

🎉 This PR is included in version 1.21.0-fix-double-join-call.7 🎉

The release is available on:

Your semantic-release bot 📦🚀

@github-actions
Copy link

🎉 This PR is included in version 1.21.0-fix-double-join-call.8 🎉

The release is available on:

Your semantic-release bot 📦🚀

@ndorin ndorin merged commit 84dcf2c into main Oct 15, 2025
3 checks passed
@ndorin ndorin deleted the fix-double-join-call branch October 15, 2025 16:39
@github-actions
Copy link

🎉 This PR is included in version 1.21.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants