mirror of
https://github.com/outbackdingo/optimclaw.git
synced 2026-09-01 17:19:24 +00:00
Add status updates to show agent thinking/processing state
- Add StatusUpdate enum with Thinking, ToolStarted, ToolCompleted, StreamChunk, Status variants - Add send_status method to Channel trait (default no-op) - Implement send_status in TuiChannel to show status in UI - Add send_status to ChannelManager for routing to specific channels - Update handle_message to send "Processing..." status for Chat/CreateJob - Update handle_chat to send "Generating response..." and show errors Now when a user sends a message, they see feedback that the agent is working. Co-Authored-By: Claude Opus 4.5 <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 4.5
parent
d1cb748914
commit
7f9f0cd21e
+44
-9
@@ -7,7 +7,7 @@ use uuid::Uuid;
|
||||
|
||||
use crate::agent::self_repair::DefaultSelfRepair;
|
||||
use crate::agent::{MessageIntent, RepairTask, Router, Scheduler};
|
||||
use crate::channels::{ChannelManager, IncomingMessage, OutgoingResponse};
|
||||
use crate::channels::{ChannelManager, IncomingMessage, OutgoingResponse, StatusUpdate};
|
||||
use crate::config::AgentConfig;
|
||||
use crate::context::ContextManager;
|
||||
use crate::error::Error;
|
||||
@@ -127,6 +127,20 @@ impl Agent {
|
||||
let intent = self.router.route(message);
|
||||
tracing::debug!("Routed to intent: {:?}", intent);
|
||||
|
||||
// Send thinking status for non-trivial operations
|
||||
match &intent {
|
||||
MessageIntent::Chat { .. } | MessageIntent::CreateJob { .. } => {
|
||||
let _ = self
|
||||
.channels
|
||||
.send_status(
|
||||
&message.channel,
|
||||
StatusUpdate::Thinking("Processing...".into()),
|
||||
)
|
||||
.await;
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
||||
// Handle based on intent
|
||||
let response = match intent {
|
||||
MessageIntent::CreateJob {
|
||||
@@ -293,19 +307,40 @@ impl Agent {
|
||||
}
|
||||
}
|
||||
|
||||
async fn handle_chat(
|
||||
&self,
|
||||
_message: &IncomingMessage,
|
||||
content: &str,
|
||||
) -> Result<String, Error> {
|
||||
async fn handle_chat(&self, message: &IncomingMessage, content: &str) -> Result<String, Error> {
|
||||
// Send thinking status
|
||||
let _ = self
|
||||
.channels
|
||||
.send_status(
|
||||
&message.channel,
|
||||
StatusUpdate::Thinking("Generating response...".into()),
|
||||
)
|
||||
.await;
|
||||
|
||||
// Use LLM for general chat
|
||||
let reasoning = Reasoning::new(self.llm.clone(), self.safety.clone());
|
||||
|
||||
let context = ReasoningContext::new().with_message(ChatMessage::user(content));
|
||||
|
||||
let response = reasoning.respond(&context).await?;
|
||||
|
||||
Ok(response)
|
||||
match reasoning.respond(&context).await {
|
||||
Ok(response) => {
|
||||
let _ = self
|
||||
.channels
|
||||
.send_status(&message.channel, StatusUpdate::Status("Done".into()))
|
||||
.await;
|
||||
Ok(response)
|
||||
}
|
||||
Err(e) => {
|
||||
let _ = self
|
||||
.channels
|
||||
.send_status(
|
||||
&message.channel,
|
||||
StatusUpdate::Status(format!("Error: {}", e)),
|
||||
)
|
||||
.await;
|
||||
Err(e.into())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async fn handle_command(
|
||||
|
||||
Reference in New Issue
Block a user