tenseleyflow/loader / f768f96

Browse files

Fix TodoListWidget crash: ensure Static always has valid content before becoming visible

Authored by espadonne
SHA
f768f960cdd95d5ac19abec0f6b510974074e0dc
Parents
42508d2
Tree
9e57172

1 changed file

StatusFile+-
M src/loader/ui/widgets/todo_list.py 10 3
src/loader/ui/widgets/todo_list.pymodified
@@ -40,16 +40,20 @@ class TodoListWidget(Widget):
4040
         self._items: list[dict[str, str]] = []
4141
 
4242
     def compose(self) -> ComposeResult:
43
-        yield Static("", id="todo-content")
43
+        # Use a space so the Static always has valid renderable content.
44
+        # An empty string can produce visual=None and crash Textual's
45
+        # render pipeline when the widget is visible.
46
+        yield Static(" ", id="todo-content")
4447
 
4548
     def update_todos(self, todos: list[dict[str, str]]) -> None:
4649
         """Replace the displayed todo list."""
4750
         self._items = list(todos)
4851
         if not self._items:
4952
             self.remove_class("has-items")
53
+            self.query_one("#todo-content", Static).update(" ")
5054
             return
51
-        self.add_class("has-items")
5255
         self._render()
56
+        self.add_class("has-items")
5357
 
5458
     def _render(self) -> None:
5559
         content = Text()
@@ -69,4 +73,7 @@ class TodoListWidget(Widget):
6973
                 content.append(label)
7074
             content.append("\n")
7175
 
72
-        self.query_one("#todo-content", Static).update(content)
76
+        try:
77
+            self.query_one("#todo-content", Static).update(content)
78
+        except Exception:
79
+            pass  # widget not mounted yet; will render on next update