From a6bd5c1071274e9e8655f3e8f54dff0136bcb55e Mon Sep 17 00:00:00 2001 From: Hadi <112569860+anotherhadi@users.noreply.github.com> Date: Tue, 12 May 2026 22:25:10 +0200 Subject: [PATCH] Rename auto-forward -> toggle-intercept Signed-off-by: Hadi <112569860+anotherhadi@users.noreply.github.com> --- internal/config/config.go | 2 +- internal/config/default_config.yaml | 4 ++-- internal/config/keybindings.go | 2 +- internal/keys/intercept.go | 6 +++--- internal/style/border.go | 4 ++-- internal/ui/intercept/model.go | 6 +++--- internal/ui/intercept/update.go | 8 ++++---- internal/ui/intercept/view.go | 4 ++-- 8 files changed, 18 insertions(+), 18 deletions(-) diff --git a/internal/config/config.go b/internal/config/config.go index 2e05e6d..eb8af89 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -33,7 +33,7 @@ type Config struct { } `mapstructure:"tui"` Intercept struct { - DefaultAutoForward bool `mapstructure:"default_auto_forward"` + DefaultInterceptEnabled bool `mapstructure:"default_intercept_enabled"` DefaultCaptureResponse bool `mapstructure:"default_capture_response"` AutoForwardRegex []string `mapstructure:"auto_forward_regex"` } `mapstructure:"intercept"` diff --git a/internal/config/default_config.yaml b/internal/config/default_config.yaml index 60a006e..139a9bd 100644 --- a/internal/config/default_config.yaml +++ b/internal/config/default_config.yaml @@ -6,7 +6,7 @@ app: plugins_dir: ~/.config/spilltea/plugins intercept: - default_auto_forward: false + default_intercept_enabled: true default_capture_response: false auto_forward_regex: - '\.(js|css|png|gif|ico|woff2?|ttf|svg)(\?.*)?$' @@ -61,7 +61,7 @@ keybindings: forward_all: "F" drop: "d" drop_all: "D" - auto_forward: "a" + toggle_intercept: "a" capture_response: "r" undo_edits: "ctrl+z" edit: "e,enter" diff --git a/internal/config/keybindings.go b/internal/config/keybindings.go index 9331455..796312a 100644 --- a/internal/config/keybindings.go +++ b/internal/config/keybindings.go @@ -22,7 +22,7 @@ type InterceptKeys struct { ForwardAll string `mapstructure:"forward_all"` Drop string `mapstructure:"drop"` DropAll string `mapstructure:"drop_all"` - AutoForward string `mapstructure:"auto_forward"` + ToggleIntercept string `mapstructure:"toggle_intercept"` CaptureResponse string `mapstructure:"capture_response"` UndoEdits string `mapstructure:"undo_edits"` Edit string `mapstructure:"edit"` diff --git a/internal/keys/intercept.go b/internal/keys/intercept.go index 84f3aba..b9165bc 100644 --- a/internal/keys/intercept.go +++ b/internal/keys/intercept.go @@ -10,7 +10,7 @@ type InterceptKeyMap struct { ForwardAll key.Binding Drop key.Binding DropAll key.Binding - AutoForward key.Binding + ToggleIntercept key.Binding CaptureResponse key.Binding UndoEdits key.Binding Edit key.Binding @@ -23,7 +23,7 @@ func newInterceptKeyMap(cfg config.InterceptKeys) InterceptKeyMap { ForwardAll: binding(cfg.ForwardAll, "forward all"), Drop: binding(cfg.Drop, "drop"), DropAll: binding(cfg.DropAll, "drop all"), - AutoForward: binding(cfg.AutoForward, "auto forward"), + ToggleIntercept: binding(cfg.ToggleIntercept, "toggle intercept"), CaptureResponse: binding(cfg.CaptureResponse, "capture response"), UndoEdits: binding(cfg.UndoEdits, "undo edits"), Edit: binding(cfg.Edit, "edit"), @@ -36,6 +36,6 @@ func (ic InterceptKeyMap) Bindings() []key.Binding { ic.Forward, ic.ForwardAll, ic.Drop, ic.DropAll, ic.Edit, ic.EditExternal, ic.UndoEdits, - ic.AutoForward, ic.CaptureResponse, + ic.ToggleIntercept, ic.CaptureResponse, } } diff --git a/internal/style/border.go b/internal/style/border.go index 196821a..6abeb96 100644 --- a/internal/style/border.go +++ b/internal/style/border.go @@ -36,8 +36,8 @@ func RenderWithTitle(border lipgloss.Style, title, content string, width, height if fillW < 0 { fillW = 0 } - topLine := "╭" + label + strings.Repeat("─", fillW) + "╮" - topLine = lipgloss.NewStyle().Foreground(border.GetBorderTopForeground()).Render(topLine) + bc := lipgloss.NewStyle().Foreground(border.GetBorderTopForeground()) + topLine := bc.Render("╭ ") + bc.Render(title) + bc.Render(" "+strings.Repeat("─", fillW)+"╮") return lipgloss.JoinVertical(lipgloss.Left, topLine, box) } diff --git a/internal/ui/intercept/model.go b/internal/ui/intercept/model.go index 9af952d..4d75466 100644 --- a/internal/ui/intercept/model.go +++ b/internal/ui/intercept/model.go @@ -29,7 +29,7 @@ type Model struct { responseCursor int editing bool - autoForward bool + interceptEnabled bool pendingEdits map[*intercept.PendingRequest]string pendingResponseEdits map[*intercept.PendingResponse]string @@ -59,8 +59,8 @@ func New(broker *intercept.Broker) Model { broker.SetCaptureResponse(cfg.Intercept.DefaultCaptureResponse) return Model{ - broker: broker, - autoForward: cfg.Intercept.DefaultAutoForward, + broker: broker, + interceptEnabled: cfg.Intercept.DefaultInterceptEnabled, captureResponse: cfg.Intercept.DefaultCaptureResponse, listViewport: lv, responseViewport: rv, diff --git a/internal/ui/intercept/update.go b/internal/ui/intercept/update.go index 40796e0..745a342 100644 --- a/internal/ui/intercept/update.go +++ b/internal/ui/intercept/update.go @@ -15,7 +15,7 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { switch msg := msg.(type) { case intercept.RequestArrivedMsg: - if m.autoForward { + if !m.interceptEnabled { m.broker.Decide(msg.Req, intercept.Forward) break } @@ -152,9 +152,9 @@ func (m Model) updateNormalMode(msg tea.KeyPressMsg, cmds *[]tea.Cmd) (tea.Model } } - case key.Matches(msg, keys.Keys.Intercept.AutoForward): - m.autoForward = !m.autoForward - if m.autoForward { + case key.Matches(msg, keys.Keys.Intercept.ToggleIntercept): + m.interceptEnabled = !m.interceptEnabled + if !m.interceptEnabled { for len(m.queue) > 0 { m.applyAndDecide(intercept.Forward) } diff --git a/internal/ui/intercept/view.go b/internal/ui/intercept/view.go index b114a15..7c6e468 100644 --- a/internal/ui/intercept/view.go +++ b/internal/ui/intercept/view.go @@ -52,8 +52,8 @@ func (m *Model) renderListPanel(w, h int) string { ) title := icons.I.Request + "Requests" - if m.autoForward { - title += " [auto forward]" + if !m.interceptEnabled { + title += " " + lipgloss.NewStyle().Foreground(style.S.Error).Render("[intercept off]") } return style.RenderWithTitle(border, title, inner, w, h) }