Add status column to context tree with tab-stop alignment
SectionView gains a status field for extra info displayed after the token count column. Memory nodes section shows "N scored, M unscored" in the status column instead of burying it in the title. Renderer uses fixed-width columns (40 name, 16 tokens, status) for consistent alignment across sections. Co-Authored-By: Proof of Concept <poc@bcachefs.org>
This commit is contained in:
parent
07b400c95c
commit
c7c69a8f06
3 changed files with 15 additions and 2 deletions
|
|
@ -18,6 +18,8 @@ pub struct SectionView {
|
|||
pub tokens: usize,
|
||||
pub content: String,
|
||||
pub children: Vec<SectionView>,
|
||||
/// Extra status text shown after the token count.
|
||||
pub status: String,
|
||||
}
|
||||
|
||||
/// Build a SectionView tree from a ContextSection.
|
||||
|
|
@ -34,6 +36,7 @@ pub fn section_to_view(section: &ContextSection) -> SectionView {
|
|||
tokens: ce.tokens,
|
||||
content,
|
||||
children: Vec::new(),
|
||||
status: String::new(),
|
||||
}
|
||||
}).collect();
|
||||
SectionView {
|
||||
|
|
@ -41,6 +44,7 @@ pub fn section_to_view(section: &ContextSection) -> SectionView {
|
|||
tokens: section.tokens(),
|
||||
content: String::new(),
|
||||
children,
|
||||
status: String::new(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -244,7 +248,13 @@ impl SectionTree {
|
|||
|
||||
let indent = " ".repeat(depth + 1);
|
||||
let marker = if !expandable { " " } else if expanded { "▼" } else { "▶" };
|
||||
let label = format!("{}{} {:30} {:>6} tokens", indent, marker, section.name, section.tokens);
|
||||
let name_col = format!("{}{} {}", indent, marker, section.name);
|
||||
let tokens_col = format!("{:>6} tokens", section.tokens);
|
||||
let label = if section.status.is_empty() {
|
||||
format!("{:40} {}", name_col, tokens_col)
|
||||
} else {
|
||||
format!("{:40} {:16} {}", name_col, tokens_col, section.status)
|
||||
};
|
||||
let style = if selected {
|
||||
Style::default().fg(Color::Yellow).add_modifier(Modifier::BOLD)
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue