Documentation
¶
Index ¶
- Constants
- Variables
- func ClockTime(t time.Time) string
- func FormatSessionDetail(detail SessionDetail) string
- func IsTTY() bool
- func PrintSessionDetail(detail SessionDetail)
- func ReconnectNote(detail SessionDetail) string
- func StatusHint(detail SessionDetail) string
- func StatusText(detail SessionDetail) string
- func TermWidth() int
- func WrapProse(text string, width int) []string
- type GuestPermissions
- type HostSessionConfirmResult
- type HostSessionModel
- type SessionDetail
Constants ¶
const ( AccessAnyone = "anyone" AccessAllowlist = "allowlist" )
The values of SessionDetail.Access.
const ( FileTransferOff = "off" FileTransferDownloads = "downloads" FileTransferAll = "all" )
The values of GuestPermissions.FileTransfer, as the admin API reports them.
const LabelWidth = 18
LabelWidth is the width of the label column, in the view and in any text that lines its rows up with it.
Variables ¶
var ( // Title/Header style - bright cyan, bold TitleStyle = renderer.NewStyle(). Bold(true). Foreground(lipgloss.Color("14")) // Label style - white (terminal's default light color) LabelStyle = renderer.NewStyle(). Foreground(lipgloss.Color("7")) // Value style - bright white ValueStyle = renderer.NewStyle(). Foreground(lipgloss.Color("15")) // Command style - bright green, bold (for SSH commands) CommandStyle = renderer.NewStyle(). Foreground(lipgloss.Color("10")). Bold(true) FooterStyle = renderer.NewStyle(). Foreground(lipgloss.Color("8")) )
Common styles used across TUI components Using basic ANSI colors (0-15) which adapt to terminal themes, ensuring readability on both light and dark backgrounds.
Functions ¶
func ClockTime ¶ added in v0.39.0
ClockTime is t as the status text gives a time: local, to the second.
func FormatSessionDetail ¶ added in v0.21.0
func FormatSessionDetail(detail SessionDetail) string
FormatSessionDetail renders a SessionDetail to a string using terminal width
func PrintSessionDetail ¶ added in v0.21.0
func PrintSessionDetail(detail SessionDetail)
PrintSessionDetail prints session detail to stdout
func ReconnectNote ¶ added in v0.35.0
func ReconnectNote(detail SessionDetail) string
ReconnectNote says the relay can't bring a dropped session back, from the first connection on and at every status, since it stays true until the session ends. Empty when the relay can, or isn't known to yet.
func StatusHint ¶ added in v0.35.0
func StatusHint(detail SessionDetail) string
StatusHint is what the user can do about the outage, for the statuses that have one: a reconnecting session, and a disconnected one, whose reason says why it will not come back. Empty for every other status and for a reason without a hint.
func StatusText ¶ added in v0.35.0
func StatusText(detail SessionDetail) string
StatusText is the status row's value. A reconnecting session says why it is down, since when, and when it tries next; every other status is its plain word. A disconnected session's hint row says why, and the outage an ended session's record keeps is not something to act on. Times are local, to the second.
Each piece is left out when it isn't known. A next attempt that is not ahead of the clock is left out too: it is stamped as each wait starts, so it is already past during every attempt and after a sleeping machine wakes mid-wait, and printing it would promise a retry that has already happened.
func TermWidth ¶ added in v0.35.0
func TermWidth() int
TermWidth returns the terminal width, defaulting to 80 if unavailable
func WrapProse ¶ added in v0.35.0
WrapProse wraps a sentence to width at spaces, as the detail view does for its status and hint rows. Unlike the view it does not look at the terminal: the caller decides whether to wrap at all. Empty text comes back as one empty line, so a row with no value still has a line to print.
Types ¶
type GuestPermissions ¶ added in v0.39.0
type GuestPermissions struct {
ReadOnly bool
FileTransfer string // FileTransferOff, FileTransferDownloads or FileTransferAll
ApprovalRequired bool // false whenever FileTransfer is FileTransferOff
LocalForwarding bool
}
GuestPermissions is what the host lets guests do, as the daemon reports it.
type HostSessionConfirmResult ¶
type HostSessionConfirmResult int
HostSessionConfirmResult represents the outcome of a confirmation prompt
const ( // HostSessionConfirmUndecided indicates nobody answered: the prompt is // still open, or ended without an answer (bubbletea quits the program on // SIGTERM). It is the zero value so that nothing reads an unanswered // prompt as an acceptance. HostSessionConfirmUndecided HostSessionConfirmResult = iota // HostSessionConfirmAccepted indicates the user accepted (pressed 'y') HostSessionConfirmAccepted // HostSessionConfirmRejected indicates the user rejected (pressed 'n') HostSessionConfirmRejected // HostSessionConfirmInterrupted indicates the user interrupted (pressed Ctrl+C) HostSessionConfirmInterrupted )
type HostSessionModel ¶
type HostSessionModel struct {
// contains filtered or unexported fields
}
HostSessionModel asks the host whether to start the session (y/n/Ctrl+C) unless auto-accept is enabled. The banner is printed once before it runs, so the prompt line is all it draws: a redraw repaints that line and nothing above it.
func NewHostSessionModel ¶
func NewHostSessionModel(autoAccept bool) HostSessionModel
NewHostSessionModel creates a model that asks whether to start the session
func (HostSessionModel) Init ¶
func (m HostSessionModel) Init() tea.Cmd
func (HostSessionModel) Result ¶
func (m HostSessionModel) Result() HostSessionConfirmResult
Result returns the confirmation result
func (HostSessionModel) View ¶
func (m HostSessionModel) View() string
View is the prompt while it waits, and nothing once it is answered: the renderer clears the line on the way out, so a y leaves no trace of the question above the session, and an n or a Ctrl-C leaves nothing at all.
type SessionDetail ¶ added in v0.21.0
type SessionDetail struct {
IsCurrent bool
AdminSocket string
Name string
Status string
SessionID string
Command string
ForceCommand string
Host string
JoinCommand string // upterm join, for guests who have upterm
SSHCommand string
SFTPEnabled bool // Whether SFTP/SCP is enabled
SFTPCommand string // SFTP command
SCPUpload string // SCP upload example
SCPDownload string // SCP download example
AuthorizedKeys string
ConnectedClients []string
// Open is true when anyone with the session ID can join and nobody was
// asked: no allowlist, and started with --accept. It is what the JSON's
// open field reports; the view reads Access, which doesn't depend on
// whether anyone was asked.
Open bool
// Access is AccessAnyone (no allowlist) or AccessAllowlist; "" when
// unknown.
Access string
// Guests is what guests may do; nil when the daemon doesn't report it.
Guests *GuestPermissions
// Reconnect is "supported" or "unsupported" once the first connection has
// shown whether the relay lets a dropped session come back under the same
// connect string. The tunnel fields describe the latest outage: why the
// latest attempt failed (one of sessiondir's TunnelReason values), when
// the outage began, and when the next attempt is due. A live session
// clears them when its tunnel comes back; only an ended session's record
// keeps its last outage. They are zero when there has been none or the
// caller has no record to read them from.
Reconnect string
TunnelReason string
TunnelLostAt time.Time
NextAttemptAt time.Time
// JoinLabel and JoinValue are the join timeout's row: its label ("Join
// timeout:" or "Join deadline:") and what it says, which the caller words
// since it depends on where the state came from. Both are empty when
// there is nothing to say, and the view then has no row.
JoinLabel string
JoinValue string
}
SessionDetail holds session information for display