Documentation
¶
Overview ¶
Package termbridge owns the daemon-side PTY lifecycle for one terminal socket (kb:anchor/terminal.ws): spawning `tmux attach-session` under a `creack/pty`-managed pseudo-terminal, streaming raw bytes both directions, and resizing with pty.Setsize then tmux resize-window, never the pane-level primitive (kb:adr/surfaces-shared-attach-single-pty). This package knows nothing about WebSockets or sessions — internal/server is the only caller (its own server.go wires Attach in), and owns the socket-level concerns (auth, takeover, frame shapes).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bridge ¶
type Bridge struct {
// contains filtered or unexported fields
}
Bridge is one daemon-owned PTY attached to a tmux session.
func Attach ¶
Attach spawns `tmux attach-session -t target` under a fresh PTY, with TERM/LANG set explicitly — without them tmux falls back to ASCII line-drawing and Claude's boxes render as "qqqq", which looks exactly like a rendering bug rather than a missing env var. ctx is exec.CommandContext's context: if it is canceled, the attach process is killed. In practice ctx is the caller's request context, so the Bridge's lifetime tracks that request for as long as it's live, and Close is what tears it down explicitly and idempotently once the caller is done with it either way.
func (*Bridge) Close ¶
Close tears down the PTY and the attach process. Safe to call more than once (the terminal handler's takeover path and its own deferred cleanup both call it).
func (*Bridge) Read ¶
Read reads raw PTY output verbatim. A macOS PTY read returns EIO once the other end (the attach process) has exited; treat that as clean EOF, matching what every other EOF-producing reader would report.