From fca0a2226e52b4e01ba199950a4eb308040c3e11 Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Tue, 29 Sep 2026 19:41:24 +0200 Subject: fix: select a launch's row whatever the keyboard last held A --message launch handed to a window already in use switched the list to the conversation and made the reply row current, and the message pane stayed empty. The same launch into a fresh window worked. selectRowAt() selected the row and then called the view's setCurrentIndex(). QAbstractItemView::setCurrentIndex() asks selectionCommand() what to do with the selection, and with no event to read it answers from QGuiApplication::keyboardModifiers(), which is the modifier state of the last input event the application received rather than anything the user is doing now. With Control in that state the command is a Toggle: the row selected a line earlier was deselected again, onThreadSelected() refused a current row that is not selected, and nothing was loaded. The provisional thread row the recovery selects first went the same way, so the pane never left the placeholder. A fresh process has received no input at all, which is why only a window in use was affected. The current index is now moved through the selection model with NoUpdate, so the selection stays exactly what select() made it. Every caller of selectRowAt() shared the defect (the stale-thread recovery, double-click, the dashboard's message entries and the launch selectors) and every one of them means "select exactly this row", so all of them take the fix. The test puts a window into use, leaves Control as the last modifier the application saw, launches --message for a reply in another thread, and asserts the reply is current, selected, and rendered in the pane. Co-Authored-By: Claude Opus 5.5 --- src/mainwindow.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src/mainwindow.cpp') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 3c94c5c..19bf3c2 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -187,7 +187,19 @@ void MainWindow::selectRowAt(const QModelIndex &index) m_threadView->selectionModel()->select( index, QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows); - m_threadView->setCurrentIndex(index); + // NoUpdate, through the selection model, and never the view's own + // setCurrentIndex(). That one asks selectionCommand() what to do with the + // selection, and with no event to read it answers from + // QGuiApplication::keyboardModifiers(): the modifiers of the LAST input + // event this application saw, not what the user is doing now. With + // Control there, the command is a Toggle, so the row selected just above + // was deselected again, onThreadSelected() refused a current row that is + // not selected, and the pane stayed empty. A fresh window has seen no + // input, which is why a launch into a new window worked and one handed + // to a window in use did not. The selection is already exactly what the + // caller asked for; only the current index moves here. + m_threadView->selectionModel()->setCurrentIndex( + index, QItemSelectionModel::NoUpdate); } /// Selects the top-level thread row at `row`. -- cgit v1.2.3