@@ -12,8 +12,9 @@ pub fn build_mount_rows(
12) -> Result<Vec<tui::MountListRow>, Box<dyn Error + Send + Sync>> {
12) -> Result<Vec<tui::MountListRow>, Box<dyn Error + Send + Sync>> {
13 let mut rows = Vec::new();
13 let mut rows = Vec::new();
14 rows.extend(default_mounts(cwd)?);
14 rows.extend(default_mounts(cwd)?);
15+ let guest_home = resolve_guest_home(cwd)?;
15 for spec in &config.box_cfg.mounts {
16 for spec in &config.box_cfg.mounts {
16− rows.push(parse_mount_spec(cwd, spec, false)?);
17+ rows.push(parse_mount_spec(cwd, spec, false, &guest_home)?);
@@ -75,6 +76,7 @@ fn parse_mount_spec(
75 cwd: &Path,
76 cwd: &Path,
76 spec: &str,
77 spec: &str,
77 default_mount: bool,
78 default_mount: bool,
78) -> Result<tui::MountListRow, Box<dyn Error + Send + Sync>> {
80) -> Result<tui::MountListRow, Box<dyn Error + Send + Sync>> {
79 let parts: Vec<&str> = spec.split(':').collect();
81 let parts: Vec<&str> = spec.split(':').collect();
80 if parts.len() < 2 || parts.len() > 3 {
82 if parts.len() < 2 || parts.len() > 3 {
@@ -99,11 +101,7 @@ fn parse_mount_spec(
101 let host_display = display_host_spec(cwd, host_part);
103 let host_display = display_host_spec(cwd, host_part);
102− let guest_display = if Path::new(guest_part).is_absolute() {
104+ let guest_display = resolve_guest_display(guest_part, guest_home);
103− guest_part.to_string()
105− format!("/root/{guest_part}")
107 Ok(tui::MountListRow {
105 Ok(tui::MountListRow {
108 host: host_display,
106 host: host_display,
109 guest: guest_display,
107 guest: guest_display,
@@ -128,6 +126,36 @@ fn display_host_spec(cwd: &Path, host: &str) -> String {
129+fn resolve_guest_home(cwd: &Path) -> Result<String, Box<dyn Error + Send + Sync>> {
130+ let instance_dir = cwd.join(session_manager::INSTANCE_DIR_NAME);
131+ if let Ok(Some(user)) = instance::read_instance_ssh_user(&instance_dir) {
132+ return Ok(format!("/home/{user}"));
134+ Ok(format!("/home/{}", instance::DEFAULT_SSH_USER))
137+fn resolve_guest_display(guest: &str, guest_home: &str) -> String {
139+ return "~".to_string();
141+ if let Some(stripped) = guest.strip_prefix("~/") {
142+ return format!("~/{stripped}");
144+ if Path::new(guest).is_absolute() {
145+ if let Ok(stripped) = Path::new(guest).strip_prefix(guest_home) {
146+ if stripped.components().next().is_none() {
149+ format!("~/{}", stripped.display())
155+ format!("/root/{guest}")
131fn display_path(path: &Path) -> String {
159fn display_path(path: &Path) -> String {
132 let Ok(home) = env::var("HOME") else {
160 let Ok(home) = env::var("HOME") else {
133 return path.display().to_string();
161 return path.display().to_string();