fix: prevent on_change_domain from wiping saved entity settings when domain matches current_domain - #32
Open
brombomb wants to merge 1 commit into
Open
fix: prevent on_change_domain from wiping saved entity settings when domain matches current_domain#32brombomb wants to merge 1 commit into
brombomb wants to merge 1 commit into
Conversation
…ches current_domain
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.
Real-World Situation & GTK Initialization Lifecycle
The domain wipe occurs due to a race condition between GTK widget initialization and StreamController's signal handling during crash recovery or layout switching:
ComboRowdropdown widget.ComboRowemits anon_changeGTK signal before StreamController populates the saved domain (current_domain) into the widget.old_domain = Noneanddomain = "ai_task"(the 0th alphabetical domain).base_core.pyevaluatesif old_domain != domain:(None != "ai_task"), which evaluates toTrueand invokesself.settings.reset("ai_task"). This permanently overwrites the saved domain and wipes outentity.Steps to Reproduce
ai_task(e.g.,domain: switch,entity: switch.living_room).on_change_domainto reset the button's domain toai_taskand clear the configured entity ("").Environment & System Info
Linux 7.0.0-28-generic x86_64)3.14.4com.core447.StreamController/stable)v1.1.1Proposed Fix
In
base_core.py(on_change_domain), check if the emitted domain matches the domain already saved inself.settings(current_domain):If
domain == current_domain,on_change_domainpreserves the existing entity configuration instead of wiping it out. Adds unit testtest_on_change_domain_matches_current_domainintest_base_core_on_change_domain.py.AI Disclosure
This pull request was diagnosed, developed, and verified with assistance from Google Antigravity (AGY). Antigravity was used to trace GTK widget signal lifecycle events, isolate settings reset triggers, author unit tests, and verify overall code correctness.