From 1c203cc89ec36d80e3fe3f5b1e3c38b7640e2bc9 Mon Sep 17 00:00:00 2001 From: l0ng-ai <24760907+l0ng-ai@users.noreply.github.com> Date: Sun, 16 Aug 2026 02:34:17 +0800 Subject: [PATCH] fix(sftp): fold a remote filename where the panel draws it MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The file tree stopped drawing raw filenames in 25d1f06, on the reasoning that it was the one place a name arrives from a filesystem nobody here chose. That was wrong by one: the SFTP panel draws names from a listing on *another machine*, which is the same hazard with more claim to it — gpui breaks a row on a newline whatever the row says, and the bytes are picked somewhere this window has no say over. Both sites the panel draws a name at: the entry row, and the transfer row's `remote_basename`. Display-only, as before. `entry.name` is what `remote_join` builds every download, delete and rename path from, at five call sites, and a `↵` spliced into one of those names nothing on the server. Checked after the fact that every `one_line` in the file sits in a label. Found by re-reading the scoping note from that commit while auditing something else. It said only the file tree took names from an arbitrary filesystem, and listed where not to bother. A remote listing is more arbitrary than a local one, not less. --- src/ui/sftp.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/ui/sftp.rs b/src/ui/sftp.rs index ba369bf5..a08b5684 100644 --- a/src/ui/sftp.rs +++ b/src/ui/sftp.rs @@ -20,6 +20,7 @@ use crate::daemon::protocol::{ }; use crate::daemon::ssh::sftp::{remote_basename, remote_join, remote_parent, safe_local_name}; use crate::terminal::RemoteTerminal; +use crate::terminal::view::one_line; use crate::ui::app::{CONTENT_INSET, TILE_GLYPH_SM, TILE_SIZE_SM, Tty7App}; use crate::ui::i18n::{L10nKey, t, t_fmt}; use crate::ui::right_panel::{META, TEXT}; @@ -1484,10 +1485,15 @@ impl Tty7App { } else { human_size(entry.size) }; + // Folded exactly as the file tree folds its rows, and for a name with + // more claim to it: this one came off another machine's listing, so it + // is bytes chosen somewhere this window has no say over. `entry.name` + // itself is untouched — it is what `remote_join` builds the download's + // path from, and a `↵` spliced into that names nothing on the server. let name_label = if is_symlink { - format!("{} →", entry.name) + format!("{} →", one_line(&entry.name)) } else { - entry.name.clone() + one_line(&entry.name) }; let row_id = SharedString::from(format!("sftp-row-{}", entry.name)); @@ -1841,7 +1847,7 @@ impl Tty7App { .text_xs() .text_color(foreground) .truncate() - .child(format!("{arrow} {name}")), + .child(format!("{arrow} {}", one_line(&name))), ) .when(done_download, |this| { this.child(