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
- func IsLocal(name string) bool
- func RestartOff(env *ui.Env) string
- func SetupOff(env *ui.Env) string
- func Switch(local *client.Client, name string) tea.Cmd
- func SyncConn(env *ui.Env, info *remote.Info)
- func Tag(gen int, cmd tea.Cmd) tea.Cmd
- func UpgradeOff(env *ui.Env) string
- type Discovery
- type Host
- func (h *Host) AskPair(p Peer) tea.Cmd
- func (h *Host) Close()
- func (h *Host) Computers() tea.Cmd
- func (h *Host) Daemon()
- func (h *Host) Doctor(env *ui.Env) tea.Cmd
- func (h *Host) Key(env *ui.Env, msg tea.KeyPressMsg) tea.Cmd
- func (h *Host) Mouse(msg tea.MouseMsg) tea.Cmd
- func (h *Host) Names() []string
- func (h *Host) Observe(st *server.State) tea.Cmd
- func (h *Host) Open() bool
- func (h *Host) RestartDaemon(env *ui.Env) tea.Cmd
- func (h *Host) Restarting() string
- func (h *Host) Setup(env *ui.Env) tea.Cmd
- func (h *Host) Update(env *ui.Env, msg tea.Msg) (tea.Cmd, bool)
- func (h *Host) Upgrade(env *ui.Env) tea.Cmd
- func (h *Host) View(env *ui.Env, screen string, w, hgt int) string
- func (h *Host) WatchConnection(env *ui.Env) tea.Cmd
- type Peer
- type Streams
- type SwitchedMsg
Constants ¶
const ( VerbUpgrade = "upgrade" VerbRestart = "restart" )
Restart verbs.
const LocalName = "local"
LocalName is the computer name that `:on` takes for this computer.
Variables ¶
This section is empty.
Functions ¶
func RestartOff ¶
RestartOff is why `:restart-daemon` does nothing.
func SetupOff ¶
SetupOff is why `:setup` and `:doctor` do nothing: coding agents are set up on this computer only, never through another one.
func Switch ¶
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 ¶
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 ¶
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 ¶
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 ¶
Discovery is GET /api/remote/peers: the tailnet and the computers on it that share their daemon.
type Host ¶
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 ¶
AskPair opens the Computers overlay on the code prompt for p, which answered that it needs pairing.
func (*Host) Mouse ¶
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) Observe ¶
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) RestartDaemon ¶
RestartDaemon asks before restarting the daemon in place.
func (*Host) Restarting ¶
Restarting is the top bar's word while an upgrade or a restart in place runs, "" otherwise.
func (*Host) WatchConnection ¶
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 ¶
NewStreams returns the streams of a program: they end with ctx and deliver their messages with send, which may block.
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.