diff --git a/AGENTS.md b/AGENTS.md index 0c93a0a..0afe902 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -33,7 +33,7 @@ ### Color and Output - Use `color_text()` helper for colored output — it respects `should_use_colors()` (terminal detection) -- Color codes are defined in `get_color()`: red (31), cyan (36), orange (33), green (32), grey (90) +- Color codes are defined in `get_color()`: red (31), cyan (36), orange (33), green (32), grey (38;5;8), magenta (1;35) - Reset color with `\x1b[0m` after colored text - Bold uses `\x1b[1;35m` (magenta bold) - Always test color output works correctly in both terminal and pipe modes @@ -43,7 +43,8 @@ - Status → orange (33) - Timestamp → cyan (36) - Title → green (32) -- Unknown values (`_None_`, `_Not set_`) → grey (90) +- Unknown values (`_None_`, `_Not set_`) → grey (38;5;8) +- Grey is indexed colour 8 in the 256-colour form, not SGR 90 or 37. Both of those failed on a real palette: 90 leans on the bright-black slot and 37 can sit on top of the default foreground. `\x1b[38;5;8m` is byte for byte what crossterm emits for ratatui's `Color::DarkGray`, the grey frig and pantop use for dimmed rows ### Code Organization - Colorization functions (`colorize_line`, `colorize_metadata`, `colorize_ordered`, `content_trim_colored`) handle markdown formatting diff --git a/Cargo.lock b/Cargo.lock index 5774085..74dc051 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1029,7 +1029,7 @@ dependencies = [ [[package]] name = "worklane" -version = "0.1.1" +version = "0.1.2" dependencies = [ "anyhow", "assert_cmd", diff --git a/Cargo.toml b/Cargo.toml index b442602..809038e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "worklane" -version = "0.1.1" +version = "0.1.2" edition = "2024" [dependencies] diff --git a/src/util.rs b/src/util.rs index d5f2c41..2042363 100644 --- a/src/util.rs +++ b/src/util.rs @@ -58,7 +58,12 @@ pub fn get_color(color: &str) -> &'static str { "cyan" => "\x1b[36m", "orange" => "\x1b[33m", "green" => "\x1b[32m", - "grey" => "\x1b[90m", + // Indexed colour 8 in the 256-colour form, which is byte for byte what + // crossterm emits for ratatui's Color::DarkGray, the grey frig and pantop + // use for dimmed rows. Neither SGR 90 nor 37 renders as grey on every + // palette: 90 leans on the bright-black slot and 37 can sit right on top + // of the default foreground. + "grey" => "\x1b[38;5;8m", // Bold, per the guideline in AGENTS.md. Its absence meant colorize_line // asked for a colour that did not exist and got an empty prefix. "magenta" => "\x1b[1;35m", @@ -493,9 +498,24 @@ pub fn status_dirs() -> Vec<&'static str> { pub type TicketItem = (String, String, String, String, String); +/// Grey for a value that is not set, per the colour guideline. +/// +/// `show` already did this through `colorize_metadata`, so the listing was the +/// one place that ignored the rule. +fn dim_if_unset(value: &str) -> String { + if is_unknown_value(value) { + color_text(value, "grey") + } else { + value.to_string() + } +} + pub fn display_ticket_items(items: &Vec) { for (title, owner, due, uuid, ts) in items { let uuid_colored = color_text(uuid, "red"); + let owner = dim_if_unset(owner); + let due = dim_if_unset(due); + if ts.is_empty() { println!( " ({}) {} | Owner: {} | Due: {}", @@ -576,6 +596,20 @@ mod tests { assert!(colors_wanted(true, None, None)); } + #[test] + fn unset_values_are_dimmed_and_set_ones_are_not() { + // Colour is off in a test process, so this asserts the decision, not the escape + for unset in ["_Not set_", "_None_"] { + assert!(is_unknown_value(unset), "{unset} should count as unset"); + assert_eq!(dim_if_unset(unset), unset); + } + + for set in ["alice", "2026-12-31", "bug,frontend"] { + assert!(!is_unknown_value(set)); + assert_eq!(dim_if_unset(set), set); + } + } + #[test] fn every_colour_the_code_asks_for_exists() { for colour in ["red", "cyan", "orange", "green", "grey", "magenta"] { @@ -583,6 +617,15 @@ mod tests { } } + /// Pinned deliberately. Both SGR spellings of grey failed on a real palette, + /// 90 reading nearly as light as the foreground and 37 sitting on top of it. + /// This is the exact sequence crossterm emits for ratatui's Color::DarkGray, + /// so worklane's grey is the one frig and pantop already render. + #[test] + fn grey_matches_the_indexed_colour_frig_uses() { + assert_eq!(get_color("grey"), "\x1b[38;5;8m"); + } + /// With no colour to carry the emphasis, the markers are the emphasis. #[test] fn bold_markers_survive_when_colour_is_off() {