shared active tools: Agent writes, TUI reads directly
Move active tool tracking from TUI message-passing to shared Arc<RwLock> state. Agent pushes on dispatch, removes on apply_tool_result. TUI reads during render. Background tasks show as active until drained at next turn start. Co-Developed-By: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
parent
d25033b9f4
commit
474b66c834
6 changed files with 62 additions and 49 deletions
|
|
@ -378,6 +378,7 @@ impl Session {
|
|||
.ok();
|
||||
let mut agent_guard = self.agent.lock().await;
|
||||
let shared_ctx = agent_guard.shared_context.clone();
|
||||
let shared_tools = agent_guard.active_tools.clone();
|
||||
*agent_guard = Agent::new(
|
||||
ApiClient::new(
|
||||
&self.config.api_base,
|
||||
|
|
@ -390,6 +391,7 @@ impl Session {
|
|||
self.config.prompt_file.clone(),
|
||||
new_log,
|
||||
shared_ctx,
|
||||
shared_tools,
|
||||
);
|
||||
}
|
||||
self.dmn = dmn::State::Resting {
|
||||
|
|
@ -826,12 +828,13 @@ async fn run(cli: cli::CliArgs) -> Result<()> {
|
|||
// Create UI channel
|
||||
let (ui_tx, mut ui_rx) = ui_channel::channel();
|
||||
|
||||
// Shared context state — agent writes, TUI reads for debug screen
|
||||
// Shared state — agent writes, TUI reads
|
||||
let shared_context = ui_channel::shared_context_state();
|
||||
let shared_active_tools = ui_channel::shared_active_tools();
|
||||
|
||||
// Initialize TUI
|
||||
let mut terminal = tui::init_terminal()?;
|
||||
let mut app = tui::App::new(config.model.clone(), shared_context.clone());
|
||||
let mut app = tui::App::new(config.model.clone(), shared_context.clone(), shared_active_tools.clone());
|
||||
|
||||
// Show startup info
|
||||
let _ = ui_tx.send(UiMessage::Info("consciousness v0.3 (tui)".into()));
|
||||
|
|
@ -868,6 +871,7 @@ async fn run(cli: cli::CliArgs) -> Result<()> {
|
|||
config.prompt_file.clone(),
|
||||
Some(conversation_log),
|
||||
shared_context,
|
||||
shared_active_tools,
|
||||
)));
|
||||
|
||||
// Keep a reference to the process tracker outside the agent lock
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue