Файли
openidea/src-tauri/src/commands/ssh.rs
T
l0ng-ai 8e8a3f397b feat(deployment): start an SSH session in a Remote Host folder (#8284)
Remote Host's context menu on an SFTP server gains Start SSH Session in Directory: a terminal tab on the server's SSH configuration whose login shell starts in the chosen folder (a file's parent, or the root on empty space). ssh_open_terminal takes an optional remote folder and runs cd -- <folder>; exec "$SHELL" -l, so a missing folder reports the error and leaves the shell in home.
2026-12-06 03:37:57 +08:00

73 рядки
2.3 KiB
Rust
Неформатований Анотація Історія

Цей файл містить неоднозначні символи Юнікоду
Цей файл містить символи Юнікоду, які можна сплутати з іншими символами. Якщо ви вважаєте, що це зроблено навмисно, можете сміливо ігнорувати це попередження. Щоб показати їх, скористайтеся кнопкою Escape.
use crate::state::AppState;
use ide_command::desktop_command;
use ide_core::{IdeEvent, IdeResult};
use tauri::State;
/// Settings › SSH Configurations: the configurations in effect.
pub(crate) fn apply_ssh_settings(state: &AppState) {
state.ssh.set_configs(state.global_settings.effective().ssh.configs);
}
/// Answers an `IdeEvent::Askpass` prompt (`None`: cancelled); every window drops it.
#[desktop_command(trust = always)]
#[tauri::command]
#[specta::specta]
pub fn ssh_askpass_answer(state: State<'_, AppState>, id: u64, answer: Option<String>, remember: bool) {
// svn's prompts (`ide_host::svn`) share the askpass dialog.
if !ide_host::svn::answer_prompt(id, answer.clone())
&& let Some(server) = &state.askpass
{
server.answer(id, answer, remember);
}
state.sink.emit(IdeEvent::AskpassDone { id });
}
/// Settings › Git › Saved credentials: `scheme://host` of every saved entry.
#[desktop_command(trust = always)]
#[tauri::command]
#[specta::specta]
pub fn git_credentials(_state: State<'_, AppState>) -> Vec<String> {
ide_ssh::git_creds::get().map(|s| s.list()).unwrap_or_default()
}
/// Forgets the credential of `key` (a `git_credentials` entry).
#[desktop_command(trust = always)]
#[tauri::command]
#[specta::specta]
pub fn git_credential_forget(_state: State<'_, AppState>, key: String) {
if let Some(store) = ide_ssh::git_creds::get() {
store.forget(&key);
}
}
/// Tools › Start SSH Session: a shell on configuration `id` in a terminal tab, through the
/// built-in client with the configuration's saved credentials.
#[desktop_command(trust = always)]
#[tauri::command]
#[specta::specta]
pub async fn ssh_open_terminal(
window: tauri::Window,
state: State<'_, AppState>,
id: String,
cwd: Option<String>,
cols: u16,
rows: u16,
on_output: tauri::ipc::Channel<String>,
) -> IdeResult<ide_terminal::TerminalInfo> {
let host = state.host.clone();
ide_host::ops::term::spawn_ssh(
&host,
window.label(),
&id,
cwd.as_deref(),
cols,
rows,
std::sync::Arc::new(move |chunk| {
let _ = on_output.send(chunk);
}),
)
.await
}
ide_command::desktop_domain!(git_credential_forget, git_credentials, ssh_askpass_answer, ssh_open_terminal,);