diff --git a/main.go b/main.go index 193d3b5..84ddecf 100644 --- a/main.go +++ b/main.go @@ -415,6 +415,25 @@ func sshSession(st *state) (*ssh.Session, *ssh.Client, error) { client.Close() return nil, nil, err } + + // A PTY makes the remote side (ninja, gclient, python) think it's + // talking to a terminal, so it line-buffers instead of block-buffering + // for a non-tty pipe -- without this, output for a multi-hour build can + // arrive in laggy multi-KB chunks instead of streaming as it happens. + // Combines stderr into stdout, which is fine for a CI log (one + // interleaved stream is what you'd see watching a real terminal + // anyway). + modes := ssh.TerminalModes{ + ssh.ECHO: 0, + ssh.TTY_OP_ISPEED: 14400, + ssh.TTY_OP_OSPEED: 14400, + } + if err := session.RequestPty("xterm", 40, 200, modes); err != nil { + session.Close() + client.Close() + return nil, nil, fmt.Errorf("requesting pty: %w", err) + } + return session, client, nil }