fix(cli): clamp curses color 8 for 8-color terminals (Docker)#30260
Merged
Conversation
curses.init_pair(N, 8, -1) uses extended color 8 ("bright black" /
dim gray) which does not exist on 8-color terminals (COLORS == 8,
valid range 0-7). This crashes the entire plugins UI, session
browser, and radio picker in Docker containers with:
curses.error: init_pair() : color number is greater than COLORS-1
Replace all 5 occurrences across plugins_cmd.py, main.py, and
curses_ui.py with min(8, curses.COLORS - 1), which falls back to
COLOR_WHITE (7) on 8-color terminals.
Closes #13688
Contributor
🔎 Lint report:
|
| Rule | Count |
|---|---|
unresolved-import |
1 |
First entries
tests/hermes_cli/test_curses_color_compat.py:17: [unresolved-import] unresolved-import: Cannot resolve imported module `pytest`
✅ Fixed issues: none
Unchanged: 4762 pre-existing issues carried over.
Diagnostics are surfaced as warnings — this check never fails the build.
19 tasks
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.
Salvage of #14771 by @Tranquil-Flow onto current main.
Summary
hermes plugins(and the session browser + curses radio picker) crashed in Docker containers with 8-color terminals becausecurses.init_pair(N, 8, -1)references color 8, which doesn't exist whencurses.COLORS == 8(valid range 0–7). Clamps fg to8 if curses.COLORS > 8 else curses.COLOR_WHITEat all 5 sites.Changes
hermes_cli/plugins_cmd.py: 3 siteshermes_cli/main.py: 1 site (session browser)hermes_cli/curses_ui.py: 1 site (curses_checklist)tests/hermes_cli/test_curses_color_compat.py(new): 3 behavioral tests (mockcurses.COLORSat 8/16/256) + 3 source guardrails preventing raw-8regressionsValidation
init_pairin the codebase usesCOLOR_*constants (0–7), only the raw8sites were broken.Fixes #13688. Closes #14771.
Infographic