WIP: Rename context_new → context, delete old files, fix UI layer
Renamed context_new.rs to context.rs, deleted context_old.rs, types.rs, openai.rs, parsing.rs. Updated all imports. Rewrote user/context.rs and user/widgets.rs for new types. Stubbed working_stack tool. Killed tokenize_conv_entry. Remaining: mind/mod.rs, mind/dmn.rs, learn.rs, chat.rs, subconscious.rs, oneshot.rs. Co-Authored-By: Proof of Concept <poc@bcachefs.org>
This commit is contained in:
parent
22146156d4
commit
bf3e2a9b73
9 changed files with 1063 additions and 1636 deletions
|
|
@ -8,10 +8,8 @@ use ratatui::{
|
|||
Frame,
|
||||
crossterm::event::KeyCode,
|
||||
};
|
||||
use crate::agent::context::{ContextSection, ConversationEntry};
|
||||
use crate::agent::context::{AstNode, NodeBody, Ast};
|
||||
|
||||
/// UI-only tree node for the section tree display.
|
||||
/// Built from ContextSection data; not used for budgeting.
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct SectionView {
|
||||
pub name: String,
|
||||
|
|
@ -22,26 +20,30 @@ pub struct SectionView {
|
|||
pub status: String,
|
||||
}
|
||||
|
||||
/// Build a SectionView tree from a ContextSection.
|
||||
/// Each entry becomes a child with label + expandable content.
|
||||
pub fn section_to_view(section: &ContextSection) -> SectionView {
|
||||
let children: Vec<SectionView> = section.entries().iter().map(|ce| {
|
||||
let content = match &ce.entry {
|
||||
ConversationEntry::Log(_) => String::new(),
|
||||
ConversationEntry::Thinking(text) => text.clone(),
|
||||
_ => ce.entry.message().content_text().to_string(),
|
||||
pub fn section_to_view(name: &str, nodes: &[AstNode]) -> SectionView {
|
||||
let children: Vec<SectionView> = nodes.iter().map(|node| {
|
||||
let content = match node.leaf().map(|l| l.body()) {
|
||||
Some(NodeBody::Log(_)) => String::new(),
|
||||
Some(body) => body.text().to_string(),
|
||||
None => node.children().iter()
|
||||
.filter_map(|c| c.leaf())
|
||||
.filter(|l| matches!(l.body(), NodeBody::Content(_)))
|
||||
.map(|l| l.body().text())
|
||||
.collect::<Vec<_>>()
|
||||
.join(""),
|
||||
};
|
||||
SectionView {
|
||||
name: ce.entry.label(),
|
||||
tokens: ce.tokens(),
|
||||
name: node.label(),
|
||||
tokens: node.tokens(),
|
||||
content,
|
||||
children: Vec::new(),
|
||||
status: String::new(),
|
||||
}
|
||||
}).collect();
|
||||
let total_tokens: usize = nodes.iter().map(|n| n.tokens()).sum();
|
||||
SectionView {
|
||||
name: section.name.clone(),
|
||||
tokens: section.tokens(),
|
||||
name: name.to_string(),
|
||||
tokens: total_tokens,
|
||||
content: String::new(),
|
||||
children,
|
||||
status: String::new(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue