From 2c5e64039affac3d367bc9745c1240c5dc82bac1 Mon Sep 17 00:00:00 2001 From: Alexander Miroshnichenko Date: Thu, 20 Aug 2026 10:33:57 +0300 Subject: [PATCH] fix(haivemind): start engine after MainScreen mounts to avoid NoMatches on #chat-log Upstream haivemind_tui.py started the engine synchronously in HaivemindApp.on_mount while MainScreen mounts asynchronously, causing ProbeStart handler to query #chat-log on the default screen (NoMatches). Move the start_run trigger into MainScreen.on_mount so it runs only once the screen is active. --- packages/haivemind/fix-chat-log-race.patch | 28 ++++++++++++++++++++++ packages/haivemind/package.nix | 2 ++ 2 files changed, 30 insertions(+) create mode 100644 packages/haivemind/fix-chat-log-race.patch diff --git a/packages/haivemind/fix-chat-log-race.patch b/packages/haivemind/fix-chat-log-race.patch new file mode 100644 index 0000000..999f92f --- /dev/null +++ b/packages/haivemind/fix-chat-log-race.patch @@ -0,0 +1,28 @@ +--- a/haivemind_tui.py ++++ b/haivemind_tui.py +@@ -1195,6 +1195,14 @@ + yield TheatrePanel(id="theatre-container") + yield Footer() + ++ def on_mount(self) -> None: ++ app = self.app ++ if ( ++ getattr(app, "_prompt", None) is not None ++ and getattr(app, "_config", None) is not None ++ ): ++ app.start_run(app._prompt, app._config) ++ + + class HaivemindApp(App): + CSS = CSS +@@ -1224,9 +1232,7 @@ + def on_mount(self) -> None: + self.push_screen(MainScreen()) + self.set_interval(0.15, self._tick_spinner) +- if self._prompt is not None and self._config is not None: +- self.start_run(self._prompt, self._config) +- else: ++ if self._prompt is None or self._config is None: + self.push_screen(ConfigScreen()) + + def start_run(self, prompt: str, config: HaivemindConfig) -> None: diff --git a/packages/haivemind/package.nix b/packages/haivemind/package.nix index a479953..76910d0 100644 --- a/packages/haivemind/package.nix +++ b/packages/haivemind/package.nix @@ -24,6 +24,8 @@ python3Packages.buildPythonApplication rec { textual ]; + patches = [ ./fix-chat-log-race.patch ]; + doCheck = false; pythonImportsCheck = [ "haivemind"