Repository navigation
fix(admin): keep an unsaved New connections choice across the 2-second refresh - #266
Open
kris-anderson wants to merge 2 commits into
Open
kris-anderson wants to merge 2 commits into
kris-anderson wants to merge 2 commits into
Conversation
…d refresh The dashboard refreshes every 2 seconds and renderAuth() set the New connections checkbox to the saved value each time, so a tick or untick was undone before Save could be pressed. A change on the checkbox now marks it edited and shows "Unsaved change: press Save to apply it."; renderAuth() leaves the checkbox and that line alone until Save, which clears the flag and renders the server's answer. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
A pending Save response can overwrite a newer checkbox edit and clear its unsaved notice, causing an unsaved choice to be lost.
1 open issue
What changed in this PR
Addresses #265 by preserving an unsaved “New connections” choice during the admin dashboard’s two-second refresh.
Changes:
- Tracks checkbox edits and displays an unsaved-change notice.
- Preserves the edited choice and notice while the rest of the auth panel refreshes.
- Clears the edit flag after a successful Save and renders the server response.
| File | Description |
|---|---|
src/roborock_local_server/standalone_admin.py |
Adds edit-state tracking and refresh protection for the New connections checkbox. |
Review effort: Balanced
| new_connections_enabled: document.getElementById("newConnectionsEnabled").checked | ||
| }}) | ||
| }}); | ||
| connectionsEdited = false; |
Contributor
Author
There was a problem hiding this comment.
Good catch, fixed in e4e943e. The flag is now cleared only when the box still matches the value the server stored, so a change made while Save is in flight stays unsaved.
I checked it in a browser with the Save reply delayed by 2 seconds:
- tick → Save → untick before the reply: the box stays unticked with the unsaved note, and the server holds the first save;
- a second Save stores
false.
The admin tests still pass (26).
Save cleared the edited flag unconditionally, so tick, Save, then untick before the reply ended with the box ticked and the unsaved note gone. The flag is now cleared only when the box still matches the value the server stored. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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.

Fixes #265
The dashboard refreshes every 2 seconds, and
renderAuth()set the New connections checkbox to the saved value each time, so a tick or untick was undone before Save could be pressed.Change
changeon the checkbox marks it edited and shows "Unsaved change: press Save to apply it."renderAuth()leaves the checkbox and that line alone. The rest of the auth panel still refreshes.Testing
uv run pytest tests/test_admin_api.py: 26 passed.tests/conftest.pywith the lifespan off:main: I ticked the box and waited 3 seconds, and it was unticked again./admin/api/authreturnsnew_connections_enabled: true);false;false.🤖 Generated with Claude Code