diff --git a/src/commands/session.rs b/src/commands/session.rs index cafdc760..cb8d6be6 100644 --- a/src/commands/session.rs +++ b/src/commands/session.rs @@ -326,10 +326,7 @@ mod tests { assert!(result.message.is_some()); let msg = result.message.unwrap(); assert!(msg.contains("compaction") || msg.contains("Compact")); - assert!(matches!( - result.action, - Some(AppAction::CompactContext) - )); + assert!(matches!(result.action, Some(AppAction::CompactContext))); } #[test] diff --git a/src/compaction.rs b/src/compaction.rs index b5bff90c..4e8cc1e5 100644 --- a/src/compaction.rs +++ b/src/compaction.rs @@ -770,13 +770,13 @@ fn extract_workflow_context(messages: &[Message], workspace: Option<&Path>) -> S let mut files_touched: Vec = Vec::new(); let mut tools_used: Vec = Vec::new(); let mut tasks_identified: Vec = Vec::new(); - + for msg in messages { for block in &msg.content { match block { ContentBlock::ToolUse { name, input, .. } => { tools_used.push(name.clone()); - + // Extract file paths from tool inputs if let Some(path) = extract_path_from_input(input) { if !files_touched.contains(&path) { @@ -797,9 +797,9 @@ fn extract_workflow_context(messages: &[Message], workspace: Option<&Path>) -> S } } } - + let mut context = String::new(); - + if !files_touched.is_empty() { context.push_str("**Files Modified/Read:**\n"); for file in &files_touched { @@ -815,13 +815,13 @@ fn extract_workflow_context(messages: &[Message], workspace: Option<&Path>) -> S } context.push('\n'); } - + if !tools_used.is_empty() { context.push_str("**Tools Used:** "); context.push_str(&tools_used.join(", ")); context.push_str("\n\n"); } - + if !tasks_identified.is_empty() { context.push_str("**Tasks/TODOs Identified:**\n"); for task in &tasks_identified { @@ -829,11 +829,11 @@ fn extract_workflow_context(messages: &[Message], workspace: Option<&Path>) -> S } context.push('\n'); } - + if context.is_empty() { context.push_str("No specific workflow context detected. Continue assisting the user with their current task.\n"); } - + context } @@ -845,7 +845,7 @@ fn extract_path_from_input(input: &serde_json::Value) -> Option { return Some(path.to_string()); } } - + // Try to find path in nested objects if let Some(obj) = input.as_object() { for (_, value) in obj { @@ -856,7 +856,7 @@ fn extract_path_from_input(input: &serde_json::Value) -> Option { } } } - + None } diff --git a/src/tui/app.rs b/src/tui/app.rs index 079ac963..4312422d 100644 --- a/src/tui/app.rs +++ b/src/tui/app.rs @@ -46,17 +46,6 @@ fn format_welcome_banner(model: &str, workspace: &PathBuf, yolo: bool) -> String ) } -/// Get the agent-facing instruction about context compaction. -/// This encourages the agent to request compaction when context gets long. -fn get_compaction_instruction() -> &'static str { - "## Context Management\n\n\ - When the conversation gets long (you'll see a context usage indicator), you can:\n\ - 1. Use `/compact` to summarize earlier context and free up space\n\ - 2. The system will preserve important information (files you're working on, recent messages, tool results)\n\ - 3. After compaction, you'll see a summary of what was discussed and can continue seamlessly\n\n\ - If you notice context is getting long (>80%), proactively suggest using `/compact` to the user." -} - // === Types === /// State machine for onboarding new users. diff --git a/src/tui/ui.rs b/src/tui/ui.rs index f9061293..6b7d5341 100644 --- a/src/tui/ui.rs +++ b/src/tui/ui.rs @@ -1126,7 +1126,8 @@ async fn run_event_loop( .await; } AppAction::CompactContext => { - app.status_message = Some("Compacting context...".to_string()); + app.status_message = + Some("Compacting context...".to_string()); let _ = engine_handle.send(Op::CompactContext).await; } AppAction::TaskAdd { prompt } => {