Skip to content

terminal: Fix 8 bit colors - #54565

Merged
ConradIrwin merged 2 commits into
zed-industries:mainfrom
feitreim:bugfix-color-ramp
Apr 30, 2026
Merged

terminal: Fix 8 bit colors#54565
ConradIrwin merged 2 commits into
zed-industries:mainfrom
feitreim:bugfix-color-ramp

Conversation

@feitreim

@feitreim feitreim commented Apr 22, 2026

Copy link
Copy Markdown
Collaborator

Right now the terminal rendering code applies a minimum contrast value (which is good, and for accessibility) to colors that appear, there was already an exemption from this for 24bit color specification, because the application explicitly asked for that color, so it should be rendered that color.

My change changes that exemption to also include ansi colors 16-255, because these are also set explicitly, the normal, non-exempt case is now the default ansi colors, 0-15, these are set by the theme and are usually specified as just 'red' or 'green', hence the importance of the min contrast.

Heres what the gradient ramp from the original issue looks like now:

Screenshot 2026-04-22 at 6 45 43 PM

This matches ghostty and VSCodium from the original issue.

test prevents regressions but idk, maybe not nessecary.

Self-Review Checklist:

  • I've reviewed my own diff for quality, security, and reliability
  • Unsafe blocks (if any) have justifying comments
  • The content is consistent with the UI/UX checklist
  • Tests cover the new/changed behavior
  • Performance impact has been considered and is acceptable

Closes #54396

Release Notes:

  • terminal: Improved 256 color ansi rendering

@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label Apr 22, 2026
@zed-community-bot zed-community-bot Bot added the guild Pull requests by someone in Zed Guild. NOTE: the label application is automated via github actions label Apr 22, 2026
Extract the contrast-skip predicate into is_app_chosen_exact_color and
cover the 256-color palette boundary (15/16 and 231/232/255), true-color
Spec, and theme-named variants so the chosen cutoff is locked in.
@ConradIrwin

Copy link
Copy Markdown
Member

Thanks! Willing to give this a go.

@ConradIrwin
ConradIrwin added this pull request to the merge queue Apr 30, 2026
Merged via the queue into zed-industries:main with commit 77cfc5d Apr 30, 2026
32 checks passed
@feitreim
feitreim deleted the bugfix-color-ramp branch April 30, 2026 17:25
ebaah46 pushed a commit to ebaah46/zed that referenced this pull request May 6, 2026
Right now the terminal rendering code applies a minimum contrast value
(which is good, and for accessibility) to colors that appear, there was
already an exemption from this for 24bit color specification, because
the application explicitly asked for that color, so it should be
rendered that color.

My change changes that exemption to also include ansi colors 16-255,
because these are also set explicitly, the normal, non-exempt case is
now the default ansi colors, 0-15, these are set by the theme and are
usually specified as just 'red' or 'green', hence the importance of the
min contrast.

Heres what the gradient ramp from the original issue looks like now:

<img width="944" height="1123" alt="Screenshot 2026-04-22 at 6 45 43 PM"
src="https://github.com/user-attachments/assets/918d62db-ed8e-475c-9ec1-c60187ad4b5e"
/>

This matches ghostty and VSCodium from the original issue.

test prevents regressions but idk, maybe not nessecary.

Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Closes zed-industries#54396 

Release Notes:

- terminal: Improved 256 color ansi rendering
jonx pushed a commit to jonx/zed-aros that referenced this pull request Jul 17, 2026
Right now the terminal rendering code applies a minimum contrast value
(which is good, and for accessibility) to colors that appear, there was
already an exemption from this for 24bit color specification, because
the application explicitly asked for that color, so it should be
rendered that color.

My change changes that exemption to also include ansi colors 16-255,
because these are also set explicitly, the normal, non-exempt case is
now the default ansi colors, 0-15, these are set by the theme and are
usually specified as just 'red' or 'green', hence the importance of the
min contrast.

Heres what the gradient ramp from the original issue looks like now:

<img width="944" height="1123" alt="Screenshot 2026-04-22 at 6 45 43 PM"
src="https://github.com/user-attachments/assets/918d62db-ed8e-475c-9ec1-c60187ad4b5e"
/>

This matches ghostty and VSCodium from the original issue.

test prevents regressions but idk, maybe not nessecary.

Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Closes zed-industries#54396 

Release Notes:

- terminal: Improved 256 color ansi rendering
jolutz pushed a commit to jolutz/zed that referenced this pull request Aug 8, 2026
Right now the terminal rendering code applies a minimum contrast value
(which is good, and for accessibility) to colors that appear, there was
already an exemption from this for 24bit color specification, because
the application explicitly asked for that color, so it should be
rendered that color.

My change changes that exemption to also include ansi colors 16-255,
because these are also set explicitly, the normal, non-exempt case is
now the default ansi colors, 0-15, these are set by the theme and are
usually specified as just 'red' or 'green', hence the importance of the
min contrast.

Heres what the gradient ramp from the original issue looks like now:

<img width="944" height="1123" alt="Screenshot 2026-04-22 at 6 45 43 PM"
src="https://github.com/user-attachments/assets/918d62db-ed8e-475c-9ec1-c60187ad4b5e"
/>

This matches ghostty and VSCodium from the original issue.

test prevents regressions but idk, maybe not nessecary.

Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Closes zed-industries#54396 

Release Notes:

- terminal: Improved 256 color ansi rendering
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement guild Pull requests by someone in Zed Guild. NOTE: the label application is automated via github actions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Grayscale terminal 8-bit colors (256 colors) seem broken

2 participants