From 9c24617642482a157a188ac9a374f87be1196ea6 Mon Sep 17 00:00:00 2001 From: Taylor Eernisse Date: Fri, 6 Feb 2026 14:28:50 -0500 Subject: [PATCH] fix: 4 bugs found during code review against PRD - output_style: use MAGENTA color per PRD (was incorrectly DIM) - vcs: pass project dir to jj exec (was None, causing wrong cwd) - tools: singular "tool" when count is 1 (was always "tools") - layout: wire up apply_formatting() in render pipeline (prefix, suffix, color override, pad, align were completely dead code) Co-Authored-By: Claude Opus 4.6 --- src/layout/mod.rs | 48 +++++++++++++++++++++++++++++++++++-- src/section/output_style.rs | 2 +- src/section/tools.rs | 3 ++- src/section/vcs.rs | 4 ++-- 4 files changed, 51 insertions(+), 6 deletions(-) diff --git a/src/layout/mod.rs b/src/layout/mod.rs index 51fa8d8..c9efd5c 100644 --- a/src/layout/mod.rs +++ b/src/layout/mod.rs @@ -2,7 +2,8 @@ pub mod flex; pub mod justify; pub mod priority; -use crate::config::{Config, JustifyMode, LayoutValue}; +use crate::config::{Config, JustifyMode, LayoutValue, SectionBase}; +use crate::format; use crate::section::{self, RenderContext, SectionOutput}; /// A section that survived priority drops and has rendered output. @@ -64,11 +65,22 @@ fn render_line(section_ids: &[String], ctx: &RenderContext, separator: &str) -> let mut active: Vec = Vec::new(); for id in section_ids { - if let Some(output) = section::render_section(id, ctx) { + if let Some(mut output) = section::render_section(id, ctx) { if output.raw.is_empty() && !section::is_spacer(id) { continue; } + // Apply per-section formatting (prefix, suffix, color override, pad, align) + if let Some(base) = section_base(id, ctx.config) { + format::apply_formatting( + &mut output.raw, + &mut output.ansi, + base, + ctx.theme, + &ctx.config.colors, + ); + } + let (prio, is_flex) = section_meta(id, ctx.config); active.push(ActiveSection { id: id.clone(), @@ -175,3 +187,35 @@ fn section_meta(id: &str, config: &Config) -> (u8, bool) { _ => (2, false), // custom sections default } } + +/// Look up the SectionBase for a given section ID. +/// Returns None for spacers and unknown custom sections. +fn section_base<'a>(id: &str, config: &'a Config) -> Option<&'a SectionBase> { + match id { + "model" => Some(&config.sections.model), + "provider" => Some(&config.sections.provider), + "project" => Some(&config.sections.project.base), + "vcs" => Some(&config.sections.vcs.base), + "beads" => Some(&config.sections.beads.base), + "context_bar" => Some(&config.sections.context_bar.base), + "context_usage" => Some(&config.sections.context_usage.base), + "context_remaining" => Some(&config.sections.context_remaining.base), + "tokens_raw" => Some(&config.sections.tokens_raw.base), + "cache_efficiency" => Some(&config.sections.cache_efficiency), + "cost" => Some(&config.sections.cost.base), + "cost_velocity" => Some(&config.sections.cost_velocity), + "token_velocity" => Some(&config.sections.token_velocity), + "cost_trend" => Some(&config.sections.cost_trend.base), + "context_trend" => Some(&config.sections.context_trend.base), + "lines_changed" => Some(&config.sections.lines_changed), + "duration" => Some(&config.sections.duration), + "tools" => Some(&config.sections.tools.base), + "turns" => Some(&config.sections.turns.base), + "load" => Some(&config.sections.load.base), + "version" => Some(&config.sections.version), + "time" => Some(&config.sections.time.base), + "output_style" => Some(&config.sections.output_style), + "hostname" => Some(&config.sections.hostname), + _ => None, + } +} diff --git a/src/section/output_style.rs b/src/section/output_style.rs index 9f8337c..930e7ac 100644 --- a/src/section/output_style.rs +++ b/src/section/output_style.rs @@ -10,7 +10,7 @@ pub fn render(ctx: &RenderContext) -> Option { let raw = style_name.to_string(); let ansi = if ctx.color_enabled { - format!("{}{raw}{}", color::DIM, color::RESET) + format!("{}{raw}{}", color::MAGENTA, color::RESET) } else { raw.clone() }; diff --git a/src/section/tools.rs b/src/section/tools.rs index 2cf2d90..663d95f 100644 --- a/src/section/tools.rs +++ b/src/section/tools.rs @@ -22,7 +22,8 @@ pub fn render(ctx: &RenderContext) -> Option { String::new() }; - let raw = format!("{count} tools{last}"); + let label = if count == 1 { "tool" } else { "tools" }; + let raw = format!("{count} {label}{last}"); let ansi = if ctx.color_enabled { format!("{}{raw}{}", color::DIM, color::RESET) } else { diff --git a/src/section/vcs.rs b/src/section/vcs.rs index 4c43993..f4eb13a 100644 --- a/src/section/vcs.rs +++ b/src/section/vcs.rs @@ -128,7 +128,7 @@ fn render_git( fn render_jj( ctx: &RenderContext, - _dir: &str, + dir: &str, ttl: &crate::config::VcsTtl, glyphs: &crate::config::GlyphConfig, ) -> Option { @@ -147,7 +147,7 @@ fn render_jj( "if(bookmarks, bookmarks.join(\",\"), change_id.shortest(8))", "--color=never", ], - None, + Some(dir), timeout, )?; ctx.cache.set("vcs_branch", &out);