@@ -228,7 +228,7 @@ func (conn *SSHConn) OpenDomainSocketListener(ctx context.Context) error {
228228// expects the output of `wsh version` which looks like `wsh v0.10.4` or "not-installed"
229229// returns (up-to-date, semver, error)
230230// if not up to date, or error, version might be ""
231- func isWshVersionUpToDate (wshVersionLine string ) (bool , string , error ) {
231+ func IsWshVersionUpToDate (wshVersionLine string ) (bool , string , error ) {
232232 wshVersionLine = strings .TrimSpace (wshVersionLine )
233233 if wshVersionLine == "not-installed" {
234234 return false , "" , nil
@@ -290,7 +290,7 @@ func (conn *SSHConn) StartConnServer(ctx context.Context) (bool, string, error)
290290 return false , "" , fmt .Errorf ("error reading wsh version: %w" , err )
291291 }
292292 conn .Infof (ctx , "got connserver version: %s\n " , strings .TrimSpace (versionLine ))
293- isUpToDate , clientVersion , err := isWshVersionUpToDate (versionLine )
293+ isUpToDate , clientVersion , err := IsWshVersionUpToDate (versionLine )
294294 if err != nil {
295295 sshSession .Close ()
296296 return false , "" , fmt .Errorf ("error checking wsh version: %w" , err )
@@ -377,6 +377,22 @@ to ensure a seamless experience.
377377Would you like to install them?
378378` )
379379
380+ func (conn * SSHConn ) UpdateWsh (ctx context.Context , clientDisplayName string , remoteInfo * wshrpc.RemoteInfo ) error {
381+ conn .Infof (ctx , "attempting to update wsh for connection %s (os:%s arch:%s version:%s)\n " ,
382+ remoteInfo .ConnName , remoteInfo .ClientOs , remoteInfo .ClientArch , remoteInfo .ClientVersion )
383+ client := conn .GetClient ()
384+ if client == nil {
385+ return fmt .Errorf ("cannot update wsh: ssh client is not connected" )
386+ }
387+ err := remote .CpWshToRemote (ctx , client , remoteInfo .ClientOs , remoteInfo .ClientArch )
388+ if err != nil {
389+ return fmt .Errorf ("error installing wsh to remote: %w" , err )
390+ }
391+ conn .Infof (ctx , "successfully updated wsh on %s\n " , conn .GetName ())
392+ return nil
393+
394+ }
395+
380396// returns (allowed, error)
381397func (conn * SSHConn ) getPermissionToInstallWsh (ctx context.Context , clientDisplayName string ) (bool , error ) {
382398 conn .Infof (ctx , "running getPermissionToInstallWsh...\n " )
0 commit comments