From d6a5d93eaf072b30d651f503fb6ea443bb83bbaa Mon Sep 17 00:00:00 2001 From: TomZz Date: Sun, 8 Nov 2026 12:51:01 +0800 Subject: [PATCH] =?UTF-8?q?fix(session):=20=E7=A7=BB=E9=99=A4=E8=BF=9E?= =?UTF-8?q?=E6=8E=A5=E6=96=AD=E5=BC=80=E8=AF=A2=E9=97=AE=E5=BC=B9=E7=AA=97?= =?UTF-8?q?=EF=BC=8C=E4=BF=9D=E7=95=99=E5=B9=B6=E4=BC=98=E5=8C=96=E7=BA=A2?= =?UTF-8?q?=E8=89=B2=E6=82=AC=E6=B5=AE=E8=A1=8C=E4=B8=8E=E5=9B=9E=E8=BD=A6?= =?UTF-8?q?=E9=87=8D=E8=BF=9E=E4=BA=A4=E4=BA=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/dialogs.rs | 128 --------------------------------------------- src/app/mod.rs | 1 - src/app/ui.rs | 8 +-- src/session/mod.rs | 27 +--------- 4 files changed, 3 insertions(+), 161 deletions(-) diff --git a/src/app/dialogs.rs b/src/app/dialogs.rs index 490332b..be43a00 100644 --- a/src/app/dialogs.rs +++ b/src/app/dialogs.rs @@ -1556,134 +1556,6 @@ impl Ashell { }); } - pub(crate) fn prompt_active_ssh_reconnect_if_needed( - &mut self, - window: &mut Window, - cx: &mut Context, - ) { - let Some(tab_id) = self.active_tab.as_ref().and_then(|active_tab_id| { - self.tabs - .iter() - .find(|tab| { - tab.id == *active_tab_id - && tab.kind == crate::terminal::TabKind::Ssh - && !tab.connected - && tab.disconnected_reason.is_some() - && tab.session.is_some() - }) - .map(|tab| tab.id.clone()) - }) else { - return; - }; - - self.show_ssh_reconnect_dialog(tab_id, window, cx); - } - - pub(crate) fn show_ssh_reconnect_dialog( - &mut self, - tab_id: String, - window: &mut Window, - cx: &mut Context, - ) { - if self.active_dialog.is_some() - || self.active_tab.as_deref() != Some(tab_id.as_str()) - || !self.tabs.iter().any(|tab| { - tab.id == tab_id - && tab.kind == crate::terminal::TabKind::Ssh - && !tab.connected - && tab.disconnected_reason.is_some() - && tab.session.is_some() - }) - { - return; - } - - let session_name = self - .tabs - .iter() - .find(|tab| tab.id == tab_id) - .map(|tab| tab.title.clone()) - .unwrap_or_else(|| tab_id.clone()); - let view = cx.entity(); - self.active_dialog = Some(crate::app::DialogKind::SshReconnect); - - window.open_dialog(cx, move |dialog: Dialog, _window, _| { - dialog - .title(t!("reconnect_ssh_title").to_string()) - .w(px(400.)) - .keyboard(false) - .on_close({ - let view = view.clone(); - move |_, _, cx| { - view.update(cx, |this, cx| { - if this.active_dialog == Some(crate::app::DialogKind::SshReconnect) { - this.active_dialog = None; - } - cx.notify(); - }); - } - }) - .content({ - let session_name = session_name.clone(); - move |content, _window, _cx| { - content.child( - div() - .w_full() - .whitespace_normal() - .text_size(ui_rems(0.917)) - .child( - t!("reconnect_ssh_desc", name = session_name.as_str()) - .to_string(), - ), - ) - } - }) - .footer({ - let view = view.clone(); - let tab_id = tab_id.clone(); - h_flex() - .w_full() - .justify_end() - .gap_2() - .child( - pointer_button("ssh-reconnect-cancel") - .ghost() - .label(t!("cancel").to_string()) - .on_click({ - let view = view.clone(); - move |_, window, cx| { - view.update(cx, |this, cx| { - if this.active_dialog - == Some(crate::app::DialogKind::SshReconnect) - { - this.active_dialog = None; - } - cx.notify(); - }); - window.close_dialog(cx); - } - }), - ) - .child( - pointer_button("ssh-reconnect-confirm") - .primary() - .label(t!("reconnect_ssh").to_string()) - .on_click(move |_, window, cx| { - view.update(cx, |this, cx| { - if this.active_dialog - == Some(crate::app::DialogKind::SshReconnect) - { - this.active_dialog = None; - } - this.retry_disconnected_tab(&tab_id, cx); - }); - window.close_dialog(cx); - }), - ) - }) - }); - } - pub(crate) fn show_connection_group_dialog( &mut self, group: Option, diff --git a/src/app/mod.rs b/src/app/mod.rs index 4dd4ffb..ce9fa8f 100644 --- a/src/app/mod.rs +++ b/src/app/mod.rs @@ -255,7 +255,6 @@ pub(crate) enum DialogKind { SftpEditor, Processes, Ports, - SshReconnect, } #[derive(Debug, Clone, Copy, Default, PartialEq, Eq)] diff --git a/src/app/ui.rs b/src/app/ui.rs index acf37bb..af61b2c 100644 --- a/src/app/ui.rs +++ b/src/app/ui.rs @@ -5221,13 +5221,8 @@ impl Ashell { .when(is_url_hovered, |d| d.cursor_pointer()) .on_mouse_down( MouseButton::Left, - cx.listener(move |this, _, window, cx| { - let active_tab_changed = - this.active_tab.as_deref() != Some(tab_id_clone2.as_str()); + cx.listener(move |this, _, _, cx| { this.focus_pane_with_id(tab_id_clone2.clone()); - if active_tab_changed { - this.prompt_active_ssh_reconnect_if_needed(window, cx); - } cx.notify(); }), ) @@ -5291,6 +5286,7 @@ impl Ashell { .on_mouse_down( MouseButton::Left, cx.listener(move |this, _, _, cx| { + this.focus_pane_with_id(tab_id_for_reconnect.clone()); this.retry_disconnected_tab(&tab_id_for_reconnect, cx); }), ), diff --git a/src/session/mod.rs b/src/session/mod.rs index 034e4da..7361487 100644 --- a/src/session/mod.rs +++ b/src/session/mod.rs @@ -302,7 +302,7 @@ impl Ashell { } } - pub(crate) fn restore_saved_tabs(&mut self, window: &mut Window, cx: &mut Context) { + pub(crate) fn restore_saved_tabs(&mut self, _window: &mut Window, cx: &mut Context) { if !self.config.remember_tabs() { return; } @@ -481,23 +481,6 @@ impl Ashell { self.sync_sftp_to_active_tab(); self.sync_system_tab_to_active_group(); self.status = "tabs restored".into(); - - // Defer the dialog until the restored view has been mounted. This also - // ensures that only the currently focused restored SSH tab is prompted. - let prompt_tab_id = self.active_tab.as_ref().and_then(|tab_id| { - self.tabs - .iter() - .find(|tab| tab.id == *tab_id && tab.kind == TabKind::Ssh && !tab.connected) - .map(|tab| tab.id.clone()) - }); - if let Some(prompt_tab_id) = prompt_tab_id { - let view = cx.entity(); - window.defer(cx, move |window, cx| { - view.update(cx, |this, cx| { - this.show_ssh_reconnect_dialog(prompt_tab_id, window, cx); - }); - }); - } cx.notify(); } @@ -1794,7 +1777,6 @@ impl Ashell { pub(crate) fn activate_tab(&mut self, id: String, window: &mut Window, cx: &mut Context) { let previous_active_tab = self.active_tab.clone(); - let active_tab_changed = previous_active_tab.as_deref() != Some(id.as_str()); // Save current group state if let Some(group_id) = self.active_group.clone() { if let Some(group) = self.tab_groups.iter_mut().find(|g| g.id == group_id) { @@ -1839,9 +1821,6 @@ impl Ashell { self.sync_system_tab_to_active_group(); self.update_terminal_focus(previous_active_tab.as_deref()); self.save_tabs_state_background(); - if active_tab_changed { - self.prompt_active_ssh_reconnect_if_needed(window, cx); - } cx.notify(); } @@ -2349,7 +2328,6 @@ impl Ashell { } if active_tab_changed { self.update_terminal_focus(previous_active_tab.as_deref()); - self.prompt_active_ssh_reconnect_if_needed(window, cx); } } @@ -2492,9 +2470,6 @@ impl Ashell { self.sync_system_tab_to_active_group(); self.update_terminal_focus(previous_active_tab.as_deref()); self.save_tabs_state_background(); - if previous_active_tab != self.active_tab { - self.prompt_active_ssh_reconnect_if_needed(window, cx); - } cx.notify(); }