Skip to content

PATCH /ports/{id}/value Timeout - #216

Merged
ccrisan merged 3 commits into
mainfrom
feature/patch-port-value-timeout
Aug 18, 2026
Merged

PATCH /ports/{id}/value Timeout#216
ccrisan merged 3 commits into
mainfrom
feature/patch-port-value-timeout

Conversation

@ccrisan

@ccrisan ccrisan commented Aug 18, 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 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 when set_last_read_value() matches a target.
  • Extend patch_port_value() to accept a timeout query parameter and raise value-timeout on 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.

Comment thread qtoggleserver/core/api/funcs/ports.py
@ccrisan
ccrisan merged commit 0956814 into main Aug 18, 2026
8 checks passed
@ccrisan
ccrisan deleted the feature/patch-port-value-timeout branch August 18, 2026 16:52
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