Skip to content

Commit b9ce52d

Browse files
agent_ui: Fix scrolling in context server configuration modal (#42502)
## Summary Fixes #42342 When installing a dev extension with long installation instructions, the configuration modal would overflow and users couldn't scroll to see the full content or interact with buttons at the bottom. ## Solution This PR adds a `ScrollHandle` to the `ConfigureContextServerModal` and passes it to the `Modal` component, enabling the built-in modal scrolling capability. This ensures all content remains accessible regardless of length. ## Changes - Added `ScrollHandle` import to the ui imports - Added `scroll_handle: ScrollHandle` field to `ConfigureContextServerModal` struct - Initialize `scroll_handle` with `ScrollHandle::new()` when creating the modal - Pass the scroll handle to `Modal::new()` instead of `None` ## Testing - Built the changes locally - Tested with extensions that have long installation instructions - Verified scrolling works and all content is accessible - Confirmed no regression for extensions with short descriptions Release Notes: - Fixed scrolling issue in extension configuration modal when installation instructions overflow the viewport --------- Co-authored-by: Finn Evers <[email protected]>
1 parent 34a7cfb commit b9ce52d

File tree

1 file changed

+30
-11
lines changed

1 file changed

+30
-11
lines changed

crates/agent_ui/src/agent_configuration/configure_context_server_modal.rs

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ use anyhow::{Context as _, Result};
77
use context_server::{ContextServerCommand, ContextServerId};
88
use editor::{Editor, EditorElement, EditorStyle};
99
use gpui::{
10-
AsyncWindowContext, DismissEvent, Entity, EventEmitter, FocusHandle, Focusable, Task,
11-
TextStyle, TextStyleRefinement, UnderlineStyle, WeakEntity, prelude::*,
10+
AsyncWindowContext, DismissEvent, Entity, EventEmitter, FocusHandle, Focusable, ScrollHandle,
11+
Task, TextStyle, TextStyleRefinement, UnderlineStyle, WeakEntity, prelude::*,
1212
};
1313
use language::{Language, LanguageRegistry};
1414
use markdown::{Markdown, MarkdownElement, MarkdownStyle};
@@ -23,7 +23,8 @@ use project::{
2323
use settings::{Settings as _, update_settings_file};
2424
use theme::ThemeSettings;
2525
use ui::{
26-
CommonAnimationExt, KeyBinding, Modal, ModalFooter, ModalHeader, Section, Tooltip, prelude::*,
26+
CommonAnimationExt, KeyBinding, Modal, ModalFooter, ModalHeader, Section, Tooltip,
27+
WithScrollbar, prelude::*,
2728
};
2829
use util::ResultExt as _;
2930
use workspace::{ModalView, Workspace};
@@ -252,6 +253,7 @@ pub struct ConfigureContextServerModal {
252253
source: ConfigurationSource,
253254
state: State,
254255
original_server_id: Option<ContextServerId>,
256+
scroll_handle: ScrollHandle,
255257
}
256258

257259
impl ConfigureContextServerModal {
@@ -361,6 +363,7 @@ impl ConfigureContextServerModal {
361363
window,
362364
cx,
363365
),
366+
scroll_handle: ScrollHandle::new(),
364367
})
365368
})
366369
})
@@ -680,6 +683,7 @@ impl ConfigureContextServerModal {
680683

681684
impl Render for ConfigureContextServerModal {
682685
fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
686+
let scroll_handle = self.scroll_handle.clone();
683687
div()
684688
.elevation_3(cx)
685689
.w(rems(34.))
@@ -699,14 +703,29 @@ impl Render for ConfigureContextServerModal {
699703
Modal::new("configure-context-server", None)
700704
.header(self.render_modal_header())
701705
.section(
702-
Section::new()
703-
.child(self.render_modal_description(window, cx))
704-
.child(self.render_modal_content(cx))
705-
.child(match &self.state {
706-
State::Idle => div(),
707-
State::Waiting => Self::render_waiting_for_context_server(),
708-
State::Error(error) => Self::render_modal_error(error.clone()),
709-
}),
706+
Section::new().child(
707+
div()
708+
.size_full()
709+
.child(
710+
div()
711+
.id("modal-content")
712+
.max_h(vh(0.7, window))
713+
.overflow_y_scroll()
714+
.track_scroll(&scroll_handle)
715+
.child(self.render_modal_description(window, cx))
716+
.child(self.render_modal_content(cx))
717+
.child(match &self.state {
718+
State::Idle => div(),
719+
State::Waiting => {
720+
Self::render_waiting_for_context_server()
721+
}
722+
State::Error(error) => {
723+
Self::render_modal_error(error.clone())
724+
}
725+
}),
726+
)
727+
.vertical_scrollbar_for(scroll_handle, window, cx),
728+
),
710729
)
711730
.footer(self.render_modal_footer(cx)),
712731
)

0 commit comments

Comments
 (0)