Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions crates/rustyclaw-core/src/security/safety_layer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
//!
//! ## Usage
//!
//! ```rust
//! use rustyclaw::security::{SafetyConfig, SafetyLayer, PolicyAction};
//! ```rust,ignore
//! use rustyclaw_core::security::{SafetyConfig, SafetyLayer, PolicyAction};
//!
//! let config = SafetyConfig {
//! prompt_injection_policy: PolicyAction::Block,
Expand Down Expand Up @@ -644,9 +644,9 @@ mod tests {
};
let safety = SafetyLayer::new(config);

// Clean request should pass
// Clean request should pass (use IP to avoid DNS resolution in CI)
let result = safety.validate_http_request(
"https://api.example.com/data",
"https://93.184.215.14/data",
&[("Content-Type".to_string(), "application/json".to_string())],
Some(b"{\"query\": \"hello\"}"),
);
Expand Down
25 changes: 15 additions & 10 deletions crates/rustyclaw-tui/src/components/message_bubble.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ use rustyclaw_core::types::MessageRole;
pub struct MessageBubbleProps {
pub role: Option<MessageRole>,
pub content: String,
/// Custom name to display for assistant messages (falls back to "Assistant").
pub assistant_name: Option<String>,
}

#[component]
Expand All @@ -20,16 +22,19 @@ pub fn MessageBubble(props: &MessageBubbleProps) -> impl Into<AnyElement<'static

let icon = role.icon();
let label = match role {
MessageRole::User => "You",
MessageRole::Assistant => "Assistant",
MessageRole::Info => "Info",
MessageRole::Success => "Success",
MessageRole::Warning => "Warning",
MessageRole::Error => "Error",
MessageRole::System => "System",
MessageRole::ToolCall => "Tool Call",
MessageRole::ToolResult => "Tool Result",
MessageRole::Thinking => "Thinking",
MessageRole::User => "You".to_string(),
MessageRole::Assistant => props
.assistant_name
.clone()
.unwrap_or_else(|| "Assistant".to_string()),
MessageRole::Info => "Info".to_string(),
MessageRole::Success => "Success".to_string(),
MessageRole::Warning => "Warning".to_string(),
MessageRole::Error => "Error".to_string(),
MessageRole::System => "System".to_string(),
MessageRole::ToolCall => "Tool Call".to_string(),
MessageRole::ToolResult => "Tool Result".to_string(),
MessageRole::Thinking => "Thinking".to_string(),
};

// Render markdown for assistant messages, plain text for others
Expand Down
5 changes: 5 additions & 0 deletions crates/rustyclaw-tui/src/components/messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,14 @@ pub struct MessagesProps {
pub spinner_tick: usize,
/// Elapsed time string (e.g., "2.3s").
pub elapsed: String,
/// Custom name to display for assistant messages.
pub assistant_name: Option<String>,
}

#[component]
pub fn Messages(props: &MessagesProps) -> impl Into<AnyElement<'static>> {
let spinner = SPINNER_FRAMES[props.spinner_tick % SPINNER_FRAMES.len()];
let assistant_name = props.assistant_name.clone();

element! {
View(
Expand All @@ -45,11 +48,13 @@ pub fn Messages(props: &MessagesProps) -> impl Into<AnyElement<'static>> {
bottom: -(props.scroll_offset),
) {
#(props.messages.iter().enumerate().map(|(i, msg)| {
let name = assistant_name.clone();
element! {
MessageBubble(
key: i as u64,
role: msg.role,
content: msg.content.clone(),
assistant_name: name,
)
}
}))
Expand Down
5 changes: 5 additions & 0 deletions crates/rustyclaw-tui/src/components/root.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,11 @@ pub fn Root(props: &mut RootProps) -> impl Into<AnyElement<'static>> {
streaming: props.streaming,
spinner_tick: props.spinner_tick,
elapsed: props.elapsed.clone(),
assistant_name: if props.soul_name.is_empty() {
None
} else {
Some(props.soul_name.clone())
},
)
CommandMenu(
completions: props.command_completions.clone(),
Expand Down
Loading