pi-agent: Implement field Protocol Probe

This commit is contained in:
proxyctl coordinator
2026-07-18 00:27:12 +08:00
parent 21dd67cf54
commit 02b49d5112
8 changed files with 482 additions and 67 deletions
+6 -10
View File
@@ -201,8 +201,8 @@ func TestProtocolProbeFailureLeavesFieldUntouchedAndSavePossible(t *testing.T) {
if got := model.form.profile.SingleURL; got != "localhost:8888" {
t.Fatalf("failed probe rewrote Single URL to %q", got)
}
if view := model.View(); !strings.Contains(view, "Protocol Probe: no proxy detected at localhost:8888: connection refused") {
t.Fatalf("form view missing failure status:\n%s", view)
if view := model.View(); !strings.Contains(view, "Protocol Probe failed for localhost:8888") || strings.Contains(view, "connection refused") {
t.Fatalf("form view missing credential-safe field failure status:\n%s", view)
}
model = updateKey(model, "ctrl+s")
if len(module.intents) != 1 || module.intents[0].Kind != app.CreateProfile {
@@ -286,10 +286,8 @@ func TestProtocolProbeLateResultIgnoredAfterEscLeavesForm(t *testing.T) {
if cmd == nil {
t.Fatal("ctrl+d did not start a Protocol Probe")
}
gen := model.form.probeGen
model = updateKey(model, "esc")
updated, _ := model.Update(probeDone{address: "localhost:8888", caps: probe.Capabilities{HTTP: true}, gen: gen})
updated, _ := model.Update(cmd())
model = updated.(Model)
if model.page != profilesPage {
@@ -319,14 +317,12 @@ func TestProtocolProbeLateResultIgnoredAfterSaveLeavesForm(t *testing.T) {
if cmd == nil {
t.Fatal("ctrl+d did not start a Protocol Probe")
}
gen := model.form.probeGen
model = updateKey(model, "ctrl+s")
if len(module.intents) != 1 {
t.Fatalf("save dispatched %d intents, want 1", len(module.intents))
}
updated, _ := model.Update(probeDone{address: "localhost:8888", caps: probe.Capabilities{HTTP: true}, gen: gen})
updated, _ := model.Update(cmd())
model = updated.(Model)
if model.page != profilesPage {
@@ -480,8 +476,8 @@ func TestProtocolProbeInAdvancedModeShowsHintWithoutProbing(t *testing.T) {
if calls != 0 {
t.Fatalf("Advanced mode probe ran %d times, want 0", calls)
}
if view := model.View(); !strings.Contains(view, "Protocol Probe: available in Single mode only") {
t.Fatalf("form view missing Advanced mode hint:\n%s", view)
if view := model.View(); strings.Contains(view, "Protocol Probe") || strings.Contains(view, "Ctrl+D") {
t.Fatalf("Advanced mode advertised an inapplicable Protocol Probe action:\n%s", view)
}
}