From 3c0a20f72bbcbeedc67962a4d5560c5f1736a516 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Thu, 25 Jun 2026 13:11:10 +0000 Subject: [PATCH] fix(ui): use GlobalIndex when copying filtered repo list item When the repository list is filtered, list.Model.Index() returns the visible index while SetItem expects the unfiltered index. Using Index() with SetItem duplicated the selected repository in the list. Fixes charmbracelet/soft-serve#510 --- pkg/ui/pages/selection/item.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/ui/pages/selection/item.go b/pkg/ui/pages/selection/item.go index b6b3a02fa..94a3729a6 100644 --- a/pkg/ui/pages/selection/item.go +++ b/pkg/ui/pages/selection/item.go @@ -129,7 +129,6 @@ func (d *ItemDelegate) Spacing() int { return 1 } // Update implements list.ItemDelegate. func (d *ItemDelegate) Update(msg tea.Msg, m *list.Model) tea.Cmd { - idx := m.Index() item, ok := m.SelectedItem().(Item) if !ok { return nil @@ -138,10 +137,11 @@ func (d *ItemDelegate) Update(msg tea.Msg, m *list.Model) tea.Cmd { case tea.KeyPressMsg: switch { case key.Matches(msg, d.common.KeyMap.Copy): - d.copiedIdx = idx + visibleIdx := m.Index() + d.copiedIdx = visibleIdx return tea.Batch( tea.SetClipboard(item.Command()), - m.SetItem(idx, item), + m.SetItem(m.GlobalIndex(), item), ) } }