feat(pty): expose terminal modes in SSHPtyConfig#164
Open
wonkyungup wants to merge 2 commits into
Open
Conversation
Add `modes: Map<int, int>?` to SSHPtyConfig and wire it through both
`shell()` and `execute()` so callers can request a PTY with specific
termios settings (RFC 4254 §8) — e.g. `{53: 0}` to disable ECHO at
pty-req time, avoiding the race where `stty -echo` runs only after the
shell already echoed the rest of the input line.
`encodeModes()` builds the standard opcode(1) + value(4 BE) bytes
terminated by TTY_OP_END (0x00). Empty/absent modes yield an empty
byte string, preserving prior behavior.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Removes the inline `<--- 추가` annotations left over from local prototyping and adds an Unreleased CHANGELOG entry describing the `SSHPtyConfig.modes` field introduced in the previous commit. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds an optional
modes: Map<int, int>?field toSSHPtyConfigand wires it throughSSHClient.shell()andSSHClient.execute()via the existingterminalModesparameter ofsendPtyReq— which previously had nopublic API to populate.
Motivation
The SSH
pty-reqmessage (RFC 4254 §8) carries an "encoded terminal modes" field — opcode/value pairs thatlet the client request specific termios settings at PTY creation time. Without exposing this at the API
level, callers have no way to control PTY behavior before the first byte hits the line discipline.
The concrete use case that motivated this: a terminal client that injects shell integration (OSC 7 cwd
reporting, prompt hooks) right after connection. Doing
client.shell()then writingstty -echo; <setup>; stty echo\ndoesn't work — the PTY echoes input character-by-character until the newline arrives, by whichtime the entire setup line has already been streamed to the user's screen. The only race-free fix is to
disable ECHO before the PTY is created, which requires sending mode 53 (
ECHO) with value 0 in theinitial
pty-req.Other common uses:
{51: 0, 53: 0}for raw-mode TUIs, customVINTR/VERASEmappings, etc.Changes
SSHPtyConfig: newfinal Map<int, int>? modesfield and constructor parameter.SSHPtyConfig.encodeModes(): encodes the map into the byte string format defined by RFC 4254 §8 —opcode(1) + value(4 BE)per entry, terminated byTTY_OP_END(0x00). ReturnsUint8List(0)whenmodesisnull or empty.
SSHClient.shell()andSSHClient.execute(): passpty.encodeModes()asterminalModestosendPtyReq.Backward compatibility
Fully backward compatible.
modesis optional and defaults tonull;encodeModes()returns an empty bytestring in that case, which is identical to the previous behavior (
sendPtyReqalready defaultedterminalModestoUint8List(0)).Example
Spec
RFC 4254 §8 — https://datatracker.ietf.org/doc/html/rfc4254#section-8