Coverage for src/lilbee/cli/tui/screens/command_palette.py: 100%

7 statements  

« prev     ^ index     » next       coverage.py v7.15.2, created at 2026-08-14 11:46 +0000

1"""Textual's command palette with the search icon replaced. 

2 

3Textual seeds ``SearchIcon`` with a magnifying-glass emoji, which the system 

4emoji font renders in its own colors at double width, making it the one element 

5on screen that ignores the theme. 

6 

7``SearchIcon`` is built inside ``CommandPalette.compose`` and ``icon`` is a 

8reactive, so the icon is set after mount rather than by overriding ``compose``, 

9which would mean copying the library's layout. The query is deliberately not 

10``query_one``: if a future Textual restructures the palette, the icon reverts 

11rather than raising out of the Ctrl+P action. 

12""" 

13 

14from __future__ import annotations 

15 

16from textual.command import CommandPalette, SearchIcon 

17 

18from lilbee.cli.tui import messages as msg 

19 

20 

21class LilbeeCommandPalette(CommandPalette): 

22 """Command palette whose search icon is a plain single-width glyph.""" 

23 

24 def on_mount(self) -> None: 

25 for icon in self.query(SearchIcon): 

26 icon.icon = msg.COMMAND_PALETTE_ICON