Skip to content

Commit e65305c

Browse files
authored
Merge pull request #49 from blockopsnetwork/fix/tui-streaming-ui
Fix/tui streaming UI
2 parents e128b05 + a9114b7 commit e65305c

1 file changed

Lines changed: 52 additions & 3 deletions

File tree

cmd/tui.go

Lines changed: 52 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,19 @@ func (m *tuiModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
332332
case tea.KeyEnter:
333333
userInput := strings.TrimSpace(m.textarea.Value())
334334
if userInput != "" && !m.loading {
335+
if len(m.currentTodos) > 0 {
336+
allDone := true
337+
for _, todo := range m.currentTodos {
338+
if todo.Status != "completed" {
339+
allDone = false
340+
break
341+
}
342+
}
343+
if allDone {
344+
m.currentTodos = nil
345+
m.showTodos = false
346+
}
347+
}
335348
if strings.HasPrefix(userInput, "/") {
336349
switch userInput {
337350
case "/", "/h", "/help":
@@ -516,7 +529,7 @@ func (m *tuiModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
516529
})
517530
m.updateViewportContent()
518531
case "tool_start":
519-
m.loadingMsg = fmt.Sprintf("Executing %s...", msg.update.Tool)
532+
m.loadingMsg = getToolContextualMessage(msg.update.Tool)
520533
m.messages = append(m.messages, ChatMessage{
521534
ID: generateMessageID(),
522535
Role: "tool_header",
@@ -555,9 +568,9 @@ func (m *tuiModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
555568
case "tool_result":
556569
var statusMsg string
557570
if msg.update.Success {
558-
statusMsg = fmt.Sprintf("%s completed successfully", msg.update.Tool)
571+
statusMsg = getToolCompletionMessage(msg.update.Tool, true)
559572
} else {
560-
statusMsg = fmt.Sprintf("%s failed", msg.update.Tool)
573+
statusMsg = getToolCompletionMessage(msg.update.Tool, false)
561574
}
562575

563576
m.loadingMsg = statusMsg
@@ -1152,6 +1165,18 @@ func getToolContextualMessage(toolName string) string {
11521165
"backup_current_state": "Creating a backup of the current state...",
11531166
"rollback_changes": "Rolling back to the previous configuration...",
11541167
"verify_upgrade_success": "Verifying the upgrade completed successfully...",
1168+
"run_diagnostics": "Running diagnostics to gather evidence...",
1169+
"slack_post_message": "Sending an update to Slack...",
1170+
"telescope_node_status": "Checking node health status...",
1171+
"telescope_sync_status": "Checking sync status...",
1172+
"telescope_recent_errors": "Collecting recent errors...",
1173+
"telescope_get_logs": "Fetching component logs...",
1174+
"telescope_query_logs": "Querying logs...",
1175+
"telescope_query_metrics": "Querying metrics...",
1176+
"telescope_cpu_usage": "Checking CPU usage...",
1177+
"telescope_memory_usage": "Checking memory usage...",
1178+
"telescope_disk_usage": "Checking disk usage...",
1179+
"telescope_network_usage": "Checking network usage...",
11551180
}
11561181

11571182
if message, exists := contextMessages[toolName]; exists {
@@ -1176,6 +1201,18 @@ func getToolCompletionMessage(toolName string, success bool) string {
11761201
"backup_current_state": "Current state backed up successfully",
11771202
"rollback_changes": "Successfully rolled back to previous configuration",
11781203
"verify_upgrade_success": "Upgrade verification completed successfully",
1204+
"run_diagnostics": "Diagnostics completed successfully",
1205+
"slack_post_message": "Slack update sent",
1206+
"telescope_node_status": "Node health retrieved",
1207+
"telescope_sync_status": "Sync status retrieved",
1208+
"telescope_recent_errors": "Recent errors retrieved",
1209+
"telescope_get_logs": "Logs retrieved",
1210+
"telescope_query_logs": "Log query completed",
1211+
"telescope_query_metrics": "Metric query completed",
1212+
"telescope_cpu_usage": "CPU usage retrieved",
1213+
"telescope_memory_usage": "Memory usage retrieved",
1214+
"telescope_disk_usage": "Disk usage retrieved",
1215+
"telescope_network_usage": "Network usage retrieved",
11791216
}
11801217

11811218
if message, exists := successMessages[toolName]; exists {
@@ -1197,6 +1234,18 @@ func getToolCompletionMessage(toolName string, success bool) string {
11971234
"backup_current_state": "Failed to backup current state",
11981235
"rollback_changes": "Failed to rollback changes",
11991236
"verify_upgrade_success": "Upgrade verification failed",
1237+
"run_diagnostics": "Diagnostics failed",
1238+
"slack_post_message": "Failed to send Slack update",
1239+
"telescope_node_status": "Failed to retrieve node health",
1240+
"telescope_sync_status": "Failed to retrieve sync status",
1241+
"telescope_recent_errors": "Failed to retrieve recent errors",
1242+
"telescope_get_logs": "Failed to retrieve logs",
1243+
"telescope_query_logs": "Log query failed",
1244+
"telescope_query_metrics": "Metric query failed",
1245+
"telescope_cpu_usage": "Failed to retrieve CPU usage",
1246+
"telescope_memory_usage": "Failed to retrieve memory usage",
1247+
"telescope_disk_usage": "Failed to retrieve disk usage",
1248+
"telescope_network_usage": "Failed to retrieve network usage",
12001249
}
12011250

12021251
if message, exists := failureMessages[toolName]; exists {

0 commit comments

Comments
 (0)