Better Peripherals Management#208
Merged
Merged
Conversation
There was a problem hiding this comment.
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
/portssemantics 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
paramsfield is markedrequired: falseandapplyData()already treats an empty value as{}, but validation currently rejects empty input becauseJSON.parse('')throws. Allow empty/blank params to pass validation (consistent withperipheral-form.js).
validate(params) {
try {
JSON.parse(params)
}
catch {
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.