tui

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 27, 2026 License: Apache-2.0 Imports: 34 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrRelayEscape = errors.New("relay: ctrl+o escape")

ErrRelayEscape is returned by PTYRelay.Run() when the user presses Ctrl+O to escape back to the TUI prefix mode.

View Source
var ErrRelayLayout = errors.New("relay: ctrl+l layout")

ErrRelayLayout is returned by PTYRelay.Run() when the user presses Ctrl+L to escape back to the TUI layout mode (e.g. to minimize/un-maximize the pane with `m`). Without this, an interactive program maximized via the relay could only be exited via Ctrl+O, leaving no way to minimize it.

View Source
var ErrRelayModeSwitch = errors.New("relay: esc esc mode switch")

ErrRelayModeSwitch is returned by PTYRelay.Run() when the user presses Esc twice — the universal "switch modes" chord — so the TUI can cycle the pane's input mode (shell → prompt → rysh → chat) without leaving the interactive session for good. Cycling back to shell re-enters the relay, the app having kept running in the PTY. Mirrors the in-pane double-Esc gesture for raw panes.

Functions

func OSC52Output

func OSC52Output() (io.Writer, func())

OSC52Output returns the writer OSC 52 sequences should be sent to, plus a cleanup func. It prefers the controlling terminal (/dev/tty) over os.Stdout: a direct stdout write can interleave with a partially-flushed bubbletea frame (corrupting the escape sequence mid-bytes), and goes nowhere useful when stdout is redirected. Falls back to os.Stdout when there is no controlling tty (e.g. Windows).

func OSC52Sequences

func OSC52Sequences(env func(string) string, s string) []string

OSC52Sequences returns the escape sequence(s) that copy s to the clipboard of the terminal that owns the display, adapted to the terminal chain described by env (os.Getenv in production):

  • Plain terminal: one raw OSC 52 sequence.
  • GNU screen (TERM=screen*): OSC 52 wrapped in DCS chunks — screen forwards DCS payloads to the outer terminal unchanged but eats raw OSC 52.
  • tmux ($TMUX set, or TERM=tmux*): BOTH a raw sequence and a tmux-passthrough-wrapped one. Raw works when tmux's set-clipboard is "on" or "external" (the default); the wrapped copy works when set-clipboard is off but allow-passthrough is on. Whichever tmux config is in effect drops the sequence it doesn't understand; if both get through, the terminal just sets the same clipboard content twice.

$TMUX wins over a screen-looking TERM because tmux sets TERM=screen* by default.

func WriteOSC52

func WriteOSC52(w io.Writer, env func(string) string, s string) error

WriteOSC52 emits the OSC 52 clipboard sequence(s) for s to w, adapted via env to the terminal chain. Split out so the exact bytes are unit-testable.

Types

type DetachMsg

type DetachMsg struct{}

DetachMsg is sent to the Bubble Tea program by the signal handler when an external "rysh detach <name>" command targets this session. It triggers the same graceful detach path as the in-app ctrl+p d / ctrl+o d keystrokes.

type Model

type Model struct {
	// contains filtered or unexported fields
}

Model is the Bubble Tea model for the Rysh TUI. It communicates with the WorkspaceActor purely via NATS messages. It does NOT import internal/actors.

func NewModel

func NewModel(cfg config.Config, logger *slog.Logger, b *bus.Bus) (Model, error)

NewModel creates the TUI model. The WorkspaceActor must already be running (spawned via bus.ActorSystem()) before this is called.

func (Model) Detached

func (m Model) Detached() bool

Detached returns true if the user detached the session (ctrl+o d) rather than quitting. Used by main.go to set the session state to "detached".

func (Model) Init

func (m Model) Init() tea.Cmd

func (Model) Update

func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (Model) View

func (m Model) View() string

type PTYRelay

type PTYRelay struct {
	// contains filtered or unexported fields
}

PTYRelay implements tea.ExecCommand. When Bubble Tea calls Run(), the relay takes over stdin/stdout and proxies data between the real terminal and the PTY via NATS — the daemon's rawReadLoop publishes raw PTY bytes to a dedicated NATS subject, and the relay writes them directly to stdout. Input from stdin is published back to the PaneActor via NATS.

func NewPTYRelay

func NewPTYRelay(nc *nats.Conn, pub *msgpkg.NATSPublisher, paneID string) *PTYRelay

NewPTYRelay creates a new NATS-based relay for the given pane.

func (*PTYRelay) Run

func (r *PTYRelay) Run() error

Run implements the blocking relay loop. It puts the real terminal in raw mode, enters alt screen, subscribes to NATS relay output, activates relay mode on the daemon, and proxies data until the interactive program exits or the user presses Ctrl+O.

func (*PTYRelay) SetStderr

func (r *PTYRelay) SetStderr(io.Writer)

SetStderr is called by Bubble Tea before Run().

func (*PTYRelay) SetStdin

func (r *PTYRelay) SetStdin(io.Reader)

SetStdin is called by Bubble Tea before Run(). We use os.Stdin.Fd() directly for dup/raw-mode, so we don't need to store this.

func (*PTYRelay) SetStdout

func (r *PTYRelay) SetStdout(out io.Writer)

SetStdout is called by Bubble Tea before Run().

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL