edbcf6f9a2c71c4922f0c7d7983502815a051f53

Author
Ayman Bagabas <ayman.bagabas@gmail.com>
Committer
Ayman Bagabas <ayman.bagabas@gmail.com>
Date

Message

fix: tui initial repo

Diff

 1diff --git a/internal/tui/session.go b/internal/tui/session.go
 2index 2b6db15b1336a2742aac58444f4ff54c146a3b1e..7501769e1c752703dd0b4d6e4e1779f5b3688bd9 100644
 3--- a/internal/tui/session.go
 4+++ b/internal/tui/session.go
 5@@ -2,34 +2,27 @@ package tui
 6 
 7 import (
 8 	"fmt"
 9-	"net/url"
10-	"strings"
11 
12 	tea "github.com/charmbracelet/bubbletea"
13 	"github.com/charmbracelet/soft-serve/internal/config"
14 	"github.com/gliderlabs/ssh"
15 )
16 
17+// SessionHandler handles the bubble tea session.
18 func SessionHandler(cfg *config.Config) func(ssh.Session) (tea.Model, []tea.ProgramOption) {
19 	return func(s ssh.Session) (tea.Model, []tea.ProgramOption) {
20+		pty, _, active := s.Pty()
21+		if !active {
22+			fmt.Println("not active")
23+			return nil, nil
24+		}
25 		cmd := s.Command()
26 		scfg := &SessionConfig{Session: s}
27 		switch len(cmd) {
28 		case 0:
29 			scfg.InitialRepo = ""
30 		case 1:
31-			p, err := url.Parse(cmd[0])
32-			if err != nil || strings.Contains(p.Path, "/") {
33-				return nil, nil
34-			}
35 			scfg.InitialRepo = cmd[0]
36-		default:
37-			return nil, nil
38-		}
39-		pty, _, active := s.Pty()
40-		if !active {
41-			fmt.Println("not active")
42-			return nil, nil
43 		}
44 		scfg.Width = pty.Window.Width
45 		scfg.Height = pty.Window.Height