pi-agent: Implement Operations Console dashboard

This commit is contained in:
proxyctl coordinator
2026-07-17 20:44:48 +08:00
parent daeb788eac
commit 8ac0695152
15 changed files with 600 additions and 138 deletions
+12 -12
View File
@@ -94,7 +94,7 @@ func TestHelpListsEveryTargetAndMainListsOnlyAvailableTargets(t *testing.T) {
}}}
model := NewModel(module)
view := model.View()
if strings.Contains(view, "APT") || !strings.Contains(view, "affects future Shell commands") || !strings.Contains(view, "integration installed") {
if strings.Contains(view, "APT") || !strings.Contains(view, "summary") || !strings.Contains(view, "integration installed") {
t.Fatalf("main Target panel:\n%s", view)
}
model = updateKey(model, "?")
@@ -103,7 +103,7 @@ func TestHelpListsEveryTargetAndMainListsOnlyAvailableTargets(t *testing.T) {
t.Fatalf("Target help:\n%s", view)
}
model = updateKey(model, "esc")
if !strings.Contains(model.View(), "Target panel") {
if !strings.Contains(model.View(), "Operations Console") {
t.Fatalf("Escape did not return from help:\n%s", model.View())
}
}
@@ -423,13 +423,13 @@ func TestRefreshClampsSelectionAfterMultipleTargetsDisappear(t *testing.T) {
refreshed := app.Snapshot{Targets: []app.TargetSnapshot{{ID: "one", Description: target.Description{Name: "One"}, Available: true}}}
module := &targetModule{snapshot: initial, result: app.Result{Snapshot: refreshed}}
model := NewModel(module)
model.selected = 3
model.selectedTargetID = "four"
updated, command := model.Update(keyMessage("r"))
model = updated.(Model)
updated, _ = model.Update(command())
model = updated.(Model)
if model.selected != 0 || !strings.Contains(model.View(), "> [ ] One") {
t.Fatalf("selection after multi-Target reduction = %d\n%s", model.selected, model.View())
if model.selectedTargetID != "one" || !strings.Contains(model.View(), "> ? Unknown One") {
t.Fatalf("selection after multi-Target reduction = %q\n%s", model.selectedTargetID, model.View())
}
module.result = app.Result{Snapshot: app.Snapshot{}}
@@ -437,8 +437,8 @@ func TestRefreshClampsSelectionAfterMultipleTargetsDisappear(t *testing.T) {
model = updated.(Model)
updated, _ = model.Update(command())
model = updated.(Model)
if model.selected != 0 {
t.Fatalf("selection with no Available Targets = %d, want 0", model.selected)
if model.selectedTargetID != "" {
t.Fatalf("selection with no Available Targets = %q, want empty", model.selectedTargetID)
}
}
@@ -458,12 +458,12 @@ func TestTargetPanelNavigationKeysAndQuitCombinations(t *testing.T) {
model := NewModel(module)
updated, _ := model.Update(down)
model = updated.(Model)
if !strings.Contains(model.View(), "> [ ] Second") {
if !strings.Contains(model.View(), "> ? Unknown Second") {
t.Fatalf("down key %q did not select second Target:\n%s", down.String(), model.View())
}
for _, up := range []tea.KeyMsg{{Type: tea.KeyUp}, {Type: tea.KeyRunes, Runes: []rune{'k'}}} {
updated, _ = model.Update(up)
if !strings.Contains(updated.(Model).View(), "> [ ] First") {
if !strings.Contains(updated.(Model).View(), "> ? Unknown First") {
t.Fatalf("up key %q did not select first Target:\n%s", up.String(), updated.(Model).View())
}
}
@@ -484,12 +484,12 @@ func TestQAndEscapeReturnFromNestedPages(t *testing.T) {
for _, key := range []tea.KeyMsg{{Type: tea.KeyRunes, Runes: []rune{'q'}}, {Type: tea.KeyEsc}} {
model := updateKey(NewModel(module), "?")
updated, command := model.Update(key)
if command != nil || !strings.Contains(updated.(Model).View(), "Target panel") {
t.Fatalf("help key %q did not return to Target panel", key.String())
if command != nil || !strings.Contains(updated.(Model).View(), "Operations Console") {
t.Fatalf("help key %q did not return to Operations Console", key.String())
}
model = updateKey(NewModel(module), "p")
updated, command = model.Update(key)
if command != nil || !strings.Contains(updated.(Model).View(), "Target panel") {
if command != nil || !strings.Contains(updated.(Model).View(), "Operations Console") {
t.Fatalf("Profile key %q did not return to Target panel", key.String())
}
}