feat: upgrade bubbletea, bubbles, and lipgloss to v2 (#118)
SonarQube Scan / SonarQube Trigger (push) Successful in 3m44s
Docker Build and Push / Run Tests (push) Successful in 2m2s
Docker Build and Push / Build and Push Docker Image (push) Successful in 17m52s

Co-authored-by: Renovate-Clanker <renovate-bot@fossy.my.id>
Reviewed-on: #118
This commit was merged in pull request #118.
This commit is contained in:
2026-03-20 14:28:43 +07:00
parent 9dc3711875
commit f20e5668ff
15 changed files with 271 additions and 224 deletions
+5 -5
View File
@@ -3,14 +3,14 @@ package interaction
import (
"strings"
"github.com/charmbracelet/bubbles/textinput"
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/lipgloss"
"charm.land/bubbles/v2/textinput"
tea "charm.land/bubbletea/v2"
"charm.land/lipgloss/v2"
)
func (m *model) comingSoonUpdate(msg tea.KeyMsg) (tea.Model, tea.Cmd) {
func (m *model) comingSoonUpdate(msg tea.KeyPressMsg) (tea.Model, tea.Cmd) {
m.showingComingSoon = false
return m, tea.Batch(tea.ClearScreen, textinput.Blink)
return m, textinput.Blink
}
func (m *model) comingSoonView() string {
+8 -8
View File
@@ -4,10 +4,10 @@ import (
"strings"
"time"
"github.com/charmbracelet/bubbles/key"
"github.com/charmbracelet/bubbles/textinput"
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/lipgloss"
"charm.land/bubbles/v2/key"
"charm.land/bubbles/v2/textinput"
tea "charm.land/bubbletea/v2"
"charm.land/lipgloss/v2"
)
func (m *model) handleCommandSelection(item commandItem) (tea.Model, tea.Cmd) {
@@ -17,24 +17,24 @@ func (m *model) handleCommandSelection(item commandItem) (tea.Model, tea.Cmd) {
m.editingSlug = true
m.slugInput.SetValue(m.interaction.slug.String())
m.slugInput.Focus()
return m, tea.Batch(tea.ClearScreen, textinput.Blink)
return m, textinput.Blink
case "tunnel-type":
m.showingCommands = false
m.showingComingSoon = true
return m, tea.Batch(tickCmd(5*time.Second), tea.ClearScreen, textinput.Blink)
return m, tickCmd(5 * time.Second)
default:
m.showingCommands = false
return m, nil
}
}
func (m *model) commandsUpdate(msg tea.KeyMsg) (tea.Model, tea.Cmd) {
func (m *model) commandsUpdate(msg tea.KeyPressMsg) (tea.Model, tea.Cmd) {
var cmd tea.Cmd
switch {
case key.Matches(msg, m.keymap.quit), msg.String() == "esc":
m.showingCommands = false
return m, tea.Batch(tea.ClearScreen, textinput.Blink)
return m, textinput.Blink
case msg.String() == "enter":
selectedItem := m.commandList.SelectedItem()
if selectedItem != nil {
+7 -7
View File
@@ -4,20 +4,20 @@ import (
"fmt"
"strings"
"github.com/charmbracelet/bubbles/key"
"github.com/charmbracelet/bubbles/textinput"
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/lipgloss"
"charm.land/bubbles/v2/key"
"charm.land/bubbles/v2/textinput"
tea "charm.land/bubbletea/v2"
"charm.land/lipgloss/v2"
)
func (m *model) dashboardUpdate(msg tea.KeyMsg) (tea.Model, tea.Cmd) {
func (m *model) dashboardUpdate(msg tea.KeyPressMsg) (tea.Model, tea.Cmd) {
switch {
case key.Matches(msg, m.keymap.quit):
m.quitting = true
return m, tea.Batch(tea.ClearScreen, textinput.Blink, tea.Quit)
return m, tea.Batch(textinput.Blink, tea.Quit)
case key.Matches(msg, m.keymap.command):
m.showingCommands = true
return m, tea.Batch(tea.ClearScreen, textinput.Blink)
return m, textinput.Blink
}
return m, nil
}
+54 -30
View File
@@ -9,13 +9,12 @@ import (
"tunnel_pls/session/slug"
"tunnel_pls/types"
"github.com/charmbracelet/bubbles/help"
"github.com/charmbracelet/bubbles/key"
"github.com/charmbracelet/bubbles/list"
"github.com/charmbracelet/bubbles/textinput"
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/lipgloss"
"github.com/muesli/termenv"
"charm.land/bubbles/v2/help"
"charm.land/bubbles/v2/key"
"charm.land/bubbles/v2/list"
"charm.land/bubbles/v2/textinput"
tea "charm.land/bubbletea/v2"
"github.com/charmbracelet/colorprofile"
"golang.org/x/crypto/ssh"
)
@@ -54,6 +53,8 @@ type interaction struct {
cancel context.CancelFunc
mode types.InteractiveMode
programMu sync.Mutex
width int
height int
}
func (i *interaction) SetMode(m types.InteractiveMode) {
@@ -72,8 +73,14 @@ func (i *interaction) Send(message string) error {
return nil
}
func (i *interaction) SetWH(w, h int) {
if i.program != nil {
i.program.Send(tea.WindowSizeMsg{
i.programMu.Lock()
i.width = w
i.height = h
prog := i.program
i.programMu.Unlock()
if prog != nil {
prog.Send(tea.WindowSizeMsg{
Width: w,
Height: h,
})
@@ -120,7 +127,7 @@ func (m *model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
switch msg := msg.(type) {
case tickMsg:
m.showingComingSoon = false
return m, tea.Batch(tea.ClearScreen, textinput.Blink)
return m, textinput.Blink
case tea.WindowSizeMsg:
m.width = msg.Width
@@ -129,17 +136,17 @@ func (m *model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
m.commandList.SetHeight(msg.Height - 4)
if msg.Width < 80 {
m.slugInput.Width = msg.Width - 10
m.slugInput.SetWidth(msg.Width - 10)
} else {
m.slugInput.Width = 50
m.slugInput.SetWidth(50)
}
return m, nil
case tea.QuitMsg:
m.quitting = true
return m, tea.Batch(tea.ClearScreen, textinput.Blink, tea.Quit)
return m, tea.Batch(textinput.Blink, tea.Quit)
case tea.KeyMsg:
case tea.KeyPressMsg:
if m.showingComingSoon {
return m.comingSoonUpdate(msg)
}
@@ -159,36 +166,43 @@ func (m *model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
}
func (i *interaction) Redraw() {
if i.program != nil {
i.program.Send(tea.ClearScreen())
i.programMu.Lock()
prog := i.program
w, h := i.width, i.height
i.programMu.Unlock()
if prog != nil {
prog.Send(tea.WindowSizeMsg{Width: w, Height: h})
}
}
func (m *model) View() string {
func (m *model) View() tea.View {
if m.quitting {
return ""
return tea.NewView("")
}
if m.showingComingSoon {
return m.comingSoonView()
return tea.NewView(m.comingSoonView())
}
if m.editingSlug {
return m.slugView()
return tea.NewView(m.slugView())
}
if m.showingCommands {
return m.commandsView()
return tea.NewView(m.commandsView())
}
return m.dashboardView()
v := tea.NewView(m.dashboardView())
v.AltScreen = true
v.MouseMode = tea.MouseModeCellMotion
return v
}
func (i *interaction) Start() {
if i.mode == types.InteractiveModeHEADLESS {
return
}
lipgloss.SetColorProfile(termenv.TrueColor)
protocol := "http"
if i.config.TLSEnabled() {
@@ -216,7 +230,7 @@ func (i *interaction) Start() {
ti := textinput.New()
ti.Placeholder = "my-custom-slug"
ti.CharLimit = 20
ti.Width = 50
ti.SetWidth(50)
m := &model{
randomizer: i.randomizer,
@@ -245,19 +259,29 @@ func (i *interaction) Start() {
}
i.programMu.Lock()
i.program = tea.NewProgram(
m,
w, h := i.width, i.height
i.programMu.Unlock()
opts := []tea.ProgramOption{
tea.WithInput(i.channel),
tea.WithOutput(i.channel),
tea.WithAltScreen(),
tea.WithMouseCellMotion(),
tea.WithColorProfile(colorprofile.TrueColor),
tea.WithoutSignals(),
tea.WithoutSignalHandler(),
tea.WithFPS(30),
)
tea.WithEnvironment([]string{"TERM=xterm-256color", "COLORTERM=truecolor"}),
}
if w > 0 && h > 0 {
opts = append(opts, tea.WithWindowSize(w, h))
}
prog := tea.NewProgram(m, opts...)
i.programMu.Lock()
i.program = prog
i.programMu.Unlock()
_, err := i.program.Run()
_, err := prog.Run()
if err != nil {
log.Printf("Cannot close tea: %s \n", err)
}
+64 -64
View File
@@ -9,10 +9,10 @@ import (
"time"
"tunnel_pls/types"
"github.com/charmbracelet/bubbles/key"
"github.com/charmbracelet/bubbles/list"
"github.com/charmbracelet/bubbles/textinput"
tea "github.com/charmbracelet/bubbletea"
"charm.land/bubbles/v2/key"
"charm.land/bubbles/v2/list"
"charm.land/bubbles/v2/textinput"
tea "charm.land/bubbletea/v2"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
"golang.org/x/crypto/ssh"
@@ -459,7 +459,7 @@ func TestInteraction_Start(t *testing.T) {
mockInteraction := New(mockRandom, mockConfig, mockSlug, mockForwarder, mockSessionRegistry, "user", mockCloser.Close)
mockInteraction.SetMode(tt.mode)
mockConfig.On("Domain").Return("tunnl.live")
mockConfig.On("Domain").Return("tunel.live")
mockConfig.On("TLSEnabled").Return(tt.tlsEnabled)
mockForwarder.On("TunnelType").Return(tt.tunnelType)
mockForwarder.On("ForwardedPort").Return(tt.port)
@@ -525,7 +525,7 @@ func TestModel_Update(t *testing.T) {
m := &model{
randomizer: mockRandom,
domain: "tunnl.live",
domain: "tunel.live",
protocol: "http",
tunnelType: types.TunnelTypeHTTP,
port: 8080,
@@ -622,7 +622,7 @@ func TestModel_View(t *testing.T) {
m := &model{
randomizer: mockRandom,
domain: "tunnl.live",
domain: "tunel.live",
protocol: "http",
tunnelType: types.TunnelTypeHTTP,
port: 8080,
@@ -651,9 +651,9 @@ func TestModel_View(t *testing.T) {
view := m.View()
if tt.expectedEmpty {
assert.Empty(t, view)
assert.Empty(t, view.Content)
} else {
assert.NotEmpty(t, view)
assert.NotEmpty(t, view.Content)
}
})
}
@@ -694,7 +694,7 @@ func TestInteraction_Integration(t *testing.T) {
func TestModel_Update_KeyMessages(t *testing.T) {
tests := []struct {
name string
key tea.KeyMsg
key tea.KeyPressMsg
showingComingSoon bool
editingSlug bool
showingCommands bool
@@ -702,25 +702,25 @@ func TestModel_Update_KeyMessages(t *testing.T) {
}{
{
name: "key press while showing coming soon",
key: tea.KeyMsg{Type: tea.KeyEnter},
key: tea.KeyPressMsg{Code: tea.KeyEnter},
showingComingSoon: true,
description: "should call comingSoonUpdate",
},
{
name: "key press while editing slug",
key: tea.KeyMsg{Type: tea.KeyEnter},
key: tea.KeyPressMsg{Code: tea.KeyEnter},
editingSlug: true,
description: "should call slugUpdate",
},
{
name: "key press while showing commands",
key: tea.KeyMsg{Type: tea.KeyEnter},
key: tea.KeyPressMsg{Code: tea.KeyEnter},
showingCommands: true,
description: "should call commandsUpdate",
},
{
name: "key press in dashboard view",
key: tea.KeyMsg{Type: tea.KeyRunes, Runes: []rune{'c'}},
key: tea.KeyPressMsg{Code: 'c', Text: "c"},
description: "should call dashboardUpdate",
},
}
@@ -742,7 +742,7 @@ func TestModel_Update_KeyMessages(t *testing.T) {
m := &model{
randomizer: mockRandom,
domain: "tunnl.live",
domain: "tunel.live",
protocol: "http",
tunnelType: types.TunnelTypeHTTP,
port: 8080,
@@ -777,7 +777,7 @@ func TestModel_SlugUpdate(t *testing.T) {
tests := []struct {
name string
tunnelType types.TunnelType
keyMsg tea.KeyMsg
keyMsg tea.KeyPressMsg
inputValue string
setupMocks func(*MockSessionRegistry, *MockSlug, *MockRandom)
expectedEdit bool
@@ -787,21 +787,21 @@ func TestModel_SlugUpdate(t *testing.T) {
{
name: "escape key cancels editing",
tunnelType: types.TunnelTypeHTTP,
keyMsg: tea.KeyMsg{Type: tea.KeyEsc},
keyMsg: tea.KeyPressMsg{Code: tea.KeyEsc},
setupMocks: func(msr *MockSessionRegistry, ms *MockSlug, mr *MockRandom) {},
expectedEdit: false,
},
{
name: "ctrl+c cancels editing",
tunnelType: types.TunnelTypeHTTP,
keyMsg: tea.KeyMsg{Type: tea.KeyCtrlC},
keyMsg: tea.KeyPressMsg{Code: 'c', Mod: tea.ModCtrl},
setupMocks: func(msr *MockSessionRegistry, ms *MockSlug, mr *MockRandom) {},
expectedEdit: false,
},
{
name: "enter key saves valid slug",
tunnelType: types.TunnelTypeHTTP,
keyMsg: tea.KeyMsg{Type: tea.KeyEnter},
keyMsg: tea.KeyPressMsg{Code: tea.KeyEnter},
inputValue: "my-custom-slug",
setupMocks: func(msr *MockSessionRegistry, ms *MockSlug, mr *MockRandom) {
ms.On("String").Return("old-slug")
@@ -816,7 +816,7 @@ func TestModel_SlugUpdate(t *testing.T) {
{
name: "enter key with error shows error message",
tunnelType: types.TunnelTypeHTTP,
keyMsg: tea.KeyMsg{Type: tea.KeyEnter},
keyMsg: tea.KeyPressMsg{Code: tea.KeyEnter},
inputValue: "invalid",
setupMocks: func(msr *MockSessionRegistry, ms *MockSlug, mr *MockRandom) {
ms.On("String").Return("old-slug")
@@ -831,7 +831,7 @@ func TestModel_SlugUpdate(t *testing.T) {
{
name: "ctrl+r generates random slug",
tunnelType: types.TunnelTypeHTTP,
keyMsg: tea.KeyMsg{Type: tea.KeyCtrlR},
keyMsg: tea.KeyPressMsg{Code: 'r', Mod: tea.ModCtrl},
setupMocks: func(msr *MockSessionRegistry, ms *MockSlug, mr *MockRandom) {
mr.On("String", 20).Return("random-generated-slug", nil)
},
@@ -841,7 +841,7 @@ func TestModel_SlugUpdate(t *testing.T) {
{
name: "ctrl+r with error does nothing",
tunnelType: types.TunnelTypeHTTP,
keyMsg: tea.KeyMsg{Type: tea.KeyCtrlR},
keyMsg: tea.KeyPressMsg{Code: 'r', Mod: tea.ModCtrl},
setupMocks: func(msr *MockSessionRegistry, ms *MockSlug, mr *MockRandom) {
mr.On("String", 20).Return("", assert.AnError)
},
@@ -850,14 +850,14 @@ func TestModel_SlugUpdate(t *testing.T) {
{
name: "regular key updates input",
tunnelType: types.TunnelTypeHTTP,
keyMsg: tea.KeyMsg{Type: tea.KeyRunes, Runes: []rune{'a'}},
keyMsg: tea.KeyPressMsg{Code: 'a', Text: "a"},
setupMocks: func(msr *MockSessionRegistry, ms *MockSlug, mr *MockRandom) {},
expectedEdit: true,
},
{
name: "tcp tunnel exits editing immediately",
tunnelType: types.TunnelTypeTCP,
keyMsg: tea.KeyMsg{Type: tea.KeyRunes, Runes: []rune{'a'}},
keyMsg: tea.KeyPressMsg{Code: 'a', Text: "a"},
setupMocks: func(msr *MockSessionRegistry, ms *MockSlug, mr *MockRandom) {},
expectedEdit: false,
},
@@ -879,7 +879,7 @@ func TestModel_SlugUpdate(t *testing.T) {
m := &model{
randomizer: mockRandom,
domain: "tunnl.live",
domain: "tunel.live",
protocol: "http",
tunnelType: tt.tunnelType,
port: 8080,
@@ -986,7 +986,7 @@ func TestModel_SlugView(t *testing.T) {
m := &model{
randomizer: mockRandom,
domain: "tunnl.live",
domain: "tunel.live",
protocol: "http",
tunnelType: tt.tunnelType,
port: 8080,
@@ -1006,19 +1006,19 @@ func TestModel_SlugView(t *testing.T) {
func TestModel_ComingSoonUpdate(t *testing.T) {
tests := []struct {
name string
keyMsg tea.KeyMsg
keyMsg tea.KeyPressMsg
}{
{
name: "any key dismisses coming soon",
keyMsg: tea.KeyMsg{Type: tea.KeyEnter},
keyMsg: tea.KeyPressMsg{Code: tea.KeyEnter},
},
{
name: "escape key dismisses",
keyMsg: tea.KeyMsg{Type: tea.KeyEsc},
keyMsg: tea.KeyPressMsg{Code: tea.KeyEsc},
},
{
name: "space key dismisses",
keyMsg: tea.KeyMsg{Type: tea.KeySpace},
keyMsg: tea.KeyPressMsg{Code: tea.KeySpace},
},
}
@@ -1097,7 +1097,7 @@ func TestModel_ComingSoonView(t *testing.T) {
func TestModel_CommandsUpdate(t *testing.T) {
tests := []struct {
name string
keyMsg tea.KeyMsg
keyMsg tea.KeyPressMsg
selectedItem list.Item
expectCommands bool
expectEditSlug bool
@@ -1105,31 +1105,31 @@ func TestModel_CommandsUpdate(t *testing.T) {
}{
{
name: "escape key closes commands",
keyMsg: tea.KeyMsg{Type: tea.KeyEsc},
keyMsg: tea.KeyPressMsg{Code: tea.KeyEsc},
expectCommands: false,
},
{
name: "q key closes commands",
keyMsg: tea.KeyMsg{Type: tea.KeyRunes, Runes: []rune{'q'}},
keyMsg: tea.KeyPressMsg{Code: 'q', Text: "q"},
expectCommands: false,
},
{
name: "enter on slug command starts editing",
keyMsg: tea.KeyMsg{Type: tea.KeyEnter},
keyMsg: tea.KeyPressMsg{Code: tea.KeyEnter},
selectedItem: commandItem{name: "slug", desc: "Set custom subdomain"},
expectCommands: false,
expectEditSlug: true,
},
{
name: "enter on tunnel-type shows coming soon",
keyMsg: tea.KeyMsg{Type: tea.KeyEnter},
keyMsg: tea.KeyPressMsg{Code: tea.KeyEnter},
selectedItem: commandItem{name: "tunnel-type", desc: "Change tunnel type"},
expectCommands: false,
expectComingSoon: true,
},
{
name: "arrow key navigates list",
keyMsg: tea.KeyMsg{Type: tea.KeyDown},
keyMsg: tea.KeyPressMsg{Code: tea.KeyDown},
expectCommands: true,
},
}
@@ -1261,28 +1261,28 @@ func TestModel_CommandsView(t *testing.T) {
func TestModel_DashboardUpdate(t *testing.T) {
tests := []struct {
name string
keyMsg tea.KeyMsg
keyMsg tea.KeyPressMsg
expectQuit bool
expectCommands bool
}{
{
name: "q key quits",
keyMsg: tea.KeyMsg{Type: tea.KeyRunes, Runes: []rune{'q'}},
keyMsg: tea.KeyPressMsg{Code: 'q', Text: "q"},
expectQuit: true,
},
{
name: "ctrl+c quits",
keyMsg: tea.KeyMsg{Type: tea.KeyCtrlC},
keyMsg: tea.KeyPressMsg{Code: 'c', Mod: tea.ModCtrl},
expectQuit: true,
},
{
name: "c key opens commands",
keyMsg: tea.KeyMsg{Type: tea.KeyRunes, Runes: []rune{'c'}},
keyMsg: tea.KeyPressMsg{Code: 'c', Text: "c"},
expectCommands: true,
},
{
name: "other keys do nothing",
keyMsg: tea.KeyMsg{Type: tea.KeyRunes, Runes: []rune{'x'}},
keyMsg: tea.KeyPressMsg{Code: 'x', Text: "x"},
},
}
@@ -1398,7 +1398,7 @@ func TestModel_DashboardView(t *testing.T) {
m := &model{
randomizer: mockRandom,
domain: "tunnl.live",
domain: "tunel.live",
protocol: tt.protocol,
tunnelType: tt.tunnelType,
port: tt.port,
@@ -1550,8 +1550,8 @@ func TestBuildURL(t *testing.T) {
name: "http url",
protocol: "http",
subdomain: "test",
domain: "tunnl.live",
expected: "http://test.tunnl.live",
domain: "tunel.live",
expected: "http://test.tunel.live",
},
{
name: "https url",
@@ -1564,8 +1564,8 @@ func TestBuildURL(t *testing.T) {
name: "custom subdomain",
protocol: "http",
subdomain: "my-custom-slug",
domain: "tunnl.live",
expected: "http://my-custom-slug.tunnl.live",
domain: "tunel.live",
expected: "http://my-custom-slug.tunel.live",
},
}
@@ -1712,30 +1712,30 @@ func TestModel_GetTunnelURL(t *testing.T) {
tunnelType: types.TunnelTypeHTTP,
protocol: "http",
slug: "my-app",
domain: "tunnl.live",
expected: "http://my-app.tunnl.live",
domain: "tunel.live",
expected: "http://my-app.tunel.live",
},
{
name: "https tunnel",
tunnelType: types.TunnelTypeHTTP,
protocol: "https",
slug: "secure-app",
domain: "tunnl.live",
expected: "https://secure-app.tunnl.live",
domain: "tunel.live",
expected: "https://secure-app.tunel.live",
},
{
name: "tcp tunnel",
tunnelType: types.TunnelTypeTCP,
domain: "tunnl.live",
domain: "tunel.live",
port: 8080,
expected: "tcp://tunnl.live:8080",
expected: "tcp://tunel.live:8080",
},
{
name: "tcp tunnel with different port",
tunnelType: types.TunnelTypeTCP,
domain: "tunnl.live",
domain: "tunel.live",
port: 3306,
expected: "tcp://tunnl.live:3306",
expected: "tcp://tunel.live:3306",
},
}
@@ -1797,28 +1797,28 @@ func TestInteraction_Start_Interactive(t *testing.T) {
tlsEnabled: false,
tunnelType: types.TunnelTypeHTTP,
port: 8080,
domain: "tunnl.live",
domain: "tunel.live",
},
{
name: "interactive mode with https",
tlsEnabled: true,
tunnelType: types.TunnelTypeHTTP,
port: 8443,
domain: "secure.tunnl.live",
domain: "secure.tunel.live",
},
{
name: "interactive mode with tcp",
tlsEnabled: false,
tunnelType: types.TunnelTypeTCP,
port: 3306,
domain: "db.tunnl.live",
domain: "db.tunel.live",
},
{
name: "interactive mode with tcp and tls enabled",
tlsEnabled: true,
tunnelType: types.TunnelTypeTCP,
port: 5432,
domain: "postgres.tunnl.live",
domain: "postgres.tunel.live",
},
}
@@ -1901,7 +1901,7 @@ func TestInteraction_Start_ProtocolSelection(t *testing.T) {
mockSessionRegistry := &MockSessionRegistry{}
closeFunc := func() error { return nil }
mockConfig.On("Domain").Return("tunnl.live")
mockConfig.On("Domain").Return("tunel.live")
mockConfig.On("TLSEnabled").Return(tt.tlsEnabled)
mockForwarder.On("TunnelType").Return(types.TunnelTypeHTTP)
mockForwarder.On("ForwardedPort").Return(uint16(8080))
@@ -1966,7 +1966,7 @@ func TestInteraction_Stop(t *testing.T) {
i := mockInteraction.(*interaction)
if tt.setupProgram {
mockConfig.On("Domain").Return("tunnl.live")
mockConfig.On("Domain").Return("tunel.live")
mockConfig.On("TLSEnabled").Return(false)
mockForwarder.On("TunnelType").Return(types.TunnelTypeHTTP)
mockForwarder.On("ForwardedPort").Return(uint16(8080))
@@ -2007,7 +2007,7 @@ func TestInteraction_Start_CommandListSetup(t *testing.T) {
mockSessionRegistry := &MockSessionRegistry{}
closeFunc := func() error { return nil }
mockConfig.On("Domain").Return("tunnl.live")
mockConfig.On("Domain").Return("tunel.live")
mockConfig.On("TLSEnabled").Return(false)
mockForwarder.On("TunnelType").Return(types.TunnelTypeHTTP)
mockForwarder.On("ForwardedPort").Return(uint16(8080))
@@ -2043,7 +2043,7 @@ func TestInteraction_Start_TextInputSetup(t *testing.T) {
mockSessionRegistry := &MockSessionRegistry{}
closeFunc := func() error { return nil }
mockConfig.On("Domain").Return("tunnl.live")
mockConfig.On("Domain").Return("tunel.live")
mockConfig.On("TLSEnabled").Return(false)
mockForwarder.On("TunnelType").Return(types.TunnelTypeHTTP)
mockForwarder.On("ForwardedPort").Return(uint16(8080))
@@ -2107,7 +2107,7 @@ func TestInteraction_Start_CleanupOnExit(t *testing.T) {
}
}
mockConfig.On("Domain").Return("tunnl.live")
mockConfig.On("Domain").Return("tunel.live")
mockConfig.On("TLSEnabled").Return(false)
mockForwarder.On("TunnelType").Return(types.TunnelTypeHTTP)
mockForwarder.On("ForwardedPort").Return(uint16(8080))
@@ -2171,7 +2171,7 @@ func TestInteraction_Start_WithDifferentChannels(t *testing.T) {
mockSessionRegistry := &MockSessionRegistry{}
closeFunc := func() error { return nil }
mockConfig.On("Domain").Return("tunnl.live")
mockConfig.On("Domain").Return("tunel.live")
mockConfig.On("TLSEnabled").Return(false)
mockForwarder.On("TunnelType").Return(types.TunnelTypeHTTP)
mockForwarder.On("ForwardedPort").Return(uint16(8080))
+6 -6
View File
@@ -6,11 +6,11 @@ import (
"tunnel_pls/internal/random"
"tunnel_pls/types"
"github.com/charmbracelet/bubbles/help"
"github.com/charmbracelet/bubbles/key"
"github.com/charmbracelet/bubbles/list"
"github.com/charmbracelet/bubbles/textinput"
tea "github.com/charmbracelet/bubbletea"
"charm.land/bubbles/v2/help"
"charm.land/bubbles/v2/key"
"charm.land/bubbles/v2/list"
"charm.land/bubbles/v2/textinput"
tea "charm.land/bubbletea/v2"
)
type commandItem struct {
@@ -77,7 +77,7 @@ type keymap struct {
type tickMsg time.Time
func (m *model) Init() tea.Cmd {
return tea.Batch(textinput.Blink, tea.WindowSize())
return tea.Batch(textinput.Blink, tea.RequestWindowSize)
}
func getResponsiveWidth(screenWidth, padding, minWidth, maxWidth int) int {
+8 -8
View File
@@ -5,26 +5,26 @@ import (
"strings"
"tunnel_pls/types"
"github.com/charmbracelet/bubbles/key"
"github.com/charmbracelet/bubbles/textinput"
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/lipgloss"
"charm.land/bubbles/v2/key"
"charm.land/bubbles/v2/textinput"
tea "charm.land/bubbletea/v2"
"charm.land/lipgloss/v2"
)
func (m *model) slugUpdate(msg tea.KeyMsg) (tea.Model, tea.Cmd) {
func (m *model) slugUpdate(msg tea.KeyPressMsg) (tea.Model, tea.Cmd) {
var cmd tea.Cmd
if m.tunnelType != types.TunnelTypeHTTP {
m.editingSlug = false
m.slugError = ""
return m, tea.Batch(tea.ClearScreen, textinput.Blink)
return m, textinput.Blink
}
switch msg.String() {
case "esc", "ctrl+c":
m.editingSlug = false
m.slugError = ""
return m, tea.Batch(tea.ClearScreen, textinput.Blink)
return m, textinput.Blink
case "enter":
inputValue := m.slugInput.Value()
if err := m.interaction.sessionRegistry.Update(m.interaction.user, types.SessionKey{
@@ -39,7 +39,7 @@ func (m *model) slugUpdate(msg tea.KeyMsg) (tea.Model, tea.Cmd) {
}
m.editingSlug = false
m.slugError = ""
return m, tea.Batch(tea.ClearScreen, textinput.Blink)
return m, textinput.Blink
default:
if key.Matches(msg, m.keymap.random) {
newSubdomain, err := m.randomizer.String(20)