kill off pub in src/usr/mod.rs
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
parent
d7c93ffdf1
commit
7de816022a
1 changed files with 55 additions and 75 deletions
130
src/user/mod.rs
130
src/user/mod.rs
|
|
@ -30,32 +30,29 @@ use std::io;
|
|||
|
||||
/// Status info for the bottom status bar.
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct StatusInfo {
|
||||
pub dmn_state: String,
|
||||
pub dmn_turns: u32,
|
||||
pub dmn_max_turns: u32,
|
||||
pub prompt_tokens: u32,
|
||||
pub completion_tokens: u32,
|
||||
pub model: String,
|
||||
pub turn_tools: u32,
|
||||
pub context_budget: String,
|
||||
struct StatusInfo {
|
||||
dmn_state: String,
|
||||
dmn_turns: u32,
|
||||
dmn_max_turns: u32,
|
||||
prompt_tokens: u32,
|
||||
model: String,
|
||||
turn_tools: u32,
|
||||
context_budget: String,
|
||||
}
|
||||
|
||||
/// Context loading details for the debug screen.
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct ContextInfo {
|
||||
pub model: String,
|
||||
pub available_models: Vec<String>,
|
||||
pub prompt_file: String,
|
||||
pub backend: String,
|
||||
pub instruction_files: Vec<(String, usize)>,
|
||||
pub memory_files: Vec<(String, usize)>,
|
||||
pub system_prompt_chars: usize,
|
||||
pub context_message_chars: usize,
|
||||
struct ContextInfo {
|
||||
model: String,
|
||||
available_models: Vec<String>,
|
||||
prompt_file: String,
|
||||
backend: String,
|
||||
system_prompt_chars: usize,
|
||||
context_message_chars: usize,
|
||||
}
|
||||
|
||||
/// Build the screen legend from screen labels.
|
||||
pub(crate) fn screen_legend_from(screens: &[Box<dyn ScreenView>]) -> String {
|
||||
fn screen_legend_from(screens: &[Box<dyn ScreenView>]) -> String {
|
||||
let parts: Vec<String> = screens.iter().enumerate()
|
||||
.map(|(i, s)| format!("F{}={}", i + 1, s.label()))
|
||||
.collect();
|
||||
|
|
@ -65,78 +62,61 @@ pub(crate) fn screen_legend_from(screens: &[Box<dyn ScreenView>]) -> String {
|
|||
// Cached legend — set once at startup by event_loop
|
||||
static SCREEN_LEGEND: std::sync::OnceLock<String> = std::sync::OnceLock::new();
|
||||
|
||||
pub(crate) fn set_screen_legend(legend: String) {
|
||||
fn set_screen_legend(legend: String) {
|
||||
let _ = SCREEN_LEGEND.set(legend);
|
||||
}
|
||||
|
||||
pub(crate) fn screen_legend() -> String {
|
||||
fn screen_legend() -> String {
|
||||
SCREEN_LEGEND.get().cloned().unwrap_or_default()
|
||||
}
|
||||
|
||||
/// Action returned from a screen's tick method.
|
||||
pub enum ScreenAction {
|
||||
/// Switch to screen at this index
|
||||
Switch(usize),
|
||||
/// Send a hotkey action to the Mind
|
||||
Hotkey(HotkeyAction),
|
||||
}
|
||||
|
||||
/// A screen that can draw itself and handle input.
|
||||
pub(crate) trait ScreenView: Send {
|
||||
trait ScreenView: Send {
|
||||
fn tick(&mut self, frame: &mut ratatui::Frame, area: ratatui::layout::Rect,
|
||||
events: &[ratatui::crossterm::event::Event], app: &mut App);
|
||||
fn label(&self) -> &'static str;
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum HotkeyAction {
|
||||
CycleReasoning, KillProcess, Interrupt, CycleAutonomy,
|
||||
/// Adjust a sampling parameter: (param_index, delta)
|
||||
/// 0=temperature, 1=top_p, 2=top_k
|
||||
AdjustSampling(usize, f32),
|
||||
#[derive(Clone)]
|
||||
struct IdleInfo {
|
||||
user_present: bool,
|
||||
since_activity: f64,
|
||||
activity_ewma: f64,
|
||||
block_reason: String,
|
||||
dreaming: bool,
|
||||
sleeping: bool,
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub(crate) struct IdleInfo {
|
||||
pub user_present: bool,
|
||||
pub since_activity: f64,
|
||||
pub activity_ewma: f64,
|
||||
pub block_reason: String,
|
||||
pub dreaming: bool,
|
||||
pub sleeping: bool,
|
||||
struct ChannelStatus {
|
||||
name: String,
|
||||
connected: bool,
|
||||
unread: u32,
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub(crate) struct ChannelStatus {
|
||||
pub name: String,
|
||||
pub connected: bool,
|
||||
pub unread: u32,
|
||||
}
|
||||
|
||||
pub struct App {
|
||||
pub(crate) status: StatusInfo,
|
||||
pub(crate) activity: String,
|
||||
pub running_processes: u32,
|
||||
pub reasoning_effort: String,
|
||||
pub temperature: f32,
|
||||
pub top_p: f32,
|
||||
pub top_k: u32,
|
||||
pub(crate) active_tools: crate::agent::tools::SharedActiveTools,
|
||||
pub should_quit: bool,
|
||||
pub submitted: Vec<String>,
|
||||
pub(crate) context_info: Option<ContextInfo>,
|
||||
pub(crate) agent_state: Vec<crate::mind::SubconsciousSnapshot>,
|
||||
pub(crate) walked_count: usize,
|
||||
pub(crate) channel_status: Vec<ChannelStatus>,
|
||||
pub(crate) idle_info: Option<IdleInfo>,
|
||||
struct App {
|
||||
status: StatusInfo,
|
||||
activity: String,
|
||||
running_processes: u32,
|
||||
reasoning_effort: String,
|
||||
temperature: f32,
|
||||
top_p: f32,
|
||||
top_k: u32,
|
||||
active_tools: crate::agent::tools::SharedActiveTools,
|
||||
should_quit: bool,
|
||||
context_info: Option<ContextInfo>,
|
||||
agent_state: Vec<crate::mind::SubconsciousSnapshot>,
|
||||
walked_count: usize,
|
||||
channel_status: Vec<ChannelStatus>,
|
||||
idle_info: Option<IdleInfo>,
|
||||
}
|
||||
|
||||
impl App {
|
||||
pub fn new(model: String, active_tools: crate::agent::tools::SharedActiveTools) -> Self {
|
||||
fn new(model: String, active_tools: crate::agent::tools::SharedActiveTools) -> Self {
|
||||
Self {
|
||||
status: StatusInfo {
|
||||
dmn_state: "resting".into(), dmn_turns: 0, dmn_max_turns: 20,
|
||||
prompt_tokens: 0, completion_tokens: 0, model,
|
||||
prompt_tokens: 0, model,
|
||||
turn_tools: 0, context_budget: String::new(),
|
||||
},
|
||||
activity: String::new(),
|
||||
|
|
@ -146,7 +126,7 @@ impl App {
|
|||
top_p: 0.95,
|
||||
top_k: 20,
|
||||
active_tools,
|
||||
should_quit: false, submitted: Vec::new(),
|
||||
should_quit: false,
|
||||
context_info: None,
|
||||
agent_state: Vec::new(),
|
||||
walked_count: 0,
|
||||
|
|
@ -155,13 +135,13 @@ impl App {
|
|||
}
|
||||
|
||||
|
||||
pub fn set_channel_status(&mut self, channels: Vec<(String, bool, u32)>) {
|
||||
fn set_channel_status(&mut self, channels: Vec<(String, bool, u32)>) {
|
||||
self.channel_status = channels.into_iter()
|
||||
.map(|(name, connected, unread)| ChannelStatus { name, connected, unread })
|
||||
.collect();
|
||||
}
|
||||
|
||||
pub fn update_idle(&mut self, state: &crate::thalamus::idle::State) {
|
||||
fn update_idle(&mut self, state: &crate::thalamus::idle::State) {
|
||||
self.idle_info = Some(IdleInfo {
|
||||
user_present: state.user_present(), since_activity: state.since_activity(),
|
||||
activity_ewma: state.activity_ewma, block_reason: state.block_reason().to_string(),
|
||||
|
|
@ -171,7 +151,7 @@ impl App {
|
|||
|
||||
}
|
||||
|
||||
pub fn init_terminal() -> io::Result<ratatui::Terminal<CrosstermBackend<io::Stdout>>> {
|
||||
fn init_terminal() -> io::Result<ratatui::Terminal<CrosstermBackend<io::Stdout>>> {
|
||||
terminal::enable_raw_mode()?;
|
||||
let mut stdout = io::stdout();
|
||||
stdout.execute(EnterAlternateScreen)?;
|
||||
|
|
@ -180,7 +160,7 @@ pub fn init_terminal() -> io::Result<ratatui::Terminal<CrosstermBackend<io::Stdo
|
|||
ratatui::Terminal::new(backend)
|
||||
}
|
||||
|
||||
pub fn restore_terminal(terminal: &mut ratatui::Terminal<CrosstermBackend<io::Stdout>>) -> io::Result<()> {
|
||||
fn restore_terminal(terminal: &mut ratatui::Terminal<CrosstermBackend<io::Stdout>>) -> io::Result<()> {
|
||||
terminal::disable_raw_mode()?;
|
||||
terminal.backend_mut().execute(DisableMouseCapture)?;
|
||||
terminal.backend_mut().execute(LeaveAlternateScreen)?;
|
||||
|
|
@ -188,7 +168,7 @@ pub fn restore_terminal(terminal: &mut ratatui::Terminal<CrosstermBackend<io::St
|
|||
}
|
||||
|
||||
/// Top-level entry point — creates Mind and UI, wires them together.
|
||||
pub async fn start(cli: crate::user::CliArgs) -> Result<()> {
|
||||
async fn start(cli: crate::user::CliArgs) -> Result<()> {
|
||||
let (config, _figment) = crate::config::load_session(&cli)?;
|
||||
|
||||
if config.app.debug {
|
||||
|
|
@ -309,7 +289,7 @@ fn is_global_event(event: &ratatui::crossterm::event::Event) -> bool {
|
|||
}
|
||||
}
|
||||
|
||||
pub async fn run(
|
||||
async fn run(
|
||||
mut app: tui::App,
|
||||
mind: &crate::mind::Mind,
|
||||
mind_tx: tokio::sync::mpsc::UnboundedSender<MindCommand>,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue