Skip to content

Commit

Permalink
fix(tea): jump to next middleware when session is not a pty
Browse files Browse the repository at this point in the history
Check if there's a program before closing non-pty sessions. If not, skip
the middleware and execute the next one.
  • Loading branch information
aymanbagabas committed Jul 31, 2024
1 parent 92feb6d commit 8aed4c3
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions bubbletea/tea.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,16 @@ func MiddlewareWithProgramHandler(handler ProgramHandler, profile termenv.Profil
return func(next ssh.Handler) ssh.Handler {
return func(sess ssh.Session) {
sess.Context().SetValue(minColorProfileKey, profile)
_, windowChanges, ok := sess.Pty()
if !ok {
wish.Fatalln(sess, "no active terminal, skipping")
return
}
program := handler(sess)
if program == nil {
next(sess)
return
}
_, windowChanges, ok := sess.Pty()
if !ok {
wish.Fatalln(sess, "no active terminal, skipping")
return
}
ctx, cancel := context.WithCancel(sess.Context())
go func() {
for {
Expand Down

0 comments on commit 8aed4c3

Please sign in to comment.