diff --git a/src/hqt/tui/widgets/session_list.py b/src/hqt/tui/widgets/session_list.py index 3b8da7d..98e3fdc 100644 --- a/src/hqt/tui/widgets/session_list.py +++ b/src/hqt/tui/widgets/session_list.py @@ -72,6 +72,11 @@ class SessionList(Widget, can_focus=False): yield Label("Sessions", id="session-header") yield VimListView(id="session-list") + def set_mode(self, archived: bool) -> None: + """Swap the column header to reflect whether archived sessions are shown.""" + header = self.query_one("#session-header", Label) + header.update("Sessions (archived)" if archived else "Sessions") + async def refresh_sessions( self, session_infos: list, select_session_id=_UNSET ) -> None: diff --git a/tests/test_tui.py b/tests/test_tui.py index 9716f48..b9bcf94 100644 --- a/tests/test_tui.py +++ b/tests/test_tui.py @@ -2015,3 +2015,23 @@ async def test_h_focuses_projects_l_focuses_sessions(tmp_path): await pilot.press("h") await pilot.pause() assert app.focused is app.query_one("#project-list") + + +@pytest.mark.asyncio +async def test_session_list_header_reflects_archived_mode(): + app = HqtApp() + async with app.run_test(size=(120, 40)) as pilot: + from hqt.tui.widgets.session_list import SessionList + from textual.widgets import Label + + sl = app.query_one(SessionList) + header = sl.query_one("#session-header", Label) + assert str(header.render()) == "Sessions" + + sl.set_mode(archived=True) + await pilot.pause() + assert "archived" in str(header.render()).lower() + + sl.set_mode(archived=False) + await pilot.pause() + assert str(header.render()) == "Sessions"