Coverage for src / lilbee / cli / tui / widgets / help_hint.py: 100%

20 statements  

« prev     ^ index     » next       coverage.py v7.13.4, created at 2026-05-15 20:55 +0000

1"""Footer chip: passive ``type / for commands · F1 for keys`` hint; click opens the list.""" 

2 

3from __future__ import annotations 

4 

5from pathlib import Path 

6from typing import ClassVar 

7 

8from textual import events 

9from textual.content import Content 

10from textual.widgets import Static 

11 

12from lilbee.cli.tui import messages as msg 

13 

14_CSS_FILE = Path(__file__).parent / "help_hint.tcss" 

15 

16 

17class HelpHint(Static): 

18 """One-row chip rendering ``type / for commands · F1 for keys`` above the chat Footer.""" 

19 

20 DEFAULT_CSS: ClassVar[str] = _CSS_FILE.read_text(encoding="utf-8") 

21 

22 def __init__(self, *, id: str | None = None) -> None: 

23 body = Content.assemble( 

24 Content.styled(msg.HELP_HINT_COMMANDS, "$success bold"), 

25 Content.styled(msg.HELP_HINT_SEPARATOR, "$text-muted"), 

26 Content.styled(msg.HELP_HINT_KEYS, "$primary bold"), 

27 ) 

28 super().__init__(body, id=id) 

29 

30 def on_click(self, event: events.Click) -> None: 

31 # Defer to the hosting screen so the chip stays UI-only and the 

32 # screen owns the modal-push + insert flow that already exists for 

33 # the /help slash command. 

34 from lilbee.cli.tui.screens.chat import ChatScreen 

35 

36 screen = self.screen 

37 if not isinstance(screen, ChatScreen): 

38 return 

39 event.stop() 

40 screen.action_show_command_catalog()