Fix crashes with ProxyCommand

This commit is contained in:
SimonGaufreteau 2025-10-15 12:58:10 +02:00
parent dcf3199464
commit 8278a3752b
2 changed files with 13 additions and 12 deletions

View File

@ -49,7 +49,7 @@ func NewAddForm(hostname string, styles Styles, width, height int, configFile st
}
}
inputs := make([]textinput.Model, 10) // Increased from 9 to 10 for RequestTTY
inputs := make([]textinput.Model, 11)
// Name input
inputs[nameInput] = textinput.New()
@ -93,7 +93,7 @@ func NewAddForm(hostname string, styles Styles, width, height int, configFile st
// ProxyCommand input
inputs[proxyCommandInput] = textinput.New()
inputs[proxyCommandInput].Placeholder = "/usr/local/bin/wssh proxy %h"
inputs[proxyCommandInput].Placeholder = "ssh -W %h:%p Jumphost"
inputs[proxyCommandInput].CharLimit = 200
inputs[proxyCommandInput].Width = 50
@ -408,7 +408,7 @@ func (m *addFormModel) renderGeneralTab() string {
{portInput, "Port"},
{identityInput, "Identity File"},
{proxyJumpInput, "ProxyJump"},
{proxyCommandInput, "ProxyCommand"}
{proxyCommandInput, "ProxyCommand"},
{tagsInput, "Tags (comma-separated)"},
}

View File

@ -91,7 +91,7 @@ func NewEditForm(hostName string, styles Styles, width, height int, configFile s
}
}
inputs := make([]textinput.Model, 9) // Increased from 8 to 9 for RequestTTY
inputs := make([]textinput.Model, 10)
// Hostname input
inputs[0] = textinput.New()
@ -130,7 +130,7 @@ func NewEditForm(hostName string, styles Styles, width, height int, configFile s
// ProxyCommand input
inputs[5] = textinput.New()
inputs[5].Placeholder = "/bin/wssh proxy"
inputs[5].Placeholder = "ssh -W %h:%p Jumphost"
inputs[5].CharLimit = 200
inputs[5].Width = 50
inputs[5].SetValue(host.ProxyCommand)
@ -260,19 +260,19 @@ func (m *editFormModel) updateFocus() tea.Cmd {
func (m *editFormModel) getPropertiesForCurrentTab() []int {
switch m.currentTab {
case 0: // General
return []int{0, 1, 2, 3, 4, 5, 6} // hostname, user, port, identity, proxyjump, proxycommand, tags
return []int{0, 1, 2, 3, 4, 5, 7} // hostname, user, port, identity, proxyjump, proxycommand, tags
case 1: // Advanced
return []int{5, 7, 8} // options, remotecommand, requesttty
return []int{6, 8, 9} // options, remotecommand, requesttty
default:
return []int{0, 1, 2, 3, 4, 6}
return []int{0, 1, 2, 3, 4, 5, 7}
}
}
// getFirstPropertyForTab returns the first property index for a given tab
func (m *editFormModel) getFirstPropertyForTab(tab int) int {
properties := []int{0, 1, 2, 3, 4, 6} // General tab
properties := []int{0, 1, 2, 3, 4, 5, 7} // General tab
if tab == 1 {
properties = []int{5, 7, 8} // Advanced tab
properties = []int{6, 8, 9} // Advanced tab
}
if len(properties) > 0 {
return properties[0]
@ -587,7 +587,8 @@ func (m *editFormModel) renderEditGeneralTab() string {
{2, "Port"},
{3, "Identity File"},
{4, "Proxy Jump"},
{6, "Tags (comma-separated)"},
{5, "Proxy Command"},
{7, "Tags (comma-separated)"},
}
for _, field := range fields {