Skip to content

Improve Home Assistant HTTP config restart recovery - #79

Closed
QuinnDamerell wants to merge 1 commit into
mainfrom
codex/ha-http-config-restart-recovery
Closed

QuinnDamerell wants to merge 1 commit into
mainfrom
codex/ha-http-config-restart-recovery

Conversation

@QuinnDamerell

Copy link
Copy Markdown
Member

Home Assistant's HTTP configuration restart can close the WebSocket before configure or confirmation responses arrive. These changes track the normalized configuration staged by Homeway so interrupted updates can be recovered without confirming unrelated user changes.

  • Confirm Homeway's staged proxy configuration immediately when possible, and retry interrupted confirmation after reconnecting. Leave unrelated or rejected pending configurations for the user.
  • Add bounded fast reconnect attempts for expected restarts, wake configuration retries on reconnect, release pending requests on socket closure, and ignore stale socket callbacks.
  • Defer the generated WebStreamMsg import used only for typing so installer imports work from the repository root. Add configuration, WebSocket, and import regression tests to CI, with test import paths configured for Pyright.

Validation

Using an isolated Python 3.12.7 environment with the repository requirements:

  • Unit tests: 18 passed; 1 Unix-only installer import test skipped on Windows.
  • Pyright: 0 errors, 0 warnings.
  • Ruff, YAML lint on the committed workflow, and git diff whitespace checks: passed.
  • CI-equivalent Pylint invocation: all targets passed except the installer, where the existing Unix-only pwd import is unavailable on Windows.

Review note

The successful pre-restart promotion path clears ServerRestartExpected in ConfigManager._PromotePendingHttpConfig before Home Assistant's queued restart occurs. That disconnect therefore uses normal reconnect backoff instead of the new fast path. The existing regression test currently asserts that early clearing. This timing issue remains for review.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 13, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-13T21:12:47.798037Z 9037351 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9037351fbd

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

shouldRetry, result = self._GetHttpConfigApiResult("confirm", response, allowEmptyResult=True)
if result is not None:
self._ClearPendingHttpConfigOwnedByHomeway()
haConnection.ClearServerRestartExpected()

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep fast reconnect armed until the queued restart occurs

When http/config/configure returns restart: true, the code immediately promotes the configuration, and a successful promotion reaches this call before Home Assistant's queued restart closes the socket. Clearing ServerRestartExpected here makes that imminent disconnect take the normal reconnect path in ConnectionThread—including an initial five-second backoff—instead of the newly added fast-reconnect path. Clear this state only after the post-restart connection is established or after it is known that no restart will occur.

Useful? React with 👍 / 👎.

@QuinnDamerell
QuinnDamerell deleted the codex/ha-http-config-restart-recovery branch September 13, 2026 21:16
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.

1 participant