From b203ec57acdc8c1bd930c23c459f587626dcfee3 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Fri, 3 Jul 2026 14:04:44 +0200 Subject: [PATCH] Bounce COMMIT_FILES model updates onto the UI thread refreshCommitFilesContext now enqueues the Model.CommitFiles write and CommitFileTreeViewModel.SetTree() call via OnUIThread, instead of running them directly on the worker goroutine that drives async refreshes. This is what makes moving SwitchToDiffFilesController's post-refresh work into Then (previous commit) actually necessary, rather than just future-proofing. Same repo-switch hazard as the FILES bounce, closed the same way: it captures the repo generation before the git work and bounces through onUIThreadUnlessRepoChanged, so the write is dropped if the user switched repos while it was in flight. Co-Authored-By: Claude Sonnet 5 --- pkg/gui/controllers/helpers/refresh_helper.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/pkg/gui/controllers/helpers/refresh_helper.go b/pkg/gui/controllers/helpers/refresh_helper.go index 875f55a30..2fda422bc 100644 --- a/pkg/gui/controllers/helpers/refresh_helper.go +++ b/pkg/gui/controllers/helpers/refresh_helper.go @@ -635,14 +635,17 @@ func (self *RefreshHelper) RefreshAuthors(commits []*models.Commit) { func (self *RefreshHelper) refreshCommitFilesContext() error { from, to := self.c.Contexts().CommitFiles.GetFromAndToForDiff() from, reverse := self.c.Modes().Diffing.GetFromAndReverseArgsForDiff(from) + generation := self.c.State().GetRepoGeneration() files, err := self.c.Git().Loaders.CommitFileLoader.GetFilesInDiff(from, to, reverse) if err != nil { return err } - self.c.Model().CommitFiles = files - self.c.Contexts().CommitFiles.CommitFileTreeViewModel.SetTree() - + self.onUIThreadUnlessRepoChanged(generation, func() error { + self.c.Model().CommitFiles = files + self.c.Contexts().CommitFiles.CommitFileTreeViewModel.SetTree() + return nil + }) self.refreshView(self.c.Contexts().CommitFiles) return nil }