Signed-off-by: Hadi <112569860+anotherhadi@users.noreply.github.com>
This commit is contained in:
Hadi
2026-05-13 18:20:33 +02:00
parent 7d4f32549e
commit 9ab7f12bf4
8 changed files with 28 additions and 29 deletions
+2 -2
View File
@@ -35,8 +35,8 @@ type Config struct {
Intercept struct { Intercept struct {
DefaultInterceptEnabled bool `mapstructure:"default_intercept_enabled"` DefaultInterceptEnabled bool `mapstructure:"default_intercept_enabled"`
DefaultCaptureResponse bool `mapstructure:"default_capture_response"` DefaultCaptureResponse bool `mapstructure:"default_capture_response"`
AutoForwardRegex []string `mapstructure:"auto_forward_regex"` AutoForwardRegex []string `mapstructure:"auto_forward_regex"`
} `mapstructure:"intercept"` } `mapstructure:"intercept"`
Replay struct { Replay struct {
+2 -2
View File
@@ -10,8 +10,8 @@ type GlobalKeys struct {
Left string `mapstructure:"left"` Left string `mapstructure:"left"`
Right string `mapstructure:"right"` Right string `mapstructure:"right"`
CycleFocus string `mapstructure:"cycle_focus"` CycleFocus string `mapstructure:"cycle_focus"`
CopyAs string `mapstructure:"copy_as"` CopyAs string `mapstructure:"copy_as"`
Copy string `mapstructure:"copy"` Copy string `mapstructure:"copy"`
SendToReplay string `mapstructure:"send_to_replay"` SendToReplay string `mapstructure:"send_to_replay"`
ScrollUp string `mapstructure:"scroll_up"` ScrollUp string `mapstructure:"scroll_up"`
ScrollDown string `mapstructure:"scroll_down"` ScrollDown string `mapstructure:"scroll_down"`
+3 -3
View File
@@ -14,9 +14,9 @@ import (
type Decision int type Decision int
const ( const (
Forward Decision = iota // forward without showing in intercept Forward Decision = iota // forward without showing in intercept
Drop // drop the flow Drop // drop the flow
Intercept // pass to the TUI for user decision Intercept // pass to the TUI for user decision
) )
type PendingRequest struct { type PendingRequest struct {
+2 -2
View File
@@ -15,7 +15,7 @@ type GlobalKeyMap struct {
Left key.Binding Left key.Binding
Right key.Binding Right key.Binding
CycleFocus key.Binding CycleFocus key.Binding
CopyAs key.Binding CopyAs key.Binding
Copy key.Binding Copy key.Binding
Escape key.Binding Escape key.Binding
SendToReplay key.Binding SendToReplay key.Binding
@@ -35,7 +35,7 @@ func newGlobalKeyMap(cfg config.GlobalKeys) GlobalKeyMap {
Left: binding(cfg.Left, "scroll left"), Left: binding(cfg.Left, "scroll left"),
Right: binding(cfg.Right, "scroll right"), Right: binding(cfg.Right, "scroll right"),
CycleFocus: binding(cfg.CycleFocus, "cycle focus"), CycleFocus: binding(cfg.CycleFocus, "cycle focus"),
CopyAs: binding(cfg.CopyAs, "copy as..."), CopyAs: binding(cfg.CopyAs, "copy as..."),
Copy: binding(cfg.Copy, "copy..."), Copy: binding(cfg.Copy, "copy..."),
Escape: key.NewBinding(key.WithKeys("esc"), key.WithHelp("esc", "cancel")), Escape: key.NewBinding(key.WithKeys("esc"), key.WithHelp("esc", "cancel")),
SendToReplay: binding(cfg.SendToReplay, "send to replay"), SendToReplay: binding(cfg.SendToReplay, "send to replay"),
+4 -4
View File
@@ -221,16 +221,16 @@ func lcsAlignedDiff(a, b, aHL, bHL []string) (left, right []diffLine) {
for i > 0 || j > 0 { for i > 0 || j > 0 {
switch { switch {
case i > 0 && j > 0 && a[i-1] == b[j-1]: case i > 0 && j > 0 && a[i-1] == b[j-1]:
left = append(left, diffLine{text: hlA(i-1), kind: lineUnchanged}) left = append(left, diffLine{text: hlA(i - 1), kind: lineUnchanged})
right = append(right, diffLine{text: hlB(j-1), kind: lineUnchanged}) right = append(right, diffLine{text: hlB(j - 1), kind: lineUnchanged})
i-- i--
j-- j--
case j > 0 && (i == 0 || dp[i][j-1] >= dp[i-1][j]): case j > 0 && (i == 0 || dp[i][j-1] >= dp[i-1][j]):
left = append(left, diffLine{kind: lineAdded}) left = append(left, diffLine{kind: lineAdded})
right = append(right, diffLine{text: hlB(j-1), kind: lineAdded}) right = append(right, diffLine{text: hlB(j - 1), kind: lineAdded})
j-- j--
default: default:
left = append(left, diffLine{text: hlA(i-1), kind: lineRemoved}) left = append(left, diffLine{text: hlA(i - 1), kind: lineRemoved})
right = append(right, diffLine{kind: lineRemoved}) right = append(right, diffLine{kind: lineRemoved})
i-- i--
} }
+13 -14
View File
@@ -14,7 +14,7 @@ import (
type panel int type panel int
const ( const (
panelRequests panel = iota panelRequests panel = iota
panelResponses panelResponses
) )
@@ -28,8 +28,8 @@ type Model struct {
responseQueue []*intercept.PendingResponse responseQueue []*intercept.PendingResponse
responseCursor int responseCursor int
editing bool editing bool
interceptEnabled bool interceptEnabled bool
pendingEdits map[*intercept.PendingRequest]string pendingEdits map[*intercept.PendingRequest]string
pendingResponseEdits map[*intercept.PendingResponse]string pendingResponseEdits map[*intercept.PendingResponse]string
@@ -37,9 +37,9 @@ type Model struct {
responseViewport viewport.Model responseViewport viewport.Model
bodyViewport viewport.Model bodyViewport viewport.Model
textarea textarea.Model textarea textarea.Model
pager paginator.Model pager paginator.Model
responsePager paginator.Model responsePager paginator.Model
help help.Model help help.Model
width int width int
height int height int
@@ -59,13 +59,13 @@ func New(broker *intercept.Broker) Model {
broker.SetCaptureResponse(cfg.Intercept.DefaultCaptureResponse) broker.SetCaptureResponse(cfg.Intercept.DefaultCaptureResponse)
return Model{ return Model{
broker: broker, broker: broker,
interceptEnabled: cfg.Intercept.DefaultInterceptEnabled, interceptEnabled: cfg.Intercept.DefaultInterceptEnabled,
captureResponse: cfg.Intercept.DefaultCaptureResponse, captureResponse: cfg.Intercept.DefaultCaptureResponse,
listViewport: lv, listViewport: lv,
responseViewport: rv, responseViewport: rv,
bodyViewport: bv, bodyViewport: bv,
textarea: ta, textarea: ta,
pager: p, pager: p,
responsePager: rp, responsePager: rp,
help: newHelp(), help: newHelp(),
@@ -115,4 +115,3 @@ func (m *Model) SetSize(w, h int) {
m.height = h m.height = h
m.recalcSizes() m.recalcSizes()
} }
+1 -1
View File
@@ -5,9 +5,9 @@ import (
tea "charm.land/bubbletea/v2" tea "charm.land/bubbletea/v2"
"github.com/anotherhadi/spilltea/internal/intercept" "github.com/anotherhadi/spilltea/internal/intercept"
"github.com/anotherhadi/spilltea/internal/keys" "github.com/anotherhadi/spilltea/internal/keys"
"github.com/anotherhadi/spilltea/internal/util"
diffUI "github.com/anotherhadi/spilltea/internal/ui/diff" diffUI "github.com/anotherhadi/spilltea/internal/ui/diff"
replayUI "github.com/anotherhadi/spilltea/internal/ui/replay" replayUI "github.com/anotherhadi/spilltea/internal/ui/replay"
"github.com/anotherhadi/spilltea/internal/util"
) )
func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
+1 -1
View File
@@ -4,8 +4,8 @@ import (
"path/filepath" "path/filepath"
"strings" "strings"
"charm.land/glamour/v2"
tea "charm.land/bubbletea/v2" tea "charm.land/bubbletea/v2"
"charm.land/glamour/v2"
"charm.land/lipgloss/v2" "charm.land/lipgloss/v2"
"github.com/anotherhadi/spilltea/internal/config" "github.com/anotherhadi/spilltea/internal/config"
"github.com/anotherhadi/spilltea/internal/icons" "github.com/anotherhadi/spilltea/internal/icons"