Skip to content

Commit 4e7ba8e

Browse files
acp_tools: Add vertical scrollbar to ACP logs (zed-industries#41740)
Release Notes: - N/A --------- Signed-off-by: Xiaobo Liu <cppcoffee@gmail.com> Co-authored-by: Danilo Leal <daniloleal09@gmail.com>
1 parent 9909b59 commit 4e7ba8e

File tree

1 file changed

+29
-22
lines changed

1 file changed

+29
-22
lines changed

crates/acp_tools/src/acp_tools.rs

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use markdown::{CodeBlockRenderer, Markdown, MarkdownElement, MarkdownStyle};
1919
use project::Project;
2020
use settings::Settings;
2121
use theme::ThemeSettings;
22-
use ui::{Tooltip, prelude::*};
22+
use ui::{Tooltip, WithScrollbar, prelude::*};
2323
use util::ResultExt as _;
2424
use workspace::{
2525
Item, ItemHandle, ToolbarItemEvent, ToolbarItemLocation, ToolbarItemView, Workspace,
@@ -291,17 +291,19 @@ impl AcpTools {
291291
let expanded = self.expanded.contains(&index);
292292

293293
v_flex()
294+
.id(index)
295+
.group("message")
296+
.cursor_pointer()
297+
.font_buffer(cx)
294298
.w_full()
295-
.px_4()
296299
.py_3()
297-
.border_color(colors.border)
298-
.border_b_1()
300+
.pl_4()
301+
.pr_5()
299302
.gap_2()
300303
.items_start()
301-
.font_buffer(cx)
302304
.text_size(base_size)
303-
.id(index)
304-
.group("message")
305+
.border_color(colors.border)
306+
.border_b_1()
305307
.hover(|this| this.bg(colors.element_background.opacity(0.5)))
306308
.on_click(cx.listener(move |this, _, _, cx| {
307309
if this.expanded.contains(&index) {
@@ -323,15 +325,14 @@ impl AcpTools {
323325
h_flex()
324326
.w_full()
325327
.gap_2()
326-
.items_center()
327328
.flex_shrink_0()
328329
.child(match message.direction {
329-
acp::StreamMessageDirection::Incoming => {
330-
ui::Icon::new(ui::IconName::ArrowDown).color(Color::Error)
331-
}
332-
acp::StreamMessageDirection::Outgoing => {
333-
ui::Icon::new(ui::IconName::ArrowUp).color(Color::Success)
334-
}
330+
acp::StreamMessageDirection::Incoming => Icon::new(IconName::ArrowDown)
331+
.color(Color::Error)
332+
.size(IconSize::Small),
333+
acp::StreamMessageDirection::Outgoing => Icon::new(IconName::ArrowUp)
334+
.color(Color::Success)
335+
.size(IconSize::Small),
335336
})
336337
.child(
337338
Label::new(message.name.clone())
@@ -501,7 +502,7 @@ impl Focusable for AcpTools {
501502
}
502503

503504
impl Render for AcpTools {
504-
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
505+
fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
505506
v_flex()
506507
.track_focus(&self.focus_handle)
507508
.size_full()
@@ -516,13 +517,19 @@ impl Render for AcpTools {
516517
.child("No messages recorded yet")
517518
.into_any()
518519
} else {
519-
list(
520-
connection.list_state.clone(),
521-
cx.processor(Self::render_message),
522-
)
523-
.with_sizing_behavior(gpui::ListSizingBehavior::Auto)
524-
.flex_grow()
525-
.into_any()
520+
div()
521+
.size_full()
522+
.flex_grow()
523+
.child(
524+
list(
525+
connection.list_state.clone(),
526+
cx.processor(Self::render_message),
527+
)
528+
.with_sizing_behavior(gpui::ListSizingBehavior::Auto)
529+
.size_full(),
530+
)
531+
.vertical_scrollbar_for(connection.list_state.clone(), window, cx)
532+
.into_any()
526533
}
527534
}
528535
None => h_flex()

0 commit comments

Comments
 (0)