git: 53b90ee074f9 - main - misc/py-oterm: Fix a runtime error

From: Nicola Vitale <nivit_at_FreeBSD.org>
Date: Fri, 09 Aug 2024 09:16:54 UTC
The branch main has been updated by nivit:

URL: https://cgit.FreeBSD.org/ports/commit/?id=53b90ee074f97b55a3242caec601f18885a74455

commit 53b90ee074f97b55a3242caec601f18885a74455
Author:     Nicola Vitale <nivit@FreeBSD.org>
AuthorDate: 2024-08-09 09:05:48 +0000
Commit:     Nicola Vitale <nivit@FreeBSD.org>
CommitDate: 2024-08-09 09:05:48 +0000

    misc/py-oterm: Fix a runtime error
    
    - Due to an incompatibility with the recent version of textproc/py-textual,
      oterm crashes when there are saved chats, with the following error
    
    │ /usr/local/lib/python3.11/site-packages/textual/widget.py:984 in mount                                                                                                                                                                                                  │
    │                                                                                                                                                                                                                                                                         │
    │    981 │   │   if self._closing or self._pruning:                                               ╭──────────── locals ────────────╮                                                                                                                                      │
    │    982 │   │   │   return AwaitMount(self, [])                                                  │   after = None                 │                                                                                                                                      │
    │    983 │   │   if not self.is_attached:                                                         │  before = None                 │                                                                                                                                      │
    │ ❱  984 │   │   │   raise MountError(f"Can't mount widget(s) before {self!r} is mounted")        │    self = TabPane(id='chat-1') │                                                                                                                                      │
    │    985 │   │   # Check for duplicate IDs in the incoming widgets                                │ widgets = (ChatContainer(),)   │                                                                                                                                      │
    │    986 │   │   ids_to_mount = [                                                                 ╰────────────────────────────────╯                                                                                                                                      │
    │    987 │   │   │   widget_id for widget in widgets if (widget_id := widget.id) is not None                                                                                                                                                                              │
    ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
    MountError: Can't mount widget(s) before TabPane(id='chat-1') is mounted
    
    So add the patch patch-oterm_app_oterm.py, that is a simple workaround
    waiting for an official solution by upstream.
    
    - Bump PORTREVISION
---
 misc/py-oterm/Makefile                       |  1 +
 misc/py-oterm/files/patch-oterm_app_oterm.py | 11 +++++++++++
 2 files changed, 12 insertions(+)

diff --git a/misc/py-oterm/Makefile b/misc/py-oterm/Makefile
index 844590d4d1ff..5f487674975e 100644
--- a/misc/py-oterm/Makefile
+++ b/misc/py-oterm/Makefile
@@ -1,5 +1,6 @@
 PORTNAME=	oterm
 DISTVERSION=	0.2.9
+PORTREVISION=	1
 CATEGORIES=	misc python
 MASTER_SITES=	PYPI
 PKGNAMEPREFIX=	${PYTHON_PKGNAMEPREFIX}
diff --git a/misc/py-oterm/files/patch-oterm_app_oterm.py b/misc/py-oterm/files/patch-oterm_app_oterm.py
new file mode 100644
index 000000000000..e96637544753
--- /dev/null
+++ b/misc/py-oterm/files/patch-oterm_app_oterm.py
@@ -0,0 +1,11 @@
+--- oterm/app/oterm.py.orig	2024-05-15 16:35:57 UTC
++++ oterm/app/oterm.py
+@@ -72,7 +72,7 @@ class OTerm(App):
+             for id, name, model, context, system, format, keep_alive in saved_chats:
+                 messages = await self.store.get_messages(id)
+                 pane = TabPane(name, id=f"chat-{id}")
+-                await pane.mount(
++                pane.compose_add_child(
+                     ChatContainer(
+                         db_id=id,
+                         chat_name=name,