Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(phrocs): use truecolor selection bg in copy mode (#59210)

Georges-Antoine Assi598cacc0415f
diff --git a/tools/phrocs/internal/palette/palette.go b/tools/phrocs/internal/palette/palette.go
index 5f005dcfd2ef..388908ab0c39 100644
--- a/tools/phrocs/internal/palette/palette.go
+++ b/tools/phrocs/internal/palette/palette.go
@@ -9,16 +9,18 @@ import (
)
var isCursor = os.Getenv("CURSOR_TRACE_ID") != ""
+var isZed = os.Getenv("TERM_PROGRAM") == "zed" || os.Getenv("ZED_TERM") == "true"
-// Fallback to regular variant in Cursor's terminal to avoid SGR 100-107 bug
-func brightOr(bright ansi.BasicColor, regular ansi.BasicColor) ansi.BasicColor {
- if isCursor {
- return regular
+// Fallback to regular variant in Cursor/Zed terminals to avoid SGR 100-107 bug
+func sgrFallback(color ansi.Color, fallback ansi.Color) ansi.Color {
+ if isCursor || isZed {
+ return fallback
}
- return bright
+ return color
}
-// ANSI 4-bit colors — these adapt automatically to the terminal's theme,
+// ANSI 4-bit colors.
+// These adapt automatically to the terminal's theme,
// so the UI looks correct on both light and dark backgrounds without
// needing explicit light/dark branching.
var (
@@ -27,29 +29,30 @@ var (
BrandRed = lipgloss.Color("#F04438")
BrandBlack = lipgloss.Color("#151515")
- ColorBlack color.Color = lipgloss.Black // ANSI 0: contrast text on bright bg
- ColorRed color.Color = lipgloss.Red // ANSI 1: error/crashed
- ColorGreen color.Color = lipgloss.Green // ANSI 2: running status
- ColorYellow color.Color = lipgloss.Yellow // ANSI 3: warnings, pending
- ColorBlue color.Color = lipgloss.Blue // ANSI 4: copy mode
- ColorMagenta color.Color = lipgloss.Magenta // ANSI 5: (unused)
- ColorCyan color.Color = lipgloss.Cyan // ANSI 6: (unused)
- ColorWhite color.Color = lipgloss.White // ANSI 7: secondary text, inactive items
- ColorBrightBlack color.Color = brightOr(lipgloss.BrightBlack, lipgloss.Black) // ANSI 8: subtle text/borders (dark)
- ColorBrightRed color.Color = brightOr(lipgloss.BrightRed, lipgloss.Red) // ANSI 9: (unused)
- ColorBrightGreen color.Color = brightOr(lipgloss.BrightGreen, lipgloss.Green) // ANSI 10: (unused)
- ColorBrightYellow color.Color = brightOr(lipgloss.BrightYellow, lipgloss.Yellow) // ANSI 11: (unused)
- ColorBrightBlue color.Color = brightOr(lipgloss.BrightBlue, lipgloss.Blue) // ANSI 12: (unused)
- ColorBrightMagenta color.Color = brightOr(lipgloss.BrightMagenta, lipgloss.Magenta) // ANSI 13: (unused)
- ColorBrightCyan color.Color = brightOr(lipgloss.BrightCyan, lipgloss.Cyan) // ANSI 14: (unused)
- ColorBrightWhite color.Color = brightOr(lipgloss.BrightWhite, lipgloss.White) // ANSI 15: subtle text/borders (light)
-
- // Selection backgrounds use explicit RGB to dodge the Cursor terminal's
- // SGR 100-107 (bright background) rendering bug — the regular-variant
- // fallback above is invisible against typical dark/light terminal bgs,
- // and TrueColor (SGR 48;2;r;g;b) is unaffected by the bug.
- SelectionBgDark color.Color = lipgloss.Color("#3a3a3a")
- SelectionBgLight color.Color = lipgloss.Color("#d4d4d4")
+ ColorBlack color.Color = lipgloss.Black // ANSI 0: contrast text on bright bg
+ ColorRed color.Color = lipgloss.Red // ANSI 1: error/crashed
+ ColorGreen color.Color = lipgloss.Green // ANSI 2: running status
+ ColorYellow color.Color = lipgloss.Yellow // ANSI 3: warnings, pending
+ ColorBlue color.Color = lipgloss.Blue // ANSI 4: copy mode
+ ColorMagenta color.Color = lipgloss.Magenta // ANSI 5: (unused)
+ ColorCyan color.Color = lipgloss.Cyan // ANSI 6: (unused)
+ ColorWhite color.Color = lipgloss.White // ANSI 7: secondary text, inactive items
+ ColorBrightBlack color.Color = sgrFallback(lipgloss.BrightBlack, lipgloss.Black) // ANSI 8: subtle text/borders (dark)
+ ColorBrightRed color.Color = sgrFallback(lipgloss.BrightRed, lipgloss.Red) // ANSI 9: (unused)
+ ColorBrightGreen color.Color = sgrFallback(lipgloss.BrightGreen, lipgloss.Green) // ANSI 10: (unused)
+ ColorBrightYellow color.Color = sgrFallback(lipgloss.BrightYellow, lipgloss.Yellow) // ANSI 11: (unused)
+ ColorBrightBlue color.Color = sgrFallback(lipgloss.BrightBlue, lipgloss.Blue) // ANSI 12: (unused)
+ ColorBrightMagenta color.Color = sgrFallback(lipgloss.BrightMagenta, lipgloss.Magenta) // ANSI 13: (unused)
+ ColorBrightCyan color.Color = sgrFallback(lipgloss.BrightCyan, lipgloss.Cyan) // ANSI 14: (unused)
+ ColorBrightWhite color.Color = sgrFallback(lipgloss.BrightWhite, lipgloss.White) // ANSI 15: subtle text/borders (light)
+
+ // Selection backgrounds: ANSI 0/7 in normal terminals (theme-aware so
+ // the highlight blends with the user's color scheme), with an explicit
+ // RGB fallback in Cursor/Zed where ANSI 0/7 maps to the default
+ // terminal background and the selection paints invisibly. TrueColor
+ // (SGR 48;2;r;g;b) is unaffected by the SGR 100-107 bug.
+ SelectionDark color.Color = sgrFallback(lipgloss.Black, lipgloss.Color("#3a3a3a"))
+ SelectionLight color.Color = sgrFallback(lipgloss.White, lipgloss.Color("#d4d4d4"))
)
const (
diff --git a/tools/phrocs/internal/tui/copy.go b/tools/phrocs/internal/tui/copy.go
index 827dccdd7fe4..fbd35bae79e6 100644
--- a/tools/phrocs/internal/tui/copy.go
+++ b/tools/phrocs/internal/tui/copy.go
@@ -36,7 +36,7 @@ func (m *Model) applyCopyStyle() {
return copyModeStyle
}
if idx >= lo && idx <= hi {
- return lipgloss.NewStyle().Background(colorBlack)
+ return lipgloss.NewStyle().Background(selectionBg(m.isDark))
}
return lipgloss.NewStyle()
}
diff --git a/tools/phrocs/internal/tui/styles.go b/tools/phrocs/internal/tui/styles.go
index 5f02dcbc3c86..77aa8e713910 100644
--- a/tools/phrocs/internal/tui/styles.go
+++ b/tools/phrocs/internal/tui/styles.go
@@ -30,8 +30,8 @@ var (
colorBrightWhite = sharedpalette.ColorBrightWhite
colorBrightBlack = sharedpalette.ColorBrightBlack
colorBrightYellow = sharedpalette.ColorBrightYellow
- selectionBgDark = sharedpalette.SelectionBgDark
- selectionBgLight = sharedpalette.SelectionBgLight
+ selectionDark = sharedpalette.SelectionDark
+ selectionLight = sharedpalette.SelectionLight
brandYellow = sharedpalette.BrandYellow
brandBlue = sharedpalette.BrandBlue
brandRed = sharedpalette.BrandRed
@@ -163,7 +163,7 @@ func statusIconColor(s process.Status) color.Color {
}
}
-// Renders a single sidebar row with icon and name
+// Renders a single sidebar row with icon and name.
func subtleBg(isDark bool) color.Color {
if isDark {
return colorBrightBlack
@@ -171,14 +171,12 @@ func subtleBg(isDark bool) color.Color {
return colorBrightWhite
}
-// Selection fill color for highlighted rows. Uses TrueColor RGB rather than
-// ANSI bright black/white so it renders consistently in Cursor's terminal,
-// where SGR 100-107 bright background codes are buggy.
+// Selection fill color for highlighted rows.
func selectionBg(isDark bool) color.Color {
if isDark {
- return selectionBgDark
+ return selectionDark
}
- return selectionBgLight
+ return selectionLight
}
// borderFor returns the border style with a foreground appropriate for the