Display memory scores in status column
Move score display from name (via label()) to status column for cleaner layout. Score now appears right of tokens for all memory nodes. Co-Authored-By: Proof of Concept <poc@bcachefs.org>
This commit is contained in:
parent
7046e63b9d
commit
4603947506
2 changed files with 20 additions and 11 deletions
|
|
@ -6,7 +6,7 @@ use ratatui::{
|
|||
widgets::{Block, Borders},
|
||||
crossterm::event::KeyCode,
|
||||
};
|
||||
use crate::agent::context::{AstNode, Ast};
|
||||
use crate::agent::context::{AstNode, Ast, NodeBody};
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct SectionView {
|
||||
|
|
@ -20,13 +20,22 @@ pub struct SectionView {
|
|||
|
||||
fn node_to_view(node: &AstNode) -> SectionView {
|
||||
match node {
|
||||
AstNode::Leaf(leaf) => SectionView {
|
||||
name: node.label(),
|
||||
tokens: node.tokens(),
|
||||
content: leaf.body().text().to_string(),
|
||||
children: Vec::new(),
|
||||
status: String::new(),
|
||||
},
|
||||
AstNode::Leaf(leaf) => {
|
||||
let (name, status) = match leaf.body() {
|
||||
NodeBody::Memory { key, score, .. } => {
|
||||
let s = score.map(|v| format!("{:.2}", v)).unwrap_or_default();
|
||||
(format!("mem: {}", key), s)
|
||||
}
|
||||
_ => (node.label(), String::new()),
|
||||
};
|
||||
SectionView {
|
||||
name,
|
||||
tokens: node.tokens(),
|
||||
content: leaf.body().text().to_string(),
|
||||
children: Vec::new(),
|
||||
status,
|
||||
}
|
||||
}
|
||||
AstNode::Branch { children, .. } => {
|
||||
let child_views: Vec<SectionView> = children.iter()
|
||||
.map(|c| node_to_view(c))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue