Help us shape the future of Go! Take the 2026 Go Developer Survey

ui

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2026 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Overview

Package ui implements sou's terminal interface.

The package is organised as an application shell (header, tab strip, status bar) drawn around one of a small number of views: the layer list, the file browser and a text pager used for file previews, the image manifest and the image config. Domain logic lives in the container package; everything here is presentation and interaction.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AbsoluteTime

func AbsoluteTime(t time.Time) string

AbsoluteTime renders a timestamp for detail panels, or an empty string when the image did not record one.

func CommandVerb

func CommandVerb(formatted string) string

CommandVerb returns the leading instruction of a formatted command (RUN, COPY, ENV, ...) so it can be colour-coded, or an empty string when the entry does not start with one.

func DisplayPath

func DisplayPath(p string) string

DisplayPath renders a browser path as an absolute path.

func FormatCommand

func FormatCommand(cmd string) string

FormatCommand turns a raw history entry into something readable.

Build tooling wraps every instruction in shell boilerplate: BuildKit appends "# buildkit", the classic builder prefixes metadata-only instructions with "/bin/sh -c #(nop)" and shell instructions with "/bin/sh -c". Stripping that noise is what makes the layer list scannable.

func FormatCount

func FormatCount(n int) string

FormatCount renders a cardinal number with thousands separators.

func FormatSize

func FormatSize(size int64) string

FormatSize renders a byte count the way a developer reads it: three significant figures and a familiar unit.

func Pluralize

func Pluralize(n int, singular, plural string) string

Pluralize renders a count with a unit, choosing the right form.

func RelativeTime

func RelativeTime(t time.Time) string

RelativeTime renders a timestamp as an approximate age. It returns an empty string for the zero time, which container images use for "unknown".

func ShortDigest

func ShortDigest(digest string, n int) string

ShortDigest shortens a "sha256:abcdef..." digest for narrow contexts.

Types

type Density

type Density int

Density selects the amount of information a row can show. It is resolved per pane rather than per frame, because a pane can be much narrower than the terminal it sits in.

const (
	// DensityMinimal is for very narrow terminals: identity and size only.
	DensityMinimal Density = iota
	// DensityCompact adds an age column.
	DensityCompact
	// DensityFull adds proportional size bars and permissions.
	DensityFull
)

type Layout

type Layout struct {
	Width  int
	Height int

	ShowTabs       bool
	ShowBottomRule bool

	// ContentTop is the zero-based screen row the main content starts on.
	ContentTop    int
	ContentHeight int
	ContentWidth  int
}

Layout is the resolved geometry of one frame. It is computed by a pure function from the terminal size alone, which keeps rendering, hit testing for the mouse and the layout tests all working from the same numbers.

func ComputeLayout

func ComputeLayout(w, h int) Layout

ComputeLayout resolves the frame geometry for a terminal of w x h cells.

func (Layout) RowToIndex

func (l Layout) RowToIndex(row, offset, headerRows, total int) (int, bool)

RowToIndex maps a screen row to an index in a scrolled list, reporting ok=false when the row falls outside the content area. It is what makes mouse clicks land on the right item.

func (Layout) Split

func (l Layout) Split(preferred float64) (list, pane int, ok bool)

Split divides the content area into a primary list and a secondary detail pane. It reports ok=false when the terminal is too narrow to carry both, in which case the list takes the full width.

type Mode

type Mode int

Mode is the screen currently in front of the user.

const (
	// LayerMode lists the layers of the image.
	LayerMode Mode = iota
	// FileMode browses the filesystem of one extracted layer.
	FileMode
	// ViewMode shows the contents of a single file.
	ViewMode
	// LoadingMode covers layer extraction, which reports progress.
	LoadingMode
	// ManifestMode shows the image manifest.
	ManifestMode
	// ConfigMode shows the image config.
	ConfigMode
	// PullingMode covers resolving and, if needed, pulling the image.
	PullingMode
	// ErrorMode is the terminal state after the image could not be loaded.
	ErrorMode
)

type Model

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

Model is the root Bubble Tea model.

func NewModel

func NewModel(ref string) (Model, tea.Cmd)

NewModel builds the root model for an image reference.

The returned command performs the initial image load. It is also returned by Init, whichever runs first; callers that drive the model by hand can use the returned command instead of calling Init.

func (*Model) Init

func (m *Model) Init() tea.Cmd

Init starts the initial image load.

func (*Model) Update

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

Update handles one message.

func (*Model) View

func (m *Model) View() string

View renders one frame. The frame is always exactly Height rows tall: the shell contributes a fixed number of rows and every view is asked to fill the remainder precisely, so nothing can ever push the status bar off screen.

type Whiteout

type Whiteout struct {
	// Name is the path the marker deletes.
	Name string
	// Opaque marks a directory whose entire previous content is hidden.
	Opaque bool
}

Whiteout describes an overlay filesystem deletion marker.

func ParseWhiteout

func ParseWhiteout(name string) (Whiteout, bool)

ParseWhiteout recognises the overlayfs deletion markers that appear inside image layers, so that the browser can present them as deletions rather than as oddly named files.

Directories

Path Synopsis
Package components holds the reusable presentation primitives of the sou interface: text measurement and fitting helpers, the application shell (header, tab strip, status bar), and the standard empty, error and loading states.
Package components holds the reusable presentation primitives of the sou interface: text measurement and fitting helpers, the application shell (header, tab strip, status bar), and the standard empty, error and loading states.
Package theme holds sou's design system: a semantic colour palette, the glyph set used to draw the interface and the pre-built lipgloss styles that every view renders through.
Package theme holds sou's design system: a semantic colour palette, the glyph set used to draw the interface and the pre-built lipgloss styles that every view renders through.

Jump to

Keyboard shortcuts

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