ssh: Do not look up dev servers when rendering the default mode (#19295)

This should help with the bug where there's a mismatch between
connection count and the list showing empty state.

Closes #ISSUE

Release Notes:

- N/A
This commit is contained in:
Piotr Osiewicz 2024-10-16 18:53:05 +02:00 committed by GitHub
parent f8f3f369f6
commit 7a5003bea2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -16,7 +16,6 @@ use gpui::canvas;
use gpui::pulsating_between; use gpui::pulsating_between;
use gpui::AsyncWindowContext; use gpui::AsyncWindowContext;
use gpui::ClipboardItem; use gpui::ClipboardItem;
use gpui::Subscription;
use gpui::Task; use gpui::Task;
use gpui::WeakView; use gpui::WeakView;
use gpui::{ use gpui::{
@ -60,9 +59,7 @@ pub struct DevServerProjects {
mode: Mode, mode: Mode,
focus_handle: FocusHandle, focus_handle: FocusHandle,
scroll_handle: ScrollHandle, scroll_handle: ScrollHandle,
dev_server_store: Model<dev_server_projects::Store>,
workspace: WeakView<Workspace>, workspace: WeakView<Workspace>,
_dev_server_subscription: Subscription,
selectable_items: SelectableItemList, selectable_items: SelectableItemList,
} }
@ -333,11 +330,6 @@ impl DevServerProjects {
pub fn new(cx: &mut ViewContext<Self>, workspace: WeakView<Workspace>) -> Self { pub fn new(cx: &mut ViewContext<Self>, workspace: WeakView<Workspace>) -> Self {
let focus_handle = cx.focus_handle(); let focus_handle = cx.focus_handle();
let dev_server_store = dev_server_projects::Store::global(cx);
let subscription = cx.observe(&dev_server_store, |_, _, cx| {
cx.notify();
});
let mut base_style = cx.text_style(); let mut base_style = cx.text_style();
base_style.refine(&gpui::TextStyleRefinement { base_style.refine(&gpui::TextStyleRefinement {
@ -349,9 +341,7 @@ impl DevServerProjects {
mode: Mode::default_mode(), mode: Mode::default_mode(),
focus_handle, focus_handle,
scroll_handle: ScrollHandle::new(), scroll_handle: ScrollHandle::new(),
dev_server_store,
workspace, workspace,
_dev_server_subscription: subscription,
selectable_items: Default::default(), selectable_items: Default::default(),
} }
} }
@ -1113,7 +1103,6 @@ impl DevServerProjects {
cx: &mut ViewContext<Self>, cx: &mut ViewContext<Self>,
) -> impl IntoElement { ) -> impl IntoElement {
let scroll_state = scroll_state.parent_view(cx.view()); let scroll_state = scroll_state.parent_view(cx.view());
let dev_servers = self.dev_server_store.read(cx).dev_servers();
let ssh_connections = SshSettings::get_global(cx) let ssh_connections = SshSettings::get_global(cx)
.ssh_connections() .ssh_connections()
.collect::<Vec<_>>(); .collect::<Vec<_>>();
@ -1171,7 +1160,7 @@ impl DevServerProjects {
) )
.into_any_element(); .into_any_element();
let server_count = format!("Servers: {}", ssh_connections.len() + dev_servers.len()); let server_count = format!("Servers: {}", ssh_connections.len());
Modal::new("remote-projects", Some(self.scroll_handle.clone())) Modal::new("remote-projects", Some(self.scroll_handle.clone()))
.header( .header(