Skip to content

SideBar

Base classes

Name Children Inherits
Vertical
textual.containers
An expanding container with vertical layout and no scrollbars.

โ‹” Inheritance diagram

graph TD
  1335608570["sidebar.SideBar"]
  723859837["containers.Vertical"]
  4188532303["widget.Widget"]
  3946681048["dom.DOMNode"]
  53685856["message_pump.MessagePump"]
  2751680898["builtins.object"]
  723859837 --> 1335608570
  4188532303 --> 723859837
  3946681048 --> 4188532303
  53685856 --> 3946681048
  2751680898 --> 53685856

๐Ÿ›ˆ DocStrings

Bases: Vertical

Plan and files, docked at the left of the session screen (hidden until opened).

Source code in src/acptui/ui/widgets/sidebar.py
class SideBar(Vertical):
    """Plan and files, docked at the left of the session screen (hidden until opened)."""

    DEFAULT_CSS = """
    SideBar {
        dock: left;
        width: 40;
        max-width: 45%;
        height: 1fr;
        border-right: tall $panel;
        display: none;
        &.-open { display: block; }
        Collapsible {
            padding: 0;
            border-top: none;
            background: transparent;
            &.-collapsed { height: auto; }
            & > Contents { padding: 0 0 0 1; }
        }
        #sidebar-plan { height: auto; }
        #sidebar-files { height: 1fr; min-height: 3; }
        #sidebar-files.-collapsed { height: auto; min-height: 1; }
        #sidebar-files > Contents { height: 1fr; }
        FileTree { height: 1fr; background: transparent; }
        #sidebar-hint { color: $text-muted; padding: 0 1; height: 1; }
    }
    """

    BINDINGS: ClassVar = [Binding("escape", "leave", "Prompt")]

    class Leave(Message):
        """Focus the prompt again (the sidebar stays open)."""

    def __init__(self, files: Files) -> None:
        super().__init__(id="sidebar")
        self.files = files

    def compose(self) -> ComposeResult:
        with Collapsible(title="Plan", collapsed=False, id="sidebar-plan"):
            yield PlanPanel()
        with Collapsible(title="Files", collapsed=False, id="sidebar-files"):
            yield FileTree(self.files)
        yield Static("a: mention ยท esc: prompt ยท ctrl+b: hide", id="sidebar-hint")

    @property
    def file_tree(self) -> FileTree:
        """The files section's tree."""
        return self.query_one(FileTree)

    @property
    def plans(self) -> PlanPanel:
        """The plan section."""
        return self.query_one(PlanPanel)

    @property
    def open(self) -> bool:
        """Whether the sidebar is shown."""
        return self.has_class("-open")

    def show(self, *, focus: bool = False) -> None:
        """Open the sidebar; ``focus``: move the focus into it (the files, else the plan)."""
        self.add_class("-open")
        if focus:
            files = self.query_one("#sidebar-files", Collapsible)
            if files.collapsed:
                self.query_one("#sidebar-plan CollapsibleTitle").focus()
            else:
                self.file_tree.focus()

    def hide(self) -> None:
        """Close the sidebar."""
        self.remove_class("-open")

    def action_leave(self) -> None:
        """Back to the prompt."""
        self.post_message(self.Leave())

file_tree property

file_tree: FileTree

The files section's tree.

open property

open: bool

Whether the sidebar is shown.

plans property

plans: PlanPanel

The plan section.

Leave

Bases: Message

Focus the prompt again (the sidebar stays open).

Source code in src/acptui/ui/widgets/sidebar.py
class Leave(Message):
    """Focus the prompt again (the sidebar stays open)."""

action_leave

action_leave() -> None

Back to the prompt.

Source code in src/acptui/ui/widgets/sidebar.py
def action_leave(self) -> None:
    """Back to the prompt."""
    self.post_message(self.Leave())

hide

hide() -> None

Close the sidebar.

Source code in src/acptui/ui/widgets/sidebar.py
def hide(self) -> None:
    """Close the sidebar."""
    self.remove_class("-open")

show

show(*, focus: bool = False) -> None

Open the sidebar; focus: move the focus into it (the files, else the plan).

Source code in src/acptui/ui/widgets/sidebar.py
def show(self, *, focus: bool = False) -> None:
    """Open the sidebar; ``focus``: move the focus into it (the files, else the plan)."""
    self.add_class("-open")
    if focus:
        files = self.query_one("#sidebar-files", Collapsible)
        if files.collapsed:
            self.query_one("#sidebar-plan CollapsibleTitle").focus()
        else:
            self.file_tree.focus()

:fa-brands-github: Show source on GitHub