tui

package
v1.12.0 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2026 License: MIT Imports: 11 Imported by: ? 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 exposes the Tasks terminal UI as an embeddable Bubble Tea v2 component. Tasks continues to own configuration, persistence, rendering, and agent processes; a host owns placement, lifecycle, and any surrounding UI.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Binding

type Binding struct {
	Key       string
	CommandID string
	Context   FocusContext
}

Binding is a default Bubble Tea key name mapped to a Tasks command.

func ExportBindings

func ExportBindings() []Binding

ExportBindings projects the single Tasks shortcut registry for host keymaps.

type Command

type Command struct {
	ID              string
	FooterLabel     string
	Description     string
	Context         FocusContext
	FooterPriority  int
	DefaultBindings []string
}

Command is Tasks-owned command metadata for host palettes and footers.

func ExportCommands

func ExportCommands() []Command

ExportCommands projects the same registry for host palettes and footers, describing delegation with the BUILT-IN mode vocabulary. A host running against a store that configures its own set passes it to ExportCommandsWith, so its palette names the words that store will actually accept.

func ExportCommandsWith added in v1.11.0

func ExportCommandsWith(modes []string) []Command

ExportCommandsWith is ExportCommands for one delegation mode vocabulary, in the order it should be read. An empty list means the built-in set. It is []string rather than an interface because an embedder resolves the vocabulary from `tasks config --json` or the API's meta document, and neither hands back a Go type.

type ContextMetadata

type ContextMetadata struct {
	Name              FocusContext
	ConsumesTextInput bool
}

ContextMetadata describes a host key-routing context. Contexts backed by an input widget may contain only the global shortcut bindings.

func ExportContexts

func ExportContexts() []ContextMetadata

ExportContexts lists every stable Tasks host context, including input-only layers whose keystrokes are interpreted by their owning editor widget.

type EmbeddedOptions

type EmbeddedOptions struct {
	SessionNamespace string
	InitialView      View
	InitialContexts  []string
	// SuppressFooter is the blunt switch: Tasks paints NO footer at all. That
	// stack is not only the key hints — it is also the agent transcript, the
	// store-read banner, the flash, the filter and context-filter lines, and the
	// prompt input itself. A host that suppresses it owns rendering all of that,
	// and the prompt becomes an invisible caret unless the host draws one. Use it
	// only for a host that genuinely re-implements the whole footer.
	//
	// SuppressKeyHints is the fine switch, and is what a host building a unified
	// key-hint bar wants: Tasks drops ONLY its ordinary key-hint row, on the same
	// reading as SuppressQuit — the HOST owns that affordance — and keeps the
	// prompt, agent transcript, store-read banner, flash, and filter lines.
	//
	// SuppressFooter wins where both are set; there is nothing left to hint.
	//
	// SuppressViewKeyHints is the header counterpart, for a host that has taken
	// the number row (Sidecar switches tabs with 1-9). Tasks drops the "1 ".."6 "
	// prefixes from its view tab strip and keeps the view names, the Inbox badge,
	// and the current-view highlight. It is an ADVERTISEMENT switch only: 1-6
	// still jump views, exactly as SuppressQuit still acts on the quit key. It is
	// independent of the two footer switches. Hosts should surface the views in
	// their own chrome — prev_view/next_view stay bound to left/right arrows.
	SuppressFooter       bool
	SuppressKeyHints     bool
	SuppressViewKeyHints bool
	SuppressQuit         bool
	Theme                ThemeOptions
	Environment          map[string]string
}

EmbeddedOptions configures a host-owned Tasks component. SessionNamespace is required so embedding can never overwrite the standalone tasks-tui session. Environment is primarily a deterministic/test seam; nil snapshots os.Environ.

type FocusContext

type FocusContext string

FocusContext names the interaction layer currently consuming keys.

const (
	FocusList                FocusContext = "tasks-list"
	FocusDetail              FocusContext = "tasks-detail"
	FocusTaskEdit            FocusContext = "tasks-task-edit"
	FocusModal               FocusContext = "tasks-modal"
	FocusModalFilter         FocusContext = "tasks-modal-filter"
	FocusForm                FocusContext = "tasks-form"
	FocusFieldModal          FocusContext = "tasks-field-modal"
	FocusPicker              FocusContext = "tasks-picker"
	FocusContextPicker       FocusContext = "tasks-context-picker"
	FocusFilter              FocusContext = "tasks-filter"
	FocusPrompt              FocusContext = "tasks-prompt"
	FocusResponse            FocusContext = "tasks-response"
	FocusResponseDetail      FocusContext = "tasks-response-detail"
	FocusAgentActivity       FocusContext = "tasks-agent-activity"
	FocusAgentActivityFilter FocusContext = "tasks-agent-activity-filter"
)

type Model

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

Model is an embeddable Tasks TUI. It intentionally does not expose the internal model or store; hosts exchange only Bubble Tea messages and strings.

func NewEmbedded

func NewEmbedded(options EmbeddedOptions) (*Model, error)

NewEmbedded resolves the normal Tasks configuration and builds the same application, renderer, provider registry, and agent queue as tasks-tui.

func (*Model) ClearQuitRequest

func (m *Model) ClearQuitRequest()

ClearQuitRequest acknowledges a nested quit request without closing Tasks.

func (*Model) Close

func (m *Model) Close() error

Close saves the host-specific session and shuts down the Tasks agent queue. It is the correct call for the model the host actually presented, and it is safe to call more than once.

Close and Discard share one guard: the FIRST of the two to run wins and the other becomes a no-op returning that first call's error. A host must never rely on calling both to mean anything.

func (*Model) CommandAvailable

func (m *Model) CommandAvailable(commandID string) (bool, error)

CommandAvailable evaluates one exported command against the model's current focus and live selection. It distinguishes conditional commands that share a default key.

func (*Model) ConsumesTextInput

func (m *Model) ConsumesTextInput() bool

ConsumesTextInput reports whether printable keys belong to Tasks input.

func (*Model) Contexts

func (m *Model) Contexts() []string

Contexts reports the current presentation-only context filters.

func (*Model) CurrentSpatialFocus added in v1.12.0

func (m *Model) CurrentSpatialFocus() SpatialFocus

CurrentSpatialFocus reports the current visible list/detail stop.

func (*Model) CurrentView

func (m *Model) CurrentView() View

CurrentView reports the active Tasks view.

func (*Model) Discard added in v1.2.0

func (m *Model) Discard() error

Discard releases a model's resources WITHOUT persisting its session.

It exists because every model a host builds for one namespace shares a single session file. A host that builds models speculatively — a project switch, an epoch race, a build that lands after the user moved on — must still shut the agent queue of the model it throws away, but calling Close there would write the discarded model's stale view state over the live model's session. Discard is the call for a model that was never presented, or whose state the host has decided not to keep.

It shuts the agent queue and provider processes exactly as Close does, and it shares Close's guard: whichever runs first wins, each is idempotent, and the two are mutually exclusive.

func (*Model) FocusContext

func (m *Model) FocusContext() FocusContext

FocusContext is the stable Tasks interaction context for host key routing.

func (*Model) Init

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

Init starts the Tasks file-watch tick and loads the first read model.

func (*Model) Invoke

func (m *Model) Invoke(commandID string) (tea.Cmd, error)

Invoke executes one available exported command by stable ID, without replaying a possibly ambiguous default key.

func (*Model) LoadError added in v1.2.0

func (m *Model) LoadError() error

LoadError reports a real failure to read the task store, as of the most recent Tasks read. It is nil when Tasks read the store successfully — which includes a store that is genuinely empty, and a store file that does not exist yet inside an existing tasks directory (a first run).

It is non-nil when the store cannot be read or cannot be trusted: unreadable permissions, a path that is a directory, a file that is not valid UTF-8 or not valid Tasks JSONL, or a tasks directory that does not exist at all. A host uses it to distinguish "Tasks is fine and there is nothing to do" from "Tasks could not read anything" and to render its own diagnostic; Tasks also renders its own banner in the non-suppressed footer.

The value only becomes meaningful once the model has performed a read, so call it after Init's command has run or after any Update.

func (*Model) QuitRequested

func (m *Model) QuitRequested() bool

QuitRequested reports a nested quit request for the host to handle.

func (*Model) SetSpatialFocus added in v1.12.0

func (m *Model) SetSpatialFocus(focus SpatialFocus) bool

SetSpatialFocus focuses one visible stop directly. It refuses unknown, hidden, or currently input/overlay-owned targets without changing focus.

func (*Model) TabOwnsFocus added in v1.12.0

func (m *Model) TabOwnsFocus() bool

TabOwnsFocus reports whether an input or overlay must receive Tab. A host with an outer focus ring may intercept Tab only when this returns false.

func (*Model) Update

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

Update passes a Bubble Tea v2 message into Tasks. Nested quit never returns tea.Quit; use QuitRequested to observe a non-suppressed request.

func (*Model) View

func (m *Model) View(width, height int) string

View renders Tasks at the host's allotted size without alternate-screen or mouse-mode ownership leaking into the host.

func (*Model) VisibleSpatialFocusStops added in v1.12.0

func (m *Model) VisibleSpatialFocusStops() []SpatialFocusStop

VisibleSpatialFocusStops reports Tasks' visible list/detail focus ring in visual order, with geometry from the same sampled layout used to render.

func (*Model) Warnings

func (m *Model) Warnings() []string

Warnings returns non-fatal messages produced by normal Tasks configuration.

type Rect added in v1.12.0

type Rect struct {
	X, Y          int
	Width, Height int
}

Rect is one half-open rectangle in 0-based terminal cells.

type SpatialFocus added in v1.12.0

type SpatialFocus string

SpatialFocus names one stable region in Tasks' rendered list/detail layout. It is separate from FocusContext, which reports input and overlay ownership.

const (
	SpatialFocusList   SpatialFocus = "list"
	SpatialFocusDetail SpatialFocus = "detail"
)

type SpatialFocusStop added in v1.12.0

type SpatialFocusStop struct {
	ID   SpatialFocus
	Rect Rect
}

SpatialFocusStop is one visible host focus destination. Stops are returned in current visual order and their rectangles are taken from the exact layout Tasks renders and hit-tests.

type ThemeOptions

type ThemeOptions struct {
	Name          string
	Colors        map[string]string
	ReplaceColors bool
}

ThemeOptions are Tasks semantic theme values, independent of any host UI.

Colors is an OVERLAY by default: each host-supplied slot wins, every slot the host does not name keeps the value the user configured in their own Tasks config, and anything neither names falls back to the named base theme. A host can therefore align three slots with its own chrome without silently destroying the palette its user chose.

ReplaceColors opts into the older wholesale behaviour: the host's map becomes the complete set of overrides and the user's configured colors are dropped. It exists for a host that must guarantee an exact palette; it is never the default, because discarding user configuration is not a reasonable default.

type View

type View string

View is a stable Tasks view key used for initial presentation only.

const (
	ViewAgenda    View = "agenda"
	ViewNext      View = "next"
	ViewQuadrants View = "quadrants"
	ViewInbox     View = "inbox"
	ViewProjects  View = "projects"
	ViewOutline   View = "outline"
)

Jump to

Keyboard shortcuts

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