Skip to content

ToolCallHeader

Base classes

Name Children Inherits
Static
textual.widgets._static
A widget to display simple static content, or use as a base class for more complex widgets.

⋔ Inheritance diagram

graph TD
  107846720879360["blocks.ToolCallHeader"]
  107846719030608["_static.Static"]
  107846718477920["widget.Widget"]
  107846718489888["dom.DOMNode"]
  107846718374032["message_pump.MessagePump"]
  137699722799616["builtins.object"]
  107846719030608 --> 107846720879360
  107846718477920 --> 107846719030608
  107846718489888 --> 107846718477920
  107846718374032 --> 107846718489888
  137699722799616 --> 107846718374032

🛈 DocStrings

Bases: Static

The one-line summary of a tool call; enter or click toggles the details.

Source code in src/acptui/ui/widgets/blocks.py
class ToolCallHeader(Static, can_focus=True):
    """The one-line summary of a tool call; enter or click toggles the details."""

    BINDINGS: ClassVar = [
        Binding("enter,space", "toggle_details", "Toggle details", show=False),
        Binding("x", "cancel", "Cancel tool call", show=False),
        Binding("r", "toggle_raw", "Raw input/output", show=False),
    ]

    DEFAULT_CSS = """
    ToolCallHeader {
        height: auto;
        padding: 0 1;
        &:focus { background: $boost; text-style: bold; }
        &:hover { background: $boost; }
    }
    """

    def action_toggle_details(self) -> None:
        parent = self.parent
        if isinstance(parent, ToolCallView):
            parent._user_toggled = True
            parent.expanded = not parent.expanded

    def action_cancel(self) -> None:
        parent = self.parent
        if (
            isinstance(parent, ToolCallView)
            and parent.entry.can_cancel
            and not parent.entry.finished
        ):
            parent.post_message(ToolCallView.CancelRequested(parent.entry.tool_call_id))

    async def action_toggle_raw(self) -> None:
        parent = self.parent
        if isinstance(parent, ToolCallView):
            parent.show_raw = not parent.show_raw
            parent.expanded = True
            await parent.rebuild()

    def on_click(self, event: Click) -> None:
        event.stop()
        self.action_toggle_details()

:fa-brands-github: Show source on GitHub