Skip to content

Better Peripherals Management#208

Merged
ccrisan merged 29 commits into
mainfrom
improvement/better-peripherals-management
Jun 3, 2026
Merged

Better Peripherals Management#208
ccrisan merged 29 commits into
mainfrom
improvement/better-peripherals-management

Conversation

@ccrisan

@ccrisan ccrisan commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown

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 enhances peripheral management across the backend and frontend by adding richer peripheral state/config fields, peripheral lifecycle events, and a PATCH-based update flow (plus a new PATCH /ports behavior to support partial restore semantics).

Changes:

  • Add peripheral lifecycle events (peripheral-add/remove/update) and expose richer peripheral JSON (driver, params, enabled, online, force_enabled), including PATCH /api/peripherals/{id} support.
  • Implement PATCH /ports semantics to update port attrs and reconcile virtual ports without resetting physical port attributes.
  • Update the frontend Peripherals UI to support editing peripherals (including force_enabled), show status decoration, and react to server peripheral events.

Reviewed changes

Copilot reviewed 34 out of 36 changed files in this pull request and generated 16 comments.

Show a summary per file
File Description
update-qui.sh Adds a post-install lockfile tweak for jQuery version during QUI updates.
tests/unit/qtoggleserver/test_startup.py Adds startup tests for peripheral initialization and failure handling.
tests/unit/qtoggleserver/peripherals/test_peripheral.py Expands peripheral unit tests to cover events, force-enable, auto-enable/disable, and JSON.
tests/unit/qtoggleserver/peripherals/test_events.py Adds tests for new peripheral event classes.
tests/unit/qtoggleserver/peripherals/api/test_funcs.py Updates and expands peripherals API tests, including PATCH behavior and rename migration tests.
tests/unit/qtoggleserver/mock/peripherals.py Adjusts mock peripheral params shape to nested params.
tests/unit/qtoggleserver/core/api/test_funcs_ports.py Adds tests for new PATCH /ports behavior and constraints.
tests/conftest.py Adds fixtures for creating/removing virtual ports used by new tests.
qtoggleserver/web/handlers.py Adds PATCH handler for /api/peripherals/{id}.
qtoggleserver/startup.py Improves cleanup resilience and adds peripheral init failure handling + peripheral-add event emission on startup.
qtoggleserver/slaves/ports.py Attempts to improve typing for SlavePort constructor parameter.
qtoggleserver/slaves/exceptions.py Attempts to improve typing for slave-related exceptions.
qtoggleserver/slaves/events.py Attempts to improve typing for slave-related events.
qtoggleserver/slaves/devices.py Adds a TODO note on get_display_name() usage.
qtoggleserver/peripherals/peripheralport.py Ensures enabling a peripheral port can enable the peripheral and emit an update.
qtoggleserver/peripherals/peripheral.py Adds force-enabled behavior, richer JSON, and peripheral event trigger helpers.
qtoggleserver/peripherals/events.py Introduces new peripheral event types and duplicate detection for updates.
qtoggleserver/peripherals/api/schema.py Extends schemas for nested params, force_enabled, and PATCH peripheral payloads.
qtoggleserver/peripherals/api/funcs.py Adds PATCH peripheral API, rename migration, and triggers peripheral lifecycle events from APIs.
qtoggleserver/peripherals/init.py Changes peripheral persistence shape (nested params) with backward-compat parsing of flattened legacy payloads.
qtoggleserver/lib/templatenotifications.py Renames display helpers for ports and adjusts template context keys.
qtoggleserver/frontend/templates/index.html Includes new peripherals CSS in dev template output.
qtoggleserver/frontend/package-lock.json Bumps @qtoggle/qui dependency version.
qtoggleserver/frontend/less/peripherals/peripherals.less Adds monospace styling for params text areas.
qtoggleserver/frontend/less/all.less Imports new peripherals LESS bundle.
qtoggleserver/frontend/js/peripherals/peripherals.js Adds dynamic peripheral icon decoration based on enabled/online state.
qtoggleserver/frontend/js/peripherals/peripherals-section.js Handles server peripheral events, updates UI, and shows toasts.
qtoggleserver/frontend/js/peripherals/peripherals-list.js Debounces UI updates and uses decorated peripheral icons in the list.
qtoggleserver/frontend/js/peripherals/peripheral-form.js Adds editable peripheral form with PATCH apply flow and force_enabled control.
qtoggleserver/frontend/js/peripherals/add-peripheral-form.js Adjusts add form to support params styling and tolerate empty params in submission.
qtoggleserver/frontend/js/api/peripherals.js Changes POST payload to nested params and adds PATCH peripheral API call.
qtoggleserver/core/ports.py Renames “display” helpers to “pretty” helpers and adds default display-name attr getter.
qtoggleserver/core/events/port.py Attempts to improve typing for port events.
qtoggleserver/core/api/schema.py Adds PATCH_PORTS schema entry.
qtoggleserver/core/api/funcs/ports.py Adds PATCH /ports implementation and avoids writing value to non-writable ports.
Files not reviewed (1)
  • qtoggleserver/frontend/package-lock.json: Language not supported
Comments suppressed due to low confidence (1)

qtoggleserver/frontend/js/peripherals/add-peripheral-form.js:67

  • This params field is marked required: false and applyData() already treats an empty value as {}, but validation currently rejects empty input because JSON.parse('') throws. Allow empty/blank params to pass validation (consistent with peripheral-form.js).
                    validate(params) {
                        try {
                            JSON.parse(params)
                        }
                        catch {

Comment thread qtoggleserver/slaves/ports.py
Comment thread qtoggleserver/slaves/exceptions.py
Comment thread qtoggleserver/slaves/exceptions.py
Comment thread qtoggleserver/slaves/exceptions.py
Comment thread qtoggleserver/slaves/events.py
Comment thread qtoggleserver/startup.py
Comment thread qtoggleserver/peripherals/api/funcs.py
Comment thread update-qui.sh
Comment thread qtoggleserver/peripherals/api/funcs.py Outdated
Comment thread qtoggleserver/core/events/port.py
@ccrisan ccrisan merged commit 722d283 into main Jun 3, 2026
7 checks passed
@ccrisan ccrisan deleted the improvement/better-peripherals-management branch June 3, 2026 09:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants