app

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: AGPL-3.0 Imports: 69 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 app is SSHYard's interface: the host sidebar, the tabs and split panes (native terminals and files browsers alike) and the settings, built with MyGo's immediate-mode ui package. Everything platform-specific (the window's theme and language, the keychain, the updater, file dialogs) comes in through Platform, so the whole interface runs in ui.Tester.

Index

Constants

View Source
const (
	Small = 14
	Tiny  = 12
)

Small is the icon size of IconButtons in dense rows (tabs, sidebar rows), Tiny in the slimmest (pane headers).

Variables

This section is empty.

Functions

func EncodeKey

func EncodeKey(k ui.Key, mods ui.Modifiers, m vt.Modes) ([]byte, bool)

EncodeKey returns what a key pressed in the terminal sends to the program, as xterm sends it, and false for keys it leaves: keys that type text (the text comes after them, InputText) and the app's own shortcuts.

Types

type App

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

App is the interface's state. Its View runs on the UI thread; work in the background posts its results with post.

func New

func New(p Platform) (*App, error)

New opens the app's data.

func (*App) ApplySettings

func (a *App) ApplySettings(s settings.Settings) error

ApplySettings applies and saves settings.

func (*App) AskAI

func (a *App) AskAI(from *conn, selection string)

AskAI sends selection to the AI pane of from's tab, opened beside from when the tab has none. The selection is marked untrusted.

func (*App) ClearChat

func (a *App) ClearChat(id int)

ClearChat forgets the pane's conversation, from the history too, and starts another.

func (*App) ClearSearch

func (a *App) ClearSearch()

ClearSearch empties the hosts' search and focuses its field.

func (*App) Close

func (a *App) Close()

Close ends every session and port forward.

func (*App) CloseFocused

func (a *App) CloseFocused()

CloseFocused closes the focused pane.

func (*App) CloseSession

func (a *App) CloseSession(id int)

CloseSession closes a pane, terminal or files, and its connection.

func (*App) Connect

func (a *App) Connect(hostID string, at openAt) (int, error)

Connect opens a terminal to a saved host, in a new tab or on a pane.

func (*App) ContinueAI

func (a *App) ContinueAI(id int)

ContinueAI resumes a turn that paused after 25 tool calls.

func (*App) DeleteChat

func (a *App) DeleteChat(host, id string)

DeleteChat deletes host's conversation id; a pane showing it starts another.

func (*App) DeleteCredential

func (a *App) DeleteCredential(id string, rebind *authChoice) error

DeleteCredential removes a credential and its secrets. The hosts that use it switch to rebind; with rebind nil a credential in use is kept (an *assets.InUseError). The secrets go first: when the keychain fails, the credential and its hosts stay as they were (a *keychainDeleteError), and only then are the hosts rebound and the entry removed.

func (*App) DeleteForward

func (a *App) DeleteForward(id string) error

DeleteForward stops a port forward, then removes it and its password; the password goes first.

func (*App) DeleteHost

func (a *App) DeleteHost(id string) error

DeleteHost removes a host, unless other hosts jump through it or forwards use it (an *assets.InUseError naming them).

func (*App) DeleteProxy

func (a *App) DeleteProxy(id string) error

DeleteProxy removes a proxy no host uses, and its password; the password goes first.

func (*App) DisconnectForwardConn

func (a *App) DisconnectForwardConn(id string, conn uint64)

DisconnectForwardConn closes one connection of a forward.

func (*App) Download

func (a *App) Download(cn *conn, paths []string, dir string)

Download copies remote files and folders into the local folder dir, asking about those already there.

func (*App) ExportBackup

func (a *App) ExportBackup(m locales.Messages) bool

ExportBackup checks the sheet's password and gathers the backup, then, off the UI thread, asks where to save it and seals it there.

func (*App) ForwardStatus

func (a *App) ForwardStatus(id string) (forward.Status, bool)

ForwardStatus is a forward's status, and whether it was started.

func (*App) Import

func (a *App) Import(m locales.Messages) (importResult, bool)

Import saves the chosen hosts of the preview.

func (*App) InsertAI

func (a *App) InsertAI(id int, text string)

InsertAI writes text into the linked terminal's input, without Enter. Control characters, including CR and LF, are removed first.

func (*App) InstallKey

func (a *App) InstallKey(ctx context.Context, h assets.Host, credID, password, passphrase string) installResult

InstallKey logs in to h as it does now (its shared connection, or a new one with password for a host that asks each time), appends the public key of the key credential credID to ~/.ssh/authorized_keys over SFTP, then logs in anew with the key alone to prove it works.

func (*App) Keychain

func (a *App) Keychain() (*keychain.Keychain, bool)

Keychain returns the keychain in use, and whether it is the system's.

func (*App) Mkdir

func (a *App) Mkdir(cn *conn, remote bool, name string) error

Mkdir makes a folder on one side of a files pane and lists it again.

func (*App) NewChat

func (a *App) NewChat(id int)

NewChat saves the pane's conversation and starts another.

func (*App) OpenAI

func (a *App) OpenAI(hostID string, at openAt, link int) (int, error)

OpenAI opens an assistant for hostID. link is a terminal pane to attach, or 0. It does not open an SSH connection. A tab has one: on a pane of a tab that has one already, it shows that one (reuse).

func (*App) OpenAIBelow

func (a *App) OpenAIBelow()

OpenAIBelow splits an assistant under the focused pane.

func (*App) OpenAIBeside

func (a *App) OpenAIBeside()

OpenAIBeside splits an assistant next to the focused pane, on its host. The link is that pane when it is a terminal.

func (*App) OpenChat

func (a *App) OpenChat(paneID int, id string)

OpenChat shows the pane's host's conversation id in the pane, to carry on, after saving the one it showed. The built-in agent takes it up where it was; an external agent keeps its own memory, so it starts afresh after it (forgot).

func (*App) OpenFiles

func (a *App) OpenFiles(hostID string, at openAt, from *conn) (int, error)

OpenFiles opens a files pane on a saved host, in a new tab or on a pane. from, when set, is the pane it was opened from (its host's connection, and secrets typed for it, serve every pane on the host).

func (*App) OpenFilesBeside

func (a *App) OpenFilesBeside()

OpenFilesBeside opens a files pane on the focused pane's host, to its right.

func (*App) OpenImport

func (a *App) OpenImport(m locales.Messages, path string)

OpenImport reads the config at path ("" ~/.ssh/config) and shows the preview.

func (*App) OpenLocalTerminal

func (a *App) OpenLocalTerminal() (int, error)

OpenLocalTerminal opens a shell of this computer under the focused pane, split from it in its tab, or in a new tab when there is none.

func (*App) OpenQuickConnect

func (a *App) OpenQuickConnect()

OpenQuickConnect shows the quick connect sheet.

func (*App) QuickConnect

func (a *App) QuickConnect(m locales.Messages) bool

QuickConnect connects to what the sheet holds, on a new temporary host.

func (*App) RestoreBackup

func (a *App) RestoreBackup(m locales.Messages) bool

RestoreBackup opens the sheet's backup with its password, off the UI thread, then merges it in.

func (*App) SaveCredForm

func (a *App) SaveCredForm(m locales.Messages) bool

SaveCredForm validates the credential sheet, saves the credential and moves its secrets into the keychain.

func (*App) SaveForm

func (a *App) SaveForm(m locales.Messages) bool

SaveForm validates the editor and saves the host.

func (*App) SaveFwdForm

func (a *App) SaveFwdForm(m locales.Messages) bool

SaveFwdForm validates the sheet, saves the forward and puts its password in the keychain; a forward running starts again with it.

func (*App) SaveGroup

func (a *App) SaveGroup(m locales.Messages) bool

SaveGroup makes or renames the group of the sheet.

func (*App) SaveProxyForm

func (a *App) SaveProxyForm(m locales.Messages) bool

SaveProxyForm validates the sheet, saves the proxy and puts its password in the keychain.

func (*App) SaveTempAs

func (a *App) SaveTempAs(id int)

SaveTempAs opens the host editor on the temporary host of the pane id, to keep it; its panes then show the saved host.

func (*App) SendAI

func (a *App) SendAI(id int, text string)

SendAI asks the pane's agent. Nothing is sent until the host's first-use notice has been confirmed.

func (*App) SetMaximized

func (a *App) SetMaximized(on bool)

SetMaximized says whether the window is maximized, for the button that maximizes or restores it.

func (*App) SetMinimized

func (a *App) SetMinimized(min bool)

SetMinimized pauses every collector while the window is minimised. Stop only cancels, so a server that never closes the channel cannot stall this caller. Probes reset on the next frame, because sessions live on the UI thread.

func (*App) SetWindow

func (a *App) SetWindow(w WindowControls)

SetWindow gives the title bar the window's buttons.

func (*App) Settings

func (a *App) Settings() settings.Settings

Settings returns the settings in effect.

func (*App) SplitFocused

func (a *App) SplitFocused(edge layout.Edge)

SplitFocused opens a terminal on the focused pane's host beside it.

func (*App) Start

func (a *App) Start()

Start applies the saved theme and language to the window.

func (*App) StartForward

func (a *App) StartForward(id string) error

StartForward starts a saved port forward on its host's connection, opening one without a shell when no pane has it. A local port in use is returned at once; the forward shows the error until stopped.

func (*App) StopAI

func (a *App) StopAI(id int)

StopAI cancels the pane's turn and any confirmation it is waiting on.

func (*App) StopAllAI

func (a *App) StopAllAI()

StopAllAI stops every AI pane.

func (*App) StopForward

func (a *App) StopForward(id string)

StopForward stops a port forward and the connections it relays.

func (*App) Store

func (a *App) Store() *assets.Store

Store returns the host store.

func (*App) SubmitPrompt

func (a *App) SubmitPrompt()

SubmitPrompt retains the non-UI entry point used by connection flows.

func (*App) SwitchToKey

func (a *App) SwitchToKey(hostID, credID, user string) error

SwitchToKey makes h log in with the credential credID, the key installed for user; it refuses when that would log in as anyone else.

func (*App) ToggleAI

func (a *App) ToggleAI()

ToggleAI closes the active tab's AI pane, or opens one beside the focused pane when it has none.

func (*App) ToggleFiles

func (a *App) ToggleFiles()

ToggleFiles closes the active tab's files pane, or opens one beside the focused pane when it has none.

func (*App) ToggleForward

func (a *App) ToggleForward(id string) error

ToggleForward starts a stopped forward and stops a started one.

func (*App) TogglePrivacy

func (a *App) TogglePrivacy() error

TogglePrivacy turns privacy mode on or off, and keeps it so.

func (*App) TrustHostKey

func (a *App) TrustHostKey() error

TrustHostKey adds the key asked about to known_hosts and connects again.

func (*App) Upload

func (a *App) Upload(cn *conn, paths []string, dir string)

Upload copies local files and folders into the remote folder dir, asking about those already there.

func (*App) View

func (a *App) View(c *ui.Context)

View builds the window.

type IconButton

type IconButton struct {
	Icon *icons.Icon
	// On is the icon while Active, as the "-fill" of a "-line" icon; nil
	// keeps Icon.
	On *icons.Icon
	// Label names the action, from the locale catalog.
	Label string
	// Active shows the button on: a toggle that is set, a view that shows.
	Active bool
	// Toggle reports Active to assistive technology as a toggle's state.
	Toggle bool
	// Disabled dims the button; it reports no clicks.
	Disabled bool
	// Danger tints the hover red, for a destructive action.
	Danger bool
	// Size is the icon's size; 0 is 16. Small is 14, for dense rows, Tiny
	// 12, for pane headers.
	Size float32
	// Badge is a count shown on the button's corner, as transfers to go;
	// "" shows none. BadgeDanger draws it red, for failures.
	Badge       string
	BadgeDanger bool
}

IconButton is the app's one icon-only button: every action shown as an icon (toolbar, tab, pane header, sidebar row, files toolbar) is one, and a text Button is kept only for the primary actions of a dialog or form. Label is required and localized: it is both the tooltip and the name assistive technology reads. The look follows the theme in use (light or dark): a circle, clear and muted at rest; a quiet tint of the brand accent (#1984FC) with the icon in the accent on hover, press and while Active; MyGo's focus ring in the accent's focus color from the keyboard.

func (IconButton) Clicked

func (b IconButton) Clicked(c *ui.Context, key string) bool

Clicked reports whether an enabled button was clicked; it saves callers from checking Disabled again.

func (IconButton) Show

func (b IconButton) Show(c *ui.Context, key string) ui.Element

Show builds the button under key and returns it, for Clicked.

type Platform

type Platform struct {
	// OpenPath opens a file in its default app; nil can't.
	OpenPath func(path string) error
	// CacheDir is where files opened in another app are copied, the
	// user's cache folder when "".
	CacheDir string
	// DataDir holds application metadata and encrypted credentials; it is required
	// unless ResolveStorage supplies the persistent storage paths.
	DataDir string
	Version string
	// Secrets stores only the random master key; failures keep the app locked.
	Secrets        keychain.Backend
	SecretLockPath string
	SecretScope    string
	StartupError   error
	ResolveStorage func() (StoragePaths, error)
	Updates        updater.Backend
	// SetTheme and SetLocale apply the user's choice to the window.
	SetTheme  func(theme.Mode)
	SetLocale func(tag string)
	// PickFile shows the system's open dialog; it may block.
	PickFile func(title string) (string, error)
	// PickFiles is PickFile choosing several files.
	PickFiles func(title string) ([]string, error)
	// SaveFile shows the system's save dialog, at path to begin with; it
	// may block. "" with no error is a cancel.
	SaveFile func(title, path string) (string, error)
	// Dial replaces net.Dialer, for tests.
	Dial func(ctx context.Context, network, addr string) (net.Conn, error)
	// HomeDir is where the local side of a files pane starts, and whose
	// .ssh/config the import reads; "" is the user's home.
	HomeDir string
	// LocalUser is the login name a host without one defaults to, as ssh
	// does; "" is the user running the app.
	LocalUser string
}

Platform is what the app needs from the system, including an explicit system keychain and a persistent data directory for encrypted secrets.

type StoragePaths

type StoragePaths struct{ DataDir, LockPath, Scope string }

StoragePaths keeps the canonical lifetime lock separate from overridden data.

type WindowControls

type WindowControls struct {
	Minimize, Maximize, Unmaximize, Close func()
}

WindowControls are the window's buttons, for a window whose view draws them itself (Linux, Windows, where the system's are hidden): main hands them over once the window is made. On macOS the traffic lights stay and there are none.

Jump to

Keyboard shortcuts

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