mirror of
https://github.com/hanzoai/insights.git
synced 2026-10-30 16:15:31 +00:00
The tree was a debranded snapshot of upstream taken around 2026-02-20, and upstream has moved about five months since. This replaces it with upstream master, mechanically re-derived: bin/debrand does the rename, and the pipeline and squashed migrations are restored from the shipped tree. Not a merge. The previous import replaced the tree wholesale in a single commit, so there is no shared content history to merge against. Reproducing the rename on the new tree is what actually converges. What survives: .hanzo/workflows, the Dockerfiles and bin/docker* entrypoints, compose files, LLM.md, and insights/migrations. The squashed initial migration is load-bearing — the live database records it by name, so upstream's ~918 individual migrations cannot come back. Nine products are dropped as unreferenced. Twenty-one more that we do not run are kept anyway because the core app still imports them; unpicking those is a refactor and does not belong in a rebase. This base does not build yet, and the reasons are not in the rename: upstream now wants Python 3.13.13 against our 3.12.12 and Django 5.2 against our 4.2, and the dependency manifests still name upstream packages that we republish under our own names. Those are decisions, not renames.
111 lines
2.9 KiB
Go
111 lines
2.9 KiB
Go
package tui
|
|
|
|
import (
|
|
"image/color"
|
|
"strings"
|
|
|
|
"github.com/insights/insights/phrocs/internal/docker"
|
|
)
|
|
|
|
// Returns true when the active process is a docker-compose process
|
|
func (m Model) isDockerMode() bool {
|
|
p := m.activeProc()
|
|
return p != nil && docker.IsDockerComposeShell(p.Cfg.Shell)
|
|
}
|
|
|
|
// Returns the service name of the selected container, or "" for status view
|
|
func (m Model) selectedContainerService() string {
|
|
if m.containerCursor <= 0 || m.containerCursor > len(m.containers) {
|
|
return ""
|
|
}
|
|
return m.containers[m.containerCursor-1].Service
|
|
}
|
|
|
|
// Returns the total number of entries in the container sidebar (1 status + N containers)
|
|
func (m Model) containerEntryCount() int {
|
|
return 1 + len(m.containers)
|
|
}
|
|
|
|
func (m *Model) ensureContainerCursorVisible() {
|
|
h := m.sidebarHeight()
|
|
total := m.containerEntryCount()
|
|
if total <= h {
|
|
m.containerOffset = 0
|
|
return
|
|
}
|
|
|
|
maxOffset := total - h
|
|
if m.containerOffset > maxOffset {
|
|
m.containerOffset = max(0, maxOffset)
|
|
}
|
|
|
|
if m.containerCursor < m.containerOffset {
|
|
m.containerOffset = m.containerCursor
|
|
} else if m.containerCursor >= m.containerOffset+h {
|
|
m.containerOffset = m.containerCursor - h + 1
|
|
}
|
|
}
|
|
|
|
// Updates the viewport when the container selection changes
|
|
func (m Model) loadContainerView() Model {
|
|
if m.containerLogStream != nil {
|
|
m.containerLogStream.Stop()
|
|
m.containerLogStream = nil
|
|
}
|
|
m.containerLines = nil
|
|
|
|
svc := m.selectedContainerService()
|
|
if svc == "" {
|
|
// Status view
|
|
m.viewport.SetContent(docker.RenderContainerStatusTable(m.containers, m.viewport.Width()))
|
|
m.viewport.GotoTop()
|
|
m.viewportAtBottom = false
|
|
} else {
|
|
// Start streaming logs for the selected container
|
|
m.containerLogStream = docker.StartContainerLogStream(m.composeArgs, svc, m.mgr.Send())
|
|
m.viewport.SetContent("")
|
|
m.viewportAtBottom = true
|
|
}
|
|
if m.searchQuery != "" {
|
|
m.recomputeSearch()
|
|
}
|
|
return m
|
|
}
|
|
|
|
func (m Model) renderContainerSidebar() string {
|
|
h := m.sidebarHeight()
|
|
innerW := containerSidebarWidth - 1
|
|
totalEntries := m.containerEntryCount()
|
|
|
|
start := max(0, min(m.containerOffset, max(0, totalEntries-1)))
|
|
end := min(totalEntries, start+h)
|
|
|
|
var rows []string
|
|
for i := start; i < end; i++ {
|
|
var icon, name string
|
|
var iconColor color.Color
|
|
if i == 0 {
|
|
icon, name, iconColor = "🐋", "Status", colorBlue
|
|
} else {
|
|
c := m.containers[i-1]
|
|
icon = docker.ContainerStateIcon(c.State)
|
|
name = truncate(c.Service, innerW-3)
|
|
iconColor = docker.ContainerStateColor(c.State)
|
|
}
|
|
rows = append(rows, renderSidebarRow(sidebarRow{
|
|
icon: icon,
|
|
name: name,
|
|
iconColor: iconColor,
|
|
selected: i == m.containerCursor,
|
|
innerW: innerW,
|
|
isDark: m.isDark,
|
|
}))
|
|
}
|
|
|
|
for i := end - start; i < h; i++ {
|
|
rows = append(rows, procInactiveStyle.Width(innerW).Render(""))
|
|
}
|
|
|
|
return borderFor(m.isDark, m.focusedPane == focusContainers).Height(h).Render(strings.Join(rows, "\n"))
|
|
}
|