Răsfoiți Sursa

fix: improve SSH interface and correct GitHub URL

- Fix GitHub repository URL to Deep-ai-inc organization
- Add character echo to SSH so users can see what they type
- Add backspace support for SSH input correction
- Add Ctrl+C and Ctrl+D for clean SSH exit
- Remove unused io import

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
ajasibley 6 luni în urmă
părinte
comite
6e44dd93a6
2 a modificat fișierele cu 24 adăugiri și 9 ștergeri
  1. 1 1
      http.go
  2. 23 8
      ssh.go

+ 1 - 1
http.go

@@ -31,7 +31,7 @@ const minimalHTML = `<!DOCTYPE html>
         <textarea name="h" style="display:none">%s</textarea>
         <input type="submit" value="Send">
     </form>
-    <p><a href="/">Clear History</a> • <a href="https://github.com/ch-at/ch.at#readme">About</a></p>
+    <p><a href="/">Clear History</a> • <a href="https://github.com/Deep-ai-inc/ch.at#readme">About</a></p>
 </body>
 </html>`
 

+ 23 - 8
ssh.go

@@ -7,7 +7,6 @@ import (
 	"crypto/x509"
 	"encoding/pem"
 	"fmt"
-	"io"
 	"net"
 	"os"
 	"strings"
@@ -120,7 +119,8 @@ func (s *SSHServer) handleSession(channel ssh.Channel, requests <-chan *ssh.Requ
 	}()
 
 	fmt.Fprintf(channel, "Welcome to ch.at\r\n")
-	fmt.Fprintf(channel, "Type your message and press Enter. Type 'exit' to quit.\r\n")
+	fmt.Fprintf(channel, "Type your message and press Enter.\r\n")
+	fmt.Fprintf(channel, "Exit: type 'exit', Ctrl+C, or Ctrl+D\r\n")
 	fmt.Fprintf(channel, "> ")
 
 	// Read line by line
@@ -130,24 +130,25 @@ func (s *SSHServer) handleSession(channel ssh.Channel, requests <-chan *ssh.Requ
 	for {
 		n, err := channel.Read(buf)
 		if err != nil {
-			if err != io.EOF {
-				// Read error - exit session
-			}
+			// EOF (Ctrl+D) or other error - exit cleanly
 			return
 		}
 
 		data := string(buf[:n])
 		for _, ch := range data {
-			if ch == '\n' || ch == '\r' {
+			if ch == 3 { // Ctrl+C
+				fmt.Fprintf(channel, "^C\r\n")
+				return
+			} else if ch == '\n' || ch == '\r' {
+				fmt.Fprintf(channel, "\r\n") // Echo newline
 				if input.Len() > 0 {
 					query := strings.TrimSpace(input.String())
 					input.Reset()
 
 					if query == "exit" {
-						fmt.Fprintf(channel, "Goodbye!\r\n")
 						return
 					}
-
+					
 					// Get LLM response with streaming
 					ctx := context.Background()
 					stream, err := getLLMResponseStream(ctx, query)
@@ -164,9 +165,23 @@ func (s *SSHServer) handleSession(channel ssh.Channel, requests <-chan *ssh.Requ
 							f.Flush()
 						}
 					}
+					
 					fmt.Fprintf(channel, "\r\n> ")
 				}
+			} else if ch == '\b' || ch == 127 { // Backspace or Delete
+				if input.Len() > 0 {
+					// Remove last character from buffer
+					str := input.String()
+					input.Reset()
+					if len(str) > 0 {
+						input.WriteString(str[:len(str)-1])
+						// Move cursor back, overwrite with space, move back again
+						fmt.Fprintf(channel, "\b \b")
+					}
+				}
 			} else {
+				// Echo the character back to the user
+				fmt.Fprintf(channel, "%c", ch)
 				input.WriteRune(ch)
 			}
 		}