From a00d35452fcef8c8bc723ba7045fcae38fe8f315 Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Mon, 7 Sep 2026 10:12:10 +0200 Subject: fix: refresh the current query when the index changes Item 192's second half, answered by the user: indexing is not repainting. The sent copy became findable the moment it was sent and a Sent view already on screen still did not show it, because nothing re-ran the query. The model cannot insert the row optimistically either, since item 170's constraint applies: the query never returned that thread. NotmuchWorker::indexChanged() is emitted at the end of both indexDraftFile() and removeIndexedFile(), the only two entry points that change what a path query would return without any query having run. MainWindow connects it to refreshCurrentQuery(), which covers all three gestures a path view can miss: a sent copy indexed, a draft saved, a draft's entry dropped on send. Wiring only the indexing half would have left a ghost draft row visible in a Drafts view after a send. The signal carries nothing, so it cannot invite an optimistic insert. It is emitted after the database closes, so a refresh reaching notmuch on the next turn of the event loop cannot race the write handle. refreshCurrentQuery() rather than runCurrentQuery(): a send must not clear the selection, the expansions or the undo stack of the window behind the composer. aSentMessageAppearsInASentViewAlreadyOnScreen drives a real send through a worker-backed window, asserts the Sent view is empty first, and asserts the row arrives with no second returnPressed() and no sync. Mutation-checked by disabling the connection. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01FWeBw3UqxpBktSc1AkZ6ir --- src/mainwindow.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/mainwindow.cpp') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index abc7875..41dbe9c 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -2756,6 +2756,19 @@ void MainWindow::wireWorker() connect(m_worker, &NotmuchWorker::threadMessagesResolved, this, &MainWindow::onThreadMessagesResolved); + // Item 192's second half. Indexing a file is not repainting a view: the + // sent copy became findable the instant it was indexed, and a Sent view + // already on screen still did not show it, because nothing re-ran the + // query. Both index entry points report here, so a saved draft, a sent + // copy and a removed draft each reach the list that queries their folder. + // + // refreshCurrentQuery(), NOT runCurrentQuery(): a send must not clear the + // selection, the expansions or the undo stack of the window behind the + // composer. It returns early when no query has run and reconciles rather + // than replacing, so a view of another folder simply sees no change. + connect(m_worker, &NotmuchWorker::indexChanged, + this, &MainWindow::refreshCurrentQuery); + m_workerThread.start(); // Queued behind the thread start, so the completer has real tags as soon -- cgit v1.2.3