INNER CODE UNIT · Python

_worker_label

VisionForge-OU/foreman · src/foreman/tui/app.py:190

    def _worker_label(iid: str, w) -> str:
        return f"{iid} [{w.status}] ${w.cost:.3f} {w.turns}t"

    def refresh_workers(self) -> None:
        workers = self.app.controller.workers
        lv = self.query_one("#wlist", ListView)
        ids = list(workers.keys())
        if self.selected is None and ids:
            self.selected = ids[0]
        # IMPORTANT: only rebuild the list when the SET of workers changes. Rebuilding
        # (clear + re-append) every tick made the sidebar flicker, wiped the arrow-key
        # highlight, and raced with click handling (Textual looked the clicked item up
        # in a node list we had just cleared → ValueError crash). In steady state we
        # update the existing labels in place instead.
        existing = [item.name for item in lv.children]
        if existing != ids:
            lv.clear()
            for iid in ids:

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…