PATCH /ports/{id}/value Timeout - #216
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds an optional server-side confirmation timeout to PATCH /ports/{id}/value, allowing clients to wait (up to a bounded duration) for the read value to reflect the written value, and receive a dedicated 504 value-timeout error when it doesn’t.
Changes:
- Add
BasePort.wait_for_read_value()plus waiter bookkeeping to resolve whenset_last_read_value()matches a target. - Extend
patch_port_value()to accept atimeoutquery parameter and raisevalue-timeouton confirmation timeout. - Update frontend to pass the confirmation timeout to the API and map the new error code; add/adjust unit tests and mocks.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/unit/qtoggleserver/mock/api.py | Populate query_arguments so APIRequest.query works in unit tests that rely on query params. |
| tests/unit/qtoggleserver/core/test_ports.py | Add unit tests covering wait_for_read_value() behavior (immediate match, timeout, cleanup). |
| tests/unit/qtoggleserver/core/api/test_funcs_ports.py | Add API-level tests for PATCH /ports/{id}/value timeout parsing and value-timeout behavior. |
| qtoggleserver/frontend/js/dashboard/widgets/widget.js | Remove widget-local “wait for value-change” logic and delegate confirmation waiting to the server API. |
| qtoggleserver/frontend/js/api/ports.js | Extend patchPortValue() to optionally pass timeout query param and adjust client request timeout accordingly. |
| qtoggleserver/frontend/js/api/constants.js | Add value-timeout to known error mappings for a user-friendly message. |
| qtoggleserver/core/ports.py | Add waiter list and implement wait_for_read_value() + notification from set_last_read_value(). |
| qtoggleserver/core/api/funcs/ports.py | Implement timeout query parsing/validation and confirmation wait + value-timeout API error. |
| qtoggleserver/core/api/init.py | Allow api_call wrappers to accept an APIRequest directly (useful for tests/helpers). |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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.