Skip to content

Commit 6d72398

Browse files
authored
fix: validate project path exists before creating session (#327)
1 parent c941064 commit 6d72398

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

src/session/builder.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,17 @@ pub fn build_instance(params: InstanceParams, existing_titles: &[&str]) -> Resul
148148
}
149149
}
150150

151+
// Validate that the final path exists and is a directory.
152+
// This catches cases where the user typed a non-existent path in the TUI;
153+
// without this check tmux silently falls back to the home directory.
154+
let final_path_buf = PathBuf::from(&final_path);
155+
if !final_path_buf.exists() {
156+
bail!("Project path does not exist: {}", final_path);
157+
}
158+
if !final_path_buf.is_dir() {
159+
bail!("Project path is not a directory: {}", final_path);
160+
}
161+
151162
let final_title = if params.title.is_empty() {
152163
civilizations::generate_random_title(existing_titles)
153164
} else {

0 commit comments

Comments
 (0)