Skip to content

Commit 6b73013

Browse files
committed
fix: cargo fmt
1 parent ba72f4a commit 6b73013

5 files changed

Lines changed: 140 additions & 114 deletions

File tree

crates/server/src/runtime/turn_exec.rs

Lines changed: 93 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -380,8 +380,7 @@ impl ServerRuntime {
380380
let command = command_display_from_input(&name, &input);
381381
let preparation_feedback =
382382
runtime.deps.registry.preparation_feedback(&name);
383-
let item_kind = if preparation_feedback
384-
== ToolPreparationFeedback::LiveOnly
383+
let item_kind = if preparation_feedback == ToolPreparationFeedback::LiveOnly
385384
{
386385
ItemKind::ToolCall
387386
} else if is_file_change_tool(&name) {
@@ -393,70 +392,68 @@ impl ServerRuntime {
393392
} else {
394393
ItemKind::ToolCall
395394
};
396-
let started_payload = if preparation_feedback
397-
== ToolPreparationFeedback::LiveOnly
398-
{
399-
serde_json::to_value(ToolCallPayload {
400-
tool_call_id: id.clone(),
401-
tool_name: name.clone(),
402-
parameters: input.clone(),
403-
command_actions: command_actions_from_tool_input(
404-
&name, &command, &input,
405-
),
406-
})
407-
.expect("serialize tool call payload")
408-
} else if is_file_change_tool(&name) {
409-
serde_json::to_value(FileChangePayload {
410-
tool_call_id: id.clone(),
411-
tool_name: Some(name.clone()),
412-
changes: Vec::new(),
413-
is_error: false,
414-
})
415-
.expect("serialize file change payload")
416-
} else if is_command_execution {
417-
serde_json::to_value(CommandExecutionPayload {
418-
tool_call_id: id.clone(),
419-
tool_name: name.clone(),
420-
command: command.clone(),
421-
source: devo_protocol::protocol::ExecCommandSource::Agent,
422-
command_actions: command_actions_from_tool_input(
423-
&name, &command, &input,
424-
),
425-
output: None,
426-
is_error: false,
427-
})
428-
.expect("serialize command execution payload")
429-
} else if is_plan_tool(&name) {
430-
serde_json::json!({
431-
"title": "Plan",
432-
"text": ""
433-
})
434-
} else {
435-
serde_json::to_value(ToolCallPayload {
436-
tool_call_id: id.clone(),
437-
tool_name: name.clone(),
438-
parameters: input.clone(),
439-
command_actions: command_actions_from_tool_input(
440-
&name, &command, &input,
441-
),
442-
})
443-
.expect("serialize tool call payload")
444-
};
445-
let (item_id, item_seq) = if preparation_feedback
446-
== ToolPreparationFeedback::LiveOnly
447-
{
448-
let (item_id, item_seq) = runtime
449-
.start_item(
450-
session_id,
451-
turn_for_events.turn_id,
452-
item_kind,
453-
started_payload,
454-
)
455-
.await;
456-
(Some(item_id), Some(item_seq))
457-
} else {
458-
(None, None)
459-
};
395+
let started_payload =
396+
if preparation_feedback == ToolPreparationFeedback::LiveOnly {
397+
serde_json::to_value(ToolCallPayload {
398+
tool_call_id: id.clone(),
399+
tool_name: name.clone(),
400+
parameters: input.clone(),
401+
command_actions: command_actions_from_tool_input(
402+
&name, &command, &input,
403+
),
404+
})
405+
.expect("serialize tool call payload")
406+
} else if is_file_change_tool(&name) {
407+
serde_json::to_value(FileChangePayload {
408+
tool_call_id: id.clone(),
409+
tool_name: Some(name.clone()),
410+
changes: Vec::new(),
411+
is_error: false,
412+
})
413+
.expect("serialize file change payload")
414+
} else if is_command_execution {
415+
serde_json::to_value(CommandExecutionPayload {
416+
tool_call_id: id.clone(),
417+
tool_name: name.clone(),
418+
command: command.clone(),
419+
source: devo_protocol::protocol::ExecCommandSource::Agent,
420+
command_actions: command_actions_from_tool_input(
421+
&name, &command, &input,
422+
),
423+
output: None,
424+
is_error: false,
425+
})
426+
.expect("serialize command execution payload")
427+
} else if is_plan_tool(&name) {
428+
serde_json::json!({
429+
"title": "Plan",
430+
"text": ""
431+
})
432+
} else {
433+
serde_json::to_value(ToolCallPayload {
434+
tool_call_id: id.clone(),
435+
tool_name: name.clone(),
436+
parameters: input.clone(),
437+
command_actions: command_actions_from_tool_input(
438+
&name, &command, &input,
439+
),
440+
})
441+
.expect("serialize tool call payload")
442+
};
443+
let (item_id, item_seq) =
444+
if preparation_feedback == ToolPreparationFeedback::LiveOnly {
445+
let (item_id, item_seq) = runtime
446+
.start_item(
447+
session_id,
448+
turn_for_events.turn_id,
449+
item_kind,
450+
started_payload,
451+
)
452+
.await;
453+
(Some(item_id), Some(item_seq))
454+
} else {
455+
(None, None)
456+
};
460457
pending_tool_calls.insert(
461458
id,
462459
PendingToolCall {
@@ -481,22 +478,20 @@ impl ServerRuntime {
481478
if let Some(mut pending) = pending_tool_calls.remove(&tool_use_id) {
482479
if pending.item_id.is_none() || pending.item_seq.is_none() {
483480
let started_payload = if let Some(tool_name) = tool_name.clone() {
484-
let item_kind = if runtime
485-
.deps
486-
.registry
487-
.preparation_feedback(&tool_name)
488-
== ToolPreparationFeedback::LiveOnly
489-
{
490-
ItemKind::ToolCall
491-
} else if is_file_change_tool(&tool_name) {
492-
ItemKind::FileChange
493-
} else if pending.is_command_execution {
494-
ItemKind::CommandExecution
495-
} else if is_plan_tool(&tool_name) {
496-
ItemKind::Plan
497-
} else {
498-
ItemKind::ToolCall
499-
};
481+
let item_kind =
482+
if runtime.deps.registry.preparation_feedback(&tool_name)
483+
== ToolPreparationFeedback::LiveOnly
484+
{
485+
ItemKind::ToolCall
486+
} else if is_file_change_tool(&tool_name) {
487+
ItemKind::FileChange
488+
} else if pending.is_command_execution {
489+
ItemKind::CommandExecution
490+
} else if is_plan_tool(&tool_name) {
491+
ItemKind::Plan
492+
} else {
493+
ItemKind::ToolCall
494+
};
500495
let payload = if runtime
501496
.deps
502497
.registry
@@ -527,7 +522,8 @@ impl ServerRuntime {
527522
tool_call_id: tool_use_id.clone(),
528523
tool_name: tool_name.clone(),
529524
command: pending.command.clone(),
530-
source: devo_protocol::protocol::ExecCommandSource::Agent,
525+
source:
526+
devo_protocol::protocol::ExecCommandSource::Agent,
531527
command_actions: command_actions_from_tool_input(
532528
&tool_name,
533529
&pending.command,
@@ -555,14 +551,14 @@ impl ServerRuntime {
555551
})
556552
.expect("serialize tool call payload")
557553
};
558-
let (item_id, item_seq) = runtime
559-
.start_item(
560-
session_id,
561-
turn_for_events.turn_id,
562-
item_kind.clone(),
563-
payload,
564-
)
565-
.await;
554+
let (item_id, item_seq) = runtime
555+
.start_item(
556+
session_id,
557+
turn_for_events.turn_id,
558+
item_kind.clone(),
559+
payload,
560+
)
561+
.await;
566562
pending.item_id = Some(item_id);
567563
pending.item_seq = Some(item_seq);
568564
item_kind
@@ -678,15 +674,19 @@ impl ServerRuntime {
678674
.get("content")
679675
.and_then(serde_json::Value::as_str)
680676
.map(ToOwned::to_owned)
681-
.unwrap_or_else(|| "\n".repeat(additions as usize)),
677+
.unwrap_or_else(|| {
678+
"\n".repeat(additions as usize)
679+
}),
682680
},
683681
"delete" => {
684682
devo_protocol::protocol::FileChange::Delete {
685683
content: file
686684
.get("content")
687685
.and_then(serde_json::Value::as_str)
688686
.map(ToOwned::to_owned)
689-
.unwrap_or_else(|| "\n".repeat(deletions as usize)),
687+
.unwrap_or_else(|| {
688+
"\n".repeat(deletions as usize)
689+
}),
690690
}
691691
}
692692
"update" | "move" => {

crates/tools/src/registry_plan.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,7 @@ pub fn build_tool_registry_plan(config: &ToolPlanConfig) -> ToolRegistryPlan {
519519
execution_mode: ToolExecutionMode::Mutating,
520520
capability_tags: vec![ToolCapabilityTag::ExecuteProcess],
521521
supports_parallel: false,
522-
preparation_feedback: ToolPreparationFeedback::None,
522+
preparation_feedback: ToolPreparationFeedback::None,
523523
},
524524
ToolHandlerKind::Bash,
525525
);

crates/tools/src/router.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -545,9 +545,7 @@ mod tests {
545545
use crate::json_schema::JsonSchema;
546546
use crate::registry::ToolRegistryBuilder;
547547
use crate::tool_handler::ToolHandler;
548-
use crate::tool_spec::{
549-
ToolExecutionMode, ToolOutputMode, ToolPreparationFeedback, ToolSpec,
550-
};
548+
use crate::tool_spec::{ToolExecutionMode, ToolOutputMode, ToolPreparationFeedback, ToolSpec};
551549
use async_trait::async_trait;
552550
use pretty_assertions::assert_eq;
553551

crates/tui/src/chatwidget.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1734,14 +1734,13 @@ impl ChatWidget {
17341734
..tool_call
17351735
});
17361736
} else {
1737-
self.active_tool_calls
1738-
.insert(
1739-
tool_use_id.clone(),
1740-
ActiveToolCall {
1741-
start_time: None,
1742-
..tool_call.clone()
1743-
},
1744-
);
1737+
self.active_tool_calls.insert(
1738+
tool_use_id.clone(),
1739+
ActiveToolCall {
1740+
start_time: None,
1741+
..tool_call.clone()
1742+
},
1743+
);
17451744
self.add_history_entry_without_redraw(Box::new(
17461745
history_cell::AgentMessageCell::new_with_prefix(
17471746
tool_call.lines,

crates/tui/src/chatwidget_tests.rs

Lines changed: 38 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2471,7 +2471,10 @@ fn preparing_write_disappears_after_patch_applied() {
24712471
parsed_commands: None,
24722472
});
24732473
let before = rendered_rows(&widget, 80, 12).join("\n");
2474-
assert!(before.contains("Preparing write..."), "expected preparing state before result:\n{before}");
2474+
assert!(
2475+
before.contains("Preparing write..."),
2476+
"expected preparing state before result:\n{before}"
2477+
);
24752478

24762479
let mut changes = std::collections::HashMap::new();
24772480
changes.insert(
@@ -2483,9 +2486,16 @@ fn preparing_write_disappears_after_patch_applied() {
24832486
widget.handle_worker_event(crate::events::WorkerEvent::PatchApplied { changes });
24842487

24852488
let after = rendered_rows(&widget, 80, 16).join("\n");
2486-
assert!(!after.contains("Preparing write..."), "preparing state should disappear after patch applied:\n{after}");
2489+
assert!(
2490+
!after.contains("Preparing write..."),
2491+
"preparing state should disappear after patch applied:\n{after}"
2492+
);
24872493
let history = scrollback_plain_lines(&widget.drain_scrollback_lines(100)).join("\n");
2488-
assert!(history.contains("Added src/lib.rs") || history.contains("Edited src/lib.rs") || history.contains("Added 1 file"));
2494+
assert!(
2495+
history.contains("Added src/lib.rs")
2496+
|| history.contains("Edited src/lib.rs")
2497+
|| history.contains("Added 1 file")
2498+
);
24892499
}
24902500

24912501
#[test]
@@ -2570,7 +2580,10 @@ fn preparing_tool_row_animates_with_pre_draw_tick() {
25702580
std::thread::sleep(std::time::Duration::from_millis(80));
25712581
widget.pre_draw_tick();
25722582
let after = rendered_rows(&widget, 80, 12).join("\n");
2573-
assert_ne!(before, after, "expected preparing row to animate across ticks");
2583+
assert_ne!(
2584+
before, after,
2585+
"expected preparing row to animate across ticks"
2586+
);
25742587
}
25752588

25762589
#[test]
@@ -4362,9 +4375,19 @@ fn added_file_patch_applied_event_renders_added_content_lines() {
43624375
widget.handle_worker_event(crate::events::WorkerEvent::PatchApplied { changes });
43634376

43644377
let blob = scrollback_plain_lines(&widget.drain_scrollback_lines(100)).join("\n");
4365-
assert!(blob.contains("Added quicksort.rs") || blob.contains("Edited quicksort.rs") || blob.contains("Added 1 file"));
4366-
assert!(blob.contains("pub fn quicksort()"), "expected added file content to render:\n{blob}");
4367-
assert!(blob.contains("println!(\"hi\");"), "expected added file body to render:\n{blob}");
4378+
assert!(
4379+
blob.contains("Added quicksort.rs")
4380+
|| blob.contains("Edited quicksort.rs")
4381+
|| blob.contains("Added 1 file")
4382+
);
4383+
assert!(
4384+
blob.contains("pub fn quicksort()"),
4385+
"expected added file content to render:\n{blob}"
4386+
);
4387+
assert!(
4388+
blob.contains("println!(\"hi\");"),
4389+
"expected added file body to render:\n{blob}"
4390+
);
43684391
}
43694392

43704393
#[test]
@@ -4584,8 +4607,14 @@ fn session_switch_restores_added_file_content_in_edited_block() {
45844607
});
45854608

45864609
let blob = scrollback_plain_lines(&widget.drain_scrollback_lines(100)).join("\n");
4587-
assert!(blob.contains("pub fn quicksort()"), "expected restored added file content:\n{blob}");
4588-
assert!(blob.contains("println!(\"hi\");"), "expected restored added file body:\n{blob}");
4610+
assert!(
4611+
blob.contains("pub fn quicksort()"),
4612+
"expected restored added file content:\n{blob}"
4613+
);
4614+
assert!(
4615+
blob.contains("println!(\"hi\");"),
4616+
"expected restored added file body:\n{blob}"
4617+
);
45894618
}
45904619

45914620
#[test]

0 commit comments

Comments
 (0)