git-ents.gitmain
⌘K
foforge
commit 8f04b8a
roots: break only long unbroken tokens in entity list cells

The generic list table marked every cell break-all, shredding short values and column headers whenever one wide key column starved the rest of the table. list_table now marks just the cells holding a whitespace-free token over 40 characters, and only those may break mid-token; headers never wrap.

Assisted-by: Claude:claude-fable-5

Joseph D. Carpinelli · 1 month ago

Reviews

No reviews of this commit yet — record a verdict below.

Start a review

verdict

crates/cli/ents-web/src/render.rs @@ -164,7 +164,7 @@ tr { td { a href=(href_for(id)) { (id) } } @for (_, rendered) in fields(entity) { - td { (rendered) } + td.long-token[has_long_token(&rendered)] { (rendered) } } } } @@ -174,6 +174,16 @@ } } +/// Whether `value` holds a token no wrap opportunity ever splits -- an ssh +/// key's base64 body, an unbroken hash -- long enough (over 40 characters) +/// that its cell must be allowed to break mid-token (`.long-token`'s +/// `break-all`) or it starves every other column of the table's width. +/// Ordinary short values keep word-boundary wrapping so a variant name +/// like `AdminRegistered` never shreds. +fn has_long_token(value: &str) -> bool { + value.split_whitespace().any(|token| token.len() > 40) +} + /// A muted marker card for one entity this crate could not reflect -- the /// `GET /{family}/{id}` show-page counterpart to [`list_table`]'s per-row /// marker: the same "unreadable" note, plus `detail` (the underlying @@ -388,6 +398,20 @@ assert!(markup.contains("jdc")); } + #[rstest] + // @relation(roots.web-agnostic, scope=function, role=Verifies) + fn list_table_breaks_only_the_cell_holding_a_long_unbroken_token() { + let key = format!("ssh-ed25519 {} jdc@host", "A".repeat(68)); + let rows = vec![( + "jdc".to_owned(), + Member::new("jdc", key, Provenance::AdminRegistered), + )]; + let markup = list_table(&rows, "username", |id| format!("/members/{id}")).into_string(); + // Exactly one cell carries the class: the key's; `AdminRegistered` + // and the short id stay word-boundary-wrapped. + assert_eq!(markup.matches("class=\"long-token\"").count(), 1); + } + #[rstest] // @relation(roots.web-agnostic, scope=function, role=Verifies) fn unreadable_disclosure_lists_each_failed_ref_behind_a_details_toggle() {
crates/cli/ents-web/src/assets/ents.css @@ -220,24 +220,27 @@ .entity-view dt + dt { padding-top: .1rem; } .entity-list { width: 100%; border-collapse: collapse; font-family: var(--font-mono); font-size: .85rem; } -.entity-list th, .entity-list td { padding: .6rem 1.1rem; text-align: left; word-break: break-all; } +.entity-list th, .entity-list td { padding: .6rem 1.1rem; text-align: left; } +.entity-list th { white-space: nowrap; } +/* `render::list_table` marks a cell `.long-token` when one whitespace-free + * token (an ssh key's base64 body, an unbroken hash) is too long to wrap + * at word boundaries; only those cells may break mid-token, so a short + * value like a variant name never shreds. */ +.entity-list td.long-token { word-break: break-all; } .entity-list thead { background: var(--color-code-bg); font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--color-text-muted); } .entity-list tbody tr + tr { border-top: 1px solid var(--color-border); } .entity-list td a { color: inherit; text-decoration: underline; text-decoration-color: color-mix(in srgb, currentColor 25%, transparent); } .entity-list td a:hover { color: var(--color-accent); } /* The commits list (`crate::pages::commits::list`) reuses `.entity-list`, - * but its oid/author/when columns are short tokens that should never - * shred mid-word the way a long unbroken key (`.entity-list`'s own - * break-all, correctly used by the members list's `key` column) needs to; - * only the subject column -- ordinary prose -- wraps at word boundaries. */ + * but its oid/author/when columns are short tokens that should stay on + * one line however narrow the table gets; only the subject column -- + * ordinary prose -- wraps at word boundaries. */ .commits-table th:nth-child(1), .commits-table td:nth-child(1), .commits-table th:nth-child(3), .commits-table td:nth-child(3), .commits-table th:nth-child(4), .commits-table td:nth-child(4) { white-space: nowrap; - word-break: normal; } -.commits-table td:nth-child(2) { word-break: normal; } .string-list { list-style: none; font-family: var(--font-mono); font-size: .9rem; } .string-list li { display: flex; align-items: center; gap: .65rem; padding: .7rem 1.1rem; }