Skip to content

Commit f42d82a

Browse files
committed
fix(ui): fully dim dashboard when help overlay is shown
When the help overlay was displayed on top of the dashboard, only the intersecting region appeared dimmed. The root cause: cancelFaint injects \033[22m (normal intensity) into each overlay line to keep it bright, and these codes survived into the composited result. A subsequent dimBackground pass couldn't override them. Fix: dimBackground now replaces \033[22m with \033[2m before applying its own faint, so nested overlays dim the entire background uniformly. Closes #146
1 parent d303ddd commit f42d82a

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

internal/app/view.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -949,6 +949,10 @@ func (m *Model) tableView(tab *Tab) string {
949949
// the dim state.
950950
func dimBackground(s string) string {
951951
dimmed := strings.ReplaceAll(s, "\033[0m", "\033[0;2m")
952+
// Neutralize cancel-faint markers left by a previous cancelFaint pass
953+
// (nested overlays). Without this, \033[22m codes embedded in an
954+
// earlier overlay's content would override the dim we're applying.
955+
dimmed = strings.ReplaceAll(dimmed, "\033[22m", "\033[2m")
952956
lines := strings.Split(dimmed, "\n")
953957
for i, line := range lines {
954958
lines[i] = "\033[2m" + line

internal/app/view_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -620,3 +620,17 @@ func TestHeaderTitleWidth(t *testing.T) {
620620
})
621621
}
622622
}
623+
624+
func TestDimBackgroundNeutralizesCancelFaint(t *testing.T) {
625+
// Simulate a composited overlay: cancelFaint injects \033[22m (normal
626+
// intensity) so the overlay content stays bright. A subsequent
627+
// dimBackground pass must neutralize those markers so the entire
628+
// background dims uniformly (nested overlay scenario).
629+
inner := cancelFaint("dashboard content")
630+
assert.Contains(t, inner, "\033[22m", "cancelFaint should inject normal-intensity")
631+
632+
dimmed := dimBackground(inner)
633+
assert.NotContains(t, dimmed, "\033[22m",
634+
"dimBackground should neutralize cancel-faint markers from nested overlays")
635+
assert.Contains(t, dimmed, "\033[2m", "dimBackground should apply faint")
636+
}

0 commit comments

Comments
 (0)