Skip to content

feat(core): derive missing ANSI 256 palette entries from base16#713

Open
kavhnr wants to merge 2 commits intoanomalyco:mainfrom
kavhnr:feat/ansi256-derived-palette
Open

feat(core): derive missing ANSI 256 palette entries from base16#713
kavhnr wants to merge 2 commits intoanomalyco:mainfrom
kavhnr:feat/ansi256-derived-palette

Conversation

@kavhnr
Copy link
Contributor

@kavhnr kavhnr commented Feb 19, 2026

Summary

  • Add CIELAB-based 256-color derivation from ANSI base16 in TerminalPalette, aligned with Ghostty's approach.
  • Fill missing palette indices 16-255 when size >= 256 and base16 + fg/bg are available, while preserving any explicit palette entries already returned by the terminal.
  • Add focused tests for derivation, non-overwrite behavior, and fallback defaults when OSC 10/11 are unavailable.

Context

This follows the Ghostty work and reference implementation notes:

Behavior

  • New GetPaletteOptions.generateFromBase16 option (default: true).
  • Generation activates only when:
    • size >= 256
    • ANSI 0-15 are present
    • foreground/background are available (from OSC 10/11, with fallback to palette 7/0).
  • Existing detected values for 16-255 are never overwritten.

Validation

  • bun test src/lib/palette-256.test.ts src/lib/terminal-palette.test.ts

@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 19, 2026

@opentui/core

npm i https://pkg.pr.new/anomalyco/opentui/@opentui/core@713

@opentui/react

npm i https://pkg.pr.new/anomalyco/opentui/@opentui/react@713

@opentui/solid

npm i https://pkg.pr.new/anomalyco/opentui/@opentui/solid@713

@opentui/core-darwin-arm64

npm i https://pkg.pr.new/anomalyco/opentui/@opentui/core-darwin-arm64@713

@opentui/core-darwin-x64

npm i https://pkg.pr.new/anomalyco/opentui/@opentui/core-darwin-x64@713

@opentui/core-linux-arm64

npm i https://pkg.pr.new/anomalyco/opentui/@opentui/core-linux-arm64@713

@opentui/core-linux-x64

npm i https://pkg.pr.new/anomalyco/opentui/@opentui/core-linux-x64@713

@opentui/core-win32-arm64

npm i https://pkg.pr.new/anomalyco/opentui/@opentui/core-win32-arm64@713

@opentui/core-win32-x64

npm i https://pkg.pr.new/anomalyco/opentui/@opentui/core-win32-x64@713

commit: 00deccc

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