fix(ui): edit-mode wizard allows keeping the same local port

Previously, editing a forward and keeping its local port unchanged
failed the wizard's port-availability check: the in-config scan
found the forward's own entry and reported '✗ Port N already
assigned to <self.ID>'. Users had to pick a different port,
edit, then change back.

checkPortCmd now accepts an excludeID. The wizard passes
wizard.originalID when isEditing so the forward being edited is
ignored during the in-config conflict scan. The OS-level port
check is unchanged (still catches actual port collisions).

New regression test: TestCheckPortCmd_ExcludeID_AllowsKeepingOwnPort.
This commit is contained in:
2026-05-06 12:45:35 +01:00
parent bfe541565b
commit dbc7830546
3 changed files with 59 additions and 12 deletions
+5 -1
View File
@@ -656,7 +656,11 @@ func (m model) handleAddWizardEnter() (tea.Model, tea.Cmd) {
wizard.localPort = port
wizard.loading = true
wizard.error = nil
return m, checkPortCmd(port, m.ui.configPath)
excludeID := ""
if wizard.isEditing {
excludeID = wizard.originalID
}
return m, checkPortCmd(port, m.ui.configPath, excludeID)
}
case StepConfirmation: