diff --git a/crates/pilotty-cli/src/args.rs b/crates/pilotty-cli/src/args.rs index 916db5d..26ff834 100644 --- a/crates/pilotty-cli/src/args.rs +++ b/crates/pilotty-cli/src/args.rs @@ -132,8 +132,7 @@ pub struct SpawnArgs { #[arg(short, long)] pub name: Option, - /// Working directory for the spawned process. - /// If omitted, inherits the daemon's current directory. + /// Working directory for the spawned process [default: current directory] #[arg(long, value_name = "DIR")] pub cwd: Option, } diff --git a/crates/pilotty-cli/src/main.rs b/crates/pilotty-cli/src/main.rs index bd3d365..1814e4a 100644 --- a/crates/pilotty-cli/src/main.rs +++ b/crates/pilotty-cli/src/main.rs @@ -44,7 +44,12 @@ fn cli_to_command(cli: &Cli) -> Option { Commands::Spawn(args) => Some(Command::Spawn { command: args.command.clone(), session_name: args.name.clone(), - cwd: args.cwd.clone(), + // Default to client's cwd if --cwd not explicitly provided + cwd: args.cwd.clone().or_else(|| { + std::env::current_dir() + .ok() + .map(|p| p.to_string_lossy().into_owned()) + }), }), Commands::Kill(args) => Some(Command::Kill { session: args.session.clone(), diff --git a/crates/pilotty-core/src/protocol.rs b/crates/pilotty-core/src/protocol.rs index 5f8c02a..0342b28 100644 --- a/crates/pilotty-core/src/protocol.rs +++ b/crates/pilotty-core/src/protocol.rs @@ -27,9 +27,9 @@ pub enum Command { session_name: Option, /// Working directory for the spawned process. /// - /// If provided, the command runs in this directory. The path must be - /// an existing directory. If not provided, the process inherits the - /// daemon's working directory. + /// The CLI defaults this to the client's current directory. The path + /// must be an existing directory. If not provided by the client, the + /// process inherits the daemon's working directory. cwd: Option, }, /// Kill a session.