Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/tabled-ansi-width.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@smooai/smooth': patch
---

th-6e77b7: `th admin` tables no longer over-widen columns containing coloured status cells — tabled's `ansi` feature makes its width calc strip escape sequences.
39 changes: 39 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/smooth-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ quick-xml = { version = "0.37", features = ["serialize"] }
# `tabled` is what nushell uses — best-of-class in the Rust table-
# rendering space. Builder API for dynamic JSON, rich modifier chain
# for theming, 10+ built-in styles.
tabled = "0.18"
tabled = { version = "0.18", features = ["ansi"] } # `ansi`: width calc strips escapes — coloured status cells were over-widening columns (th-6e77b7)

# Pearl th-fcb579: browser-based `th auth login`.
# - `tiny_http`: minimal blocking HTTP listener for the OAuth
Expand Down
15 changes: 15 additions & 0 deletions crates/smooth-cli/src/admin/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,21 @@ mod tests {
assert_eq!(opts.label, Some("users"));
}

#[test]
fn ansi_escapes_do_not_widen_columns_th_6e77b7() {
// Explicit escapes (owo-colors may no-op off-TTY): the coloured
// cell must render the same table width as the plain one.
let table_width = |cell: &str| {
let mut b = Builder::default();
b.push_record(["status"]);
b.push_record([cell]);
let mut t = b.build();
apply_modern_style(&mut t);
t.to_string().lines().next().map_or(0, |l| l.chars().count())
};
assert_eq!(table_width("\u{1b}[32;1mactive\u{1b}[0m"), table_width("active"));
}

#[test]
fn colour_status_known_values_get_colour_codes_other_passthrough() {
// Coloured = contains an ANSI escape. The actual code depends
Expand Down
Loading