fix(tui): guard app-level UI work with is_running - #895
Open
MBemera wants to merge 1 commit into
Open
Conversation
StrixTUIApp subclasses textual.app.App, whose is_mounted is a method taking a widget, not the Widget.is_mounted property. A bare self.is_mounted is a bound method object and always truthy, so every if-not-self.is_mounted guard was dead code. Switch the 13 app-level lifecycle checks to App.is_running. Add regression coverage that verifies the Textual API distinction, locks all 13 replacements, and proves a stopped StrixTUIApp action returns before querying the widget tree.
Contributor
Greptile SummaryThis PR corrects ineffective TUI lifecycle guards and adds regression coverage.
Confidence Score: 5/5The PR appears safe to merge, with the lifecycle guards now preventing UI operations after the app has stopped. The changed handlers consistently use Textual’s app-level running state, while the regression test exercises the real stopped-app action path and confirms it returns before querying the unmounted UI. Important Files Changed
Reviews (1): Last reviewed commit: "fix(tui): guard app-level UI work with i..." | Re-trigger Greptile |
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.
Addresses #894.
App.is_mountedis a method taking a widget, not theWidget.is_mountedproperty, so a bareself.is_mountedis always truthy and all thirteenif not self.is_mounted: returnguards were dead code. This switches them toApp.is_running. Scan behaviour is unchanged —is_runningis only false before the app starts or after it stops, and every guarded method is a timer, action or event handler. Line 1931 is on aWidgetand is left alone.mypy and pyright each flagged all thirteen sites; the fix clears 20 mypy and 13 pyright errors and adds none.
pytest519 passed, ruff clean. The test drives the realaction_toggle_helpagainst a stopped app — revertingapp.pyfails it withassert 1 == 0. Happy to adjust.