@@ -12,8 +12,9 @@ pub fn build_mount_rows(
1212) -> Result<Vec<tui::MountListRow>, Box<dyn Error + Send + Sync>> {
1313 let mut rows = Vec::new();
1414 rows.extend(default_mounts(cwd)?);
15+ let guest_home = resolve_guest_home(cwd)?;
1516 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)?);
1718 }
1819 Ok(rows)
1920}
@@ -75,6 +76,7 @@ fn parse_mount_spec(
7576 cwd: &Path,
7677 spec: &str,
7778 default_mount: bool,
79+ guest_home: &str,
7880) -> Result<tui::MountListRow, Box<dyn Error + Send + Sync>> {
7981 let parts: Vec<&str> = spec.split(':').collect();
8082 if parts.len() < 2 || parts.len() > 3 {
@@ -99,11 +101,7 @@ fn parse_mount_spec(
99101 };
100102
101103 let host_display = display_host_spec(cwd, host_part);
102− let guest_display = if Path::new(guest_part).is_absolute() {
103− guest_part.to_string()
104− } else {
105− format!("/root/{guest_part}")
106− };
104+ let guest_display = resolve_guest_display(guest_part, guest_home);
107105 Ok(tui::MountListRow {
108106 host: host_display,
109107 guest: guest_display,
@@ -128,6 +126,36 @@ fn display_host_spec(cwd: &Path, host: &str) -> String {
128126 }
129127}
130128
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}"));
133+ }
134+ Ok(format!("/home/{}", instance::DEFAULT_SSH_USER))
135+}
136+
137+fn resolve_guest_display(guest: &str, guest_home: &str) -> String {
138+ if guest == "~" {
139+ return "~".to_string();
140+ }
141+ if let Some(stripped) = guest.strip_prefix("~/") {
142+ return format!("~/{stripped}");
143+ }
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() {
147+ "~".to_string()
148+ } else {
149+ format!("~/{}", stripped.display())
150+ }
151+ } else {
152+ guest.to_string()
153+ }
154+ } else {
155+ format!("/root/{guest}")
156+ }
157+}
158+
131159fn display_path(path: &Path) -> String {
132160 let Ok(home) = env::var("HOME") else {
133161 return path.display().to_string();