Skip to content

Commit 92906fd

Browse files
committed
fix: properly detect pty changes on windows
1 parent 88dcea5 commit 92906fd

File tree

5 files changed

+59
-20
lines changed

5 files changed

+59
-20
lines changed

.github/workflows/release.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ permissions:
1414

1515
jobs:
1616
goreleaser:
17-
runs-on: ubuntu-latest
17+
runs-on: ubuntu-latest-8-cores
1818
steps:
1919
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
2020
with:

.goreleaser.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,4 @@ signs:
4646
# release:
4747
# draft: true
4848
changelog:
49-
skip: true
49+
use: github-native

cmd/wush/send.go

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,23 @@ import (
88
"log/slog"
99
"net/netip"
1010
"os"
11-
"os/signal"
1211
"time"
1312

1413
"github.com/charmbracelet/huh"
15-
"github.com/coder/coder/v2/pty"
16-
"github.com/coder/serpent"
17-
"github.com/coder/wush/cliui"
18-
"github.com/coder/wush/overlay"
19-
"github.com/coder/wush/tsserver"
2014
"github.com/mattn/go-isatty"
2115
"golang.org/x/crypto/ssh"
22-
"golang.org/x/sys/unix"
2316
"golang.org/x/term"
2417
"golang.org/x/xerrors"
2518
"tailscale.com/client/tailscale"
2619
"tailscale.com/net/netns"
2720
"tailscale.com/tailcfg"
21+
22+
"github.com/coder/coder/v2/pty"
23+
"github.com/coder/serpent"
24+
"github.com/coder/wush/cliui"
25+
"github.com/coder/wush/overlay"
26+
"github.com/coder/wush/tsserver"
27+
xssh "github.com/coder/wush/xssh"
2828
)
2929

3030
func sendCmd() *serpent.Command {
@@ -156,7 +156,7 @@ func sendCmd() *serpent.Command {
156156
_ = pty.RestoreTerminal(stdoutFile.Fd(), outState)
157157
}()
158158

159-
windowChange := listenWindowSize(ctx)
159+
windowChange := xssh.ListenWindowSize(ctx)
160160
go func() {
161161
for {
162162
select {
@@ -207,16 +207,6 @@ func sendCmd() *serpent.Command {
207207
}
208208
}
209209

210-
func listenWindowSize(ctx context.Context) <-chan os.Signal {
211-
windowSize := make(chan os.Signal, 1)
212-
signal.Notify(windowSize, unix.SIGWINCH)
213-
go func() {
214-
<-ctx.Done()
215-
signal.Stop(windowSize)
216-
}()
217-
return windowSize
218-
}
219-
220210
func waitUntilHasPeerHasIP(ctx context.Context, lc *tailscale.LocalClient) (netip.Addr, error) {
221211
for {
222212
select {

xssh/windowsize_other.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//go:build !windows
2+
// +build !windows
3+
4+
package ssh
5+
6+
import (
7+
"context"
8+
"os"
9+
"os/signal"
10+
11+
"golang.org/x/sys/unix"
12+
)
13+
14+
func ListenWindowSize(ctx context.Context) <-chan os.Signal {
15+
windowSize := make(chan os.Signal, 1)
16+
signal.Notify(windowSize, unix.SIGWINCH)
17+
go func() {
18+
<-ctx.Done()
19+
signal.Stop(windowSize)
20+
}()
21+
return windowSize
22+
}

xssh/windowsize_windows.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
//go:build windows
2+
// +build windows
3+
4+
package ssh
5+
6+
import (
7+
"context"
8+
"os"
9+
"time"
10+
)
11+
12+
func ListenWindowSize(ctx context.Context) <-chan os.Signal {
13+
windowSize := make(chan os.Signal, 3)
14+
ticker := time.NewTicker(time.Second)
15+
go func() {
16+
defer ticker.Stop()
17+
for {
18+
select {
19+
case <-ctx.Done():
20+
return
21+
case <-ticker.C:
22+
}
23+
windowSize <- nil
24+
}
25+
}()
26+
return windowSize
27+
}

0 commit comments

Comments
 (0)