Skip to content

LoginScreen

Base classes

Name Children Inherits
ModalScreen
textual.screen
A screen with bindings that take precedence over the App's key bindings.

โ‹” Inheritance diagram

graph TD
  161093106["dialogs.LoginScreen"]
  1923423225["screen.ModalScreen"]
  642899982["screen.Screen"]
  3481597255["typing.Generic"]
  2751680898["builtins.object"]
  4188532303["widget.Widget"]
  3946681048["dom.DOMNode"]
  53685856["message_pump.MessagePump"]
  1923423225 --> 161093106
  642899982 --> 1923423225
  3481597255 --> 642899982
  2751680898 --> 3481597255
  4188532303 --> 642899982
  3946681048 --> 4188532303
  53685856 --> 3946681048
  2751680898 --> 53685856

๐Ÿ›ˆ DocStrings

Bases: ModalScreen[str | None]

The agent's login methods with their (Markdown) descriptions; returns a method id.

Methods acptui cannot run (unknown types) are listed but disabled.

Source code in src/acptui/ui/screens/dialogs.py
class LoginScreen(ModalScreen[str | None]):
    """The agent's login methods with their (Markdown) descriptions; returns a method id.

    Methods acptui cannot run (unknown types) are listed but disabled.
    """

    DEFAULT_CSS = (
        "LoginScreen {"
        + DIALOG_CSS
        + """ #login-description {
            height: auto; max-height: 12; margin: 1 0 0 0; padding: 0; background: transparent;
        } }"""
    )
    BINDINGS: ClassVar = [Binding("escape", "dismiss_none", "Close")]

    def __init__(self, agent_name: str, methods: Sequence[AuthMethod]) -> None:
        super().__init__()
        self.agent_name = agent_name
        self.methods = list(methods)

    def compose(self) -> ComposeResult:
        with Vertical(id="dialog"):
            yield Static(Content(f"Log in to {self.agent_name}"), id="dialog-title")
            options: list[Option] = []
            for index, method in enumerate(self.methods):
                runnable = isinstance(method, AuthMethodAgent | AuthMethodTerminal)
                kind = (
                    "in a terminal"
                    if isinstance(method, AuthMethodTerminal)
                    else "via the agent"
                    if runnable
                    else f"unsupported: {method.type}"
                )
                label = Content.assemble((method.name, "bold"), (f"  ({kind})", "$text-muted"))
                options.append(
                    Option(
                        _described(label, method_description(method)),
                        id=f"m:{index}",
                        disabled=not runnable,
                    )
                )
            yield OptionList(*options, id="methods")
            yield AgentMarkdown(id="login-description")
            yield Static("enter: log in ยท escape: close", id="dialog-hint")

    def on_mount(self) -> None:
        options = self.query_one(OptionList)
        options.focus()
        if self.methods:
            options.highlighted = 0

    def on_option_list_option_highlighted(self, event: OptionList.OptionHighlighted) -> None:
        index = int((event.option_id or "m:0")[2:])
        description = method_description(self.methods[index]) if self.methods else ""
        panel = self.query_one("#login-description", AgentMarkdown)
        panel.display = bool(description)
        panel.update(description)

    def on_option_list_option_selected(self, event: OptionList.OptionSelected) -> None:
        index = int((event.option_id or "m:0")[2:])
        self.dismiss(self.methods[index].method_id)

    def action_dismiss_none(self) -> None:
        """Close."""
        self.dismiss(None)

action_dismiss_none

action_dismiss_none() -> None

Close.

Source code in src/acptui/ui/screens/dialogs.py
def action_dismiss_none(self) -> None:
    """Close."""
    self.dismiss(None)

:fa-brands-github: Show source on GitHub