Hmbown/CodeWhale · error

truecolor tint

Error message

truecolor tint

What it means

This is a Rust `Option::expect` panic with the message 'truecolor tint': `reasoning_surface_tint(ColorDepth::TrueColor)` returned None, so calling adapt_bg_for_palette_mode on it never happened and the test aborted. The library's tint function throws (returns None) when it cannot resolve a reasoning-surface tint for the requested color depth — i.e. the TrueColor branch lacks a tint entry or the internal lookup is misconfigured. It indicates an internal lookup gap rather than bad caller input.

Solutions

  1. Inspect reasoning_surface_tint's implementation and add/restore the TrueColor entry in its lookup so the Option is Some.
  2. Exhaustively match the ColorDepth enum (match without wildcard) so the compiler forces a tint for every variant added later.
  3. If None is legitimate for some depths, make the function return Result and let tests assert the specific expected depth.

Example fix

// before
fn reasoning_surface_tint(depth: ColorDepth) -> Option<Rgb> {
    match depth {
        ColorDepth::Simple => Some(SIMPLE_TINT),
        _ => None,
    }
}
// after
fn reasoning_surface_tint(depth: ColorDepth) -> Option<Rgb> {
    match depth {
        ColorDepth::Simple => Some(SIMPLE_TINT),
        ColorDepth::TrueColor => Some(TRUECOLOR_TINT),
    }
}
Defensive patterns

Strategy: type-guard

Validate before calling

if reasoning_surface_tint(ColorDepth::TrueColor).is_none() {
    panic!("tint table has no TrueColor entry; extend reasoning_surface_tint's match");
}

Type guard

fn has_truecolor_tint(depth: ColorDepth) -> bool {
    reasoning_surface_tint(depth).is_some()
}

Try / catch

let tint = reasoning_surface_tint(ColorDepth::TrueColor)
    .unwrap_or_else(|| panic!("no reasoning tint for ColorDepth::TrueColor — check the tint table"));

Prevention

When it happens

Trigger: Calling `reasoning_surface_tint(ColorDepth::TrueColor)` (or any ColorDepth variant) when the tint table for that depth has no entry — e.g. a new ColorDepth enum member added without extending the tint mapping, or a feature/precision downgrade path that yields no TrueColor tint.

Common situations: Adding a new ColorDepth variant without updating reasoning_surface_tint's match; regressing the tint table during palette refactors; tests asserting per-depth tint availability after the mapping was narrowed.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@433685b202 (2026-09-15). Data as JSON: /api/errors/d843606535882754. Report an issue: GitHub.

Appendix: source

Thrown at crates/palette/src/tests.rs:564

}

#[test]
fn light_palette_maps_reasoning_tint_to_light_surface() {
    assert_eq!(
        SURFACE_REASONING_TINT,
        Color::Rgb(
            WHALE_REASONING_TINT_RGB.0,
            WHALE_REASONING_TINT_RGB.1,
            WHALE_REASONING_TINT_RGB.2
        )
    );
    assert_eq!(
        adapt_bg_for_palette_mode(SURFACE_REASONING_TINT, PaletteMode::Light),
        LIGHT_REASONING
    );
    assert_eq!(
        adapt_bg_for_palette_mode(
            reasoning_surface_tint(ColorDepth::TrueColor).expect("truecolor tint"),
            PaletteMode::Light,
        ),
        LIGHT_REASONING
    );
}

#[test]
fn blend_at_zero_returns_bg_at_one_returns_fg() {
    let fg = Color::Rgb(200, 100, 50);
    let bg = Color::Rgb(0, 0, 0);
    assert_eq!(blend(fg, bg, 0.0), bg);
    assert_eq!(blend(fg, bg, 1.0), fg);
}

#[test]
fn blend_at_half_is_midpoint() {
    let mid = blend(Color::Rgb(200, 100, 0), Color::Rgb(0, 0, 0), 0.5);
    assert_eq!(mid, Color::Rgb(100, 50, 0));

View on GitHub (pinned to 433685b202)