Repository navigation
cli: use the terminal palette for low-confidence groups - #1538
Open
shivamtiwari3 wants to merge 1 commit into
Open
shivamtiwari3 wants to merge 1 commit into
shivamtiwari3 wants to merge 1 commit into
Conversation
…#1243) The fallback color for content type groups without an explicit truecolor mapping (including "text", "unknown", "binary", "font" and "inode") was a fixed light gray (#cccccc). On light-background terminals this is barely readable, as reported in google#1243. Use the terminal palette instead: bright black renders as a dark gray on light backgrounds and as a light gray on dark backgrounds, so it adapts to the user's theme without needing a new flag. This follows the preference noted in google#1243 that the palette is the safest choice. Add a regression test that checks the "text" group output uses the palette code and not the previous #cccccc truecolor.
This was referenced Oct 9, 2026
Author
|
@ia0 since you own the Rust code, could you take a look when you have a moment? It's a small change in The Rust CI job hasn't run yet — it may be waiting on a maintainer to approve workflows for this fork PR. Locally I get clean Heads up that #1531 also touches |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1243.
Summary
The Rust CLI's fallback color for content type groups without an explicit mapping (including the common
"text"and"unknown", plus"binary","database","font","geometry","gis","model","scientific","inode"and"undefined") was a fixed light gray,#cccccc:On a light-background terminal this is barely visible, which is what #1243 reports ("The very light gray used by low-quality detection reports works very poorly there").
Fix
Use the terminal palette for the fallback instead of a fixed truecolor:
bright_blackmaps to the terminal palette (ANSI bright black), so it renders as a dark gray on light backgrounds and as a light gray on dark backgrounds. It adapts to the user's theme, so no--light-modeflag or extra configuration is needed. This follows the preference already expressed on #1243 by @ia0 that using the palette is the safest choice.The eight highlighted groups keep their deliberate Tailwind truecolors; only the low-confidence fallback changes.
Testing
rust/cli/test.sh: added a regression test that runs the CLI with--colorson a plain.txtfile (group"text"), asserts the output contains the palette code (\x1b[1;90m) and does not contain the old#cccccctruecolor (\x1b[1;38;2;204;204;204m).cargo build,cargo clippy -- --deny=warningsandcargo fmt -- --checkare clean.magika --colors text.txtnow emits\x1b[1;90m...\x1b[0m.Notes
This is the Rust CLI counterpart of the now-closed #1317 (which targeted the removed Python fallback client). Opened as requested by @ebursztein on #1317, where #1243 was left open for the Rust CLI. Happy to switch to a
--light-modeflag or a--color-fileoption (both suggested on #1243) if you prefer that direction.