Skip to content

Commit c734b3c

Browse files
Alex HolmbergAlex Holmberg
authored andcommitted
fix(fomatting): missing formatting
1 parent da56df9 commit c734b3c

18 files changed

Lines changed: 293 additions & 225 deletions

src/agent/history.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -705,7 +705,10 @@ mod tests {
705705
// to_messages should still work and include summary
706706
let messages = history.to_messages();
707707
if history.summary_frame.is_some() {
708-
assert!(!messages.is_empty(), "Should still have summary in messages");
708+
assert!(
709+
!messages.is_empty(),
710+
"Should still have summary in messages"
711+
);
709712
}
710713
}
711714

@@ -736,7 +739,10 @@ mod tests {
736739
history_preserve.summary_frame.is_some(),
737740
"preserve should keep summary"
738741
);
739-
assert!(history_clear.summary_frame.is_none(), "clear removes summary");
742+
assert!(
743+
history_clear.summary_frame.is_none(),
744+
"clear removes summary"
745+
);
740746
}
741747

742748
// Both should have no turns

src/agent/mod.rs

Lines changed: 31 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -317,30 +317,35 @@ pub async fn run_interactive(
317317
println!();
318318

319319
// Try to restore from history_snapshot (new format with full context)
320-
let restored_from_snapshot =
321-
if let Some(history_json) = &record.history_snapshot {
322-
match ConversationHistory::from_json(history_json) {
323-
Ok(restored) => {
324-
conversation_history = restored;
325-
// Rebuild raw_chat_history from restored conversation_history
326-
raw_chat_history = conversation_history.to_messages();
327-
println!(
320+
let restored_from_snapshot = if let Some(history_json) =
321+
&record.history_snapshot
322+
{
323+
match ConversationHistory::from_json(history_json) {
324+
Ok(restored) => {
325+
conversation_history = restored;
326+
// Rebuild raw_chat_history from restored conversation_history
327+
raw_chat_history = conversation_history.to_messages();
328+
println!(
328329
"{}",
329330
" ✓ Restored full conversation context (including compacted history)".green()
330331
);
331-
true
332-
}
333-
Err(e) => {
334-
eprintln!(
335-
"{}",
336-
format!(" Warning: Failed to restore history snapshot: {}", e).yellow()
337-
);
338-
false
339-
}
332+
true
340333
}
341-
} else {
342-
false
343-
};
334+
Err(e) => {
335+
eprintln!(
336+
"{}",
337+
format!(
338+
" Warning: Failed to restore history snapshot: {}",
339+
e
340+
)
341+
.yellow()
342+
);
343+
false
344+
}
345+
}
346+
} else {
347+
false
348+
};
344349

345350
// Fallback: Load from messages (old format or if snapshot failed)
346351
if !restored_from_snapshot {
@@ -359,13 +364,13 @@ pub async fn run_interactive(
359364
persistence::MessageRole::Assistant => {
360365
raw_chat_history
361366
.push(rig::completion::Message::Assistant {
362-
id: Some(msg.id.clone()),
363-
content: rig::one_or_many::OneOrMany::one(
364-
rig::completion::message::AssistantContent::text(
365-
&msg.content,
366-
),
367+
id: Some(msg.id.clone()),
368+
content: rig::one_or_many::OneOrMany::one(
369+
rig::completion::message::AssistantContent::text(
370+
&msg.content,
367371
),
368-
});
372+
),
373+
});
369374
}
370375
persistence::MessageRole::System => {}
371376
}

src/agent/session/commands.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
//! - `/resume` - Browse and select a session to resume
1010
//! - `/sessions` - List available sessions
1111
12+
use super::ChatSession;
1213
use super::plan_mode::find_incomplete_plans;
1314
use super::providers::{get_available_models, prompt_api_key};
14-
use super::ChatSession;
1515
use crate::agent::{AgentResult, ProviderType};
1616
use crate::config::{load_agent_config, save_agent_config};
1717
use colored::Colorize;
@@ -700,7 +700,7 @@ pub fn handle_plans_command(session: &ChatSession) -> AgentResult<()> {
700700
/// Handle /resume command - browse and select a session to resume
701701
/// Returns true if a session was loaded and should be displayed
702702
pub fn handle_resume_command(session: &mut ChatSession) -> AgentResult<bool> {
703-
use crate::agent::persistence::{browse_sessions, format_relative_time, SessionSelector};
703+
use crate::agent::persistence::{SessionSelector, browse_sessions, format_relative_time};
704704

705705
let selector = SessionSelector::new(&session.project_path);
706706
let sessions = selector.list_sessions();
@@ -747,7 +747,7 @@ pub fn handle_resume_command(session: &mut ChatSession) -> AgentResult<bool> {
747747

748748
/// Handle /sessions command - list available sessions
749749
pub fn handle_list_sessions_command(session: &ChatSession) {
750-
use crate::agent::persistence::{format_relative_time, SessionSelector};
750+
use crate::agent::persistence::{SessionSelector, format_relative_time};
751751

752752
let selector = SessionSelector::new(&session.project_path);
753753
let sessions = selector.list_sessions();

src/agent/session/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ mod providers;
1515
mod ui;
1616

1717
// Re-exports for backward compatibility
18-
pub use plan_mode::{find_incomplete_plans, IncompletePlan, PlanMode};
18+
pub use plan_mode::{IncompletePlan, PlanMode, find_incomplete_plans};
1919
pub use providers::{get_available_models, get_configured_providers, prompt_api_key};
2020

2121
use crate::agent::commands::TokenUsage;

src/agent/session/providers.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,7 @@ pub fn has_api_key(provider: ProviderType) -> bool {
113113
ProviderType::Bedrock => {
114114
if let Some(bedrock) = &profile.bedrock
115115
&& (bedrock.profile.is_some()
116-
|| (bedrock.access_key_id.is_some()
117-
&& bedrock.secret_access_key.is_some()))
116+
|| (bedrock.access_key_id.is_some() && bedrock.secret_access_key.is_some()))
118117
{
119118
return true;
120119
}
@@ -148,8 +147,7 @@ pub fn has_api_key(provider: ProviderType) -> bool {
148147
ProviderType::Bedrock => {
149148
if let Some(bedrock) = &profile.bedrock
150149
&& (bedrock.profile.is_some()
151-
|| (bedrock.access_key_id.is_some()
152-
&& bedrock.secret_access_key.is_some()))
150+
|| (bedrock.access_key_id.is_some() && bedrock.secret_access_key.is_some()))
153151
{
154152
return true;
155153
}
@@ -410,8 +408,7 @@ pub(crate) fn run_bedrock_setup_wizard() -> AgentResult<String> {
410408
}
411409
"3" => {
412410
// Use existing env vars
413-
if std::env::var("AWS_ACCESS_KEY_ID").is_err()
414-
&& std::env::var("AWS_PROFILE").is_err()
411+
if std::env::var("AWS_ACCESS_KEY_ID").is_err() && std::env::var("AWS_PROFILE").is_err()
415412
{
416413
println!("{}", "No AWS credentials found in environment!".yellow());
417414
println!("Set AWS_ACCESS_KEY_ID + AWS_SECRET_ACCESS_KEY or AWS_PROFILE");

src/agent/session/ui.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//!
33
//! Contains display functions for help, logo, and welcome banner.
44
5-
use super::{find_incomplete_plans, ChatSession};
5+
use super::{ChatSession, find_incomplete_plans};
66
use crate::agent::commands::SLASH_COMMANDS;
77
use crate::agent::ui::ansi;
88
use colored::Colorize;

src/agent/tools/analyze.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,7 @@ Returns a compressed summary with key findings. Full analysis is stored and can
155155
}
156156

157157
let json_value = serde_json::to_value(&analysis).map_err(|e| {
158-
AnalyzeError(format!(
159-
"Failed to serialize analysis results: {}",
160-
e
161-
))
158+
AnalyzeError(format!("Failed to serialize analysis results: {}", e))
162159
})?;
163160

164161
// Use smart compression with RAG retrieval pattern
@@ -186,10 +183,7 @@ Returns a compressed summary with key findings. Full analysis is stored and can
186183
} else if error_str.contains("not found") || error_str.contains("No such file") {
187184
(
188185
ErrorCategory::FileNotFound,
189-
vec![
190-
"Verify the path exists",
191-
"Use list_directory to explore",
192-
],
186+
vec!["Verify the path exists", "Use list_directory to explore"],
193187
)
194188
} else {
195189
(
@@ -287,6 +281,10 @@ mod tests {
287281

288282
let result = tool.call(args).await.unwrap();
289283
// Should return error formatted for LLM
290-
assert!(result.contains("error") || result.contains("not found") || result.contains("Path not found"));
284+
assert!(
285+
result.contains("error")
286+
|| result.contains("not found")
287+
|| result.contains("Path not found")
288+
);
291289
}
292290
}

src/agent/tools/dclint.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,10 @@ USAGE:
475475
return Ok(format_error_for_llm(
476476
"dclint",
477477
ErrorCategory::ValidationFailed,
478-
&format!("Invalid Docker Compose YAML syntax: {}", result.parse_errors.join(", ")),
478+
&format!(
479+
"Invalid Docker Compose YAML syntax: {}",
480+
result.parse_errors.join(", ")
481+
),
479482
Some(vec![
480483
"Check YAML indentation (use spaces, not tabs)",
481484
"Verify key-value pair syntax (key: value)",

src/agent/tools/error.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -361,8 +361,10 @@ mod tests {
361361

362362
#[test]
363363
fn test_tool_error_context() {
364-
let result: Result<(), std::io::Error> =
365-
Err(std::io::Error::new(std::io::ErrorKind::NotFound, "file missing"));
364+
let result: Result<(), std::io::Error> = Err(std::io::Error::new(
365+
std::io::ErrorKind::NotFound,
366+
"file missing",
367+
));
366368

367369
let with_context = result.with_tool_context("read_file", "reading config");
368370
assert!(with_context.is_err());

0 commit comments

Comments
 (0)