refactor(ui): use bubblezone/v2 fork

Ayman Bagabas created

Change summary

cmd/soft/browse/browse.go              |  8 +++---
go.mod                                 |  1 
go.sum                                 |  2 +
pkg/ssh/ui.go                          |  8 +++---
pkg/ui/common/common.go                |  2 
pkg/ui/components/selector/selector.go | 26 +++++++++++-----------
pkg/ui/components/tabs/tabs.go         | 12 +++++-----
pkg/ui/pages/repo/repo.go              | 31 ++++++++++++++-------------
8 files changed, 47 insertions(+), 43 deletions(-)

Detailed changes

cmd/soft/browse/browse.go 🔗

@@ -169,10 +169,10 @@ func (m *model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
 		mouse := msg.Mouse()
 		switch mouse.Button {
 		case tea.MouseLeft:
-			// switch {
-			// case m.common.Zone.Get("footer").InBounds(msg):
-			// 	cmds = append(cmds, footer.ToggleFooterCmd)
-			// }
+			switch {
+			case m.common.Zone.Get("footer").InBounds(msg):
+				cmds = append(cmds, footer.ToggleFooterCmd)
+			}
 		}
 	case footer.ToggleFooterMsg:
 		m.footer.SetShowAll(!m.footer.ShowAll())

go.mod 🔗

@@ -57,6 +57,7 @@ require (
 require (
 	github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be // indirect
 	github.com/atotto/clipboard v0.1.4 // indirect
+	github.com/aymanbagabas/bubblezone/v2 v2.0.0-20250319214444-bb232f16d5e3 // indirect
 	github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
 	github.com/aymerick/douceur v0.2.0 // indirect
 	github.com/beorn7/perks v1.0.1 // indirect

go.sum 🔗

@@ -10,6 +10,8 @@ github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be h1:9AeTilPcZAjCFI
 github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be/go.mod h1:ySMOLuWl6zY27l47sB3qLNK6tF2fkHG55UZxx8oIVo4=
 github.com/atotto/clipboard v0.1.4 h1:EH0zSVneZPSuFR11BlR9YppQTVDbh5+16AmcJi4g1z4=
 github.com/atotto/clipboard v0.1.4/go.mod h1:ZY9tmq7sm5xIbd9bOK4onWV4S6X0u6GY7Vn0Yu86PYI=
+github.com/aymanbagabas/bubblezone/v2 v2.0.0-20250319214444-bb232f16d5e3 h1:1z2ihw0YUYUhNmRaavyXvG9ZU/9Tj0vj6sA3z5DFIJ8=
+github.com/aymanbagabas/bubblezone/v2 v2.0.0-20250319214444-bb232f16d5e3/go.mod h1:sJwqZoo/BSKSizmr0pSJ758RuRsnjlkrOaxPtwlWtOs=
 github.com/aymanbagabas/git-module v1.8.4-0.20231101154130-8d27204ac6d2 h1:3w5KT+shE3hzWhORGiu2liVjEoaCEXm9uZP47+Gw4So=
 github.com/aymanbagabas/git-module v1.8.4-0.20231101154130-8d27204ac6d2/go.mod h1:d4gQ7/3/S2sPq4NnKdtAgUOVr6XtLpWFtxyVV5/+76U=
 github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k=

pkg/ssh/ui.go 🔗

@@ -206,10 +206,10 @@ func (ui *UI) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
 		case tea.MouseClickMsg:
 			switch msg.Mouse().Button {
 			case tea.MouseLeft:
-				// switch {
-				// case ui.common.Zone.Get("footer").InBounds(msg):
-				// 	cmds = append(cmds, footer.ToggleFooterCmd)
-				// }
+				switch {
+				case ui.common.Zone.Get("footer").InBounds(msg):
+					cmds = append(cmds, footer.ToggleFooterCmd)
+				}
 			}
 		}
 	case footer.ToggleFooterMsg:

pkg/ui/common/common.go 🔗

@@ -5,6 +5,7 @@ import (
 	"fmt"
 
 	"github.com/alecthomas/chroma/v2/lexers"
+	zone "github.com/aymanbagabas/bubblezone/v2"
 	"github.com/charmbracelet/log"
 	"github.com/charmbracelet/soft-serve/git"
 	"github.com/charmbracelet/soft-serve/pkg/backend"
@@ -12,7 +13,6 @@ import (
 	"github.com/charmbracelet/soft-serve/pkg/ui/keymap"
 	"github.com/charmbracelet/soft-serve/pkg/ui/styles"
 	"github.com/charmbracelet/ssh"
-	zone "github.com/lrstanley/bubblezone"
 )
 
 type contextKey struct {

pkg/ui/components/selector/selector.go 🔗

@@ -238,19 +238,19 @@ func (s *Selector) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
 		case tea.MouseWheelDown:
 			s.CursorDown()
 		case tea.MouseLeft:
-			// curIdx := s.Index()
-			// for i, item := range s.Items() {
-			// 	item, _ := item.(IdentifiableItem)
-			// 	// Check each item to see if it's in bounds.
-			// 	if item != nil && s.common.Zone.Get(item.ID()).InBounds(msg) {
-			// 		if i == curIdx {
-			// 			cmds = append(cmds, s.SelectItemCmd)
-			// 		} else {
-			// 			s.Select(i)
-			// 		}
-			// 		break
-			// 	}
-			// }
+			curIdx := s.Index()
+			for i, item := range s.Items() {
+				item, _ := item.(IdentifiableItem)
+				// Check each item to see if it's in bounds.
+				if item != nil && s.common.Zone.Get(item.ID()).InBounds(msg) {
+					if i == curIdx {
+						cmds = append(cmds, s.SelectItemCmd)
+					} else {
+						s.Select(i)
+					}
+					break
+				}
+			}
 		}
 	case tea.KeyMsg:
 		filterState := s.FilterState()

pkg/ui/components/tabs/tabs.go 🔗

@@ -66,12 +66,12 @@ func (t *Tabs) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
 	case tea.MouseClickMsg:
 		switch msg.Button {
 		case tea.MouseLeft:
-			// for i, tab := range t.tabs {
-			// 	if t.common.Zone.Get(tab).InBounds(msg) {
-			// 		t.activeTab = i
-			// 		cmds = append(cmds, t.activeTabCmd)
-			// 	}
-			// }
+			for i, tab := range t.tabs {
+				if t.common.Zone.Get(tab).InBounds(msg) {
+					t.activeTab = i
+					cmds = append(cmds, t.activeTabCmd)
+				}
+			}
 		}
 	case SelectTabMsg:
 		tab := int(msg)

pkg/ui/pages/repo/repo.go 🔗

@@ -12,6 +12,7 @@ import (
 	"github.com/charmbracelet/soft-serve/git"
 	"github.com/charmbracelet/soft-serve/pkg/proto"
 	"github.com/charmbracelet/soft-serve/pkg/ui/common"
+	"github.com/charmbracelet/soft-serve/pkg/ui/components/footer"
 	"github.com/charmbracelet/soft-serve/pkg/ui/components/selector"
 	"github.com/charmbracelet/soft-serve/pkg/ui/components/statusbar"
 	"github.com/charmbracelet/soft-serve/pkg/ui/components/tabs"
@@ -176,26 +177,26 @@ func (r *Repo) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
 		if cmd != nil {
 			cmds = append(cmds, cmd)
 		}
-		// if r.selectedRepo != nil {
-		// 	urlID := fmt.Sprintf("%s-url", r.selectedRepo.Name())
-		// 	cmd := r.common.CloneCmd(r.common.Config().SSH.PublicURL, r.selectedRepo.Name())
-		// 	if msg, ok := msg.(tea.MouseMsg); ok && r.common.Zone.Get(urlID).InBounds(msg) {
-		// 		cmds = append(cmds, copyCmd(cmd, "Command copied to clipboard"))
-		// 	}
-		// }
+		if r.selectedRepo != nil {
+			urlID := fmt.Sprintf("%s-url", r.selectedRepo.Name())
+			cmd := r.common.CloneCmd(r.common.Config().SSH.PublicURL, r.selectedRepo.Name())
+			if msg, ok := msg.(tea.MouseMsg); ok && r.common.Zone.Get(urlID).InBounds(msg) {
+				cmds = append(cmds, copyCmd(cmd, "Command copied to clipboard"))
+			}
+		}
 		switch msg := msg.(type) {
 		case tea.MouseClickMsg:
 			switch msg.Button {
 			case tea.MouseLeft:
-				// switch {
-				// case r.common.Zone.Get("repo-help").InBounds(msg):
-				// 	cmds = append(cmds, footer.ToggleFooterCmd)
-				// }
+				switch {
+				case r.common.Zone.Get("repo-help").InBounds(msg):
+					cmds = append(cmds, footer.ToggleFooterCmd)
+				}
 			case tea.MouseRight:
-				// switch {
-				// case r.common.Zone.Get("repo-main").InBounds(msg):
-				// 	cmds = append(cmds, goBackCmd)
-				// }
+				switch {
+				case r.common.Zone.Get("repo-main").InBounds(msg):
+					cmds = append(cmds, goBackCmd)
+				}
 			}
 		}
 		switch msg := msg.(type) {