Skip to content

fix: prevent GTK widget-tree corruption when navigating back to a page with HA buttons#24

Open
Copilot wants to merge 3 commits into
mainfrom
copilot/fix-home-assistant-crash-issue
Open

fix: prevent GTK widget-tree corruption when navigating back to a page with HA buttons#24
Copilot wants to merge 3 commits into
mainfrom
copilot/fix-home-assistant-crash-issue

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 18, 2026

  • Analyse crash logs and identify root cause
  • Add _clearing flag to CustomizationCore to block _load_customizations() during on_remove()
  • Override on_remove() in CustomizationCore to set the flag, call super().on_remove(), clear the expander, then reset the flag
  • Guard _load_customizations() with the flag
  • Add unit tests for the new behaviour
  • Fix failing test: add instance._clearing = False to test_load_customizations (instance was created via __new__, bypassing __init__)
  • Pass code review; CodeQL: 0 alerts

@gensyn
Copy link
Copy Markdown
Owner

gensyn commented May 18, 2026

@copilot Please fix the failing tests.

Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 18, 2026

@copilot Please fix the failing tests.

Fixed in d5025e8. The test_load_customizations test creates its instance via CustomizationCore.__new__() (bypassing __init__), so _clearing was never set, causing the AttributeError. Added instance._clearing = False to that test's setup to match how a normally constructed instance would look.

Copilot finished work on behalf of gensyn May 18, 2026 09:01
Copilot AI requested a review from gensyn May 18, 2026 09:01
@gensyn gensyn marked this pull request as ready for review May 18, 2026 09:04
Copilot AI review requested due to automatic review settings May 18, 2026 09:04
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes a GTK crash caused by widget-tree corruption when navigating back to actions that use Home Assistant customizations, by preventing _load_customizations() from mutating the expander while the action is being removed/detached.

Changes:

  • Add a _clearing flag to CustomizationCore and guard _load_customizations() to no-op while clearing.
  • Override CustomizationCore.on_remove() to set _clearing during super().on_remove(), then clear the expander rows and reset the flag.
  • Add/adjust unit tests to validate the new on_remove() behavior and ensure _clearing is initialized in __new__-constructed instances.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
actions/cores/customization_core/customization_core.py Introduces _clearing, guards _load_customizations(), and adds a safe on_remove() cleanup sequence to avoid GTK widget-tree corruption.
test/actions/cores/customization_core/test_customization_core.py Adds unit tests for skipping loads during clearing and for on_remove() flag/cleanup behavior; fixes an existing test setup to initialize _clearing.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

3 participants