Skip to content

fix(tui): guard app-level UI work with is_running - #895

Open
MBemera wants to merge 1 commit into
usestrix:mainfrom
MBemera:fix/tui-is-mounted-guard
Open

fix(tui): guard app-level UI work with is_running#895
MBemera wants to merge 1 commit into
usestrix:mainfrom
MBemera:fix/tui-is-mounted-guard

Conversation

@MBemera

@MBemera MBemera commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Addresses #894.

App.is_mounted is a method taking a widget, not the Widget.is_mounted property, so a bare self.is_mounted is always truthy and all thirteen if not self.is_mounted: return guards were dead code. This switches them to App.is_running. Scan behaviour is unchanged — is_running is 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 a Widget and is left alone.

mypy and pyright each flagged all thirteen sites; the fix clears 20 mypy and 13 pyright errors and adds none. pytest 519 passed, ruff clean. The test drives the real action_toggle_help against a stopped app — reverting app.py fails it with assert 1 == 0. Happy to adjust.

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.
@greptile-apps

greptile-apps Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR corrects ineffective TUI lifecycle guards and adds regression coverage.

  • Replaces thirteen app-level self.is_mounted checks with self.is_running so UI work is skipped when the Textual app is stopped.
  • Preserves the widget-level is_mounted usage.
  • Adds API-shape, source-regression, and stopped-app behavior tests.

Confidence Score: 5/5

The 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

Filename Overview
strix/interface/tui/app.py Replaces always-truthy bound-method checks with the appropriate app lifecycle property across UI timers, actions, watchers, and event handlers.
tests/test_tui_mount_guard.py Adds focused regression coverage confirming Textual lifecycle API semantics and verifying that stopped-app actions avoid UI queries.

Reviews (1): Last reviewed commit: "fix(tui): guard app-level UI work with i..." | Re-trigger Greptile

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.

1 participant