fix: bright-yellow SGR crashes TUI log render#81
Conversation
pyte names SGR 93 'brightbrown'; _PYTE_COLOR_FIX remapped it to the
already-prefixed 'bright_yellow', which _rich_color then re-prefixed into
the invalid 'bright__yellow' — raising ColorParseError and blanking the
dashboard log pane on the first bright-yellow line (common in agent output).
Keep the remap in pyte's underscore-free namespace ('brightyellow') so the
'bright' -> 'bright_' transform produces a valid 'bright_yellow'. Add a
regression test asserting every mapped color parses via rich.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughThe TUI color helpers now avoid invalid Rich color names during pyte color conversion and fall back safely when Rich cannot parse a derived color. Tests cover both the remap behavior and the unparseable-color fallback. ChangesTUI color parsing hardening
Estimated code review effort: 2 (Simple) | ~10 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Completes the bright__yellow fix for the whole failure class: - pyte 0.8.2's BG_AIXTERM[105] is misspelled "bfightmagenta"; it passed through _rich_color untouched and raised the same ColorParseError on any background bright-magenta (SGR 105). Remap it alongside brown/brightbrown. - Sweep every name in pyte's FG/BG/FG_AIXTERM/BG_AIXTERM tables through _rich_color in the regression test so a pyte bump that adds or renames entries fails in CI, not in the dashboard's poll worker. - Guard _char_style: an unparseable color now degrades to an uncolored run instead of killing the poll worker (textual workers default to exit_on_error=True, so that crash could take the whole TUI down).
|
Thanks @thesleepingsage — great catch and a clean diagnosis; the regression test was exactly the right shape. Confirmed the repro on While reviewing I swept every name in pyte 0.8.2's color tables through
Merging once CI is green. |
pbean
left a comment
There was a problem hiding this comment.
Issue confirmed and reproduced on main; fix validated locally (full suite + an end-to-end LogView render of raw SGR 93/105 bytes). Completed the failure class in e592059 (pyte's bfightmagenta typo + exhaustive table sweep + graceful degrade in _char_style).
What
Fixes the TUI log pane rendering blank due to a
ColorParseErroron bright‑yellow output. Closes #80.Why
pyte names SGR 93
brightbrown._PYTE_COLOR_FIXremapped it tobright_yellow— a value that already carries thebright_prefix._rich_colorthen applies its"bright"→"bright_"transform unconditionally, doubling the underscore intobright__yellow, whichrichrejects:The
_pollworker raises on the first bright‑yellow line (common in agent output), sobmad-loop tui's dashboard log pane never draws.The fix
Keep the remap target in pyte's underscore‑free namespace so the downstream transform produces a valid color:
Now
brightbrown→brightyellow→bright_yellow. I also expanded the comment above the table to record the invariant (remap values must stay underscore‑free) so it can't be reintroduced.Test
Added
test_rich_color_maps_pyte_names_to_valid_rich_colorstotests/test_tui_data.py: asserts the pyte→rich mapping for the brown/bright‑brown/bright/hex/default cases and that every non‑None result parses viarich.color.Color.parse— so a future invalid‑color regression fails the test instead of the TUI.Scope
One‑line behavior change + comment + one test. No control‑loop logic touched.
Summary by CodeRabbit