From 82063b476d3d7aa625330d314a0f84633100a467 Mon Sep 17 00:00:00 2001 From: Klement Sekera Date: Tue, 17 Mar 2026 08:17:33 +0100 Subject: [PATCH] thread: fix get_last_msg_idx() crash when called with root index Handle the default QModelIndex (invalid/root) case by starting from the last root node, instead of crashing on None.children. Co-Authored-By: Claude Opus 4.6 --- dodo/thread.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/dodo/thread.py b/dodo/thread.py index ab9c50a..17425c5 100644 --- a/dodo/thread.py +++ b/dodo/thread.py @@ -307,6 +307,10 @@ def _fetch_matching_ids(self) -> set[str]: return set(json.loads(r.stdout)) def get_last_msg_idx(self, parent: QModelIndex=QModelIndex()) -> QModelIndex: + if not parent.isValid(): + if not self.roots: + return QModelIndex() + return self.get_last_msg_idx(self.createIndex(len(self.roots)-1, 0, self.roots[-1])) children = parent.internalPointer().children if children: return self.get_last_msg_idx(self.index(len(children)-1, 0, parent))