From aa61831a14ee25cc88131b9fb11a03048d45b419 Mon Sep 17 00:00:00 2001 From: IAvecilla Date: Tue, 21 Apr 2026 15:32:59 -0300 Subject: [PATCH 1/2] fix(cli): keep snake_case underscores intact in strip markdown mode --- cli.py | 6 +++--- tests/cli/test_cli_markdown_rendering.py | 23 +++++++++++++++++++++++ ui-tui/src/__tests__/text.test.ts | 8 ++++++++ ui-tui/src/lib/text.ts | 4 ++-- 4 files changed, 36 insertions(+), 5 deletions(-) diff --git a/cli.py b/cli.py index aec48aef74..1ba5071ed9 100644 --- a/cli.py +++ b/cli.py @@ -1155,11 +1155,11 @@ def _strip_markdown_syntax(text: str) -> str: plain = re.sub(r"!\[([^\]]*)\]\([^\)]*\)", r"\1", plain) plain = re.sub(r"\[([^\]]+)\]\([^\)]*\)", r"\1", plain) plain = re.sub(r"\*\*\*([^*]+)\*\*\*", r"\1", plain) - plain = re.sub(r"___([^_]+)___", r"\1", plain) + plain = re.sub(r"(? { expect(estimateRows(md, 40)).toBe(2) }) + + it('keeps intraword underscores when sizing snake_case identifiers', () => { + const w = 80 + const snake = 'look at recover_with_credential_pool now' + const plain = 'look at recover with credential pool now' + + expect(estimateRows(snake, w)).toBe(estimateRows(plain, w)) + }) }) diff --git a/ui-tui/src/lib/text.ts b/ui-tui/src/lib/text.ts index fb10d7d2d4..8541ac3f68 100644 --- a/ui-tui/src/lib/text.ts +++ b/ui-tui/src/lib/text.ts @@ -25,9 +25,9 @@ const renderEstimateLine = (line: string) => { .replace(/\[(.+?)\]\((https?:\/\/[^\s)]+)\)/g, '$1') .replace(/`([^`]+)`/g, '$1') .replace(/\*\*(.+?)\*\*/g, '$1') - .replace(/__(.+?)__/g, '$1') + .replace(/(? Date: Tue, 21 Apr 2026 16:00:34 -0300 Subject: [PATCH 2/2] Rename test variables --- tests/cli/test_cli_markdown_rendering.py | 11 ++++++----- ui-tui/src/__tests__/text.test.ts | 4 ++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/tests/cli/test_cli_markdown_rendering.py b/tests/cli/test_cli_markdown_rendering.py index 42f5fd2d97..01f0bab6c6 100644 --- a/tests/cli/test_cli_markdown_rendering.py +++ b/tests/cli/test_cli_markdown_rendering.py @@ -119,15 +119,16 @@ def test_final_assistant_content_can_leave_markdown_raw(): def test_strip_mode_preserves_intraword_underscores_in_snake_case_identifiers(): renderable = _render_final_assistant_content( - "Let me look at recover_with_credential_pool and MY_CONST " - "then /home/user/path_with_stuff/file.py", + "Let me look at test_case_with_underscores and SOME_CONST " + "then /tmp/snake_case_dir/file_with_name.py", mode="strip", ) output = _render_to_text(renderable) - assert "recover_with_credential_pool" in output - assert "MY_CONST" in output - assert "path_with_stuff" in output + assert "test_case_with_underscores" in output + assert "SOME_CONST" in output + assert "snake_case_dir" in output + assert "file_with_name" in output def test_strip_mode_still_strips_boundary_underscore_emphasis(): diff --git a/ui-tui/src/__tests__/text.test.ts b/ui-tui/src/__tests__/text.test.ts index 246cdd7cfe..d4a2469e8f 100644 --- a/ui-tui/src/__tests__/text.test.ts +++ b/ui-tui/src/__tests__/text.test.ts @@ -100,8 +100,8 @@ describe('estimateRows', () => { it('keeps intraword underscores when sizing snake_case identifiers', () => { const w = 80 - const snake = 'look at recover_with_credential_pool now' - const plain = 'look at recover with credential pool now' + const snake = 'look at test_case_with_underscores now' + const plain = 'look at test case with underscores now' expect(estimateRows(snake, w)).toBe(estimateRows(plain, w)) })