Skip to content

fix(cli): clamp curses color 8 for 8-color terminals (Docker)#30260

Merged
teknium1 merged 1 commit into
mainfrom
hermes/hermes-36f9711d
May 22, 2026
Merged

fix(cli): clamp curses color 8 for 8-color terminals (Docker)#30260
teknium1 merged 1 commit into
mainfrom
hermes/hermes-36f9711d

Conversation

@teknium1

@teknium1 teknium1 commented May 22, 2026

Copy link
Copy Markdown
Contributor

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 because curses.init_pair(N, 8, -1) references color 8, which doesn't exist when curses.COLORS == 8 (valid range 0–7). Clamps fg to 8 if curses.COLORS > 8 else curses.COLOR_WHITE at all 5 sites.

Changes

  • hermes_cli/plugins_cmd.py: 3 sites
  • hermes_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 (mock curses.COLORS at 8/16/256) + 3 source guardrails preventing raw-8 regressions

Validation

  • Sibling audit: every other init_pair in the codebase uses COLOR_* constants (0–7), only the raw 8 sites were broken.
  • Targeted suite: 6/6 pass.

Fixes #13688. Closes #14771.

Infographic

PR #30260 infographic

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
@github-actions

Copy link
Copy Markdown
Contributor

🔎 Lint report: hermes/hermes-36f9711d vs origin/main

ruff

Total: 0 on HEAD, 0 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 0 pre-existing issues carried over.

ty (type checker)

Total: 9012 on HEAD, 9011 on base (🆕 +1)

🆕 New issues (1):

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.

@teknium1 teknium1 merged commit d3f62c6 into main May 22, 2026
17 of 18 checks passed
@teknium1 teknium1 deleted the hermes/hermes-36f9711d branch May 22, 2026 06:41
@alt-glitch alt-glitch added type/bug Something isn't working comp/cli CLI entry point, hermes_cli/, setup wizard backend/docker Docker container execution P2 Medium — degraded but workaround exists labels May 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend/docker Docker container execution comp/cli CLI entry point, hermes_cli/, setup wizard P2 Medium — degraded but workaround exists type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: hermes plugins throws Value error

3 participants