Upgrade rivo/tview to v0.42.0
Problem to solve
The current version of rivo/tview is v0.0.0-20230621164836-6cc0565babaf
. There has been a recent release that introduces Semantic Versioning. The library is generally backwards-compatible by default
Proposal
Upgrade the package and verify behavior with unit tests
Further details
The newer version also introduces Pages.GetPage()
, which can be used instead of the current manual page tracking approach:
Current Approach: Manual tracking with maps
view.go
var (
boxes map[string]*tview.TextView // For pipeline visualization
logViews map[string]*tview.TextView // For log content (search functionality)
)
// Store TextView manually
if logViews == nil {
logViews = make(map[string]*tview.TextView)
}
logViews[logsKey] = tv
// Retrieve TextView manually
if logViews != nil {
if tv, exists := logViews[logsKey]; exists {
logContent = tv.GetText(false)
}
}
Proposed Approach with GetPage()
func getLogContent(jobName string) string {
logsKey := "logs-" + jobName
if page := root.GetPage(logsKey); page != nil {
if tv, ok := page.(*tview.TextView); ok {
return tv.GetText(false)
}
}
return ""
}
Benefits:
- Eliminate separate tracking maps (reduced complexity)
- Let
tview
manage page lifecycle (memory efficiency) - Less manual state synchronization required (bug risk reduced)