pi-agent: Implement mature Profile editor

This commit is contained in:
proxyctl coordinator
2026-07-17 23:57:30 +08:00
parent 112f700650
commit c56c206d8b
9 changed files with 677 additions and 179 deletions
+12 -11
View File
@@ -87,8 +87,8 @@ func TestProfileFormMapsKeyboardInputToCreateIntent(t *testing.T) {
if intent.Kind != app.CreateProfile || intent.Profile.Name != "home" || intent.Profile.SingleURL != "socks5://localhost:1080" {
t.Fatalf("create form dispatched %#v", intent)
}
if got := intent.Profile.Bypass; len(got) != 1 || got[0] != "localhost, .example.com" {
t.Fatalf("create form Bypass = %#v", got)
if got := intent.Profile.Bypass; len(got) != 2 || got[0] != "localhost" || got[1] != ".example.com" {
t.Fatalf("create form normalized Bypass = %#v", got)
}
}
@@ -487,15 +487,16 @@ func TestProtocolProbeInAdvancedModeShowsHintWithoutProbing(t *testing.T) {
func updateKey(model Model, key string) Model {
msg := tea.KeyMsg{Type: tea.KeyRunes, Runes: []rune(key)}
switch key {
case "tab":
msg = tea.KeyMsg{Type: tea.KeyTab}
case "ctrl+s":
msg = tea.KeyMsg{Type: tea.KeyCtrlS}
case "ctrl+t":
msg = tea.KeyMsg{Type: tea.KeyCtrlT}
case "backspace":
msg = tea.KeyMsg{Type: tea.KeyBackspace}
special := map[string]tea.KeyType{
"tab": tea.KeyTab, "shift+tab": tea.KeyShiftTab,
"enter": tea.KeyEnter, "esc": tea.KeyEsc,
"up": tea.KeyUp, "down": tea.KeyDown, "left": tea.KeyLeft, "right": tea.KeyRight,
"home": tea.KeyHome, "end": tea.KeyEnd, "delete": tea.KeyDelete, "backspace": tea.KeyBackspace,
"pgup": tea.KeyPgUp, "pgdown": tea.KeyPgDown,
"ctrl+d": tea.KeyCtrlD, "ctrl+s": tea.KeyCtrlS, "ctrl+t": tea.KeyCtrlT, "ctrl+u": tea.KeyCtrlU,
}
if keyType, ok := special[key]; ok {
msg = tea.KeyMsg{Type: keyType}
}
updated, _ := model.Update(msg)
return updated.(Model)