Skip to content

ForkScreen

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
  107846720179264["dialogs.ForkScreen"]
  107846717906624["screen.ModalScreen"]
  107846717858048["screen.Screen"]
  107846685555472["typing.Generic"]
  137699722799616["builtins.object"]
  107846718477920["widget.Widget"]
  107846718489888["dom.DOMNode"]
  107846718374032["message_pump.MessagePump"]
  107846717906624 --> 107846720179264
  107846717858048 --> 107846717906624
  107846685555472 --> 107846717858048
  137699722799616 --> 107846685555472
  107846718477920 --> 107846717858048
  107846718489888 --> 107846718477920
  107846718374032 --> 107846718489888
  137699722799616 --> 107846718374032

๐Ÿ›ˆ DocStrings

Bases: ModalScreen[tuple[str | None] | None]

Choose where to fork: the whole session, or at one of the agent's cursors.

Source code in src/acptui/ui/screens/dialogs.py
class ForkScreen(ModalScreen[tuple[str | None] | None]):
    """Choose where to fork: the whole session, or at one of the agent's cursors."""

    DEFAULT_CSS = "ForkScreen {" + DIALOG_CSS + "}"
    BINDINGS: ClassVar = [Binding("escape", "dismiss_none", "Close")]

    def __init__(self, state: SessionState) -> None:
        super().__init__()
        self.state = state

    def compose(self) -> ComposeResult:
        with Vertical(id="dialog"):
            yield Static("Fork the session", id="dialog-title")
            options = [Option("The whole session", id="whole")]
            options += [
                Option(Content(describe_anchor(cursor, self.state)), id=f"c:{cursor.cursor_id}")
                for cursor in self.state.cursors.values()
                if cursor.can_fork and cursor.anchor is not None
            ]
            yield OptionList(*options, id="cursors")
            yield Static("enter: fork ยท escape: close", id="dialog-hint")

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

    def on_option_list_option_selected(self, event: OptionList.OptionSelected) -> None:
        option_id = event.option_id or ""
        self.dismiss((option_id[2:] if option_id.startswith("c:") else None,))

    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