Skip to content

fix: do not override a forced color profile with a capability report - #1773

Open
s-johri wants to merge 1 commit into
charmbracelet:mainfrom
s-johri:fix/forced-color-profile
Open

fix: do not override a forced color profile with a capability report#1773
s-johri wants to merge 1 commit into
charmbracelet:mainfrom
s-johri:fix/forced-color-profile

Conversation

@s-johri

@s-johri s-johri commented Aug 18, 2026

Copy link
Copy Markdown

What

WithColorProfile documents that it forces a color profile, but the event loop
replaces that profile when the terminal answers a capability request:

case CapabilityMsg:
	switch msg.Content {
	case "RGB", "Tc":
		if *p.profile != colorprofile.TrueColor {

Program keeps no record of where the profile came from, so this code cannot
tell a caller's choice from a detected value. It overwrites both.

Repro

p := tea.NewProgram(model, tea.WithColorProfile(colorprofile.NoTTY))
// Init or Update returns tea.RequestCapability("RGB").
// On a terminal that answers, the profile becomes TrueColor and color returns.

The new test drives the same path with p.Send(CapabilityMsg{Content: "RGB"}).

Fix

Record that the profile came from the option, then skip the upgrade. Detection
is unchanged, and a program that does not use the option behaves as before.

Found while mapping NO_COLOR to NoTTY. It also affects tests that pin a
profile, which the v2 upgrade guide recommends, and applications with their own
"color: off" setting.

Note for the reviewer

ColorProfileMsg is not sent when the profile is forced, because the profile
does not change. Tell me if you prefer to send it anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant