[PR #4842] fix: handle ANSI color indexes in theme resolution #11143

Closed
opened 2026-02-16 18:15:56 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/4842

State: closed
Merged: Yes


Fixes #4429.

Issue

The theme engine was crashing when encountering numeric color values (ANSI color indexes) in theme definitions. It expected strings (hex codes or reference names) or RGBA objects, but not numbers.

Fix

This PR adds native support for ANSI color indexes (0-255) in the resolveColor function.
It implements a new helper ansiToRgba that converts these indexes to their corresponding RGBA values:

  • 0-15: Standard ANSI colors.
  • 16-231: 6x6x6 Color Cube.
  • 232-255: Grayscale Ramp.

This ensures that themes using ANSI color codes work correctly instead of crashing the application.

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/4842 **State:** closed **Merged:** Yes --- Fixes #4429. ## Issue The theme engine was crashing when encountering numeric color values (ANSI color indexes) in theme definitions. It expected strings (hex codes or reference names) or RGBA objects, but not numbers. ## Fix This PR adds native support for ANSI color indexes (0-255) in the `resolveColor` function. It implements a new helper `ansiToRgba` that converts these indexes to their corresponding RGBA values: - **0-15**: Standard ANSI colors. - **16-231**: 6x6x6 Color Cube. - **232-255**: Grayscale Ramp. This ensures that themes using ANSI color codes work correctly instead of crashing the application.
yindo added the pull-request label 2026-02-16 18:15:56 -05:00
yindo closed this issue 2026-02-16 18:15:56 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#11143