fix(cli): clamp curses color 8 for 8-color terminals (Docker)#14771
Closed
Tranquil-Flow wants to merge 1 commit into
Closed
fix(cli): clamp curses color 8 for 8-color terminals (Docker)#14771Tranquil-Flow wants to merge 1 commit into
Tranquil-Flow wants to merge 1 commit into
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 NousResearch#13688
Contributor
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.
What does this PR do?
Fixes a crash in
hermes plugins, the session browser, and the curses radio picker on 8-color terminals (common in Docker containers).curses.init_pair(N, 8, -1)uses extended color 8 ("bright black" / dim gray) which does not exist whencurses.COLORS == 8(valid range: 0-7), causingcurses.error: init_pair() : color number is greater than COLORS-1.Replaces all 5 instances across 3 files with
8 if curses.COLORS > 8 else curses.COLOR_WHITE, falling back to white (7) on 8-color terminals.Related Issue
Fixes #13688
Type of Change
Changes Made
hermes_cli/plugins_cmd.py: Fixed 3 instances of raw color 8 in_run_composite_ui()color init blockshermes_cli/main.py: Fixed 1 instance in session browser color inithermes_cli/curses_ui.py: Fixed 1 instance incurses_checklist()color inittests/hermes_cli/test_curses_color_compat.py(new): 3 behavioral tests (mockcurses.COLORSat 8/16/256, verifyinit_paircalled with clamped values) + 3 source guardrail testsHow to Test
python -m pytest -o 'addopts=' tests/hermes_cli/test_curses_color_compat.py -vChecklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests passDocumentation & Housekeeping
docs/, docstrings) — or N/Acli-config.yaml.exampleif I added/changed config keys — or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — or N/Aexcept Exceptionfallback)Screenshots / Logs