Spacebar toggle for all agents, persist to config, scan agent directory
- Scan agents directory for all .agent files instead of hardcoded list - Persist enabled state to ~/.consciousness/agent-enabled.json - Spacebar on F3 agent list toggles selected agent on/off - Both subconscious and unconscious agents support toggle - Disabled agents shown dimmed with "off" indicator - New agents default to disabled (safe default) Co-Authored-By: Proof of Concept <poc@bcachefs.org>
This commit is contained in:
parent
7aba17e5f0
commit
c73f037265
6 changed files with 98 additions and 28 deletions
|
|
@ -109,6 +109,8 @@ struct App {
|
|||
agent_state: Vec<crate::mind::SubconsciousSnapshot>,
|
||||
unconscious_state: Vec<crate::mind::UnconsciousSnapshot>,
|
||||
graph_health: Option<crate::subconscious::daemon::GraphHealth>,
|
||||
/// Agent toggle requests from UI — consumed by mind loop.
|
||||
pub agent_toggles: Vec<String>,
|
||||
walked_count: usize,
|
||||
channel_status: Vec<ChannelStatus>,
|
||||
idle_info: Option<IdleInfo>,
|
||||
|
|
@ -134,6 +136,7 @@ impl App {
|
|||
agent_state: Vec::new(),
|
||||
unconscious_state: Vec::new(),
|
||||
graph_health: None,
|
||||
agent_toggles: Vec::new(),
|
||||
walked_count: 0,
|
||||
channel_status: Vec::new(), idle_info: None,
|
||||
}
|
||||
|
|
@ -374,6 +377,18 @@ async fn run(
|
|||
idle_state.decay_ewma();
|
||||
app.update_idle(&idle_state);
|
||||
app.agent_state = mind.subconscious_snapshots().await;
|
||||
{
|
||||
let toggles: Vec<String> = app.agent_toggles.drain(..).collect();
|
||||
if !toggles.is_empty() {
|
||||
let mut sub = mind.subconscious.lock().await;
|
||||
let mut unc = mind.unconscious.lock().await;
|
||||
for name in &toggles {
|
||||
if sub.toggle(name).is_none() {
|
||||
unc.toggle(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
let unc = mind.unconscious.lock().await;
|
||||
app.unconscious_state = unc.snapshots();
|
||||
|
|
|
|||
|
|
@ -79,6 +79,11 @@ impl ScreenView for SubconsciousScreen {
|
|||
self.list_state.select_next();
|
||||
self.reset_pane_state();
|
||||
}
|
||||
KeyCode::Char(' ') => {
|
||||
if let Some(name) = self.selected_agent_name(app) {
|
||||
app.agent_toggles.push(name);
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
Pane::Outputs => self.output_tree.handle_nav(code, &output_sections, area.height),
|
||||
|
|
@ -124,6 +129,20 @@ impl ScreenView for SubconsciousScreen {
|
|||
}
|
||||
|
||||
impl SubconsciousScreen {
|
||||
/// Map the selected list index to an agent name.
|
||||
/// Accounts for the separator line between subconscious and unconscious.
|
||||
fn selected_agent_name(&self, app: &App) -> Option<String> {
|
||||
let idx = self.selected();
|
||||
let sub_count = app.agent_state.len();
|
||||
if idx < sub_count {
|
||||
// Subconscious agent
|
||||
return Some(app.agent_state[idx].name.clone());
|
||||
}
|
||||
// Skip separator line
|
||||
let unc_idx = idx.checked_sub(sub_count + 1)?;
|
||||
app.unconscious_state.get(unc_idx).map(|s| s.name.clone())
|
||||
}
|
||||
|
||||
fn reset_pane_state(&mut self) {
|
||||
self.output_tree = SectionTree::new();
|
||||
self.context_tree = SectionTree::new();
|
||||
|
|
@ -165,7 +184,12 @@ impl SubconsciousScreen {
|
|||
|
||||
fn draw_list(&mut self, frame: &mut Frame, area: Rect, app: &App) {
|
||||
let mut items: Vec<ListItem> = app.agent_state.iter().map(|snap| {
|
||||
if snap.running {
|
||||
if !snap.enabled {
|
||||
ListItem::from(Line::from(vec![
|
||||
Span::styled(&snap.name, Style::default().fg(Color::DarkGray)),
|
||||
Span::styled(" ○ off", Style::default().fg(Color::DarkGray)),
|
||||
]))
|
||||
} else if snap.running {
|
||||
ListItem::from(Line::from(vec![
|
||||
Span::styled(&snap.name, Style::default().fg(Color::Green)),
|
||||
Span::styled(" ● ", Style::default().fg(Color::Green)),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue