Skip to content

Commit e65a217

Browse files
bsamekclaude
andcommitted
Fix word wrap in RichLog panels
Set min_width=0 on RichLog widgets so text wraps at actual panel width instead of the default 78 characters. With 3 side-by-side panels, the default caused text to render wider than the panel and get clipped. Also adds text-wrap: wrap CSS property for completeness. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 588f3c6 commit e65a217

2 files changed

Lines changed: 10 additions & 9 deletions

File tree

app.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def __init__(self, model_id: str, title: str, **kwargs):
7272

7373
def compose(self) -> ComposeResult:
7474
yield Static(self.title, classes="panel-title")
75-
yield RichLog(id=f"log-{sanitize_id(self.model_id)}", markup=True, wrap=True)
75+
yield RichLog(id=f"log-{sanitize_id(self.model_id)}", markup=True, wrap=True, min_width=0)
7676

7777

7878
class PromptInput(Input):
@@ -122,6 +122,7 @@ class MultiLLMApp(App):
122122
RichLog {
123123
height: 1fr;
124124
scrollbar-gutter: stable;
125+
text-wrap: wrap;
125126
}
126127
127128
#prompt-container {

test_app.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -257,10 +257,10 @@ async def test_slash_new_clears_all_logs(mock_llm):
257257
prompt.value = "/new"
258258
await pilot.press("enter")
259259

260-
# Logs should only have the confirmation message
260+
# Logs should only have the confirmation message (may wrap to 2 lines)
261261
for model_id in MODELS:
262262
log = app.query_one(f"#log-{sanitize_id(model_id)}", RichLog)
263-
assert len(log.lines) == 1 # Just confirmation
263+
assert 1 <= len(log.lines) <= 2 # Just confirmation, possibly wrapped
264264

265265

266266
@pytest.mark.asyncio
@@ -289,10 +289,10 @@ async def test_slash_new_shows_confirmation(mock_llm):
289289
prompt.value = "/new"
290290
await pilot.press("enter")
291291

292-
# Each log should have the confirmation message
292+
# Each log should have the confirmation message (may wrap to 2 lines)
293293
for model_id in MODELS:
294294
log = app.query_one(f"#log-{sanitize_id(model_id)}", RichLog)
295-
assert len(log.lines) == 1
295+
assert 1 <= len(log.lines) <= 2
296296

297297

298298
@pytest.mark.asyncio
@@ -719,7 +719,7 @@ async def test_slash_command_case_insensitive(mock_llm):
719719
# Logs should have confirmation message
720720
for model_id in MODELS:
721721
log = app.query_one(f"#log-{sanitize_id(model_id)}", RichLog)
722-
assert len(log.lines) == 1
722+
assert 1 <= len(log.lines) <= 2
723723

724724

725725
@pytest.mark.asyncio
@@ -738,7 +738,7 @@ async def test_slash_command_with_leading_space_still_executes(mock_llm):
738738
for model_id in MODELS:
739739
log = app.query_one(f"#log-{sanitize_id(model_id)}", RichLog)
740740
# Should have only the confirmation message
741-
assert len(log.lines) == 1
741+
assert 1 <= len(log.lines) <= 2
742742

743743

744744
# --- Additional Coverage: handle_slash_command Edge Cases ---
@@ -755,7 +755,7 @@ async def test_handle_slash_command_with_trailing_whitespace(mock_llm):
755755
# Command should execute, confirmation should appear
756756
for model_id in MODELS:
757757
log = app.query_one(f"#log-{sanitize_id(model_id)}", RichLog)
758-
assert len(log.lines) == 1
758+
assert 1 <= len(log.lines) <= 2
759759

760760

761761
@pytest.mark.asyncio
@@ -767,7 +767,7 @@ async def test_handle_slash_command_with_mixed_case(mock_llm):
767767

768768
for model_id in MODELS:
769769
log = app.query_one(f"#log-{sanitize_id(model_id)}", RichLog)
770-
assert len(log.lines) == 1
770+
assert 1 <= len(log.lines) <= 2
771771

772772

773773
@pytest.mark.asyncio

0 commit comments

Comments
 (0)