diff --git a/nebula_app/src/gpui_shell/ssh_settings/library.rs b/nebula_app/src/gpui_shell/ssh_settings/library.rs index 60033b2..2760251 100644 --- a/nebula_app/src/gpui_shell/ssh_settings/library.rs +++ b/nebula_app/src/gpui_shell/ssh_settings/library.rs @@ -129,14 +129,16 @@ impl SettingsPane { .label .filter(|label| !label.trim().is_empty()) .unwrap_or_else(|| host.clone()); - let label = self.ssh_hosts.profiles.next_default_label(label.trim()); + let copy_label = self.ssh_hosts.profiles.next_default_label(label.trim()); - self.open_ssh_editor(Some(host), window, cx); + self.open_ssh_editor(Some(host.clone()), window, cx); if let Some(editor) = self.ssh_editor.as_mut() { editor.original_destination = None; + // 复制不会重命名原主机,编辑路径排除的原地址仍应可用作新主机的跳板。 + editor.jump_choices.push((host, label)); } self.ssh_destination_input.update(cx, |input, cx| input.set_value("", window, cx)); - self.ssh_label_input.update(cx, |input, cx| input.set_value(label, window, cx)); + self.ssh_label_input.update(cx, |input, cx| input.set_value(copy_label, window, cx)); self.ssh_password_input.update(cx, |input, cx| { input.set_placeholder( crate::gpui_shell::config::ui_language(cx) diff --git a/nebula_app/src/gpui_shell/ssh_settings/library/tests.rs b/nebula_app/src/gpui_shell/ssh_settings/library/tests.rs index 8ec506b..3aeae33 100644 --- a/nebula_app/src/gpui_shell/ssh_settings/library/tests.rs +++ b/nebula_app/src/gpui_shell/ssh_settings/library/tests.rs @@ -66,10 +66,14 @@ fn pairing_design_ssh_cards_keep_icon_anchors_and_compact_filter(cx: &mut gpui:: cx.update(|window, cx| { pane.update(cx, |pane, cx| { pane.duplicate_ssh_host("nebula-test".into(), window, cx); + let editor = pane.ssh_editor.as_ref().expect("copied host draft"); + assert!(editor.original_destination.is_none()); assert!( - pane.ssh_editor - .as_ref() - .is_some_and(|editor| editor.original_destination.is_none()) + editor + .jump_choices + .iter() + .any(|(host, label)| host == "nebula-test" && label == "Alpha"), + "the copied-from host remains available as a jump host" ); assert_eq!(pane.ssh_destination_input.read(cx).value(), ""); assert_eq!(pane.ssh_label_input.read(cx).value(), "Alpha 1");