Documentation
¶
Index ¶
- type DirectRenderer
- type KubectlExecBackend
- func (kb *KubectlExecBackend) Alive() bool
- func (kb *KubectlExecBackend) Close() error
- func (kb *KubectlExecBackend) Namespace() string
- func (kb *KubectlExecBackend) PodName() string
- func (kb *KubectlExecBackend) Read(buf []byte) (int, error)
- func (kb *KubectlExecBackend) Resize(cols, rows int) error
- func (kb *KubectlExecBackend) Write(data []byte) (int, error)
- type Session
- type SessionBackend
- type TermView
- func (tv *TermView) Height() int
- func (tv *TermView) IsScrolled() bool
- func (tv *TermView) Render() string
- func (tv *TermView) Resize(cols, rows int)
- func (tv *TermView) ScrollDown(n int)
- func (tv *TermView) ScrollUp(n int)
- func (tv *TermView) SnapToBottom()
- func (tv *TermView) Width() int
- func (tv *TermView) Write(data []byte)
- type TmuxSession
- func (ts *TmuxSession) Alive() bool
- func (ts *TmuxSession) Close() error
- func (ts *TmuxSession) Read(buf []byte) (int, error)
- func (ts *TmuxSession) Render() string
- func (ts *TmuxSession) Resize(cols, rows int) error
- func (ts *TmuxSession) SessionName() string
- func (ts *TmuxSession) Write(data []byte) (int, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DirectRenderer ¶
type DirectRenderer interface {
Render() string
}
DirectRenderer is an optional interface that backends can implement when their output is already rendered terminal text (e.g., tmux capture-pane). SessionView checks for this: if present, it skips the VT emulator and uses Render() directly. If absent, output goes through the VT emulator.
type KubectlExecBackend ¶ added in v0.7.0
type KubectlExecBackend struct {
// contains filtered or unexported fields
}
KubectlExecBackend implements SessionBackend for remote K8s pod sessions. It uses `kubectl exec -it` with a real PTY (via creack/pty) to provide full interactive terminal access to a tmux session inside a pod.
func NewKubectlExec ¶ added in v0.7.0
func NewKubectlExec(podName, namespace, container string, cols, rows int) (*KubectlExecBackend, error)
NewKubectlExec starts `kubectl exec -it` with a real PTY, attaching to (or creating) a tmux session named "main" inside the pod.
func (*KubectlExecBackend) Alive ¶ added in v0.7.0
func (kb *KubectlExecBackend) Alive() bool
Alive checks if the kubectl process is still running.
func (*KubectlExecBackend) Close ¶ added in v0.7.0
func (kb *KubectlExecBackend) Close() error
Close kills the kubectl process and closes the PTY. The tmux session inside the pod continues running and can be reattached later.
func (*KubectlExecBackend) Namespace ¶ added in v0.7.0
func (kb *KubectlExecBackend) Namespace() string
Namespace returns the namespace for external reference.
func (*KubectlExecBackend) PodName ¶ added in v0.7.0
func (kb *KubectlExecBackend) PodName() string
PodName returns the pod name for external reference.
func (*KubectlExecBackend) Read ¶ added in v0.7.0
func (kb *KubectlExecBackend) Read(buf []byte) (int, error)
Read reads from the PTY. Blocks until data is available or the PTY closes. This is called from a Bubble Tea command goroutine, so blocking is fine — Bubble Tea handles key events on a separate goroutine.
func (*KubectlExecBackend) Resize ¶ added in v0.7.0
func (kb *KubectlExecBackend) Resize(cols, rows int) error
Resize changes the PTY and remote tmux window size.
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session manages a PTY-backed subprocess. It provides thread-safe read, write, and resize operations for embedding interactive terminal processes.
func (*Session) Alive ¶
Alive returns true if the session is still open and the process has not exited.
func (*Session) Close ¶
Close terminates the PTY session. It sends terminal reset sequences to restore standard modes, then closes the PTY file descriptor and signals the process to exit. Cleanup runs in a background goroutine so the TUI returns immediately. It is safe to call multiple times.
type SessionBackend ¶
type SessionBackend interface {
Read(buf []byte) (int, error)
Write(data []byte) (int, error)
Resize(cols, rows int) error
Close() error
Alive() bool
}
SessionBackend is the common interface for terminal session backends. The direct PTY backend (Session) and the tmux mirror backend (TmuxSession) both implement this interface. SessionView works with either.
type TermView ¶
type TermView struct {
// contains filtered or unexported fields
}
TermView wraps a charmbracelet/x/vt terminal emulator, providing a thread-safe interface for writing PTY output and rendering the screen buffer as an ANSI-styled string.
func NewTermView ¶
NewTermView creates a new TermView with the given column and row dimensions. An optional responseSink receives terminal responses (device attributes, cursor position reports, etc.) generated by the VT emulator. Pass the PTY backend so the child process gets the responses it expects. If nil, responses are discarded.
The VT emulator uses an io.Pipe for responses — writes block until read. A background goroutine drains the pipe to prevent deadlocks.
func (*TermView) IsScrolled ¶ added in v0.6.0
IsScrolled returns true if viewing history (not live bottom).
func (*TermView) Render ¶
Render returns the current screen buffer as a string with ANSI styling. When scrolled back, it returns lines from the history buffer instead of the live terminal output.
func (*TermView) ScrollDown ¶ added in v0.6.0
ScrollDown moves the viewport down by n lines. Snaps to live at 0.
func (*TermView) SnapToBottom ¶ added in v0.6.0
func (tv *TermView) SnapToBottom()
SnapToBottom resets scroll to live view.
type TmuxSession ¶
type TmuxSession struct {
// contains filtered or unexported fields
}
TmuxSession mirrors a tmux session's pane content. It polls `tmux capture-pane` for output and forwards keystrokes via `tmux send-keys`. This allows embedding any TUI (Codex, Gemini) inside aimux's split view.
func AttachTmux ¶
func AttachTmux(sessionName string, cols, rows int) (*TmuxSession, error)
AttachTmux mirrors an existing tmux session without creating it. The session is left running when Close is called.
func StartTmux ¶
StartTmux creates a new tmux session running cmd, then mirrors it. The session is killed when Close is called.
func (*TmuxSession) Alive ¶
func (ts *TmuxSession) Alive() bool
Alive returns true if the tmux session still exists.
func (*TmuxSession) Close ¶
func (ts *TmuxSession) Close() error
Close stops polling. If the session was created by StartTmux, it kills the tmux session. If it was attached via AttachTmux, the session continues running.
func (*TmuxSession) Read ¶
func (ts *TmuxSession) Read(buf []byte) (int, error)
Read returns captured pane content. Blocks until data is available or the session is closed.
func (*TmuxSession) Render ¶
func (ts *TmuxSession) Render() string
Render returns the latest captured pane content. This implements the DirectRenderer interface, allowing SessionView to skip the VT emulator and display the tmux output directly (it's already rendered terminal text).
func (*TmuxSession) Resize ¶
func (ts *TmuxSession) Resize(cols, rows int) error
Resize changes the tmux window dimensions.
func (*TmuxSession) SessionName ¶
func (ts *TmuxSession) SessionName() string
SessionName returns the tmux session name for external reference.