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 ¶
- type Binding
- type Command
- type ContextMetadata
- type EmbeddedOptions
- type FocusContext
- type Model
- func (m *Model) ClearQuitRequest()
- func (m *Model) Close() error
- func (m *Model) CommandAvailable(commandID string) (bool, error)
- func (m *Model) ConsumesTextInput() bool
- func (m *Model) Contexts() []string
- func (m *Model) CurrentView() View
- func (m *Model) Discard() error
- func (m *Model) FocusContext() FocusContext
- func (m *Model) Init() tea.Cmd
- func (m *Model) Invoke(commandID string) (tea.Cmd, error)
- func (m *Model) LoadError() error
- func (m *Model) QuitRequested() bool
- func (m *Model) Update(message tea.Msg) (*Model, tea.Cmd)
- func (m *Model) View(width, height int) string
- func (m *Model) Warnings() []string
- type ThemeOptions
- type View
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
Description string
Context FocusContext
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.
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
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" 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 ¶
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 ¶
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 ¶
ConsumesTextInput reports whether printable keys belong to Tasks input.
func (*Model) CurrentView ¶
CurrentView reports the active Tasks view.
func (*Model) Discard ¶ added in v1.2.0
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) Invoke ¶
Invoke executes one available exported command by stable ID, without replaying a possibly ambiguous default key.
func (*Model) LoadError ¶ added in v1.2.0
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 ¶
QuitRequested reports a nested quit request for the host to handle.
func (*Model) Update ¶
Update passes a Bubble Tea v2 message into Tasks. Nested quit never returns tea.Quit; use QuitRequested to observe a non-suppressed request.
type ThemeOptions ¶
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.