Delete ui_channel.rs — relocate types, remove all UiMessage/UiSender plumbing
Types relocated: - StreamTarget → mind/mod.rs (Mind decides Conversation vs Autonomous) - SharedActiveTools + shared_active_tools() → agent/tools/mod.rs - ContextSection + SharedContextState → agent/context.rs (already there) - StatusInfo + ContextInfo → user/mod.rs (UI display state) Removed UiSender from: Agent::turn, Mind, learn.rs, all function signatures. The entire message-passing layer is gone. All state flows through Agent fields (activities, entries, streaming) read by the UI via try_lock. Co-Authored-By: Proof of Concept <poc@bcachefs.org>
This commit is contained in:
parent
cfddb55ed9
commit
f390fa1617
11 changed files with 72 additions and 165 deletions
|
|
@ -25,7 +25,14 @@ use crate::agent::{Agent, TurnResult};
|
|||
use crate::agent::api::ApiClient;
|
||||
use crate::config::{AppConfig, SessionConfig};
|
||||
use crate::subconscious::learn;
|
||||
use crate::user::ui_channel::{self, StreamTarget};
|
||||
/// Which pane streaming text should go to.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum StreamTarget {
|
||||
/// User-initiated turn — text goes to conversation pane.
|
||||
Conversation,
|
||||
/// DMN-initiated turn — text goes to autonomous pane.
|
||||
Autonomous,
|
||||
}
|
||||
|
||||
/// Compaction threshold — context is rebuilt when prompt tokens exceed this.
|
||||
fn compaction_threshold(app: &AppConfig) -> u32 {
|
||||
|
|
@ -192,7 +199,6 @@ pub struct Mind {
|
|||
pub agent: Arc<tokio::sync::Mutex<Agent>>,
|
||||
pub shared: Arc<SharedMindState>,
|
||||
pub config: SessionConfig,
|
||||
ui_tx: ui_channel::UiSender,
|
||||
turn_tx: mpsc::Sender<(Result<TurnResult>, StreamTarget)>,
|
||||
turn_watch: tokio::sync::watch::Sender<bool>,
|
||||
bg_tx: mpsc::UnboundedSender<BgEvent>,
|
||||
|
|
@ -203,11 +209,10 @@ pub struct Mind {
|
|||
impl Mind {
|
||||
pub fn new(
|
||||
config: SessionConfig,
|
||||
ui_tx: ui_channel::UiSender,
|
||||
turn_tx: mpsc::Sender<(Result<TurnResult>, StreamTarget)>,
|
||||
) -> Self {
|
||||
let shared_context = ui_channel::shared_context_state();
|
||||
let shared_active_tools = ui_channel::shared_active_tools();
|
||||
let shared_context = crate::agent::context::shared_context_state();
|
||||
let shared_active_tools = crate::agent::tools::shared_active_tools();
|
||||
|
||||
let client = ApiClient::new(&config.api_base, &config.api_key, &config.model);
|
||||
let conversation_log = log::ConversationLog::new(
|
||||
|
|
@ -233,7 +238,7 @@ impl Mind {
|
|||
sup.load_config();
|
||||
sup.ensure_running();
|
||||
|
||||
Self { agent, shared, config, ui_tx, turn_tx, turn_watch, bg_tx,
|
||||
Self { agent, shared, config, turn_tx, turn_watch, bg_tx,
|
||||
bg_rx: std::sync::Mutex::new(Some(bg_rx)), _supervisor: sup }
|
||||
}
|
||||
|
||||
|
|
@ -303,10 +308,9 @@ impl Mind {
|
|||
self.shared.lock().unwrap().turn_active = true;
|
||||
let _ = self.turn_watch.send(true);
|
||||
let agent = self.agent.clone();
|
||||
let ui_tx = self.ui_tx.clone();
|
||||
let result_tx = self.turn_tx.clone();
|
||||
self.shared.lock().unwrap().turn_handle = Some(tokio::spawn(async move {
|
||||
let result = Agent::turn(agent, &input, &ui_tx, target).await;
|
||||
let result = Agent::turn(agent, &input, target).await;
|
||||
let _ = result_tx.send((result, target)).await;
|
||||
}));
|
||||
}
|
||||
|
|
@ -317,7 +321,6 @@ impl Mind {
|
|||
pub fn start_memory_scoring(&self) {
|
||||
let agent = self.agent.clone();
|
||||
let bg_tx = self.bg_tx.clone();
|
||||
let ui_tx = self.ui_tx.clone();
|
||||
let cfg = crate::config::get();
|
||||
let max_age = cfg.scoring_interval_secs;
|
||||
let response_window = cfg.scoring_response_window;
|
||||
|
|
@ -329,7 +332,7 @@ impl Mind {
|
|||
(ag.context.clone(), ag.client_clone())
|
||||
};
|
||||
let result = learn::score_memories_incremental(
|
||||
&context, max_age as i64, response_window, &client, &ui_tx, &agent,
|
||||
&context, max_age as i64, response_window, &client, &agent,
|
||||
).await;
|
||||
{
|
||||
let mut ag = agent.lock().await;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue