[PR #713] feat(core): derive missing ANSI 256 palette entries from base16 #730

Open
opened 2026-03-02 23:47:52 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/anomalyco/opentui/pull/713
Author: @kavhnr
Created: 2/19/2026
Status: 🔄 Open

Base: mainHead: feat/ansi256-derived-palette


📝 Commits (2)

  • a075cd5 feat(core): derive missing ansi256 palette entries from base16
  • 00deccc refactor(core): tighten ansi256 derivation defaults and API surface

📊 Changes

4 files changed (+324 additions, -4 deletions)

View changed files

packages/core/src/lib/palette-256.test.ts (+43 -0)
packages/core/src/lib/palette-256.ts (+173 -0)
📝 packages/core/src/lib/terminal-palette.test.ts (+88 -0)
📝 packages/core/src/lib/terminal-palette.ts (+20 -4)

📄 Description

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

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/anomalyco/opentui/pull/713 **Author:** [@kavhnr](https://github.com/kavhnr) **Created:** 2/19/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `feat/ansi256-derived-palette` --- ### 📝 Commits (2) - [`a075cd5`](https://github.com/anomalyco/opentui/commit/a075cd5d56b01313a70c9a606c76efb35f218e57) feat(core): derive missing ansi256 palette entries from base16 - [`00deccc`](https://github.com/anomalyco/opentui/commit/00deccce57c81e49bd5e2fc6af6e0fcfb4567f1b) refactor(core): tighten ansi256 derivation defaults and API surface ### 📊 Changes **4 files changed** (+324 additions, -4 deletions) <details> <summary>View changed files</summary> ➕ `packages/core/src/lib/palette-256.test.ts` (+43 -0) ➕ `packages/core/src/lib/palette-256.ts` (+173 -0) 📝 `packages/core/src/lib/terminal-palette.test.ts` (+88 -0) 📝 `packages/core/src/lib/terminal-palette.ts` (+20 -4) </details> ### 📄 Description ## 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: - https://github.com/ghostty-org/ghostty/pull/10554 - https://gist.github.com/jake-stewart/0a8ea46159a7da2c808e5be2177e1783 ## 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` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/opentui#730
No description provided.