Skip to content

Commit 4ece161

Browse files
committed
Fix clippy errors
1 parent 84dd6b5 commit 4ece161

7 files changed

Lines changed: 48 additions & 39 deletions

File tree

crates/code_assistant/src/agent/runner.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -702,15 +702,11 @@ impl Agent {
702702
let parser = parser.as_ref();
703703
let mut removed = 0usize;
704704

705-
loop {
706-
let Some(last_assistant_idx) = self
707-
.message_history
708-
.iter()
709-
.rposition(|message| message.role == MessageRole::Assistant)
710-
else {
711-
break;
712-
};
713-
705+
while let Some(last_assistant_idx) = self
706+
.message_history
707+
.iter()
708+
.rposition(|message| message.role == MessageRole::Assistant)
709+
{
714710
let last_assistant = &self.message_history[last_assistant_idx];
715711

716712
if !parser.message_contains_tool_invocation(last_assistant) {
@@ -1876,7 +1872,7 @@ impl Agent {
18761872
}
18771873

18781874
// Sort descending by size
1879-
sizes.sort_by(|a, b| b.1.cmp(&a.1));
1875+
sizes.sort_by_key(|item| std::cmp::Reverse(item.1));
18801876

18811877
// Replace results that are above a minimum threshold (50KB) — there is no
18821878
// point replacing tiny results since they are unlikely to be the cause.

crates/code_assistant/src/persistence.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,7 @@ impl FileSessionPersistence {
672672
};
673673

674674
// Sort by updated_at in descending order (newest first)
675-
metadata_list.sort_by(|a, b| b.updated_at.cmp(&a.updated_at));
675+
metadata_list.sort_by_key(|item| std::cmp::Reverse(item.updated_at));
676676

677677
Ok(metadata_list)
678678
}

crates/code_assistant/src/session/instance.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -833,11 +833,9 @@ impl UserInterface for ProxyUI {
833833
UiEvent::UpdateSessionActivityState {
834834
session_id,
835835
activity_state,
836-
} => {
837-
if session_id == &self.session_id {
838-
self.update_activity_state(activity_state.clone());
839-
return Ok(());
840-
}
836+
} if session_id == &self.session_id => {
837+
self.update_activity_state(activity_state.clone());
838+
return Ok(());
841839
}
842840
_ => {}
843841
}

crates/code_assistant/src/ui/gpui/elements.rs

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1514,7 +1514,7 @@ impl BlockView {
15141514
&& (block.status == ToolStatus::Pending || block.status == ToolStatus::Running);
15151515

15161516
// --- Build the element ---
1517-
let mut container = div().w_full();
1517+
let mut container = div().w_full().mt_0p5();
15181518

15191519
// Header line: clickable area with icon + description + chevron-on-hover
15201520
let header = div()
@@ -1629,6 +1629,7 @@ impl Render for BlockView {
16291629
fn render(&mut self, window: &mut gpui::Window, cx: &mut Context<Self>) -> impl IntoElement {
16301630
match self.block.clone() {
16311631
BlockData::TextBlock(block) => div()
1632+
.mt_3()
16321633
.text_color(cx.theme().foreground)
16331634
.child(self.markdown_view(&block.content, true, cx))
16341635
.into_any_element(),
@@ -1664,6 +1665,7 @@ impl Render for BlockView {
16641665
let text_color = cx.theme().info_foreground;
16651666

16661667
div()
1668+
.mt_2()
16671669
.rounded_md()
16681670
.bg(thinking_bg)
16691671
.flex()
@@ -1828,24 +1830,29 @@ impl Render for BlockView {
18281830
window,
18291831
cx,
18301832
) {
1831-
return element;
1833+
return div().mt_2().child(element).into_any_element();
18321834
}
18331835
// Renderer returned None (e.g. parameters still
18341836
// streaming) — show a skeleton card with just
18351837
// the header so we don't flash a raw "[name]"
18361838
// placeholder.
1837-
return self.render_card_skeleton(
1838-
&block,
1839-
renderer.as_ref(),
1840-
&theme,
1841-
);
1839+
return div()
1840+
.mt_2()
1841+
.child(self.render_card_skeleton(
1842+
&block,
1843+
renderer.as_ref(),
1844+
&theme,
1845+
))
1846+
.into_any_element();
18421847
}
18431848
}
18441849
} else {
18451850
tracing::warn!("No ToolBlockRenderer registered for tool '{}'", block.name);
18461851
}
18471852
}
1853+
18481854
div()
1855+
.mt_0p5()
18491856
.px_2()
18501857
.py_1()
18511858
.text_color(cx.theme().muted_foreground)
@@ -1926,6 +1933,7 @@ impl Render for BlockView {
19261933
}
19271934

19281935
div()
1936+
.mt_2()
19291937
.rounded_md()
19301938
.border_1()
19311939
.border_color(cx.theme().border)
@@ -1939,8 +1947,8 @@ impl Render for BlockView {
19391947
}
19401948
BlockData::ImageBlock(block) => {
19411949
if let Some(image) = &block.image {
1942-
// Render the actual image - margins/spacing handled by parent container
19431950
div()
1951+
.mt_2()
19441952
.flex_none() // Don't grow or shrink
19451953
.child(
19461954
div()
@@ -1960,6 +1968,7 @@ impl Render for BlockView {
19601968
} else {
19611969
// Fallback to placeholder if image parsing failed
19621970
div()
1971+
.mt_2()
19631972
.flex_none()
19641973
.p_2()
19651974
.bg(cx.theme().warning.opacity(0.1))

crates/code_assistant/src/ui/gpui/messages.rs

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -553,18 +553,25 @@ impl MessagesView {
553553
};
554554

555555
// Create message container with appropriate styling.
556-
// p_3 provides interior padding. max_w is applied via the centering
557-
// wrapper returned at the end of this function.
558-
let mut message_container = div().w_full().p_3().flex().flex_col().gap(rems(0.625));
559-
560-
if is_user_message {
561-
message_container = message_container
556+
// max_w is applied via the centering wrapper returned at the end.
557+
// For user messages: uniform padding + gap between children.
558+
// For assistant messages: only horizontal padding; each block controls
559+
// its own vertical margin so inline tools can be tighter than text.
560+
let message_container = if is_user_message {
561+
div()
562+
.w_full()
563+
.p_3()
564+
.flex()
565+
.flex_col()
566+
.gap(rems(0.625))
562567
.bg(cx.theme().muted)
563568
.border_1()
564569
.border_color(cx.theme().border)
565570
.rounded_md()
566-
.shadow_xs();
567-
}
571+
.shadow_xs()
572+
} else {
573+
div().w_full().px_3().pb_1().flex().flex_col()
574+
};
568575

569576
// Create message container with user badge and edit button if needed
570577
let message_container = if is_user_message {

crates/code_assistant/src/ui/gpui/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2422,6 +2422,9 @@ impl Gpui {
24222422
// Trigger a re-render so the sidebar picks up the change.
24232423
cx.refresh();
24242424
}
2425+
BackendResponse::ProjectAlreadyExists { project_name } => {
2426+
info!("Project '{}' already exists — nothing to do", project_name);
2427+
}
24252428
}
24262429
}
24272430
}

crates/code_assistant/src/ui/streaming/test_utils.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,9 @@ impl TestUI {
6060
value: new_value,
6161
tool_id: new_id,
6262
},
63-
) => {
64-
if last_name == new_name && last_id == new_id {
65-
last_value.push_str(new_value);
66-
true
67-
} else {
68-
false
69-
}
63+
) if last_name == new_name && last_id == new_id => {
64+
last_value.push_str(new_value);
65+
true
7066
}
7167

7268
// No other fragments can be merged

0 commit comments

Comments
 (0)