MCPcopy Create free account
hub / github.com/devnullvoid/pvetui / ShowResultModal

Method ShowResultModal

internal/plugins/command-runner/ui.go:294–359  ·  view source on GitHub ↗

ShowResultModal displays the command execution result in a modal

(result ExecutionResult, onClose func())

Source from the content-addressed store, hash-verified

292
293// ShowResultModal displays the command execution result in a modal
294func (u *UIManager) ShowResultModal(result ExecutionResult, onClose func()) {
295 pages := u.app.Pages()
296
297 // Remove the "executing" modal first
298 pages.RemovePage("executingCommand")
299
300 // Close function that removes the result page
301 closeResult := func() {
302 pages.RemovePage("commandResult")
303 if onClose != nil {
304 onClose()
305 }
306 }
307
308 var text strings.Builder
309
310 fmt.Fprintf(&text, "Command: %s\n", result.Command)
311 fmt.Fprintf(&text, "Duration: %v\n\n", result.Duration)
312
313 if result.Error != nil {
314 fmt.Fprintf(&text, "Error: %v\n\n", result.Error)
315 if result.Output != "" {
316 text.WriteString("Output:\n")
317 text.WriteString(result.Output)
318 }
319 } else {
320 text.WriteString("Output:\n")
321 text.WriteString(result.Output)
322
323 if result.Truncated {
324 text.WriteString("\n\n[Output truncated]")
325 }
326 }
327
328 // Create text view for scrollable output
329 textView := tview.NewTextView().
330 SetText(text.String()).
331 SetDynamicColors(true).
332 SetScrollable(true)
333
334 textView.SetBorder(true)
335 textView.SetTitle(" Command Result ")
336
337 // Set input handler on the text view (which will have focus)
338 textView.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey {
339 if isBackKey(event) {
340 closeResult()
341 return nil // Consume the event to prevent bubbling
342 }
343 return event
344 })
345
346 // Add button bar at bottom with color tags
347 buttons := tview.NewTextView().
348 SetText(" [primary]ESC/Backspace[-] Close | [primary]↑/↓[-] Scroll ").
349 SetTextAlign(tview.AlignCenter).
350 SetDynamicColors(true)
351

Callers 1

executeAndShowResultMethod · 0.95

Calls 5

isBackKeyFunction · 0.70
PagesMethod · 0.65
SetTitleMethod · 0.65
SetTextMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected