Skip to content

Commit 6365d93

Browse files
committed
fix(cli): improve ssh warnings and tmux copy
1 parent f1b07c7 commit 6365d93

4 files changed

Lines changed: 12 additions & 6 deletions

File tree

infra/sidecar/embedded-tmux.conf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ set -g set-clipboard on
1313
set -g default-terminal "tmux-256color"
1414

1515
setw -g mode-keys vi
16+
bind -T copy-mode MouseDragEnd1Pane send-keys -X copy-selection-and-cancel
17+
bind -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-selection-and-cancel
1618

1719
set -g status-position bottom
1820
set -g status-interval 5

infra/sidecar/tmux.conf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ set -g default-terminal "tmux-256color"
1717

1818
# Prefer vi keys in copy mode for logs/code.
1919
setw -g mode-keys vi
20+
bind -T copy-mode MouseDragEnd1Pane send-keys -X copy-selection-and-cancel
21+
bind -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-selection-and-cancel
2022

2123
# Route new windows and panes through the dev-shell wrapper so tmux always
2224
# lands in the dev container rather than the sidecar.

internal/cli/ssh.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ func newSSHCmd(opts *Options) *cobra.Command {
167167
})
168168
var lastRTTWarnNanos atomic.Int64
169169
tm.SetKeepAliveRTTCallback(func(rtt time.Duration) {
170-
if rtt < 2*time.Second {
170+
if rtt < 5*time.Second {
171171
return
172172
}
173173
now := time.Now().UnixNano()
@@ -176,7 +176,7 @@ func newSSHCmd(opts *Options) *cobra.Command {
176176
return
177177
}
178178
if lastRTTWarnNanos.CompareAndSwap(prev, now) {
179-
fmt.Fprintf(cmd.ErrOrStderr(), "warning: ssh keepalive RTT is high: %s\n", rtt.Round(10*time.Millisecond))
179+
fmt.Fprintf(cmd.ErrOrStderr(), "warning: ssh keepalive RTT is very high: %s\n", rtt.Round(10*time.Millisecond))
180180
}
181181
})
182182
stopConnect := startTransientStatus(errOut, "Connecting to session")

internal/cli/up.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -435,8 +435,7 @@ func detectEmbeddedTmux(ctx context.Context, k devShellExecutor, namespace, pod
435435
}
436436

437437
func installEmbeddedTmux(ctx context.Context, k devShellExecutor, namespace, pod, installer string, progress func(string)) (bool, string, error) {
438-
installCtx, cancel := context.WithTimeout(ctx, 3*time.Minute)
439-
defer cancel()
438+
installCtx := ctx
440439
if progress != nil && installer != "" && installer != "none" {
441440
ticker := time.NewTicker(10 * time.Second)
442441
defer ticker.Stop()
@@ -458,8 +457,11 @@ func installEmbeddedTmux(ctx context.Context, k devShellExecutor, namespace, pod
458457
var raw bytes.Buffer
459458
err := k.StreamShInContainer(installCtx, namespace, pod, "dev", script, &raw, &raw)
460459
if err != nil {
461-
if errors.Is(installCtx.Err(), context.DeadlineExceeded) {
462-
return false, "", fmt.Errorf("timed out while installing tmux via %s; inspect %s in the dev container", installer, embeddedTmuxLogPath)
460+
if errors.Is(ctx.Err(), context.DeadlineExceeded) {
461+
return false, "", fmt.Errorf("tmux install cancelled after timeout via parent context; inspect %s in the dev container", embeddedTmuxLogPath)
462+
}
463+
if errors.Is(ctx.Err(), context.Canceled) {
464+
return false, "", fmt.Errorf("tmux install cancelled; inspect %s in the dev container", embeddedTmuxLogPath)
463465
}
464466
return false, "", err
465467
}

0 commit comments

Comments
 (0)