Rename auto-forward -> toggle-intercept

Signed-off-by: Hadi <112569860+anotherhadi@users.noreply.github.com>
This commit is contained in:
Hadi
2026-05-12 22:25:10 +02:00
parent 7879720d07
commit a6bd5c1071
8 changed files with 18 additions and 18 deletions
+1 -1
View File
@@ -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"`
+2 -2
View File
@@ -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"
+1 -1
View File
@@ -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"`
+3 -3
View File
@@ -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,
}
}
+2 -2
View File
@@ -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)
}
+2 -2
View File
@@ -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
@@ -60,7 +60,7 @@ func New(broker *intercept.Broker) Model {
return Model{
broker: broker,
autoForward: cfg.Intercept.DefaultAutoForward,
interceptEnabled: cfg.Intercept.DefaultInterceptEnabled,
captureResponse: cfg.Intercept.DefaultCaptureResponse,
listViewport: lv,
responseViewport: rv,
+4 -4
View File
@@ -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)
}
+2 -2
View File
@@ -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)
}