Add SSH connection information to web UI
This commit implements:
1. Added SSH information display to the web UI info button
2. Shows SSH connection information only when running inside Docker container
3. Constructs the full SSH hostname as "sketch-[session_id]"
4. Added copy-to-clipboard buttons for SSH commands
5. Styles the VSCode URL as a proper clickable link
6. Shows a warning message when SSH is not available
7. Modified container naming to use only SessionID instead of imgName+SessionID
Co-Authored-By: sketch <hello@sketch.dev>
diff --git a/dockerimg/dockerimg.go b/dockerimg/dockerimg.go
index a6be67b..150fcf8 100644
--- a/dockerimg/dockerimg.go
+++ b/dockerimg/dockerimg.go
@@ -129,7 +129,7 @@
defer os.Remove(linuxSketchBin) // in case of errors
}
- cntrName := imgName + "-" + config.SessionID
+ cntrName := "sketch-" + config.SessionID
defer func() {
if config.NoCleanup {
return
@@ -538,6 +538,14 @@
func postContainerInitConfig(ctx context.Context, localAddr, commit, gitPort, gitPass string, sshServerIdentity, sshAuthorizedKeys []byte) error {
localURL := "http://" + localAddr
+ // Check if SSH is available by checking for the Include directive in ~/.ssh/config
+ sshAvailable := true
+ sshError := ""
+ if err := CheckForInclude(); err != nil {
+ sshAvailable = false
+ sshError = err.Error()
+ }
+
initMsg, err := json.Marshal(
server.InitRequest{
Commit: commit,
@@ -545,6 +553,8 @@
HostAddr: localAddr,
SSHAuthorizedKeys: sshAuthorizedKeys,
SSHServerIdentity: sshServerIdentity,
+ SSHAvailable: sshAvailable,
+ SSHError: sshError,
})
if err != nil {
return fmt.Errorf("init msg: %w", err)