feat: SessionList.set_mode swaps header for archived view
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user