From 460394750641cc6a6b6d696062a5b787720b3292 Mon Sep 17 00:00:00 2001 From: Kent Overstreet Date: Wed, 15 Apr 2026 06:08:27 -0400 Subject: [PATCH] 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 --- src/user/context.rs | 6 +++--- src/user/widgets.rs | 25 +++++++++++++++++-------- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/src/user/context.rs b/src/user/context.rs index 6418f4c..4cfa78d 100644 --- a/src/user/context.rs +++ b/src/user/context.rs @@ -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(), }); } } diff --git a/src/user/widgets.rs b/src/user/widgets.rs index 82a0f05..6b2a11d 100644 --- a/src/user/widgets.rs +++ b/src/user/widgets.rs @@ -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 = children.iter() .map(|c| node_to_view(c))