Help us shape the future of Go! Take the 2026 Go Developer Survey

relay

package
v0.1.3 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: 3 Imported by: 0

Documentation

Overview

Package relay provides a thread-safe in-process registry that maps pane IDs to PTY relay handles. When the TUI activates a relay for a pane, the rawReadLoop in the PaneActor sends raw PTY output to the handle's OutputCh, and the relay writes it directly to stdout — bypassing the NATS/VTerm/snapshot polling loop for native-speed interactive programs (vim, htop, etc.).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(paneID string, h *Handle)

Register associates a pane ID with a relay Handle.

func Unregister

func Unregister(paneID string)

Unregister removes the relay Handle for a pane ID.

Types

type Handle

type Handle struct {
	PtyFile  *os.File    // direct reference to PTY master fd
	OutputCh chan []byte // rawReadLoop sends chunks here when relay is active
	// contains filtered or unexported fields
}

Handle holds the shared state between the PaneActor's rawReadLoop goroutine and the TUI's PTYRelay. All fields are safe for concurrent access: - OutputCh is a buffered channel (concurrent send/recv is safe by design). - active is an atomic.Bool. - altExitCh is only closed once (guarded by sync.Once in SignalAltExit).

func Get

func Get(paneID string) *Handle

Get returns the relay Handle for a pane ID, or nil if not registered.

func NewHandle

func NewHandle(ptyFile *os.File) *Handle

NewHandle creates a new relay Handle for the given PTY file.

func (*Handle) Activate

func (h *Handle) Activate()

Activate prepares the handle for a new relay session. It drains any stale data from OutputCh, resets the alt-screen exit channel, and sets active=true.

func (*Handle) AltExitCh

func (h *Handle) AltExitCh() <-chan struct{}

AltExitCh returns a channel that is closed when the alt screen exits during an active relay.

func (*Handle) Deactivate

func (h *Handle) Deactivate()

Deactivate marks the relay as inactive. rawReadLoop will stop sending to OutputCh.

func (*Handle) IsActive

func (h *Handle) IsActive() bool

IsActive returns true if the relay is currently active (TUI has taken over).

func (*Handle) SignalAltExit

func (h *Handle) SignalAltExit()

SignalAltExit closes the altExitCh to notify the relay that the interactive program has exited (alt screen deactivated). Safe to call multiple times.

Jump to

Keyboard shortcuts

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