forked from kent/consciousness
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
|
|
@ -37,14 +37,14 @@ impl ConsciousScreen {
|
||||||
let mut unscored = 0usize;
|
let mut unscored = 0usize;
|
||||||
for node in ctx.conversation() {
|
for node in ctx.conversation() {
|
||||||
if let AstNode::Leaf(leaf) = node {
|
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; }
|
if score.is_some() { scored += 1; } else { unscored += 1; }
|
||||||
mem_children.push(SectionView {
|
mem_children.push(SectionView {
|
||||||
name: node.label(),
|
name: format!("mem: {}", key),
|
||||||
tokens: node.tokens(),
|
tokens: node.tokens(),
|
||||||
content: text.clone(),
|
content: text.clone(),
|
||||||
children: Vec::new(),
|
children: Vec::new(),
|
||||||
status: String::new(),
|
status: score.map(|s| format!("{:.2}", s)).unwrap_or_default(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ use ratatui::{
|
||||||
widgets::{Block, Borders},
|
widgets::{Block, Borders},
|
||||||
crossterm::event::KeyCode,
|
crossterm::event::KeyCode,
|
||||||
};
|
};
|
||||||
use crate::agent::context::{AstNode, Ast};
|
use crate::agent::context::{AstNode, Ast, NodeBody};
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct SectionView {
|
pub struct SectionView {
|
||||||
|
|
@ -20,13 +20,22 @@ pub struct SectionView {
|
||||||
|
|
||||||
fn node_to_view(node: &AstNode) -> SectionView {
|
fn node_to_view(node: &AstNode) -> SectionView {
|
||||||
match node {
|
match node {
|
||||||
AstNode::Leaf(leaf) => SectionView {
|
AstNode::Leaf(leaf) => {
|
||||||
name: node.label(),
|
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(),
|
tokens: node.tokens(),
|
||||||
content: leaf.body().text().to_string(),
|
content: leaf.body().text().to_string(),
|
||||||
children: Vec::new(),
|
children: Vec::new(),
|
||||||
status: String::new(),
|
status,
|
||||||
},
|
}
|
||||||
|
}
|
||||||
AstNode::Branch { children, .. } => {
|
AstNode::Branch { children, .. } => {
|
||||||
let child_views: Vec<SectionView> = children.iter()
|
let child_views: Vec<SectionView> = children.iter()
|
||||||
.map(|c| node_to_view(c))
|
.map(|c| node_to_view(c))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue