fix: implement lazy widget loading and store references

Defer widget creation from __init__ to compose() and store references
as instance variables to prevent garbage collection and initialization
order issues. This resolves ScreenStackError during TUI startup.

Changes:
- Move LogPane, GraphOverview, ChatRepl creation to compose()
- Store widgets as instance variables (self.log_pane, etc)
- Restore Horizontal/Vertical container layout

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
mubarakar95
2026-01-30 01:27:56 +05:30
parent a6536cef94
commit ed95dab9f3
+7 -3
View File
@@ -53,14 +53,18 @@ class AdenTUI(App):
def __init__(self, runtime: AgentRuntime):
super().__init__()
self.runtime = runtime
self.log_pane = LogPane()
self.graph_view = GraphOverview()
self.chat_repl = ChatRepl(runtime)
# Widgets will be created lazily in compose()
def compose(self) -> ComposeResult:
"""Create child widgets for the app."""
yield Header()
# Lazy-load widgets here to avoid initialization order issues
# Store as instance variables to prevent garbage collection
self.log_pane = LogPane()
self.graph_view = GraphOverview()
self.chat_repl = ChatRepl(self.runtime)
yield Horizontal(
Container(self.graph_view, id="left-pane"),
Vertical(