remote

package
v0.12.2 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: MIT Imports: 29 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package remote is the terminal UI's view of the computers around the daemon and of the daemon itself: the Computers overlay (other computers over Tailscale, sharing, forwarded ports) and the switch of the session to another computer, the daemon's details with its upgrade and restart in place, and the coding-agent setup (design/tui.md "Other computers and the daemon").

Index

Constants

View Source
const (
	VerbUpgrade = "upgrade"
	VerbRestart = "restart"
)

Restart verbs.

View Source
const LocalName = "local"

LocalName is the computer name that `:on` takes for this computer.

Variables

This section is empty.

Functions

func IsLocal

func IsLocal(name string) bool

IsLocal reports whether a name given to :on means this computer.

func RestartOff

func RestartOff(env *ui.Env) string

RestartOff is why `:restart-daemon` does nothing.

func SetupOff

func SetupOff(env *ui.Env) string

SetupOff is why `:setup` and `:doctor` do nothing: coding agents are set up on this computer only, never through another one.

func Switch

func Switch(local *client.Client, name string) tea.Cmd

Switch connects this daemon to the computer called name, unless it is connected to it already, and returns a client whose requests go there, as --on does; IsLocal names return local itself.

func SyncConn

func SyncConn(env *ui.Env, info *remote.Info)

SyncConn makes the session's connection this daemon's connection info while the session targets the computer it is to; another computer's or none leaves the session without one, so its addresses do not resolve (ui.Session.URL and PortURL are empty) instead of reaching whatever now holds a port that was forwarded. A session on this computer has none.

func Tag

func Tag(gen int, cmd tea.Cmd) tea.Cmd

Tag makes the message of cmd a ui.GenMsg of session gen, so the root model drops it once another session is current. Bubble Tea's own messages (quit, window title) pass unchanged, and the commands of a batch or a sequence are tagged one by one, so the program still runs them. A ui.ExecMsg becomes Bubble Tea's exec, whose callback result is tagged the same way when it arrives, after the UI comes back; a session that ended with ui.ErrEnding quits instead. Bubble Tea's own exec message passes untagged: suspend the UI through ui.Exec.

func UpgradeOff

func UpgradeOff(env *ui.Env) string

UpgradeOff is why `:upgrade` does nothing: it replaces the daemon of this computer with this binary, in place, only when that is newer.

Types

type Discovery

type Discovery struct {
	remote.Discovery
	Prompt string `json:"prompt"`
}

Discovery is GET /api/remote/peers: the tailnet and the computers on it that share their daemon.

type Host

type Host struct {
	Local *client.Client
	// contains filtered or unexported fields
}

Host owns the overlays of this package and the restart in progress. Local is the client of this computer's daemon: the computers, the daemon's upgrade and the agents always go there, whatever computer the session targets.

func (*Host) AskPair

func (h *Host) AskPair(p Peer) tea.Cmd

AskPair opens the Computers overlay on the code prompt for p, which answered that it needs pairing.

func (*Host) Close

func (h *Host) Close()

Close closes the open overlay.

func (*Host) Computers

func (h *Host) Computers() tea.Cmd

Computers opens the Computers overlay and scans the tailnet.

func (*Host) Daemon

func (h *Host) Daemon()

Daemon opens the daemon's details.

func (*Host) Doctor

func (h *Host) Doctor(env *ui.Env) tea.Cmd

Doctor suspends the terminal UI for `doctor`, or says why it is off.

func (*Host) Key

func (h *Host) Key(env *ui.Env, msg tea.KeyPressMsg) tea.Cmd

Key handles a key while an overlay is open.

func (*Host) Mouse

func (h *Host) Mouse(msg tea.MouseMsg) tea.Cmd

Mouse scrolls the open overlay with the wheel; a click on a row puts the cursor on it (twice in a row on the Computers overlay runs its enter), and a click on an action, the sharing line, a port's forwarding or an agent's check box runs it as its key does.

func (*Host) Names

func (h *Host) Names() []string

Names are the computers `:on` completes.

func (*Host) Observe

func (h *Host) Observe(st *server.State) tea.Cmd

Observe sees a snapshot: once the daemon answers with another start time than before the restart, the restart is over and a notice says with what version.

func (*Host) Open

func (h *Host) Open() bool

Open reports whether an overlay of the host takes the keys.

func (*Host) RestartDaemon

func (h *Host) RestartDaemon(env *ui.Env) tea.Cmd

RestartDaemon asks before restarting the daemon in place.

func (*Host) Restarting

func (h *Host) Restarting() string

Restarting is the top bar's word while an upgrade or a restart in place runs, "" otherwise.

func (*Host) Setup

func (h *Host) Setup(env *ui.Env) tea.Cmd

Setup opens the coding-agent setup, or says why it is off.

func (*Host) Update

func (h *Host) Update(env *ui.Env, msg tea.Msg) (tea.Cmd, bool)

Update takes the host's messages; ok is false for the others.

func (*Host) Upgrade

func (h *Host) Upgrade(env *ui.Env) tea.Cmd

Upgrade asks before replacing the daemon with this binary in place.

func (*Host) View

func (h *Host) View(env *ui.Env, screen string, w, hgt int) string

View draws the open overlay centered over the screen (the root dims it).

func (*Host) WatchConnection

func (h *Host) WatchConnection(env *ui.Env) tea.Cmd

WatchConnection keeps the session's connection (ui.Session.Conn, which resolves the other computer's addresses here) in line with this daemon's while the session targets another computer: it reads it now and every connRefresh. A later call replaces the loop; the root calls it whenever the session changes.

type Peer

type Peer struct {
	Name, DNSName string
}

Peer names another computer by what the API takes.

type Streams

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

Streams runs the live state stream of the current session: Start stops the previous session's stream and starts one for the new client, whose messages carry the session's generation.

A stream never waits for the program: while the UI is suspended (an attached terminal, a shell, the editor) the program reads no messages, and a stream that stopped reading would be dropped by the daemon. Its messages go to a mailbox that keeps the latest snapshot and the latest connection report of each session, and one goroutine hands them to the program in the order they last arrived.

func NewStreams

func NewStreams(ctx context.Context, send func(tea.Msg)) *Streams

NewStreams returns the streams of a program: they end with ctx and deliver their messages with send, which may block.

func (*Streams) Start

func (st *Streams) Start(s *live.Stream, c *client.Client, gen int)

Start stops the running stream and runs s for client c as session gen.

func (*Streams) Wait

func (st *Streams) Wait()

Wait returns when every stream has ended (the program's context ended).

type SwitchedMsg

type SwitchedMsg struct {
	Computer string
	Client   *client.Client
	Conn     *client.Connection
	Err      error
	// Pair is set when the computer needs pairing first.
	Pair Peer
}

SwitchedMsg is the outcome of :on: the client and connection of the computer the session now targets (Computer "" for this one), or why the switch did not happen.

Jump to

Keyboard shortcuts

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