Skip to content

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

Closed
Tranquil-Flow wants to merge 1 commit into
NousResearch:mainfrom
Tranquil-Flow:fix/plugins-curses-docker-color
Closed

fix(cli): clamp curses color 8 for 8-color terminals (Docker)#14771
Tranquil-Flow wants to merge 1 commit into
NousResearch:mainfrom
Tranquil-Flow:fix/plugins-curses-docker-color

Conversation

@Tranquil-Flow

@Tranquil-Flow Tranquil-Flow commented Apr 23, 2026

Copy link
Copy Markdown
Contributor

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 when curses.COLORS == 8 (valid range: 0-7), causing curses.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

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 🔒 Security fix
  • 📝 Documentation update
  • ✅ Tests (adding or improving test coverage)
  • ♻️ Refactor (no behavior change)
  • 🎯 New skill (bundled or hub)

Changes Made

  • hermes_cli/plugins_cmd.py: Fixed 3 instances of raw color 8 in _run_composite_ui() color init blocks
  • hermes_cli/main.py: Fixed 1 instance in session browser color init
  • hermes_cli/curses_ui.py: Fixed 1 instance in curses_checklist() color init
  • tests/hermes_cli/test_curses_color_compat.py (new): 3 behavioral tests (mock curses.COLORS at 8/16/256, verify init_pair called with clamped values) + 3 source guardrail tests

How to Test

  1. Run:
    python -m pytest -o 'addopts=' tests/hermes_cli/test_curses_color_compat.py -v
  2. Confirm result: 6 passed.

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits (fix(scope):, feat(scope):, etc.)
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix/feature (no unrelated commits)
  • I've run pytest tests/ -q and all tests pass
  • I've added tests for my changes (required for bug fixes, strongly encouraged for features)
  • I've tested on my platform: macOS 15 (Darwin 24.6.0)

Documentation & Housekeeping

  • I've updated relevant documentation (README, docs/, docstrings) — or N/A
  • I've updated cli-config.yaml.example if I added/changed config keys — or N/A
  • I've updated CONTRIBUTING.md or AGENTS.md if I changed architecture or workflows — or N/A
  • I've considered cross-platform impact (Windows, macOS) per the compatibility guide — or N/A (curses is Unix-only; Windows uses the except Exception fallback)
  • I've updated tool descriptions/schemas if I changed tool behavior — or N/A

Screenshots / Logs

python -m pytest -o 'addopts=' tests/hermes_cli/test_curses_color_compat.py -v
# 6 passed

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
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/cli CLI entry point, hermes_cli/, setup wizard area/docker Docker image, Compose, packaging labels Apr 23, 2026
@teknium1

Copy link
Copy Markdown
Contributor

Salvaged via PR #30260, merged to main. Your commit was cherry-picked with authorship preserved. Thanks for the fix and clean tests — and credit to whoever in the original issue suggested the exact 8 if COLORS > 8 else COLOR_WHITE clamp. Fixes #13688.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/docker Docker image, Compose, packaging 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