apptypes

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const UngroupedGroup = "ungrouped"

UngroupedGroup is the reserved group name cais shows for every service that carries no profiles: key. It is spelled the way a Compose profile would be, and rendered verbatim like any other group name, so the groups list needs no special case for it.

Reserved on both counts: the name cannot be given to a real group (see groupnamemodal), and the group is read-only in the UI - there is no profile tag behind it, and its membership is derived rather than chosen. Every one of those decisions is a comparison against this constant, which is why there is no "synthetic" flag on the list item.

Variables

View Source
var PageLabels = map[string]string{
	"Home":          "Groups",
	"Services":      "Services",
	"Compose Files": "Files",
}

PageLabels maps page IDs to their display labels in the main menu. Page IDs are preserved for all state comparisons; only the label changes.

View Source
var PageTitles = []string{
	"Home",
	"Services",
	"Compose Files",
	"Backups",
}

PageTitles is the ordered list of page IDs used for navigation state.

Functions

func FormatMemUsage

func FormatMemUsage(memUsage, memPerc string) string

FormatMemUsage formats memory usage as "Usage (Percent)", e.g., "21.71MiB / 31.02GiB" + "0.07%" -> "21.71MiB (0.07%)". If percent is empty, returns just the usage part (before "/").

It takes docker's raw strings, and is the one copy: the service list row and the details panel's runtime table both render through it, so the two never drift apart. Applying it twice is not idempotent - the second pass finds no "/" to split on and appends the percent again - so call it at render time and keep the raw values in the fields.

func PageForShortcut

func PageForShortcut(letter string) string

PageForShortcut returns the page a chord letter jumps to, or "" if the letter is not a page chord. When two labels share a first letter the first page wins - acceptable for an alias, since the digits are the primary scheme and are unambiguous.

func PageLabel

func PageLabel(page string) string

PageLabel returns a page's display label, falling back to the page ID.

func PageShortcut

func PageShortcut(page string) string

PageShortcut returns the letter of a page's alt+<letter> chord: the first letter of its display label, lowercased.

The chord is an alias. The digits are the primary page scheme, rendered on the tabs themselves; the chord stays for the terminals that send Option as Alt. It is still derived from the label rather than listed in a table, because a hand-maintained table drifts. Two labels may now share a first letter - the digits are unambiguous, and the alias simply resolves to the first matching page.

func SumContainerMemory

func SumContainerMemory(containers []DockerContainer) (int64, int)

SumContainerMemory adds the used side of every container's MemUsage. Returns the total used bytes and how many containers reported one.

Types

type CheckableServiceItem

type CheckableServiceItem struct {
	Name    string
	Checked bool
}

CheckableServiceItem is a list.Item for the service-selection checklist shown when creating a group.

func (CheckableServiceItem) FilterValue

func (s CheckableServiceItem) FilterValue() string

func (CheckableServiceItem) Title

func (s CheckableServiceItem) Title() string

type ComposeFileItem

type ComposeFileItem struct {
	Name   string
	Active bool
}

ComposeFileItem is a list.Item for the file picker on the Files page. Active marks the file currently loaded, so the picker can say which one the user is already looking at.

func (ComposeFileItem) FilterValue

func (s ComposeFileItem) FilterValue() string

func (ComposeFileItem) Title

func (s ComposeFileItem) Title() string

type ContainerListItem

type ContainerListItem DockerContainer

func (ContainerListItem) Description

func (i ContainerListItem) Description(isSelected bool) string

func (ContainerListItem) FilterValue

func (i ContainerListItem) FilterValue() string

func (ContainerListItem) Title

func (i ContainerListItem) Title() string

type DockerContainer

type DockerContainer struct {
	Command   string
	CreatedAt string
	// docker compose ps names this field "Health". Without the tag, the
	// field never binds and the HEALTH column reads "-" for every
	// container, healthy ones included.
	HealthStatus string `json:"Health"`
	ID           string
	Image        string
	Labels       string
	LocalVolumes string
	Mounts       string
	Names        string
	Networks     string
	Platforms    struct {
		// contains filtered or unexported fields
	}
	Ports      string
	RunningFor string
	Service    string
	Size       string
	State      string
	Status     string

	// Runtime stats from `docker stats --no-stream`. These are populated
	// by GetContainerStats, not by docker compose ps.
	MemPerc  string // e.g. "0.07%"
	MemUsage string // e.g. "21.71MiB / 31.02GiB"
	NetIO    string // e.g. "3.22MB / 4.7kB"
	BlockIO  string // e.g. "70.3MB / 43.7MB"
	CPUPerc  string // e.g. "0.00%"
	PIDs     string // e.g. "19"
}

type GroupListItem

type GroupListItem struct {
	Name    string
	Running int
	Total   int
}

GroupListItem is one row in the groups list. It carries the group's name plus how many of its member services are running, so the row can render a status dot (green when fully running, amber half-circle when mixed).

func (GroupListItem) FilterValue

func (s GroupListItem) FilterValue() string

func (GroupListItem) Title

func (s GroupListItem) Title() string

type ListItem

type ListItem struct {
	ItemTitle, ItemDesc string
}

func (ListItem) Description

func (i ListItem) Description() string

func (ListItem) FilterValue

func (i ListItem) FilterValue() string

func (ListItem) Title

func (i ListItem) Title() string

type ServiceListItem

type ServiceListItem struct {
	Service types.ServiceConfig
	// Status reflects the docker container state for this service:
	// "running", "stopped", or "" (unknown / no container yet). Set by
	// ServicesListModel when a GetRunningContainersMsg arrives.
	Status string
	// MemUsage is the real-time memory usage from docker stats, exactly as
	// docker reports it: "21.71MiB / 31.02GiB". Empty when stats are
	// unavailable. Store it raw - FormatMemUsage is applied once, at render
	// time, and formatting it on the way in instead would double-apply the
	// percent suffix.
	MemUsage string
	// MemPerc is the memory usage percentage from docker stats, e.g. "0.07%"
	MemPerc string
}

func (ServiceListItem) Description

func (s ServiceListItem) Description(isActive bool) string

func (ServiceListItem) FilterValue

func (s ServiceListItem) FilterValue() string

func (ServiceListItem) StatusPill

func (s ServiceListItem) StatusPill() string

StatusPill returns a styled pill showing the service's current status. It uses the same visual language as the group's statusPill in GroupDetailsPanel, but for a single service.

func (ServiceListItem) Title

func (s ServiceListItem) Title() string

type ThemeItem

type ThemeItem struct {
	Name   string
	Active bool
}

ThemeItem is a list.Item for the theme picker modal. Active marks the theme that was in effect when the modal opened, so the user can see which one they started from and Esc can restore it.

func (ThemeItem) FilterValue

func (t ThemeItem) FilterValue() string

func (ThemeItem) Title

func (t ThemeItem) Title() string

Jump to

Keyboard shortcuts

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