prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Add message `Collapsible.Toggled`
  What it says on the tin.
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `src/textual/widgets/_collapsible.py`
  Content:
  ```
  1 from __future__ import annotations
  2 
  3 from rich.console import RenderableType
  4 from rich.text import Text
  5 
  6 from .. import events
  7 from ..app import ComposeResult
  8 from ..binding import Binding
  9 from ..containers import Container
  10 from ..css.query import NoMatches
  11 from ..message import Message
  12 from ..reactive import reactive
  13 from ..widget import Widget
  14 
  15 __all__ = ["Collapsible", "CollapsibleTitle"]
  16 
  17 
  18 class CollapsibleTitle(Widget, can_focus=True):
  19     """Title and symbol for the Collapsible."""
  20 
  21     DEFAULT_CSS = """
  22     CollapsibleTitle {
  23         width: auto;
  24         height: auto;
  25         padding: 0 1 0 1;
  26     }
  27 
  28     CollapsibleTitle:hover {
  29         background: $foreground 10%;
  30         color: $text;
  31     }
  32 
  33     CollapsibleTitle:focus {
  34         background: $accent;
  35         color: $text;
  36     }
  37     """
  38 
  39     BINDINGS = [Binding("enter", "toggle", "Toggle collapsible", show=False)]
  40     """
  41     | Key(s) | Description |
  42     | :- | :- |
  43     | enter | Toggle the collapsible. |
  44     """
  45 
  46     collapsed = reactive(True)
  47 
  48     def __init__(
  49         self,
  50         *,
  51         label: str,
  52         collapsed_symbol: str,
  53         expanded_symbol: str,
  54         collapsed: bool,
  55     ) -> None:
  56         super().__init__()
  57         self.collapsed_symbol = collapsed_symbol
  58         self.expanded_symbol = expanded_symbol
  59         self.label = label
  60         self.collapse = collapsed
  61 
  62     class Toggle(Message):
  63         """Request toggle."""
  64 
  65     async def _on_click(self, event: events.Click) -> None:
  66         """Inform ancestor we want to toggle."""
  67         event.stop()
  68         self.post_message(self.Toggle())
  69 
  70     def action_toggle(self) -> None:
  71         """Toggle the state of the parent collapsible."""
  72         self.post_message(self.Toggle())
  73 
  74     def render(self) -> RenderableType:
  75         """Compose right/down arrow and label."""
  76         if self.collapsed:
  77             return Text(f"{self.collapsed_symbol} {self.label}")
  78         else:
  79             return Text(f"{self.expanded_symbol} {self.label}")
  80 
  81 
  82 class Collapsible(Widget):
  83     """A collapsible container."""
  84 
  85     collapsed = reactive(True)
  86 
  87     DEFAULT_CSS = """
  88     Collapsible {
  89         width: 1fr;
  90         height: auto;
  91         background: $boost;
  92         border-top: hkey $background;
  93         padding-bottom: 1;
  94         padding-left: 1;
  95     }
  96 
  97     Collapsible.-collapsed > Contents {
  98         display: none;
  99     }
  100     """
  101 
  102     class Contents(Container):
  103         DEFAULT_CSS = """
  104         Contents {
  105             width: 100%;
  106             height: auto;
  107             padding: 1 0 0 3;
  108         }
  109         """
  110 
  111     def __init__(
  112         self,
  113         *children: Widget,
  114         title: str = "Toggle",
  115         collapsed: bool = True,
  116         collapsed_symbol: str = "▶",
  117         expanded_symbol: str = "▼",
  118         name: str | None = None,
  119         id: str | None = None,
  120         classes: str | None = None,
  121         disabled: bool = False,
  122     ) -> None:
  123         """Initialize a Collapsible widget.
  124 
  125         Args:
  126             *children: Contents that will be collapsed/expanded.
  127             title: Title of the collapsed/expanded contents.
  128             collapsed: Default status of the contents.
  129             collapsed_symbol: Collapsed symbol before the title.
  130             expanded_symbol: Expanded symbol before the title.
  131             name: The name of the collapsible.
  132             id: The ID of the collapsible in the DOM.
  133             classes: The CSS classes of the collapsible.
  134             disabled: Whether the collapsible is disabled or not.
  135         """
  136         self._title = CollapsibleTitle(
  137             label=title,
  138             collapsed_symbol=collapsed_symbol,
  139             expanded_symbol=expanded_symbol,
  140             collapsed=collapsed,
  141         )
  142         self._contents_list: list[Widget] = list(children)
  143         super().__init__(name=name, id=id, classes=classes, disabled=disabled)
  144         self.collapsed = collapsed
  145 
  146     def on_collapsible_title_toggle(self, event: CollapsibleTitle.Toggle) -> None:
  147         event.stop()
  148         self.collapsed = not self.collapsed
  149 
  150     def _watch_collapsed(self, collapsed: bool) -> None:
  151         """Update collapsed state when reactive is changed."""
  152         self._update_collapsed(collapsed)
  153 
  154     def _update_collapsed(self, collapsed: bool) -> None:
  155         """Update children to match collapsed state."""
  156         try:
  157             self._title.collapsed = collapsed
  158             self.set_class(collapsed, "-collapsed")
  159         except NoMatches:
  160             pass
  161 
  162     def _on_mount(self) -> None:
  163         """Initialise collapsed state."""
  164         self._update_collapsed(self.collapsed)
  165 
  166     def compose(self) -> ComposeResult:
  167         yield self._title
  168         yield self.Contents(*self._contents_list)
  169 
  170     def compose_add_child(self, widget: Widget) -> None:
  171         """When using the context manager compose syntax, we want to attach nodes to the contents.
  172 
  173         Args:
  174             widget: A Widget to add.
  175         """
  176         self._contents_list.append(widget)
  177
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/src/textual/widgets/_collapsible.py b/src/textual/widgets/_collapsible.py
  --- a/src/textual/widgets/_collapsible.py
  +++ b/src/textual/widgets/_collapsible.py
  @@ -99,6 +99,42 @@
       }
       """
   
  +    class Toggled(Message):
  +        """Parent class subclassed by `Collapsible` messages.
  +
  +        Can be handled with `on(Collapsible.Toggled)` if you want to handle expansions
  +        and collapsed in the same way, or you can handle the specific events individually.
  +        """
  +
  +        def __init__(self, collapsible: Collapsible) -> None:
  +            """Create an instance of the message.
  +
  +            Args:
  +                collapsible: The `Collapsible` widget that was toggled.
  +            """
  +            self.collapsible: Collapsible = collapsible
  +            """The collapsible that was toggled."""
  +            super().__init__()
  +
  +        @property
  +        def control(self) -> Collapsible:
  +            """An alias for [Toggled.collapsible][textual.widgets.Collapsible.Toggled.collapsible]."""
  +            return self.collapsible
  +
  +    class Expanded(Toggled):
  +        """Event sent when the `Collapsible` widget is expanded.
  +
  +        Can be handled using `on_collapsible_expanded` in a subclass of
  +        [`Collapsible`][textual.widgets.Collapsible] or in a parent widget in the DOM.
  +        """
  +
  +    class Collapsed(Toggled):
  +        """Event sent when the `Collapsible` widget is collapsed.
  +
  +        Can be handled using `on_collapsible_collapsed` in a subclass of
  +        [`Collapsible`][textual.widgets.Collapsible] or in a parent widget in the DOM.
  +        """
  +
       class Contents(Container):
           DEFAULT_CSS = """
           Contents {
  @@ -143,9 +179,13 @@
           super().__init__(name=name, id=id, classes=classes, disabled=disabled)
           self.collapsed = collapsed
   
  -    def on_collapsible_title_toggle(self, event: CollapsibleTitle.Toggle) -> None:
  +    def _on_collapsible_title_toggle(self, event: CollapsibleTitle.Toggle) -> None:
           event.stop()
           self.collapsed = not self.collapsed
  +        if self.collapsed:
  +            self.post_message(self.Collapsed(self))
  +        else:
  +            self.post_message(self.Expanded(self))
   
       def _watch_collapsed(self, collapsed: bool) -> None:
           """Update collapsed state when reactive is changed."""
  
verification_info: {"golden_diff": "diff --git a/src/textual/widgets/_collapsible.py b/src/textual/widgets/_collapsible.py\n--- a/src/textual/widgets/_collapsible.py\n+++ b/src/textual/widgets/_collapsible.py\n@@ -99,6 +99,42 @@\n     }\n     \"\"\"\n \n+    class Toggled(Message):\n+        \"\"\"Parent class subclassed by `Collapsible` messages.\n+\n+        Can be handled with `on(Collapsible.Toggled)` if you want to handle expansions\n+        and collapsed in the same way, or you can handle the specific events individually.\n+        \"\"\"\n+\n+        def __init__(self, collapsible: Collapsible) -> None:\n+            \"\"\"Create an instance of the message.\n+\n+            Args:\n+                collapsible: The `Collapsible` widget that was toggled.\n+            \"\"\"\n+            self.collapsible: Collapsible = collapsible\n+            \"\"\"The collapsible that was toggled.\"\"\"\n+            super().__init__()\n+\n+        @property\n+        def control(self) -> Collapsible:\n+            \"\"\"An alias for [Toggled.collapsible][textual.widgets.Collapsible.Toggled.collapsible].\"\"\"\n+            return self.collapsible\n+\n+    class Expanded(Toggled):\n+        \"\"\"Event sent when the `Collapsible` widget is expanded.\n+\n+        Can be handled using `on_collapsible_expanded` in a subclass of\n+        [`Collapsible`][textual.widgets.Collapsible] or in a parent widget in the DOM.\n+        \"\"\"\n+\n+    class Collapsed(Toggled):\n+        \"\"\"Event sent when the `Collapsible` widget is collapsed.\n+\n+        Can be handled using `on_collapsible_collapsed` in a subclass of\n+        [`Collapsible`][textual.widgets.Collapsible] or in a parent widget in the DOM.\n+        \"\"\"\n+\n     class Contents(Container):\n         DEFAULT_CSS = \"\"\"\n         Contents {\n@@ -143,9 +179,13 @@\n         super().__init__(name=name, id=id, classes=classes, disabled=disabled)\n         self.collapsed = collapsed\n \n-    def on_collapsible_title_toggle(self, event: CollapsibleTitle.Toggle) -> None:\n+    def _on_collapsible_title_toggle(self, event: CollapsibleTitle.Toggle) -> None:\n         event.stop()\n         self.collapsed = not self.collapsed\n+        if self.collapsed:\n+            self.post_message(self.Collapsed(self))\n+        else:\n+            self.post_message(self.Expanded(self))\n \n     def _watch_collapsed(self, collapsed: bool) -> None:\n         \"\"\"Update collapsed state when reactive is changed.\"\"\"\n", "issue": "Add message `Collapsible.Toggled`\nWhat it says on the tin.\n", "before_files": [{"content": "from __future__ import annotations\n\nfrom rich.console import RenderableType\nfrom rich.text import Text\n\nfrom .. import events\nfrom ..app import ComposeResult\nfrom ..binding import Binding\nfrom ..containers import Container\nfrom ..css.query import NoMatches\nfrom ..message import Message\nfrom ..reactive import reactive\nfrom ..widget import Widget\n\n__all__ = [\"Collapsible\", \"CollapsibleTitle\"]\n\n\nclass CollapsibleTitle(Widget, can_focus=True):\n    \"\"\"Title and symbol for the Collapsible.\"\"\"\n\n    DEFAULT_CSS = \"\"\"\n    CollapsibleTitle {\n        width: auto;\n        height: auto;\n        padding: 0 1 0 1;\n    }\n\n    CollapsibleTitle:hover {\n        background: $foreground 10%;\n        color: $text;\n    }\n\n    CollapsibleTitle:focus {\n        background: $accent;\n        color: $text;\n    }\n    \"\"\"\n\n    BINDINGS = [Binding(\"enter\", \"toggle\", \"Toggle collapsible\", show=False)]\n    \"\"\"\n    | Key(s) | Description |\n    | :- | :- |\n    | enter | Toggle the collapsible. |\n    \"\"\"\n\n    collapsed = reactive(True)\n\n    def __init__(\n        self,\n        *,\n        label: str,\n        collapsed_symbol: str,\n        expanded_symbol: str,\n        collapsed: bool,\n    ) -> None:\n        super().__init__()\n        self.collapsed_symbol = collapsed_symbol\n        self.expanded_symbol = expanded_symbol\n        self.label = label\n        self.collapse = collapsed\n\n    class Toggle(Message):\n        \"\"\"Request toggle.\"\"\"\n\n    async def _on_click(self, event: events.Click) -> None:\n        \"\"\"Inform ancestor we want to toggle.\"\"\"\n        event.stop()\n        self.post_message(self.Toggle())\n\n    def action_toggle(self) -> None:\n        \"\"\"Toggle the state of the parent collapsible.\"\"\"\n        self.post_message(self.Toggle())\n\n    def render(self) -> RenderableType:\n        \"\"\"Compose right/down arrow and label.\"\"\"\n        if self.collapsed:\n            return Text(f\"{self.collapsed_symbol} {self.label}\")\n        else:\n            return Text(f\"{self.expanded_symbol} {self.label}\")\n\n\nclass Collapsible(Widget):\n    \"\"\"A collapsible container.\"\"\"\n\n    collapsed = reactive(True)\n\n    DEFAULT_CSS = \"\"\"\n    Collapsible {\n        width: 1fr;\n        height: auto;\n        background: $boost;\n        border-top: hkey $background;\n        padding-bottom: 1;\n        padding-left: 1;\n    }\n\n    Collapsible.-collapsed > Contents {\n        display: none;\n    }\n    \"\"\"\n\n    class Contents(Container):\n        DEFAULT_CSS = \"\"\"\n        Contents {\n            width: 100%;\n            height: auto;\n            padding: 1 0 0 3;\n        }\n        \"\"\"\n\n    def __init__(\n        self,\n        *children: Widget,\n        title: str = \"Toggle\",\n        collapsed: bool = True,\n        collapsed_symbol: str = \"\u25b6\",\n        expanded_symbol: str = \"\u25bc\",\n        name: str | None = None,\n        id: str | None = None,\n        classes: str | None = None,\n        disabled: bool = False,\n    ) -> None:\n        \"\"\"Initialize a Collapsible widget.\n\n        Args:\n            *children: Contents that will be collapsed/expanded.\n            title: Title of the collapsed/expanded contents.\n            collapsed: Default status of the contents.\n            collapsed_symbol: Collapsed symbol before the title.\n            expanded_symbol: Expanded symbol before the title.\n            name: The name of the collapsible.\n            id: The ID of the collapsible in the DOM.\n            classes: The CSS classes of the collapsible.\n            disabled: Whether the collapsible is disabled or not.\n        \"\"\"\n        self._title = CollapsibleTitle(\n            label=title,\n            collapsed_symbol=collapsed_symbol,\n            expanded_symbol=expanded_symbol,\n            collapsed=collapsed,\n        )\n        self._contents_list: list[Widget] = list(children)\n        super().__init__(name=name, id=id, classes=classes, disabled=disabled)\n        self.collapsed = collapsed\n\n    def on_collapsible_title_toggle(self, event: CollapsibleTitle.Toggle) -> None:\n        event.stop()\n        self.collapsed = not self.collapsed\n\n    def _watch_collapsed(self, collapsed: bool) -> None:\n        \"\"\"Update collapsed state when reactive is changed.\"\"\"\n        self._update_collapsed(collapsed)\n\n    def _update_collapsed(self, collapsed: bool) -> None:\n        \"\"\"Update children to match collapsed state.\"\"\"\n        try:\n            self._title.collapsed = collapsed\n            self.set_class(collapsed, \"-collapsed\")\n        except NoMatches:\n            pass\n\n    def _on_mount(self) -> None:\n        \"\"\"Initialise collapsed state.\"\"\"\n        self._update_collapsed(self.collapsed)\n\n    def compose(self) -> ComposeResult:\n        yield self._title\n        yield self.Contents(*self._contents_list)\n\n    def compose_add_child(self, widget: Widget) -> None:\n        \"\"\"When using the context manager compose syntax, we want to attach nodes to the contents.\n\n        Args:\n            widget: A Widget to add.\n        \"\"\"\n        self._contents_list.append(widget)\n", "path": "src/textual/widgets/_collapsible.py"}], "after_files": [{"content": "from __future__ import annotations\n\nfrom rich.console import RenderableType\nfrom rich.text import Text\n\nfrom .. import events\nfrom ..app import ComposeResult\nfrom ..binding import Binding\nfrom ..containers import Container\nfrom ..css.query import NoMatches\nfrom ..message import Message\nfrom ..reactive import reactive\nfrom ..widget import Widget\n\n__all__ = [\"Collapsible\", \"CollapsibleTitle\"]\n\n\nclass CollapsibleTitle(Widget, can_focus=True):\n    \"\"\"Title and symbol for the Collapsible.\"\"\"\n\n    DEFAULT_CSS = \"\"\"\n    CollapsibleTitle {\n        width: auto;\n        height: auto;\n        padding: 0 1 0 1;\n    }\n\n    CollapsibleTitle:hover {\n        background: $foreground 10%;\n        color: $text;\n    }\n\n    CollapsibleTitle:focus {\n        background: $accent;\n        color: $text;\n    }\n    \"\"\"\n\n    BINDINGS = [Binding(\"enter\", \"toggle\", \"Toggle collapsible\", show=False)]\n    \"\"\"\n    | Key(s) | Description |\n    | :- | :- |\n    | enter | Toggle the collapsible. |\n    \"\"\"\n\n    collapsed = reactive(True)\n\n    def __init__(\n        self,\n        *,\n        label: str,\n        collapsed_symbol: str,\n        expanded_symbol: str,\n        collapsed: bool,\n    ) -> None:\n        super().__init__()\n        self.collapsed_symbol = collapsed_symbol\n        self.expanded_symbol = expanded_symbol\n        self.label = label\n        self.collapse = collapsed\n\n    class Toggle(Message):\n        \"\"\"Request toggle.\"\"\"\n\n    async def _on_click(self, event: events.Click) -> None:\n        \"\"\"Inform ancestor we want to toggle.\"\"\"\n        event.stop()\n        self.post_message(self.Toggle())\n\n    def action_toggle(self) -> None:\n        \"\"\"Toggle the state of the parent collapsible.\"\"\"\n        self.post_message(self.Toggle())\n\n    def render(self) -> RenderableType:\n        \"\"\"Compose right/down arrow and label.\"\"\"\n        if self.collapsed:\n            return Text(f\"{self.collapsed_symbol} {self.label}\")\n        else:\n            return Text(f\"{self.expanded_symbol} {self.label}\")\n\n\nclass Collapsible(Widget):\n    \"\"\"A collapsible container.\"\"\"\n\n    collapsed = reactive(True)\n\n    DEFAULT_CSS = \"\"\"\n    Collapsible {\n        width: 1fr;\n        height: auto;\n        background: $boost;\n        border-top: hkey $background;\n        padding-bottom: 1;\n        padding-left: 1;\n    }\n\n    Collapsible.-collapsed > Contents {\n        display: none;\n    }\n    \"\"\"\n\n    class Toggled(Message):\n        \"\"\"Parent class subclassed by `Collapsible` messages.\n\n        Can be handled with `on(Collapsible.Toggled)` if you want to handle expansions\n        and collapsed in the same way, or you can handle the specific events individually.\n        \"\"\"\n\n        def __init__(self, collapsible: Collapsible) -> None:\n            \"\"\"Create an instance of the message.\n\n            Args:\n                collapsible: The `Collapsible` widget that was toggled.\n            \"\"\"\n            self.collapsible: Collapsible = collapsible\n            \"\"\"The collapsible that was toggled.\"\"\"\n            super().__init__()\n\n        @property\n        def control(self) -> Collapsible:\n            \"\"\"An alias for [Toggled.collapsible][textual.widgets.Collapsible.Toggled.collapsible].\"\"\"\n            return self.collapsible\n\n    class Expanded(Toggled):\n        \"\"\"Event sent when the `Collapsible` widget is expanded.\n\n        Can be handled using `on_collapsible_expanded` in a subclass of\n        [`Collapsible`][textual.widgets.Collapsible] or in a parent widget in the DOM.\n        \"\"\"\n\n    class Collapsed(Toggled):\n        \"\"\"Event sent when the `Collapsible` widget is collapsed.\n\n        Can be handled using `on_collapsible_collapsed` in a subclass of\n        [`Collapsible`][textual.widgets.Collapsible] or in a parent widget in the DOM.\n        \"\"\"\n\n    class Contents(Container):\n        DEFAULT_CSS = \"\"\"\n        Contents {\n            width: 100%;\n            height: auto;\n            padding: 1 0 0 3;\n        }\n        \"\"\"\n\n    def __init__(\n        self,\n        *children: Widget,\n        title: str = \"Toggle\",\n        collapsed: bool = True,\n        collapsed_symbol: str = \"\u25b6\",\n        expanded_symbol: str = \"\u25bc\",\n        name: str | None = None,\n        id: str | None = None,\n        classes: str | None = None,\n        disabled: bool = False,\n    ) -> None:\n        \"\"\"Initialize a Collapsible widget.\n\n        Args:\n            *children: Contents that will be collapsed/expanded.\n            title: Title of the collapsed/expanded contents.\n            collapsed: Default status of the contents.\n            collapsed_symbol: Collapsed symbol before the title.\n            expanded_symbol: Expanded symbol before the title.\n            name: The name of the collapsible.\n            id: The ID of the collapsible in the DOM.\n            classes: The CSS classes of the collapsible.\n            disabled: Whether the collapsible is disabled or not.\n        \"\"\"\n        self._title = CollapsibleTitle(\n            label=title,\n            collapsed_symbol=collapsed_symbol,\n            expanded_symbol=expanded_symbol,\n            collapsed=collapsed,\n        )\n        self._contents_list: list[Widget] = list(children)\n        super().__init__(name=name, id=id, classes=classes, disabled=disabled)\n        self.collapsed = collapsed\n\n    def _on_collapsible_title_toggle(self, event: CollapsibleTitle.Toggle) -> None:\n        event.stop()\n        self.collapsed = not self.collapsed\n        if self.collapsed:\n            self.post_message(self.Collapsed(self))\n        else:\n            self.post_message(self.Expanded(self))\n\n    def _watch_collapsed(self, collapsed: bool) -> None:\n        \"\"\"Update collapsed state when reactive is changed.\"\"\"\n        self._update_collapsed(collapsed)\n\n    def _update_collapsed(self, collapsed: bool) -> None:\n        \"\"\"Update children to match collapsed state.\"\"\"\n        try:\n            self._title.collapsed = collapsed\n            self.set_class(collapsed, \"-collapsed\")\n        except NoMatches:\n            pass\n\n    def _on_mount(self) -> None:\n        \"\"\"Initialise collapsed state.\"\"\"\n        self._update_collapsed(self.collapsed)\n\n    def compose(self) -> ComposeResult:\n        yield self._title\n        yield self.Contents(*self._contents_list)\n\n    def compose_add_child(self, widget: Widget) -> None:\n        \"\"\"When using the context manager compose syntax, we want to attach nodes to the contents.\n\n        Args:\n            widget: A Widget to add.\n        \"\"\"\n        self._contents_list.append(widget)\n", "path": "src/textual/widgets/_collapsible.py"}]}