mirror of
https://github.com/usestrix/strix.git
synced 2026-10-05 02:41:38 +00:00
fix(tui): drop the Model label from the stats panel
This commit is contained in:
parent
faca0d4d1d
commit
849671f288
3 changed files with 15 additions and 15 deletions
|
|
@ -109,15 +109,12 @@ func (m Model) panelTitle(panel sidebarPanel) string {
|
|||
case panelMcp:
|
||||
return fmt.Sprintf("MCP (%d)", len(m.snapshot.Connections))
|
||||
default:
|
||||
return "Model"
|
||||
return m.snapshot.Model
|
||||
}
|
||||
}
|
||||
|
||||
func (m Model) panelHeader(panel sidebarPanel, width int) string {
|
||||
style := lipgloss.NewStyle().Foreground(dim)
|
||||
if panel == panelStats {
|
||||
return truncate(style.Render(m.panelTitle(panel)), max(1, width))
|
||||
}
|
||||
glyph := panelZoomGlyph
|
||||
if m.zoomedPanel == panel {
|
||||
glyph = panelUnzoomGlyph
|
||||
|
|
@ -144,9 +141,12 @@ func (m Model) panelBox(panel sidebarPanel, body string, width, height int, focu
|
|||
if focused {
|
||||
border = green
|
||||
}
|
||||
content := m.panelHeader(panel, width-4)
|
||||
if body != "" {
|
||||
content += "\n" + body
|
||||
content := body
|
||||
if panel != panelStats {
|
||||
content = m.panelHeader(panel, width-4)
|
||||
if body != "" {
|
||||
content += "\n" + body
|
||||
}
|
||||
}
|
||||
return lipgloss.NewStyle().Width(width-2).Height(height-2).Border(lipgloss.RoundedBorder()).
|
||||
BorderForeground(border).Padding(0, 1).Render(content)
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ func panelsModel(t *testing.T) Model {
|
|||
url := "http://127.0.0.1:57388/?token=abc"
|
||||
m.snapshot = protocol.Snapshot{
|
||||
ScanStarted: true, ScanState: "running", Agents: agents, Connections: conns,
|
||||
ViewerStatus: "running", ViewerURL: &url,
|
||||
ViewerStatus: "running", ViewerURL: &url, Model: "openrouter/z-ai/glm-5.3",
|
||||
Vulnerabilities: []map[string]any{{"id": "v1", "title": "Finding one", "severity": "high"}},
|
||||
}
|
||||
m.resizeViewport()
|
||||
|
|
@ -58,7 +58,7 @@ func TestSidebarPanelsRenderHeadersWithControls(t *testing.T) {
|
|||
m := panelsModel(t)
|
||||
_, sidebarWidth, _, _ := m.layout()
|
||||
view := ansi.Strip(m.sidebarView(sidebarWidth, m.height))
|
||||
for _, want := range []string{"▾ Agents (31)", "▾ Findings (1)", "▾ MCP (12)", "Model", "⤢"} {
|
||||
for _, want := range []string{"▾ Agents (31)", "▾ Findings (1)", "▾ MCP (12)", "⤢"} {
|
||||
if !strings.Contains(view, want) {
|
||||
t.Fatalf("sidebar missing %q:\n%s", want, view)
|
||||
}
|
||||
|
|
@ -266,8 +266,8 @@ func TestModelPanelHasNoControlsAndNeverShrinks(t *testing.T) {
|
|||
_, sidebarWidth, _, _ := m.layout()
|
||||
stats := panelRectOf(t, m, panelStats)
|
||||
rows := strings.Split(ansi.Strip(m.sidebarView(sidebarWidth, m.height)), "\n")
|
||||
if header := rows[stats.top+1]; strings.ContainsAny(header, "▾▸⤢⤡") || !strings.Contains(header, "Model") {
|
||||
t.Fatalf("Model header should carry no controls: %q", header)
|
||||
if first := rows[stats.top+1]; strings.ContainsAny(first, "▾▸⤢⤡") || strings.Contains(first, "Model") || !strings.Contains(first, m.snapshot.Model[:8]) {
|
||||
t.Fatalf("Model panel should start with the model name and carry no controls: %q", first)
|
||||
}
|
||||
before := m.sidebarPanels()
|
||||
m = click(t, m, m.width-3, stats.top+1)
|
||||
|
|
@ -300,8 +300,8 @@ func TestModelPanelSticksToBottom(t *testing.T) {
|
|||
if len(rows) != m.height {
|
||||
t.Fatalf("sidebar renders %d rows, want %d", len(rows), m.height)
|
||||
}
|
||||
if !strings.Contains(rows[stats.top+1], "Model") {
|
||||
t.Fatalf("Model header not where its rect says:\n%s", strings.Join(rows[stats.top-2:], "\n"))
|
||||
if !strings.Contains(rows[stats.top+1], m.snapshot.Model[:8]) {
|
||||
t.Fatalf("Model panel not where its rect says:\n%s", strings.Join(rows[stats.top-2:], "\n"))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -585,7 +585,7 @@ func (m Model) sidebarView(width, height int) string {
|
|||
}
|
||||
stats := ""
|
||||
if statsHeight > 1 {
|
||||
stats = fixedPanelBody(lipgloss.NewStyle().Width(width-4).Render(m.statsView()), width-4, statsHeight-3)
|
||||
stats = fixedPanelBody(lipgloss.NewStyle().Width(width-4).Render(m.statsView()), width-4, statsHeight-2)
|
||||
}
|
||||
parts = append(parts, m.panelBox(panelStats, stats, width, statsHeight, false))
|
||||
return lipgloss.JoinVertical(lipgloss.Left, parts...)
|
||||
|
|
@ -596,7 +596,7 @@ func (m Model) sidebarHeights() (statsHeight, vulnHeight, mcpHeight, agentHeight
|
|||
// wraps inside the sidebar, and counting only its newlines would size the
|
||||
// box short and push the whole frame past the bottom of the terminal.
|
||||
statsRows := lipgloss.Height(lipgloss.NewStyle().Width(m.sidebarInnerWidth()).Render(m.statsView()))
|
||||
statsHeight = m.panelHeight(panelStats, min(15, statsRows+3))
|
||||
statsHeight = m.panelHeight(panelStats, min(15, statsRows+2))
|
||||
if len(m.snapshot.Vulnerabilities) > 0 {
|
||||
vulnHeight = m.panelHeight(panelFindings, min(12, len(m.vulnerabilityRows(m.vulnerabilityListWidth()))+3))
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue