fix(cli): use Rich [dim] tag instead of ANSI escape in session resume messages - #39482
Merged
kshitijk4poor merged 1 commit intoJun 5, 2026
Conversation
…on_cwd
Replace [{_DIM}] with [dim] in all _restore_session_cwd and
_preload_resumed_session messages that go through _console_print (Rich
Console.print). _DIM is an ANSI escape (\x1b[2;3m) that Rich cannot
parse as a markup tag, causing MarkupError on session resume when the
stored cwd is missing or inaccessible.
Also uses [/dim] closing tag for explicit tag matching.
Fixes NousResearch#39469
tonydwb
approved these changes
Jun 5, 2026
tonydwb
left a comment
There was a problem hiding this comment.
Code Review Summary
Verdict: Approved
Regression fix for a rich.errors.MarkupError that occurred when _restore_session_cwd displayed dimmed warning/info messages using the ANSI escape variable _DIM inside Rich markup strings.
✅ Looks Good
- Root cause is correctly diagnosed:
[{_DIM}]is a Rich variable interpolation, but_DIMresolves to a raw ANSI escape (\x1b[2;3m), not a valid Rich tag name — causing a markup parse error. - Fix replaces
[{_DIM}]...[/]with Rich's native[dim]...[/dim]tag, which is the correct approach. - Three regression tests added covering all affected paths: missing dir, chdir failure, and success case — all assert
console.printwas called without raisingMarkupError.
No concerns
- Minimal, targeted change with no side effects.
- New tests use
unittest.mock.MagicMockandunittest.mock.patchcorrectly.
Reviewed by Hermes Agent
alt-glitch
pushed a commit
that referenced
this pull request
Jun 14, 2026
…ssion-resume fix(cli): use Rich [dim] tag instead of ANSI escape in session resume messages
T02200059
pushed a commit
to T02200059/hermes-agent
that referenced
this pull request
Jun 18, 2026
…-error-on-session-resume fix(cli): use Rich [dim] tag instead of ANSI escape in session resume messages
waefrebeorn
pushed a commit
to waefrebeorn/slermes
that referenced
this pull request
Jul 2, 2026
…-error-on-session-resume fix(cli): use Rich [dim] tag instead of ANSI escape in session resume messages
santhreal
pushed a commit
to santhreal/hermes-agent
that referenced
this pull request
Jul 13, 2026
…-error-on-session-resume fix(cli): use Rich [dim] tag instead of ANSI escape in session resume messages
Gravezzz
pushed a commit
to Gravezzz/hermes-agent
that referenced
this pull request
Jul 21, 2026
…-error-on-session-resume fix(cli): use Rich [dim] tag instead of ANSI escape in session resume messages
leewenjie
pushed a commit
to leewenjie/hermes-agent
that referenced
this pull request
Aug 7, 2026
…-error-on-session-resume fix(cli): use Rich [dim] tag instead of ANSI escape in session resume messages
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
rich.errors.MarkupErrorcrash when resuming a session whose recorded working directory is missing or inaccessible. The CLI uses Rich's markup system for styled console output, but 4 locations in_restore_session_cwdand_preload_resumed_sessioninjected an ANSI escape code (_DIM = \x1b[2;3m) inside Rich's[...]tag syntax. Rich interprets the escape bytes as an invalid tag, then fails on the matching[/]close tag.Related Issue
Fixes #39469
Type of Change
Changes Made
cli.py: Replaced[{_DIM}]...[/]with[dim]...[/dim]in 4 locations where_DIM(ANSI escape) was used inside Rich Console.print() markup. This uses Rich's nativedimstyle tag, consistent with existing usage elsewhere in the file (e.g., lines 4322, 4350, 5314).tests/cli/test_cli_resume_command.py: Added 3 regression tests covering the missing-directory, chdir-failure, and success paths of_restore_session_cwd.How to Test
hermes chathermes chat -r <session_id>MarkupErrorpytest tests/cli/test_cli_resume_command.py -xvs— all 15 tests passChecklist
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/ACode Intelligence
cli.py:_restore_session_cwd()(lines 5350-5401),cli.py:_preload_resumed_session()(line 5100)_preload_resumed_sessioncalled fromrun(),_restore_session_cwdcalled from_preload_resumed_sessionand_do_resume[dim]Rich tag already used at lines 4322, 4350, 5314 in the same file;_DIMANSI escape remains safe in_cprint()calls (prompt_toolkit renderer, not Rich)