tui

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2026 License: Apache-2.0 Imports: 60 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 tui is conch's Bubble Tea client: a tree of machines, projects, branches and agents beside the selected pane, branch changes or project.

Index

Constants

View Source
const AppWindowEnv = "CONCH_APP_WINDOW"

AppWindowEnv is the variable `conch app` sets in the window it opens.

Variables

View Source
var AppShortcuts = func() []AppShortcut {
	keys := []AppShortcut{
		{"", "t", "c"},
		{"", "w", "x"},
		{"shift", "w", "&"},
		{"", "d", "%"},
		{"shift", "d", "\""},
		{"shift", "]", "n"},
		{"shift", "[", "p"},
		{"", "]", "o"},
		{"", "[", ";"},
		{"shift", "enter", "z"},
		{"", "k", "/"},
		{"", ".", "!"},
		{"", "/", "?"},
		{"", "n", "N"},
		{"alt", "up", "\x1b[A"},
		{"alt", "down", "\x1b[B"},
		{"alt", "right", "\x1b[C"},
		{"alt", "left", "\x1b[D"},
	}
	for d := '1'; d <= '9'; d++ {
		keys = append(keys, AppShortcut{"", string(d), string(d)})
	}
	return keys
}()

Functions

func AutopilotPolicy added in v0.1.9

func AutopilotPolicy(v config.VerifyCfg) proto.AutopilotPolicy

AutopilotPolicy is the policy a server acts on from [verify]: what the TUI hands every server, and `conch autopilot push` for a window that is not the TUI (Conch.app), so it is one rule wherever it is sent from.

func MatchSpans added in v0.1.9

func MatchSpans(plain, q string) [][2]int

MatchSpans lists the [from, to) cells where q occurs in plain text, with the same smart case as the server's search: a query without capitals matches either case.

func RestartEnv

func RestartEnv(model tea.Model) []string

RestartEnv is the environment for the TUI restarted from model: it updates remote machines, except those unticked for this update.

func RestartRequested

func RestartRequested(model tea.Model) bool

RestartRequested reports whether the TUI quit to restart onto a new build.

func SettingsChoices added in v0.1.9

func SettingsChoices(agents []string) configweb.Choices

SettingsChoices is what the settings page offers: the themes and accents this build draws, the sandbox providers it knows, and agents (the four supported ones when none are given). conch config web passes none, since it has no machine to ask.

func TerminalColors added in v0.1.9

func TerminalColors(theme, accent string) (bg, fg, cursor, selection string)

TerminalColors are what a terminal conch configures for itself should draw with under a theme (and an accent override, as applyTheme takes it): its background and text, the cursor in the accent, and a selection in the theme's dim selection colour. `conch app` writes them into the window it opens, so that window is the theme rather than a terminal's stock black with conch's colours on it.

func UserThemeProblems added in v0.1.9

func UserThemeProblems() []string

UserThemeProblems says what was wrong with the theme files left out at the last reading, for the status bar and conch doctor.

func UserThemesDir added in v0.1.9

func UserThemesDir() string

UserThemesDir is where conch looks for themes of your own.

func WholeSequences added in v0.1.9

func WholeSequences(f *os.File) io.Reader

WholeSequences wraps the terminal conch reads keys and mouse from so that no read ends partway through an escape sequence.

Bubble Tea reads 256 bytes at a time and parses each read on its own. A fast wheel or a moving pointer fills that buffer with mouse reports, and when one is cut at the edge — `ESC [ < 6 5 ; 1 3` | `0 ; 4 3 M` — it reports the halves as keys: alt+[ and then the runes `<65;130;43M`. conch forwards keys to the focused pane, so the shell there printed `65;130;43M` at its prompt, a few at a time, while somebody scrolled. Holding the unfinished tail back for the next read gives Bubble Tea the whole report.

It is still the terminal (Fd, Name, Write, Close are the file's), so Bubble Tea puts it in raw mode and waits on it as it would on stdin.

Types

type AppShortcut added in v0.1.9

type AppShortcut struct {
	Mods string // "", "shift" or "alt", beside ⌘
	Key  string // a letter, digit, punctuation, or enter/up/down/left/right
	Send string // what follows the prefix
}

AppShortcut is a ⌘ shortcut in conch's own window: the terminal sends conch's prefix and then Send, so it does exactly what that key does in any terminal and the TUI needs nothing of its own to take it. These are the shortcuts every macOS application has (⌘T a tab, ⌘W close, ⌘1–9 a tab), put on what conch calls the same thing, and they replace the terminal's own — which would make a tab or a split of the *terminal*, outside conch, where nothing of conch's can see it. cmd/conch writes them into the terminal's configuration; the palette names them.

type Model

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

Model is the root Bubble Tea model.

func New

func New(local *client.Client, cfg config.Config) Model

New builds the TUI around a connected local client. Saved remote machines connect in the background once the program starts.

func (Model) Doctor added in v0.1.9

func (m Model) Doctor(run func() []doctor.Check) Model

Doctor gives the TUI the checks `conch doctor` runs.

func (Model) Init

func (m Model) Init() tea.Cmd

func (Model) LaunchedIn added in v0.1.7

func (m Model) LaunchedIn(dir string) Model

LaunchedIn records the folder conch was started in, for the first list of the local machine's projects to place the tree by. The TUI's own tests never call it: they run inside conch's repository. A TUI restarted onto a new build keeps where you were instead.

func (Model) Update

func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd)

Update handles a message, then schedules clearing the status bar message when one is showing.

func (Model) View

func (m Model) View() string

View renders the whole screen, as the terminal may be given it (safeView).

func (Model) Warn added in v0.1.3

func (m Model) Warn(text string) Model

Init starts every machine's connection work. Warn puts a message on screen as soon as the TUI starts — settings that could not be read, say. It is shown like any other error, and fades.

Jump to

Keyboard shortcuts

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