Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 4 additions & 9 deletions src-tauri/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -804,9 +804,9 @@ pub async fn get_system_stats(
// Disk stats for root filesystem
let disk_cmd = os_info.disk_cmd();
let disk_output = client.execute_command(disk_cmd).await.unwrap_or_default();
let disk_parts: Vec<&str> = disk_output.trim().split_whitespace().collect();
let disk_parts: Vec<&str> = disk_output.split_whitespace().collect();
let disk = DiskStats {
total: disk_parts.get(0).unwrap_or(&"0").to_string(),
total: disk_parts.first().unwrap_or(&"0").to_string(),
used: disk_parts.get(1).unwrap_or(&"0").to_string(),
available: disk_parts.get(2).unwrap_or(&"0").to_string(),
use_percent: disk_parts
Expand Down Expand Up @@ -1594,13 +1594,6 @@ pub async fn list_connections(
Ok(state.list_connections().await)
}

#[derive(Debug, Serialize, Deserialize)]
pub struct TailLogRequest {
pub connection_id: String,
pub log_path: String,
pub lines: Option<u32>, // Number of lines to show (default 50)
}

#[tauri::command]
pub async fn tail_log(
connection_id: String,
Expand Down Expand Up @@ -3553,6 +3546,7 @@ pub async fn cancel_transfer(
}
}

#[allow(clippy::too_many_arguments)]
#[tauri::command]
pub async fn transfer_directory(
connection_id: String,
Expand Down Expand Up @@ -3613,6 +3607,7 @@ pub async fn download_remote_file(
.await
}

#[allow(clippy::too_many_arguments)]
#[tauri::command]
pub async fn download_remote_file_confined(
connection_id: String,
Expand Down
3 changes: 3 additions & 0 deletions src-tauri/src/config_sync/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -921,6 +921,9 @@ pub async fn config_sync_commit(
.await
}

// The sync record fields are already grouped at the call site; splitting this
// internal helper into a context struct would obscure the upload flow.
#[allow(clippy::too_many_arguments)]
async fn commit(
runtime: &mut Runtime,
provider: &dyn ObjectStore,
Expand Down
9 changes: 7 additions & 2 deletions src-tauri/src/connection_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ use std::sync::atomic::{AtomicU64, Ordering};
use std::sync::Arc;
use std::time::Duration;
use tauri::Emitter;
use tokio::sync::mpsc;
use tokio::sync::RwLock;
#[cfg(test)]
use tokio::sync::mpsc;
use tokio_util::sync::CancellationToken;

/// State of a single active SOCKS proxy rule. Every entry in the manager's
Expand Down Expand Up @@ -164,6 +165,10 @@ pub struct SessionHealth {
pub connection_type: Option<String>,
}

/// A desktop (RDP/VNC) connection: write-locked because the protocol state is
/// mutated for every frame and input event.
type DesktopConnection = Arc<RwLock<Box<dyn DesktopProtocol>>>;

pub struct ConnectionManager {
pub(crate) monitor_jobs: Arc<crate::ssh::monitor::MonitorJobs>,
connections: Arc<RwLock<HashMap<String, Arc<RwLock<SshClient>>>>>,
Expand All @@ -182,7 +187,7 @@ pub struct ConnectionManager {
/// long transfer from blocking every other connection's operations.
ftp_connections: Arc<RwLock<HashMap<String, Arc<tokio::sync::Mutex<FtpClient>>>>>,
/// Remote desktop (RDP/VNC) connections
desktop_connections: Arc<RwLock<HashMap<String, Arc<RwLock<Box<dyn DesktopProtocol>>>>>>,
desktop_connections: Arc<RwLock<HashMap<String, DesktopConnection>>>,
/// Keep cancelled attempts registered until they finish, so an old
/// attempt cannot clear a newer attempt's token or resurrect a closed tab.
pending_desktop_connections: RwLock<HashMap<String, CancellationToken>>,
Expand Down
1 change: 1 addition & 0 deletions src-tauri/src/folder_transfer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ async fn archive_transfer(
}
}

#[allow(clippy::too_many_arguments)]
pub(crate) async fn run(
manager: &Arc<ConnectionManager>,
connection_id: &str,
Expand Down
3 changes: 3 additions & 0 deletions src-tauri/src/ftp_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ pub struct FtpClient {
config: Option<FtpConfig>,
}

// `new`, `is_connected`, and the transfer helpers form the client's surface
// and are exercised by the unit tests; they have no non-test caller yet.
#[cfg_attr(not(test), allow(dead_code))]
impl FtpClient {
pub fn new() -> Self {
Self {
Expand Down
44 changes: 22 additions & 22 deletions src-tauri/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ fn build_app_menu<F: Fn(&str) -> String>(
&MenuItem::with_id(
app,
"quit_app",
&t("menuBar.quit"),
t("menuBar.quit"),
true,
Some("CmdOrCtrl+Q"),
)?,
Expand All @@ -138,28 +138,28 @@ fn build_app_menu<F: Fn(&str) -> String>(
let file_menu = Submenu::with_id_and_items(
app,
"m_file",
&t("menuBar.file"),
t("menuBar.file"),
true,
&[
&MenuItem::with_id(
app,
"new_connection",
&t("menuBar.newConnection"),
t("menuBar.newConnection"),
true,
None::<&str>,
)?,
&PredefinedMenuItem::separator(app)?,
&MenuItem::with_id(
app,
"save_connection",
&t("menuBar.saveFile"),
t("menuBar.saveFile"),
true,
None::<&str>,
)?,
&MenuItem::with_id(
app,
"close_connection",
&t("menuBar.closeTab"),
t("menuBar.closeTab"),
true,
None::<&str>,
)?,
Expand All @@ -176,7 +176,7 @@ fn build_app_menu<F: Fn(&str) -> String>(
let edit_menu = Submenu::with_id_and_items(
app,
"m_edit",
&t("menuBar.edit"),
t("menuBar.edit"),
true,
&[
&PredefinedMenuItem::undo(app, Some(&t("menuBar.undo")))?,
Expand All @@ -188,11 +188,11 @@ fn build_app_menu<F: Fn(&str) -> String>(
&PredefinedMenuItem::separator(app)?,
&PredefinedMenuItem::select_all(app, Some(&t("menuBar.selectAll")))?,
&PredefinedMenuItem::separator(app)?,
&MenuItem::with_id(app, "find", &t("menuBar.find"), true, None::<&str>)?,
&MenuItem::with_id(app, "find", t("menuBar.find"), true, None::<&str>)?,
&MenuItem::with_id(
app,
"clear_screen",
&t("menuBar.clearScreen"),
t("menuBar.clearScreen"),
true,
None::<&str>,
)?,
Expand All @@ -203,21 +203,21 @@ fn build_app_menu<F: Fn(&str) -> String>(
let tools_menu = Submenu::with_id_and_items(
app,
"m_tools",
&t("menuBar.tools"),
t("menuBar.tools"),
true,
&[
&MenuItem::with_id(
app,
"settings",
&t("menuBar.options"),
t("menuBar.options"),
true,
None::<&str>,
)?,
&PredefinedMenuItem::separator(app)?,
&MenuItem::with_id(
app,
"check_updates",
&t("menuBar.checkForUpdates"),
t("menuBar.checkForUpdates"),
true,
None::<&str>,
)?,
Expand All @@ -228,38 +228,38 @@ fn build_app_menu<F: Fn(&str) -> String>(
let connection_menu = Submenu::with_id_and_items(
app,
"m_connection",
&t("menuBar.connection"),
t("menuBar.connection"),
true,
&[
&MenuItem::with_id(
app,
"new_tab",
&t("menuBar.newTab"),
t("menuBar.newTab"),
true,
None::<&str>,
)?,
&MenuItem::with_id(
app,
"clone_tab",
&t("menuBar.duplicateTab"),
t("menuBar.duplicateTab"),
true,
None::<&str>,
)?,
&PredefinedMenuItem::separator(app)?,
&MenuItem::with_id(app, "next_tab", &t("menuBar.nextTab"), true, None::<&str>)?,
&MenuItem::with_id(app, "next_tab", t("menuBar.nextTab"), true, None::<&str>)?,
&MenuItem::with_id(
app,
"prev_tab",
&t("menuBar.previousTab"),
t("menuBar.previousTab"),
true,
None::<&str>,
)?,
&PredefinedMenuItem::separator(app)?,
&MenuItem::with_id(app, "reconnect", &t("menuBar.reconnect"), true, None::<&str>)?,
&MenuItem::with_id(app, "reconnect", t("menuBar.reconnect"), true, None::<&str>)?,
&MenuItem::with_id(
app,
"disconnect",
&t("menuBar.disconnect"),
t("menuBar.disconnect"),
true,
None::<&str>,
)?,
Expand All @@ -270,7 +270,7 @@ fn build_app_menu<F: Fn(&str) -> String>(
let window_menu = Submenu::with_id_and_items(
app,
"m_window",
&t("menuBar.window"),
t("menuBar.window"),
true,
&[
&PredefinedMenuItem::minimize(app, Some(&t("menuBar.minimize")))?,
Expand Down Expand Up @@ -378,7 +378,7 @@ pub fn run() {
// Register native macOS menu and forward item events to the frontend
#[cfg(target_os = "macos")]
{
match build_app_menu(&app.handle(), default_menu_text) {
match build_app_menu(app.handle(), default_menu_text) {
Ok(menu) => {
if let Err(e) = app.set_menu(menu) {
tracing::warn!("Failed to set native menu: {}", e);
Expand Down Expand Up @@ -476,7 +476,7 @@ pub fn run() {
// Keep the quit guard's dirty/pending registries free of stale
// window labels (also resolves a pending quit when the last
// dirty editor is discarded during quit confirmation).
if matches!(event, tauri::WindowEvent::Destroyed { .. }) {
if matches!(event, tauri::WindowEvent::Destroyed) {
#[cfg(target_os = "macos")]
{
let label = window.label().to_string();
Expand Down Expand Up @@ -705,7 +705,7 @@ pub fn run() {
let _ = main.set_focus();
} else if let Some(window_config) = app.config().app.windows.first() {
let builder = tauri::WebviewWindowBuilder::from_config(app, window_config);
if let Err(e) = builder.map_err(tauri::Error::from).and_then(|b| b.build()) {
if let Err(e) = builder.and_then(|b| b.build()) {
tracing::warn!("Failed to recreate main window: {e}");
}
}
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/src/os_detect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ fn classify_family(id: &str, id_like: &str, uname: &str) -> OsFamily {
}

// Fallback to uname
match uname.as_ref() {
match uname {
"darwin" => OsFamily::MacOS,
"freebsd" | "openbsd" | "netbsd" => OsFamily::Bsd,
"linux" => OsFamily::GenericLinux,
Expand Down
4 changes: 3 additions & 1 deletion src-tauri/src/os_keypath.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
use std::path::{Path, PathBuf};
use std::path::Path;
#[cfg(test)]
use std::path::PathBuf;

/// Identity files offered, in OpenSSH's order, when no key file is configured.
/// Security-key (`*_sk`) and DSA keys are left out: russh cannot use them.
Expand Down
4 changes: 0 additions & 4 deletions src-tauri/src/rdp/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@ mod pointer_wire {
pub const MIDDLE_BUTTON_OR_WHEEL: u16 = 0x4000;
pub const RIGHT_BUTTON: u16 = 0x2000;
pub const VERTICAL_WHEEL: u16 = 0x0200;
pub const HORIZONTAL_WHEEL: u16 = 0x0400;
/// Set by `MousePdu::encode` itself when the rotation value is negative;
/// never set it in the flags here.
pub const WHEEL_NEGATIVE: u16 = 0x0100;
}

/// One wheel rotation unit on the wire is a 120th of a notch
Expand Down
20 changes: 2 additions & 18 deletions src-tauri/src/rdp/native_render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ fn map_rect(

let x0 = (fx * sw / rw) as usize;
let y0 = (fy * sh / rh) as usize;
let x1 = (((fx + fw) * sw + rw - 1) / rw) as usize;
let y1 = (((fy + fh) * sh + rh - 1) / rh) as usize;
let x1 = ((fx + fw) * sw).div_ceil(rw) as usize;
let y1 = ((fy + fh) * sh).div_ceil(rh) as usize;

let x1 = x1.min(surface_w as usize);
let y1 = y1.min(surface_h as usize);
Expand Down Expand Up @@ -175,16 +175,6 @@ impl NativeRenderer {
})
}

/// Current surface (window pixel) dimensions.
pub fn size(&self) -> (u32, u32) {
(self.surface_w, self.surface_h)
}

/// Current remote desktop dimensions.
pub fn remote_size(&self) -> (u16, u16) {
(self.remote_w, self.remote_h)
}

/// Track a remote desktop size change (reactivation / Display Control
/// resize). Does not touch the surface — that follows the window.
pub fn set_remote_size(&mut self, remote_w: u16, remote_h: u16) {
Expand Down Expand Up @@ -260,12 +250,6 @@ impl NativeRenderer {
self.present();
}

/// Present the full framebuffer without compositing anything new
/// (e.g. right after a surface resize that preserved the composite).
pub fn present_full(&mut self) {
self.present();
}

/// Copy the composite framebuffer into the surface pixel buffer and
/// present. softbuffer's macOS backend recycles buffers (fresh black
/// buffer per frame), so the full copy is required every frame.
Expand Down
4 changes: 2 additions & 2 deletions src-tauri/src/rdp/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ pub(super) async fn rdp_session_loop(
// the slow-path sequence instead.

// ── Main session loop ───────────────────────────────────────────
let mut consecutive_errors = 0;
let mut consecutive_errors;
let mut loop_iter: u64 = 0;
let mut pending_resize = PendingResize::default();
loop {
Expand Down Expand Up @@ -864,7 +864,7 @@ struct InputRoute {
/// (via `encode_resize`).
fn map_input_to_outputs(
route: InputRoute,
enable_server_pointer: bool,
_enable_server_pointer: bool,
active_stage: &mut ActiveStage,
image: &mut DecodedImage,
cmd: InputCommand,
Expand Down
14 changes: 7 additions & 7 deletions src-tauri/src/rdp_keymap.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/// Maps JavaScript `keyCode` (virtual-key codes) to PC Set-1 scancodes used by RDP.
///
/// Coverage: letters, digits, F-keys, modifiers, arrows, navigation cluster,
/// Enter / Escape / Tab / Backspace / Space, and common punctuation.
/// Keys not in this table return `None` and are silently dropped.
///
/// Reference: <https://learn.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes>
//! Maps JavaScript `keyCode` (virtual-key codes) to PC Set-1 scancodes used by RDP.
//!
//! Coverage: letters, digits, F-keys, modifiers, arrows, navigation cluster,
//! Enter / Escape / Tab / Backspace / Space, and common punctuation.
//! Keys not in this table return `None` and are silently dropped.
//!
//! Reference: <https://learn.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes>

/// Convert a JS keyCode to a PC Set-1 scancode.
/// Returns `None` when the key is unmapped.
Expand Down
3 changes: 3 additions & 0 deletions src-tauri/src/sftp_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,9 @@ fn sftp_transport_config(config: &SftpConfig, window_size: u32) -> client::Confi
transport
}

// `new` and the transfer helpers are covered by the unit tests; the
// connection-manager path only calls `connect`, so keep the surface quiet.
#[cfg_attr(not(test), allow(dead_code))]
impl StandaloneSftpClient {
pub fn new() -> Self {
Self {
Expand Down
Loading
Loading