Skip to content

Commit 22fbcae

Browse files
xsh310Isaac
andcommitted
Address review: collapse whitespace in the description footer preview
Embedded newlines rendered as hard breaks in the fixed two-line footer, clipping later content even under the char budget. Collapse whitespace runs to single spaces so the footer soft-wraps content across both lines. Co-authored-by: Isaac <no-reply@databricks.com>
1 parent 7ebc19c commit 22fbcae

2 files changed

Lines changed: 6 additions & 0 deletions

File tree

src/ucode/ui/interactive_picker.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ def _description_footer_tokens(description: str) -> list[tuple[str, str]]:
4949
A caller emphasizes a leading label by formatting the description as ``"label: text"``:
5050
the ``label:`` renders bold and the rest as the truncated preview. A description with no
5151
``": "`` renders entirely as the preview."""
52+
description = " ".join(description.split())
5253
label, sep, body = description.partition(": ")
5354
if not sep:
5455
return [("class:instruction", _description_preview(description))]

tests/test_interactive_picker.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,8 @@ def test_only_the_body_is_truncated(self):
6969
label_token, body_token = _description_footer_tokens(f"triage: {long_body}")
7070
assert label_token == ("bold", "triage: ")
7171
assert body_token == ("class:instruction", _description_preview(long_body))
72+
73+
def test_newlines_and_whitespace_runs_collapse_to_single_spaces(self):
74+
assert _description_footer_tokens(
75+
"Routes tickets.\n\nSeverity from the body.\tEscalates."
76+
) == [("class:instruction", "Routes tickets. Severity from the body. Escalates.")]

0 commit comments

Comments
 (0)