Since we are starting the coder agent in the tmpdir, SFTP sessions also start in that folder.
Arguably, the session should start in $HOME because this is my experience with OpenSSH and it's more useful when doing sftp followed by ls (list files) or doing something with home-relative paths.
sftp coder.work.main
Connected to coder.work.main.
sftp> pwd
Remote working directory: /tmp/coder.KnYnxH
There are (potentially) two ways to fix this:
- Run
os.Chdir in an early part of coder agent startup to change the default working directory by anything started by the agent
- Switch out
sftp.Server for sftp.RequestServer (e.g. sftp.NewRequestServer(session, sftp.InMemHandler(), sftp.WithStartDirectory(os.Getenv("HOME"))))
Re: 2, I don't know if sftp.RequestServer can work as a drop-in replacement, the documentation is quite vague.
Definition of done
- The user lands in
$HOME when using sftp
Since we are starting the coder agent in the tmpdir, SFTP sessions also start in that folder.
Arguably, the session should start in
$HOMEbecause this is my experience with OpenSSH and it's more useful when doingsftpfollowed byls(list files) or doing something with home-relative paths.There are (potentially) two ways to fix this:
os.Chdirin an early part ofcoder agentstartup to change the default working directory by anything started by the agentsftp.Serverforsftp.RequestServer(e.g.sftp.NewRequestServer(session, sftp.InMemHandler(), sftp.WithStartDirectory(os.Getenv("HOME"))))Re: 2, I don't know if
sftp.RequestServercan work as a drop-in replacement, the documentation is quite vague.Definition of done
$HOMEwhen usingsftp