Repository navigation
Preserve terminal theme contrast for status labels - #2592
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5c0c83e16c
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #2592 +/- ##
==========================================
- Coverage 93.87% 93.87% -0.01%
==========================================
Files 140 140
Lines 29060 29047 -13
==========================================
- Hits 27280 27267 -13
Misses 1780 1780 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
📦 Cargo Bloat Comparison
Expand for cargo-bloat outputHead Branch ResultsBase Branch Results |
⚡️ Hyperfine BenchmarksSummary: 0 regressions, 0 improvements above the 10% threshold. Environment
CLI CommandsBenchmarking basic commands in the main repo:
|
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
prek-base --version |
2.3 ± 0.1 | 2.1 | 2.5 | 1.06 ± 0.07 |
prek-head --version |
2.2 ± 0.1 | 2.0 | 2.4 | 1.00 |
prek list
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
prek-base list |
9.0 ± 0.3 | 8.8 | 11.3 | 1.03 ± 0.03 |
prek-head list |
8.8 ± 0.1 | 8.6 | 9.2 | 1.00 |
prek validate-config .pre-commit-config.yaml
⏭️ Skipped: .pre-commit-config.yaml not found
prek sample-config
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
prek-base sample-config |
2.5 ± 0.1 | 2.4 | 2.8 | 1.06 ± 0.06 |
prek-head sample-config |
2.4 ± 0.1 | 2.3 | 3.3 | 1.00 |
Cold vs Warm Runs
Comparing first run (cold) vs subsequent runs (warm cache):
prek run --all-files (cold - no cache)
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
prek-base run --all-files |
38.7 ± 1.2 | 37.1 | 40.6 | 1.02 ± 0.04 |
prek-head run --all-files |
38.1 ± 1.0 | 37.3 | 40.2 | 1.00 |
prek run --all-files (warm - with cache)
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
prek-base run --all-files |
39.3 ± 1.5 | 36.9 | 42.5 | 1.01 ± 0.05 |
prek-head run --all-files |
39.0 ± 1.1 | 36.9 | 40.6 | 1.00 |
Full Hook Suite
Running the builtin hook suite on the benchmark workspace:
prek run --all-files (full builtin hook suite)
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
prek-base run --all-files |
38.5 ± 1.1 | 35.8 | 40.9 | 1.01 ± 0.04 |
prek-head run --all-files |
38.2 ± 1.1 | 35.1 | 41.2 | 1.00 |
Individual Hook Performance
Benchmarking each hook individually on the test repo:
prek run trailing-whitespace --all-files
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
prek-base run trailing-whitespace --all-files |
13.0 ± 0.3 | 12.6 | 13.8 | 1.01 ± 0.03 |
prek-head run trailing-whitespace --all-files |
12.8 ± 0.3 | 12.1 | 13.4 | 1.00 |
prek run end-of-file-fixer --all-files
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
prek-base run end-of-file-fixer --all-files |
11.0 ± 0.3 | 10.3 | 11.8 | 1.01 ± 0.05 |
prek-head run end-of-file-fixer --all-files |
10.8 ± 0.5 | 10.2 | 12.7 | 1.00 |
prek run check-json --all-files
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
prek-base run check-json --all-files |
7.8 ± 0.2 | 7.5 | 8.3 | 1.01 ± 0.04 |
prek-head run check-json --all-files |
7.8 ± 0.3 | 7.4 | 8.4 | 1.00 |
prek run check-yaml --all-files
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
prek-base run check-yaml --all-files |
7.8 ± 0.1 | 7.5 | 8.0 | 1.04 ± 0.03 |
prek-head run check-yaml --all-files |
7.5 ± 0.2 | 7.2 | 7.9 | 1.00 |
prek run check-toml --all-files
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
prek-base run check-toml --all-files |
7.8 ± 0.3 | 7.4 | 8.4 | 1.03 ± 0.06 |
prek-head run check-toml --all-files |
7.6 ± 0.4 | 7.2 | 8.9 | 1.00 |
prek run check-xml --all-files
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
prek-base run check-xml --all-files |
7.6 ± 0.2 | 7.3 | 8.1 | 1.02 ± 0.05 |
prek-head run check-xml --all-files |
7.5 ± 0.3 | 7.1 | 8.1 | 1.00 |
prek run detect-private-key --all-files
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
prek-base run detect-private-key --all-files |
11.0 ± 0.5 | 10.1 | 12.1 | 1.03 ± 0.07 |
prek-head run detect-private-key --all-files |
10.7 ± 0.5 | 9.7 | 11.5 | 1.00 |
prek run fix-byte-order-marker --all-files
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
prek-base run fix-byte-order-marker --all-files |
13.3 ± 0.8 | 11.9 | 14.9 | 1.01 ± 0.12 |
prek-head run fix-byte-order-marker --all-files |
13.2 ± 1.3 | 11.8 | 18.5 | 1.00 |
Installation Performance
Benchmarking hook installation (fast path hooks skip Python setup):
prek install-hooks (cold - no cache)
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
prek-base install-hooks |
4.5 ± 0.1 | 4.5 | 4.6 | 1.04 ± 0.02 |
prek-head install-hooks |
4.4 ± 0.1 | 4.3 | 4.5 | 1.00 |
prek install-hooks (warm - with cache)
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
prek-base install-hooks |
4.6 ± 0.1 | 4.5 | 4.7 | 1.04 ± 0.02 |
prek-head install-hooks |
4.4 ± 0.1 | 4.3 | 4.5 | 1.00 |
File Filtering/Scoping Performance
Testing different file selection modes:
prek run (staged files only)
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
prek-base run |
23.6 ± 0.2 | 23.2 | 24.1 | 1.01 ± 0.02 |
prek-head run |
23.5 ± 0.3 | 22.9 | 24.0 | 1.00 |
prek run --files '*.json' (specific file type)
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
prek-base run --files '*.json' |
5.2 ± 0.1 | 5.1 | 5.4 | 1.06 ± 0.02 |
prek-head run --files '*.json' |
5.0 ± 0.0 | 4.9 | 5.1 | 1.00 |
Workspace Discovery & Initialization
Benchmarking hook discovery and initialization overhead:
prek run --dry-run --all-files (measures init overhead)
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
prek-base run --dry-run --all-files |
6.9 ± 0.2 | 6.8 | 7.6 | 1.04 ± 0.03 |
prek-head run --dry-run --all-files |
6.7 ± 0.1 | 6.6 | 6.8 | 1.00 |
Meta Hooks Performance
Benchmarking meta hooks separately:
prek run check-hooks-apply --all-files
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
prek-base run check-hooks-apply --all-files |
8.1 ± 0.1 | 8.0 | 8.2 | 1.03 ± 0.01 |
prek-head run check-hooks-apply --all-files |
7.8 ± 0.1 | 7.7 | 8.0 | 1.00 |
prek run check-useless-excludes --all-files
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
prek-base run check-useless-excludes --all-files |
8.1 ± 0.1 | 7.9 | 8.2 | 1.03 ± 0.02 |
prek-head run check-useless-excludes --all-files |
7.8 ± 0.1 | 7.7 | 8.0 | 1.00 |
prek run identity --all-files
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
prek-base run identity --all-files |
7.0 ± 0.1 | 6.9 | 7.1 | 1.03 ± 0.02 |
prek-head run identity --all-files |
6.8 ± 0.1 | 6.7 | 7.0 | 1.00 |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 84be964f6f
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
@gurgeous Why are you using ANSI 256 colors instead of explicit 24-bit Truecolor? |
I have no preference personally. There are still a few terminals that don't support truecolor. Last time I looked the two major laggards were gitlab CI and Apple Terminal pre-Tahoe. Popular software (like prek) might encounter those in the wild, so sometimes it's easier to just use ansi 256. Totally up to you, of course. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 298ae473d5
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
Thanks for confirming! I think any terminal theme should at least keep these predefined colors readable against its default background, so reverse video seems like the safest option here. |
|
BTW I added a tool on ansi.md to illustrate for next time, in case anyone is interested. Still love prek and use it in all my projects, thank you for this fix. See https://ansi.md/bad-colors. "theme bg" on "ansi green" looks ok, though there are a few themes that are hard to read. |

Love prek, I am using it in all my projects now. There is just one tiny thing I would like to fix... See #1310, which is still a problem for many terminal themes (like mine).
We should probably be using fully specified ansi colors for bg/fg since you can't rely on the user's theme for bg colors. This PR switches to ANSI 256 colors (from ANSI 16). Also consider adding a space on either side of the text to make it prettier, but that's a separate thing. Thanks guys!
NEW
OLD
Fixes #1310