From 47b7a0d92aaf46536e25de2f51f9a99b77c46d0f Mon Sep 17 00:00:00 2001 From: Kris Anderson <1562427+kris-anderson@users.noreply.github.com> Date: Sun, 15 Nov 2026 17:33:34 -0800 Subject: [PATCH 1/2] fix(admin): keep an unsaved New connections choice across the 2-second 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 --- src/roborock_local_server/standalone_admin.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/roborock_local_server/standalone_admin.py b/src/roborock_local_server/standalone_admin.py index e1c24dd..51a2891 100644 --- a/src/roborock_local_server/standalone_admin.py +++ b/src/roborock_local_server/standalone_admin.py @@ -154,11 +154,20 @@ def _admin_dashboard_html(project_support: dict[str, Any]) -> str: container.appendChild(card); }} }} + // The page refreshes every 2 seconds. Until Save is pressed, a changed checkbox keeps the + // user's choice instead of snapping back to the saved setting. + let connectionsEdited = false; + document.getElementById("newConnectionsEnabled").addEventListener("change", () => {{ + connectionsEdited = true; + document.getElementById("authMeta").textContent = "Unsaved change: press Save to apply it."; + }}); function renderAuth(auth) {{ const enabled = Boolean(auth.new_connections_enabled); - document.getElementById("newConnectionsEnabled").checked = enabled; - document.getElementById("authMeta").textContent = - `New connections: ${{enabled ? "Allowed" : "Blocked"}}. Persisted sessions: ${{Number(auth.protocol_session_count || 0)}}.`; + if (!connectionsEdited) {{ + document.getElementById("newConnectionsEnabled").checked = enabled; + document.getElementById("authMeta").textContent = + `New connections: ${{enabled ? "Allowed" : "Blocked"}}. Persisted sessions: ${{Number(auth.protocol_session_count || 0)}}.`; + }} const sessionSecret = String(auth.admin_session_secret || ""); document.getElementById("adminSessionSecret").value = sessionSecret; document.getElementById("syncSecretMeta").textContent = sessionSecret @@ -266,6 +275,7 @@ def _admin_dashboard_html(project_support: dict[str, Any]) -> str: new_connections_enabled: document.getElementById("newConnectionsEnabled").checked }}) }}); + connectionsEdited = false; renderAuth(payload); await refresh(); }} catch (error) {{ From e4e943e10873e67792803f3b1467f39553146030 Mon Sep 17 00:00:00 2001 From: Kris Anderson <1562427+kris-anderson@users.noreply.github.com> Date: Sun, 15 Nov 2026 17:41:37 -0800 Subject: [PATCH 2/2] fix(admin): keep a change made while Save is in flight unsaved 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 --- src/roborock_local_server/standalone_admin.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/roborock_local_server/standalone_admin.py b/src/roborock_local_server/standalone_admin.py index 51a2891..8dd4d8c 100644 --- a/src/roborock_local_server/standalone_admin.py +++ b/src/roborock_local_server/standalone_admin.py @@ -275,7 +275,11 @@ def _admin_dashboard_html(project_support: dict[str, Any]) -> str: new_connections_enabled: document.getElementById("newConnectionsEnabled").checked }}) }}); - connectionsEdited = false; + // Only a choice the server now holds stops being unsaved; a change made while Save + // was in flight stays unsaved. + if (document.getElementById("newConnectionsEnabled").checked === Boolean(payload.new_connections_enabled)) {{ + connectionsEdited = false; + }} renderAuth(payload); await refresh(); }} catch (error) {{