Skip to content

SubagentView

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
  107846720886832["blocks.SubagentView"]
  107846719030608["_static.Static"]
  107846718477920["widget.Widget"]
  107846718489888["dom.DOMNode"]
  107846718374032["message_pump.MessagePump"]
  137699722799616["builtins.object"]
  107846719030608 --> 107846720886832
  107846718477920 --> 107846719030608
  107846718489888 --> 107846718477920
  107846718374032 --> 107846718489888
  137699722799616 --> 107846718374032

🛈 DocStrings

Bases: Static

A subagent session; enter opens its conversation, x cancels its work.

Source code in src/acptui/ui/widgets/blocks.py
class SubagentView(Static, can_focus=True):
    """A subagent session; enter opens its conversation, x cancels its work."""

    BINDINGS: ClassVar = [
        Binding("enter", "open", "Open subagent", show=False),
        Binding("x", "cancel", "Cancel subagent", show=False),
    ]

    DEFAULT_CSS = """
    SubagentView {
        height: auto;
        border: round $accent 50%;
        padding: 0 1;
        margin: 0 0 1 0;
        &:focus { border: round $accent; }
    }
    """

    class Open(Message):
        """The user wants to see the subagent's conversation."""

        def __init__(self, session_id: str) -> None:
            super().__init__()
            self.session_id = session_id

    class CancelRequested(Message):
        """The user asked to cancel the subagent's work."""

        def __init__(self, session_id: str) -> None:
            super().__init__()
            self.session_id = session_id

    def __init__(self, entry: SubagentEntry) -> None:
        super().__init__()
        self.entry = entry
        self.refresh_entry()

    def refresh_entry(self) -> None:
        """Re-render."""
        entry = self.entry
        running = entry.activity in {"running", "requires_action"}
        icon = status_icon(
            "in_progress" if running else "completed" if entry.activity == "idle" else "pending"
        )
        hints = "enter: open" + ("  x: cancel" if entry.can_cancel and running else "")
        parts: list[Content | str | tuple[str, str]] = [
            icon,
            " ",
            ("subagent ", "$text-muted"),
            (entry.display_title, "bold"),
            (f"  {entry.activity}", "$text-muted"),
            (f"  ({hints})", "$text-muted italic"),
        ]
        if entry.description:
            parts += ["\n", (entry.description, "$text-muted")]
        self.update(Content.assemble(*parts))

    def action_open(self) -> None:
        self.post_message(self.Open(self.entry.session_id))

    def action_cancel(self) -> None:
        if self.entry.can_cancel:
            self.post_message(self.CancelRequested(self.entry.session_id))

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

CancelRequested

Bases: Message

The user asked to cancel the subagent's work.

Source code in src/acptui/ui/widgets/blocks.py
class CancelRequested(Message):
    """The user asked to cancel the subagent's work."""

    def __init__(self, session_id: str) -> None:
        super().__init__()
        self.session_id = session_id

Open

Bases: Message

The user wants to see the subagent's conversation.

Source code in src/acptui/ui/widgets/blocks.py
class Open(Message):
    """The user wants to see the subagent's conversation."""

    def __init__(self, session_id: str) -> None:
        super().__init__()
        self.session_id = session_id

refresh_entry

refresh_entry() -> None

Re-render.

Source code in src/acptui/ui/widgets/blocks.py
def refresh_entry(self) -> None:
    """Re-render."""
    entry = self.entry
    running = entry.activity in {"running", "requires_action"}
    icon = status_icon(
        "in_progress" if running else "completed" if entry.activity == "idle" else "pending"
    )
    hints = "enter: open" + ("  x: cancel" if entry.can_cancel and running else "")
    parts: list[Content | str | tuple[str, str]] = [
        icon,
        " ",
        ("subagent ", "$text-muted"),
        (entry.display_title, "bold"),
        (f"  {entry.activity}", "$text-muted"),
        (f"  ({hints})", "$text-muted italic"),
    ]
    if entry.description:
        parts += ["\n", (entry.description, "$text-muted")]
    self.update(Content.assemble(*parts))

:fa-brands-github: Show source on GitHub