50710d3c4a8d64d4c3467c51e0aa83ee27acad6a

Author
Ayman Bagabas <ayman.bagabas@gmail.com>
Committer
Ayman Bagabas <ayman.bagabas@gmail.com>
Date

Message

refactor(ui): use bubblezone/v2 fork

Diff

  1diff --git a/cmd/soft/browse/browse.go b/cmd/soft/browse/browse.go
  2index 10fd15d19f4964e1d6184fb055933561949035ba..4ab28cb2fb84dc30873241d1cf366fe9d73bed35 100644
  3--- a/cmd/soft/browse/browse.go
  4+++ b/cmd/soft/browse/browse.go
  5@@ -169,10 +169,10 @@ func (m *model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
  6 		mouse := msg.Mouse()
  7 		switch mouse.Button {
  8 		case tea.MouseLeft:
  9-			// switch {
 10-			// case m.common.Zone.Get("footer").InBounds(msg):
 11-			// 	cmds = append(cmds, footer.ToggleFooterCmd)
 12-			// }
 13+			switch {
 14+			case m.common.Zone.Get("footer").InBounds(msg):
 15+				cmds = append(cmds, footer.ToggleFooterCmd)
 16+			}
 17 		}
 18 	case footer.ToggleFooterMsg:
 19 		m.footer.SetShowAll(!m.footer.ShowAll())
 20diff --git a/go.mod b/go.mod
 21index f9b88720be7645aeeb57209a25e1338ea633ac9a..be57b5809e22f70b2999fca8c3688a8178bdd212 100644
 22--- a/go.mod
 23+++ b/go.mod
 24@@ -57,6 +57,7 @@ require (
 25 require (
 26 	github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be // indirect
 27 	github.com/atotto/clipboard v0.1.4 // indirect
 28+	github.com/aymanbagabas/bubblezone/v2 v2.0.0-20250319214444-bb232f16d5e3 // indirect
 29 	github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
 30 	github.com/aymerick/douceur v0.2.0 // indirect
 31 	github.com/beorn7/perks v1.0.1 // indirect
 32diff --git a/go.sum b/go.sum
 33index 637ac4dc47b78ce32a54134bf35278415a3a6970..919a7c3772c3b02ad1f01ad250635e548716fd49 100644
 34--- a/go.sum
 35+++ b/go.sum
 36@@ -10,6 +10,8 @@ github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be h1:9AeTilPcZAjCFI
 37 github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be/go.mod h1:ySMOLuWl6zY27l47sB3qLNK6tF2fkHG55UZxx8oIVo4=
 38 github.com/atotto/clipboard v0.1.4 h1:EH0zSVneZPSuFR11BlR9YppQTVDbh5+16AmcJi4g1z4=
 39 github.com/atotto/clipboard v0.1.4/go.mod h1:ZY9tmq7sm5xIbd9bOK4onWV4S6X0u6GY7Vn0Yu86PYI=
 40+github.com/aymanbagabas/bubblezone/v2 v2.0.0-20250319214444-bb232f16d5e3 h1:1z2ihw0YUYUhNmRaavyXvG9ZU/9Tj0vj6sA3z5DFIJ8=
 41+github.com/aymanbagabas/bubblezone/v2 v2.0.0-20250319214444-bb232f16d5e3/go.mod h1:sJwqZoo/BSKSizmr0pSJ758RuRsnjlkrOaxPtwlWtOs=
 42 github.com/aymanbagabas/git-module v1.8.4-0.20231101154130-8d27204ac6d2 h1:3w5KT+shE3hzWhORGiu2liVjEoaCEXm9uZP47+Gw4So=
 43 github.com/aymanbagabas/git-module v1.8.4-0.20231101154130-8d27204ac6d2/go.mod h1:d4gQ7/3/S2sPq4NnKdtAgUOVr6XtLpWFtxyVV5/+76U=
 44 github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k=
 45diff --git a/pkg/ssh/ui.go b/pkg/ssh/ui.go
 46index f58c00398a0ffb4e7ad1f4ae3291093aa475dd9d..89d5ee5f6fe07af8fbd89793319f7d96573e96c8 100644
 47--- a/pkg/ssh/ui.go
 48+++ b/pkg/ssh/ui.go
 49@@ -206,10 +206,10 @@ func (ui *UI) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
 50 		case tea.MouseClickMsg:
 51 			switch msg.Mouse().Button {
 52 			case tea.MouseLeft:
 53-				// switch {
 54-				// case ui.common.Zone.Get("footer").InBounds(msg):
 55-				// 	cmds = append(cmds, footer.ToggleFooterCmd)
 56-				// }
 57+				switch {
 58+				case ui.common.Zone.Get("footer").InBounds(msg):
 59+					cmds = append(cmds, footer.ToggleFooterCmd)
 60+				}
 61 			}
 62 		}
 63 	case footer.ToggleFooterMsg:
 64diff --git a/pkg/ui/common/common.go b/pkg/ui/common/common.go
 65index df16d027c1042c3061b19fe89b655aa3cedf3081..76b6ac488e8f71f21b5fb94c054f137331146bd7 100644
 66--- a/pkg/ui/common/common.go
 67+++ b/pkg/ui/common/common.go
 68@@ -5,6 +5,7 @@ import (
 69 	"fmt"
 70 
 71 	"github.com/alecthomas/chroma/v2/lexers"
 72+	zone "github.com/aymanbagabas/bubblezone/v2"
 73 	"github.com/charmbracelet/log"
 74 	"github.com/charmbracelet/soft-serve/git"
 75 	"github.com/charmbracelet/soft-serve/pkg/backend"
 76@@ -12,7 +13,6 @@ import (
 77 	"github.com/charmbracelet/soft-serve/pkg/ui/keymap"
 78 	"github.com/charmbracelet/soft-serve/pkg/ui/styles"
 79 	"github.com/charmbracelet/ssh"
 80-	zone "github.com/lrstanley/bubblezone"
 81 )
 82 
 83 type contextKey struct {
 84diff --git a/pkg/ui/components/selector/selector.go b/pkg/ui/components/selector/selector.go
 85index 45cb031b8bd9b3ff8c928dbe07edf9b4628f5bf3..ff43816bb5fd6dd749008fee496b014085b5c8a7 100644
 86--- a/pkg/ui/components/selector/selector.go
 87+++ b/pkg/ui/components/selector/selector.go
 88@@ -238,19 +238,19 @@ func (s *Selector) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
 89 		case tea.MouseWheelDown:
 90 			s.CursorDown()
 91 		case tea.MouseLeft:
 92-			// curIdx := s.Index()
 93-			// for i, item := range s.Items() {
 94-			// 	item, _ := item.(IdentifiableItem)
 95-			// 	// Check each item to see if it's in bounds.
 96-			// 	if item != nil && s.common.Zone.Get(item.ID()).InBounds(msg) {
 97-			// 		if i == curIdx {
 98-			// 			cmds = append(cmds, s.SelectItemCmd)
 99-			// 		} else {
100-			// 			s.Select(i)
101-			// 		}
102-			// 		break
103-			// 	}
104-			// }
105+			curIdx := s.Index()
106+			for i, item := range s.Items() {
107+				item, _ := item.(IdentifiableItem)
108+				// Check each item to see if it's in bounds.
109+				if item != nil && s.common.Zone.Get(item.ID()).InBounds(msg) {
110+					if i == curIdx {
111+						cmds = append(cmds, s.SelectItemCmd)
112+					} else {
113+						s.Select(i)
114+					}
115+					break
116+				}
117+			}
118 		}
119 	case tea.KeyMsg:
120 		filterState := s.FilterState()
121diff --git a/pkg/ui/components/tabs/tabs.go b/pkg/ui/components/tabs/tabs.go
122index 2756595a361de3a4b2505bb86311ba8a7adfbd27..51aec590e5c06da697408cb89ef2ffbb586e5853 100644
123--- a/pkg/ui/components/tabs/tabs.go
124+++ b/pkg/ui/components/tabs/tabs.go
125@@ -66,12 +66,12 @@ func (t *Tabs) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
126 	case tea.MouseClickMsg:
127 		switch msg.Button {
128 		case tea.MouseLeft:
129-			// for i, tab := range t.tabs {
130-			// 	if t.common.Zone.Get(tab).InBounds(msg) {
131-			// 		t.activeTab = i
132-			// 		cmds = append(cmds, t.activeTabCmd)
133-			// 	}
134-			// }
135+			for i, tab := range t.tabs {
136+				if t.common.Zone.Get(tab).InBounds(msg) {
137+					t.activeTab = i
138+					cmds = append(cmds, t.activeTabCmd)
139+				}
140+			}
141 		}
142 	case SelectTabMsg:
143 		tab := int(msg)
144diff --git a/pkg/ui/pages/repo/repo.go b/pkg/ui/pages/repo/repo.go
145index b68c8084a359087e223a1c082aaa1fdfdce36f82..5aba643528281850c17a85e8faef09c5b4dd9b6e 100644
146--- a/pkg/ui/pages/repo/repo.go
147+++ b/pkg/ui/pages/repo/repo.go
148@@ -12,6 +12,7 @@ import (
149 	"github.com/charmbracelet/soft-serve/git"
150 	"github.com/charmbracelet/soft-serve/pkg/proto"
151 	"github.com/charmbracelet/soft-serve/pkg/ui/common"
152+	"github.com/charmbracelet/soft-serve/pkg/ui/components/footer"
153 	"github.com/charmbracelet/soft-serve/pkg/ui/components/selector"
154 	"github.com/charmbracelet/soft-serve/pkg/ui/components/statusbar"
155 	"github.com/charmbracelet/soft-serve/pkg/ui/components/tabs"
156@@ -176,26 +177,26 @@ func (r *Repo) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
157 		if cmd != nil {
158 			cmds = append(cmds, cmd)
159 		}
160-		// if r.selectedRepo != nil {
161-		// 	urlID := fmt.Sprintf("%s-url", r.selectedRepo.Name())
162-		// 	cmd := r.common.CloneCmd(r.common.Config().SSH.PublicURL, r.selectedRepo.Name())
163-		// 	if msg, ok := msg.(tea.MouseMsg); ok && r.common.Zone.Get(urlID).InBounds(msg) {
164-		// 		cmds = append(cmds, copyCmd(cmd, "Command copied to clipboard"))
165-		// 	}
166-		// }
167+		if r.selectedRepo != nil {
168+			urlID := fmt.Sprintf("%s-url", r.selectedRepo.Name())
169+			cmd := r.common.CloneCmd(r.common.Config().SSH.PublicURL, r.selectedRepo.Name())
170+			if msg, ok := msg.(tea.MouseMsg); ok && r.common.Zone.Get(urlID).InBounds(msg) {
171+				cmds = append(cmds, copyCmd(cmd, "Command copied to clipboard"))
172+			}
173+		}
174 		switch msg := msg.(type) {
175 		case tea.MouseClickMsg:
176 			switch msg.Button {
177 			case tea.MouseLeft:
178-				// switch {
179-				// case r.common.Zone.Get("repo-help").InBounds(msg):
180-				// 	cmds = append(cmds, footer.ToggleFooterCmd)
181-				// }
182+				switch {
183+				case r.common.Zone.Get("repo-help").InBounds(msg):
184+					cmds = append(cmds, footer.ToggleFooterCmd)
185+				}
186 			case tea.MouseRight:
187-				// switch {
188-				// case r.common.Zone.Get("repo-main").InBounds(msg):
189-				// 	cmds = append(cmds, goBackCmd)
190-				// }
191+				switch {
192+				case r.common.Zone.Get("repo-main").InBounds(msg):
193+					cmds = append(cmds, goBackCmd)
194+				}
195 			}
196 		}
197 		switch msg := msg.(type) {