MCPcopy Create free account
hub / github.com/Thunder-Compute/thunder-cli / renderEventsSection

Method renderEventsSection

tui/status.go:704–750  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

702}
703
704func (m *statusModel) renderEventsSection() string {
705 // Collect instances with recent events
706 type instanceEvent struct {
707 id string
708 name string
709 reason string
710 message string
711 timestamp time.Time
712 }
713
714 var events []instanceEvent
715 for _, instance := range m.instances {
716 if instance.LastRestart == nil {
717 continue
718 }
719 if !m.verbose && time.Since(instance.LastRestart.Timestamp) > time.Hour {
720 continue
721 }
722 events = append(events, instanceEvent{
723 id: instance.ID,
724 name: instance.Name,
725 reason: instance.LastRestart.Reason,
726 message: instance.LastRestart.Message,
727 timestamp: instance.LastRestart.Timestamp,
728 })
729 }
730
731 if len(events) == 0 {
732 return ""
733 }
734
735 var b strings.Builder
736 b.WriteString("\n")
737 b.WriteString(SubtleTextStyle().Bold(true).Render("Recent Events:"))
738 b.WriteString("\n\n")
739
740 for _, ev := range events {
741 ts := ev.timestamp.Local().Format("2006-01-02_15:04:05.0000")
742 b.WriteString(fmt.Sprintf(" %s\n", SubtleTextStyle().Render(ev.name)))
743 b.WriteString(fmt.Sprintf(" %s\n",
744 SubtleTextStyle().Render(fmt.Sprintf("[%s]: %s — %s", ts, ev.reason, ev.message)),
745 ))
746 b.WriteString("\n")
747 }
748
749 return b.String()
750}
751
752func truncate(s string, maxLen int) string {
753 if len(s) <= maxLen {

Callers 1

ViewMethod · 0.95

Calls 1

SubtleTextStyleFunction · 0.85

Tested by

no test coverage detected