Skip to content

Commit 2d4c55f

Browse files
committed
fix: compact risk panel layout to save vertical space
1 parent ec7f5cb commit 2d4c55f

1 file changed

Lines changed: 41 additions & 22 deletions

File tree

internal/tui/risk_panel.go

Lines changed: 41 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -110,20 +110,25 @@ func (p riskPanel) render(caps detect.Capabilities, mode detect.PastewatchMode,
110110
b.WriteString("\n")
111111
}
112112

113-
// Pressure heat map — per-sentence risk
113+
// Pressure heat map — compact single-line when one sentence.
114114
if len(p.pressureScores) > 0 {
115115
b.WriteString("\n")
116-
b.WriteString(stylePanelTitle.Render("PRESSURE"))
117-
b.WriteString("\n")
118-
maxShow := 8
119-
for i, ps := range p.pressureScores {
120-
if i >= maxShow {
121-
b.WriteString(styleMuted.Render(fmt.Sprintf(" ... +%d more", len(p.pressureScores)-maxShow)))
116+
if len(p.pressureScores) == 1 {
117+
b.WriteString(stylePanelTitle.Render("PRESSURE") + " " + renderPressureBarInline(p.pressureScores[0]))
118+
b.WriteString("\n")
119+
} else {
120+
b.WriteString(stylePanelTitle.Render("PRESSURE"))
121+
b.WriteString("\n")
122+
maxShow := 8
123+
for i, ps := range p.pressureScores {
124+
if i >= maxShow {
125+
b.WriteString(styleMuted.Render(fmt.Sprintf(" ... +%d more", len(p.pressureScores)-maxShow)))
126+
b.WriteString("\n")
127+
break
128+
}
129+
b.WriteString(renderPressureBar(ps))
122130
b.WriteString("\n")
123-
break
124131
}
125-
b.WriteString(renderPressureBar(ps))
126-
b.WriteString("\n")
127132
}
128133
}
129134

@@ -248,12 +253,10 @@ func (p riskPanel) render(caps detect.Capabilities, mode detect.PastewatchMode,
248253
}
249254
}
250255

251-
// VectorCourt account status — only when configured and fetched.
256+
// VectorCourt account status — compact header with tier.
252257
if p.accountStatus != nil {
253258
b.WriteString("\n")
254-
b.WriteString(stylePanelTitle.Render("VECTORCOURT"))
255-
b.WriteString("\n")
256-
b.WriteString(styleMuted.Render(fmt.Sprintf(" tier: %s", p.accountStatus.Tier)))
259+
b.WriteString(stylePanelTitle.Render(fmt.Sprintf("VECTORCOURT [%s]", p.accountStatus.Tier)))
257260
b.WriteString("\n")
258261
used := p.accountStatus.SubmissionsToday
259262
limit := p.accountStatus.DailyLimit
@@ -402,23 +405,19 @@ func (p riskPanel) render(caps detect.Capabilities, mode detect.PastewatchMode,
402405

403406
func (p riskPanel) renderPastewatchStatus(b *strings.Builder, caps detect.Capabilities, mode detect.PastewatchMode, scan detect.ScanResult) {
404407
label := detect.StatusLabel(caps, mode)
405-
b.WriteString(styleMuted.Render(" pastewatch: "))
406408

407409
if !caps.Pastewatch {
408-
b.WriteString(styleMuted.Render(label))
410+
b.WriteString(styleMuted.Render(" pastewatch: " + label))
409411
b.WriteString("\n")
410412
return
411413
}
412414

413-
b.WriteString(styleMuted.Render(label))
414-
b.WriteString("\n")
415-
416-
// Show scan result if there was a scan.
415+
// Compact: pastewatch + clipboard status on one line.
417416
if scan.Clean {
418-
b.WriteString(styleSuccess.Render(" clipboard: ✓ clean"))
417+
b.WriteString(styleMuted.Render(" pastewatch: "+label+" | ") + styleSuccess.Render("✓ clean"))
419418
b.WriteString("\n")
420419
} else {
421-
b.WriteString(styleError.Render(" clipboard: ⚠ secrets detected"))
420+
b.WriteString(styleMuted.Render(" pastewatch: "+label+" | ") + styleError.Render("⚠ secrets"))
422421
b.WriteString("\n")
423422
for _, finding := range scan.Findings {
424423
b.WriteString(styleError.Render(fmt.Sprintf(" - %s", finding)))
@@ -452,6 +451,26 @@ func renderPressureBar(ps pressure.SentenceScore) string {
452451
return s.Render(fmt.Sprintf(" %s %3d%s", bar, ps.Score, signals))
453452
}
454453

454+
// renderPressureBarInline returns a compact bar without leading whitespace (for inline use).
455+
func renderPressureBarInline(ps pressure.SentenceScore) string {
456+
barLen := ps.Score / 10
457+
if barLen < 1 && ps.Score > 0 {
458+
barLen = 1
459+
}
460+
bar := strings.Repeat("█", barLen) + strings.Repeat("░", 10-barLen)
461+
462+
var s lipgloss.Style
463+
switch ps.Level {
464+
case pressure.LevelHigh:
465+
s = styleError
466+
case pressure.LevelMedium:
467+
s = styleWarning
468+
default:
469+
s = styleSuccess
470+
}
471+
return s.Render(fmt.Sprintf("%s %d", bar, ps.Score))
472+
}
473+
455474
func describeDriftChange(axis drift.Axis, c drift.TokenChange) string {
456475
switch c.Kind {
457476
case "upgrade":

0 commit comments

Comments
 (0)