feat: unify interactive operation coordination

This commit is contained in:
proxyctl coordinator
2026-07-17 22:23:31 +08:00
parent 177bf34354
commit 7c0b4481d7
17 changed files with 985 additions and 1013 deletions
+11 -9
View File
@@ -16,9 +16,7 @@ type dashboardRenderState struct {
selectedTargetID string
focus dashboardPane
detailsOffset int
applying bool
profileTransition bool
progressTarget string
operationProgress map[string]app.TargetProgressPhase
}
func (p terminalPresentation) renderDashboard(state dashboardRenderState, width, height int) string {
@@ -51,9 +49,7 @@ func (p terminalPresentation) renderTargetListPane(state dashboardRenderState, w
if item.ID == state.selectedTargetID {
cursor = "> "
}
applying := (state.progressTarget != "" && item.ID == state.progressTarget) ||
(!state.profileTransition && state.progressTarget == "" && state.applying && item.ID == state.selectedTargetID)
badge := p.targetBadge(item, applying)
badge := p.targetBadge(item, state.operationProgress[item.ID])
lines = append(lines, cursor+badge+" "+item.Description.Name)
}
if len(lines) == 0 {
@@ -105,7 +101,13 @@ func fixedViewport(content string, width, height, offset int, wrap bool) string
return view.View()
}
func (p terminalPresentation) targetBadge(item app.TargetSnapshot, applying bool) string {
func (p terminalPresentation) targetBadge(item app.TargetSnapshot, progress app.TargetProgressPhase) string {
switch progress {
case app.TargetProgressRunning:
return p.theme.renderTargetState(item.State, true)
case app.TargetProgressFailed:
return p.theme.checkFailed.Render("! Failed")
}
switch item.DetectionPhase {
case app.TargetChecking:
return p.theme.checking.Render("… Checking")
@@ -115,11 +117,11 @@ func (p terminalPresentation) targetBadge(item app.TargetSnapshot, applying bool
if !item.Available {
return p.theme.unavailable.Render("○ Unavailable")
}
return p.theme.renderTargetState(item.State, applying)
return p.theme.renderTargetState(item.State, false)
}
func (p terminalPresentation) targetDetails(item app.TargetSnapshot) string {
state := p.targetBadge(item, false)
state := p.targetBadge(item, 0)
evidence := item.Evidence
switch item.DetectionPhase {
case app.TargetChecking: