From 7d1d90ae4d319f8f1bb54f99e46c2bae20ff66e8 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Thu, 21 May 2026 11:54:18 +0200 Subject: [PATCH] Preserve empty Worktrees slice when worktree list fails to load If `git worktree list` fails, we want the Worktrees model to fall back to an empty slice so callers iterating over it stay correct. The error branch was setting it to `[]`, but the line below unconditionally overwrote it with the nil `worktrees` value from the failed call. Use an else branch so the empty-slice fallback actually sticks. Co-Authored-By: Claude Opus 4.7 (1M context) --- pkg/gui/controllers/helpers/refresh_helper.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/gui/controllers/helpers/refresh_helper.go b/pkg/gui/controllers/helpers/refresh_helper.go index 2922b4403..d27b38feb 100644 --- a/pkg/gui/controllers/helpers/refresh_helper.go +++ b/pkg/gui/controllers/helpers/refresh_helper.go @@ -724,9 +724,9 @@ func (self *RefreshHelper) loadWorktrees() { if err != nil { self.c.Log.Error(err) self.c.Model().Worktrees = []*models.Worktree{} + } else { + self.c.Model().Worktrees = worktrees } - - self.c.Model().Worktrees = worktrees } func (self *RefreshHelper) refreshWorktrees() {