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:
Kent Overstreet 2026-04-15 06:08:27 -04:00
parent 7046e63b9d
commit 4603947506
2 changed files with 20 additions and 11 deletions

View file

@ -37,14 +37,14 @@ impl ConsciousScreen {
let mut unscored = 0usize;
for node in ctx.conversation() {
if let AstNode::Leaf(leaf) = node {
if let NodeBody::Memory { score, text, .. } = leaf.body() {
if let NodeBody::Memory { key, score, text } = leaf.body() {
if score.is_some() { scored += 1; } else { unscored += 1; }
mem_children.push(SectionView {
name: node.label(),
name: format!("mem: {}", key),
tokens: node.tokens(),
content: text.clone(),
children: Vec::new(),
status: String::new(),
status: score.map(|s| format!("{:.2}", s)).unwrap_or_default(),
});
}
}

View file

@ -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(),
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: String::new(),
},
status,
}
}
AstNode::Branch { children, .. } => {
let child_views: Vec<SectionView> = children.iter()
.map(|c| node_to_view(c))