trogon icon indicating copy to clipboard operation
trogon copied to clipboard

[Bug]: Trogon apps break on CTRL+O (show command info)

Open Haran opened this issue 8 months ago • 2 comments

Reproduction scenario

  • Use any of examples
    • https://github.com/Textualize/trogon/blob/main/examples/demo.py
    • https://github.com/Textualize/trogon/blob/main/examples/nogroup_demo.py
  • Launch, press CTRL+O for command info
  • Expected behavior: no information is shown or in case of docstring present, information popup is displayed
  • Actual behavior:

Image

Info

Item Value
Platform Linux
Python versions From 3.9 to 3.12

Additional info

  • Adding docstring to command doesn't change behavior, however docstring description shows in the "title"
    • Checked docstring formats (all have no effect): Epytext, reST, Google, Numpydoc

Haran avatar May 14 '25 10:05 Haran

Whoever faces similar issue, the only workaround I've found so far is to monkey-patch action_show_command_info(), preventing the app from falling into exception.

Disabling ctrl+o

from trogon import tui, Trogon
Trogon.action_show_command_info = lambda self: None

@tui
#....

Show graceful message on ctrl+o

from trogon import tui, Trogon
from trogon.widgets.about import TextDialog

class NotSupportedDialog(TextDialog):
    def __init__(self) -> None:
        super().__init__("Not supported", "This is function is not supported")
Trogon.action_show_command_info = lambda self: self.app.push_screen(NotSupportedDialog())

@tui
#....

Haran avatar May 14 '25 14:05 Haran

Better temporary fix while PR#120 is open:

from trogon.widgets.command_info import CommandInfo
from trogon.widgets.form import CommandForm

Trogon.action_show_command_info = lambda self: self.push_screen(CommandInfo(self.query_one(CommandForm).command_schema))

@tui
#....

After this monekypatching ctrl+o displays correct command information and command metadata.

Haran avatar Oct 07 '25 16:10 Haran