fix emoji spacing (#2735)

before:
<img width="295" height="266" alt="Screenshot 2025-08-26 at 5 05 03 PM"
src="https://github.com/user-attachments/assets/3e876f08-26d0-407e-a995-28fd072e288f"
/>

after:
<img width="295" height="129" alt="Screenshot 2025-08-26 at 5 05 30 PM"
src="https://github.com/user-attachments/assets/2a019d52-19ed-40ef-8155-4f02c400796a"
/>
This commit is contained in:
Jeremy Rose
2025-08-26 17:34:24 -07:00
committed by GitHub
parent 435154ce93
commit b367790d9b
3 changed files with 13 additions and 11 deletions

View File

@@ -3,4 +3,4 @@ source: tui/src/chatwidget/tests.rs
expression: exec_blob
---
>_
✗ ⌨️  sleep 1
✗ ⌨sleep 1

View File

@@ -1246,7 +1246,7 @@ fn stream_error_is_rendered_to_history() {
let cells = drain_insert_history(&mut rx);
assert!(!cells.is_empty(), "expected a history cell for StreamError");
let blob = lines_to_single_string(cells.last().unwrap());
assert!(blob.contains(" "));
assert!(blob.contains("\u{200A} "));
assert!(blob.contains("stream error:"));
assert!(blob.contains("idle timeout waiting for SSE"));
}

View File

@@ -230,14 +230,11 @@ fn pretty_provider_name(id: &str) -> String {
title_case(id)
}
}
/// Return the emoji followed by a hair space (U+200A) and a normal space.
/// This creates a reasonable gap across different terminals,
/// in particular Terminal.app and iTerm, which render too tightly with just a single normal space.
///
/// Improvements here could be to condition this behavior on terminal,
/// or possibly on emoji.
/// Return the emoji followed by a hair space (U+200A).
/// Using only the hair space avoids excessive padding after the emoji while
/// still providing a small visual gap across terminals.
fn padded_emoji(emoji: &str) -> String {
format!("{emoji}\u{200A} ")
format!("{emoji}\u{200A}")
}
/// Convenience function over `padded_emoji()`.
@@ -900,14 +897,19 @@ pub(crate) fn new_error_event(message: String) -> PlainHistoryCell {
// in terminals like Ghostty.
let lines: Vec<Line<'static>> = vec![
"".into(),
vec![padded_emoji("🖐").red().bold(), message.into()].into(),
vec![padded_emoji("🖐").red().bold(), " ".into(), message.into()].into(),
];
PlainHistoryCell { lines }
}
pub(crate) fn new_stream_error_event(message: String) -> PlainHistoryCell {
let lines: Vec<Line<'static>> = vec![
vec![padded_emoji("").magenta().bold(), message.dim()].into(),
vec![
padded_emoji("").magenta().bold(),
" ".into(),
message.dim(),
]
.into(),
"".into(),
];
PlainHistoryCell { lines }