Skip to content

Commit 9f77052

Browse files
MaojiaShengopenviking
andauthored
fix: change CLI cutoff abs (#1921)
Co-authored-by: openviking <openviking@example.com>
1 parent 373665f commit 9f77052

1 file changed

Lines changed: 16 additions & 7 deletions

File tree

crates/ov_cli/src/output.rs

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,7 @@ fn summarize_message_content(parts: Option<&Vec<serde_json::Value>>) -> String {
600600
struct ColumnInfo {
601601
max_width: usize, // Max width for alignment (capped at 120)
602602
is_numeric: bool, // True if all values in column are numeric
603-
is_uri_column: bool, // True if column name is "uri"
603+
is_unbounded_column: bool, // True if column should respect server-side length
604604
}
605605

606606
fn format_array_to_table(items: &Vec<serde_json::Value>, compact: bool) -> Option<String> {
@@ -668,7 +668,7 @@ fn format_array_to_table(items: &Vec<serde_json::Value>, compact: bool) -> Optio
668668
let mut column_info: Vec<ColumnInfo> = Vec::new();
669669

670670
for key in &keys {
671-
let is_uri_column = key == "uri";
671+
let is_unbounded_column = key == "uri" || key == "abstract";
672672
let mut is_numeric = true;
673673
let mut max_width = key.width(); // Start with header width
674674

@@ -691,7 +691,7 @@ fn format_array_to_table(items: &Vec<serde_json::Value>, compact: bool) -> Optio
691691
column_info.push(ColumnInfo {
692692
max_width,
693693
is_numeric,
694-
is_uri_column,
694+
is_unbounded_column,
695695
});
696696
}
697697

@@ -718,7 +718,7 @@ fn format_array_to_table(items: &Vec<serde_json::Value>, compact: bool) -> Optio
718718
let value = obj.get(k).map(|v| format_value(v)).unwrap_or_default();
719719

720720
let (content, skip_padding) =
721-
truncate_string(&value, info.is_uri_column, info.max_width);
721+
truncate_string(&value, info.is_unbounded_column, info.max_width);
722722

723723
if skip_padding {
724724
// Long URI, output as-is without padding
@@ -771,11 +771,12 @@ fn is_numeric_value(v: &serde_json::Value) -> bool {
771771
}
772772
}
773773

774-
fn truncate_string(s: &str, is_uri: bool, max_width: usize) -> (String, bool) {
774+
fn truncate_string(s: &str, is_unbounded: bool, max_width: usize) -> (String, bool) {
775775
let display_width = s.width();
776776

777-
// URI columns: never truncate
778-
if is_uri {
777+
// URI/abstract columns: never truncate. For long values, skip padding so
778+
// the server-side limit (such as --abs-limit) remains authoritative.
779+
if is_unbounded {
779780
if display_width > max_width {
780781
return (s.to_string(), true); // true = skip padding
781782
} else {
@@ -837,4 +838,12 @@ mod tests {
837838
let obj = json!({});
838839
print_table(obj, true);
839840
}
841+
842+
#[test]
843+
fn test_abstract_column_is_not_truncated_by_cli_renderer() {
844+
let long_abstract = "a".repeat(MAX_COL_WIDTH + 50);
845+
let (rendered, skip_padding) = truncate_string(&long_abstract, true, 10);
846+
assert_eq!(rendered, long_abstract);
847+
assert!(skip_padding);
848+
}
840849
}

0 commit comments

Comments
 (0)