Skip to content

fix(tui::ui::components::lyric): cap lyric title lengths - #795

Open
SomSamantray wants to merge 3 commits into
tramhao:masterfrom
SomSamantray:fix/612-lyric-title-truncation
Open

SomSamantray wants to merge 3 commits into
tramhao:masterfrom
SomSamantray:fix/612-lyric-title-truncation

Conversation

@SomSamantray

@SomSamantray SomSamantray commented Oct 11, 2026 •

Copy link
Copy Markdown

The Lyrics panel keeps short names unpadded while limiting artist names to 20 characters and track titles to 40. The caps use the original character-count behavior, and narrow panels still clip the combined title at the border.

Validation: cargo +stable fmt --all -- --check, cargo +stable clippy --all-targets --all-features -- -D warnings, and cargo +stable test --workspace --features cover,all-backends,rusty-soundtouch passed (234 tests).

AI disclosure: The original change (4361f0c) used OpenAI Codex assistance (model not recorded). Follow-up 9207f1c and this revision were made with OpenAI Codex CLI using gpt-6-luna.

re #612

@hasezoey hasezoey left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this a slight improvement over the current max 20 characters per variable.
Though i dont think just unlocking the maximal length is a long-term solution (see #612 (comment) for my suggestions)

Additionally, i dont quite like that this now specifies a minimal length of 20 characters, resulting in for example:

╭────────── Lyrics of     Alan Walker      -      Jump Start      ──────────╮
// or
╭ Lyrics of Alan Walker & Imanbek Maratuly Zeikenov -     Sweet Dreams     ─╮

Personally, as a temporary solution, i would just completely drop the min / max length. (or bound the total length to the space available to the component, but that would require some more in-depth changes)

@tramhao what do you think about this change?

@SomSamantray

Copy link
Copy Markdown
Author

I removed the fixed-width padding from lyric titles. Short names now render without extra spacing, long names remain complete when the panel has room, and narrow panels clip the title to the border. I pushed commit 9207f1c76786435524819157669853edef837082 with tests for those cases.

@tramhao

tramhao commented Oct 12, 2026

Copy link
Copy Markdown
Owner

For TUI applications, word length is definitely a problem. If we don't limit the length, it'll take up all the space unless we scroll it. That's overkill for names. I think changing the length of track name to longer(maybe 40?) will suit English better. For Chinese, the length is sufficient.

@SomSamantray SomSamantray changed the title fix(tui::ui::components::lyric): show full track titles fix(tui::ui::components::lyric): cap lyric title lengths Oct 12, 2026
@SomSamantray

Copy link
Copy Markdown
Author

Thanks, tramhao. I’ve restored a 20-character cap for artist names and raised the track title cap to 40 characters. Short names stay unpadded, and narrow panels still clip at the border. I pushed this in d58d7a5.

@hasezoey hasezoey left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM as a temporary solution.

Comment on lines +495 to +508
let backend = TestBackend::new(width, 3);
let mut terminal = Terminal::new(backend).unwrap();
let title = format_lyric_title(artist, title);
let mut textarea =
Textarea::default().borders(Borders::default().modifiers(BorderType::Rounded));
textarea = textarea.title(Title::from(title).alignment(HorizontalAlignment::Center));

terminal
.draw(|frame| textarea.view(frame, frame.area()))
.unwrap();

(0..width)
.map(|x| terminal.backend().buffer()[(x, 0)].symbol())
.collect()

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI tuirealm has some helpers for that, see tuirealm::testing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants