feat(ui): toggle httpLog per-forward in add/edit wizard

Adds an HTTP-log enable toggle to the wizard's confirmation step so
users can flip httpLog on a forward without editing YAML by hand.

Behaviour:
- 'h' on the confirmation step toggles HTTPLog when not focused on
  the alias text input. When focus is on alias, 'h' is treated as
  text so users can still type aliases like 'host' or 'http-proxy'.
- The confirmation summary shows '[x] enabled' or '[ ] disabled'.
- New forwards: toggle on -> &HTTPLogSpec{Enabled: true}; off -> nil.
- Edit mode: pre-populates the toggle from the existing forward and
  preserves any advanced HTTPLog fields the user had configured in
  YAML (logFile, includeHeaders, maxBodySize, filterPath) by copying
  the original spec on save. Toggling off discards the advanced
  fields (consistent with 'absent in YAML = disabled').

State changes:
- ForwardStatus gains *config.HTTPLogSpec so the wizard can see the
  full original spec on edit.
- AddWizardState gains httpLog bool + httpLogOriginal *HTTPLogSpec.

Three new tests:
- TestHandleAddWizardKeys_HToggleHTTPLog
- TestHandleAddWizardKeys_HOnAliasFocusIsTextInput
- TestEditPrefill_PreservesHTTPLog
This commit is contained in:
2026-05-06 12:41:36 +01:00
parent c413b808f1
commit bfe541565b
6 changed files with 136 additions and 6 deletions
+8 -5
View File
@@ -3,6 +3,7 @@ package ui
import (
"strings"
"github.com/lukaszraczylo/kportal/internal/config"
"github.com/lukaszraczylo/kportal/internal/k8s"
)
@@ -110,6 +111,7 @@ func (r ResourceType) Description() string {
// AddWizardState maintains the state for the add port forward wizard
type AddWizardState struct {
error error
httpLogOriginal *config.HTTPLogSpec
resourceValue string
originalID string
portCheckMsg string
@@ -119,16 +121,16 @@ type AddWizardState struct {
selector string
selectedContext string
selectedNamespace string
pods []k8s.PodInfo
contexts []string
services []k8s.ServiceInfo
detectedPorts []k8s.PortInfo
matchingPods []k8s.PodInfo
services []k8s.ServiceInfo
contexts []string
namespaces []string
scrollOffset int
pods []k8s.PodInfo
localPort int
selectedResourceType ResourceType
step AddWizardStep
localPort int
scrollOffset int
cursor int
remotePort int
inputMode InputMode
@@ -136,6 +138,7 @@ type AddWizardState struct {
portAvailable bool
isEditing bool
loading bool
httpLog bool
}
// newAddWizardState creates a new add wizard state initialized to the first step