Documentation
¶
Overview ¶
Package tui is the Go TUI's shell: the Bubble Tea root model, the screen geometry, view switching, the task list and its selection, and the right panel that shows task and project details.
It is a REBUILD of lib/tui/app.rb on Bubble Tea, not a transliteration. The Ruby terminal event loop, its raw-mode key decoder, its paint-dirty bookkeeping and its winsize polling are all things Bubble Tea already owns, so none of them are ported. What IS ported is everything Bubble Tea has no opinion about: which rows a view emits, how selection survives a refresh, what the panel says, and how the screen is divided.
Everything in this file's neighbourhood is deliberately pure. Row building, geometry, panel scrolling and detail content are functions from values to values, so they are tested by calling them rather than by scraping a terminal.
Index ¶
- Constants
- Variables
- func AgentAvailability(env determinism.Env, conf llm.Config, dataDir string) func(agent.Entry) bool
- func AgentFactory(paths config.Paths, env determinism.Env, conf llm.Config, ...) func(agent.Entry) (agent.Adapter, error)
- func EmbeddedSessionPath(env determinism.Env, namespace string) string
- func ExportMarkdown(item store.Item, notes []string) string
- func ExportReference(item store.Item) string
- func FormatTemporal(value any) string
- func KeySequence(message tea.KeyPressMsg) string
- func MinimumEditTerminalHeight(footerRows int) int
- func MinimumEditTerminalWidth() int
- func NormalizeContextFilters(values []string) []string
- func ParseTemporal(text string, today temporal.Date, context temporal.Context) (any, error)
- func SaveEmbeddedSession(state SessionState, env determinism.Env, namespace string) error
- func SaveSession(state SessionState, env determinism.Env) error
- func SessionPath(env determinism.Env) string
- func ViewKeys() []string
- func ZoneIdentifiers() []string
- type ActionPalette
- func (a *ActionPalette) Fail(message string)
- func (a *ActionPalette) HandleKey(key string) PaletteOutcome
- func (a *ActionPalette) Hit(rowOffset int) PaletteOutcome
- func (a *ActionPalette) Move(delta int) PaletteOutcome
- func (a *ActionPalette) Paste(text string) PaletteOutcome
- func (a *ActionPalette) Picker() *ChoicePicker
- func (a *ActionPalette) ReturnMode() ReturnMode
- func (a *ActionPalette) TargetID() string
- type AgentAdapter
- func (a *AgentAdapter) Available() bool
- func (a *AgentAdapter) Cancel() error
- func (a *AgentAdapter) ExitStatus() (int, bool)
- func (a *AgentAdapter) Output() string
- func (a *AgentAdapter) ProcessStatus() agent.ProcessStatus
- func (a *AgentAdapter) Pump() (bool, error)
- func (a *AgentAdapter) Start(prompt, model string) error
- func (a *AgentAdapter) Success() bool
- type AgentEntry
- type BuildRequest
- type ChoicePicker
- func (p *ChoicePicker) Current() *PickerOption
- func (p *ChoicePicker) CursorIndex() int
- func (p *ChoicePicker) Error() string
- func (p *ChoicePicker) Fail(message string)
- func (p *ChoicePicker) HandleKey(key string) PickerResult
- func (p *ChoicePicker) Hit(rowOffset int) PickerResult
- func (p *ChoicePicker) Input() string
- func (p *ChoicePicker) InputCursor() int
- func (p *ChoicePicker) Move(delta int) PickerResult
- func (p *ChoicePicker) Options() []PickerOption
- func (p *ChoicePicker) Paste(text string) PickerResult
- func (p *ChoicePicker) Popup(styler Styler, maxWidth, maxHeight int, inlineInput func(string, int) string) []string
- func (p *ChoicePicker) RefreshOptions(options []PickerOption, selection []string)
- func (p *ChoicePicker) Results() []PickerOption
- func (p *ChoicePicker) Selected(id string) bool
- func (p *ChoicePicker) SelectionChanged() bool
- func (p *ChoicePicker) Staged() []string
- func (p *ChoicePicker) Title() string
- func (p *ChoicePicker) ViewportStart() int
- type ChoicePickerOptions
- type ContextOutcome
- type ContextPalette
- func (c *ContextPalette) CurrentFilters() []string
- func (c *ContextPalette) HandleKey(key string) ContextOutcome
- func (c *ContextPalette) Hit(rowOffset int) ContextOutcome
- func (c *ContextPalette) Move(delta int) ContextOutcome
- func (c *ContextPalette) Paste(text string) ContextOutcome
- func (c *ContextPalette) Picker() *ChoicePicker
- func (c *ContextPalette) RefreshOptions(contexts, current []string)
- type DetailContent
- type EditSnapshot
- type EditorConfirmationPrompt
- type EditorConflict
- type EditorOutcome
- type EditorStatus
- type ErrIllegalTransition
- type FormRender
- type FormRenderRequest
- type Group
- type IntakeCounts
- type LayoutRequest
- type Modal
- func (m *Modal) AllLines() []string
- func (m *Modal) Filter() string
- func (m *Modal) Filterable() bool
- func (m *Modal) Kind() ModalKind
- func (m *Modal) Lines() []string
- func (m *Modal) Replace(title string, lines []string, filterGroups []string)
- func (m *Modal) Scroll() int
- func (m *Modal) ScrollHalf(direction, bodyHeight int)
- func (m *Modal) ScrollLine(delta, bodyHeight int)
- func (m *Modal) ScrollPage(direction, bodyHeight int)
- func (m *Modal) SetFilter(query string)
- func (m *Modal) Title() string
- func (m *Modal) View(styler Styler, bodyHeight int, filterLine string) ModalView
- func (m *Modal) Viewport(bodyHeight int) int
- func (m *Modal) Width(styler Styler) int
- type ModalContent
- type ModalKind
- type ModalOptions
- type ModalView
- type Mode
- type Model
- func (m *Model) ActionPalette() *ActionPalette
- func (m *Model) AgentEntries() []AgentEntry
- func (m *Model) ApplyContextFilter(contexts []string)
- func (m *Model) ArchiveSweep()
- func (m *Model) BumpPriority(delta int)
- func (m *Model) CancelQueuedAgentRequests()
- func (m *Model) CaptureIntoProject()
- func (m *Model) ClearQuitRequest()
- func (m *Model) CloseActionPalette()
- func (m *Model) CloseContextPalette()
- func (m *Model) CloseForm(success bool)
- func (m *Model) CloseModal()
- func (m *Model) ClosePanel()
- func (m *Model) CloseTaskEdit(message string)
- func (m *Model) CollapseAll()
- func (m *Model) CollapseSelected()
- func (m *Model) CommandAvailable(id string) (bool, error)
- func (m *Model) CompleteSelected()
- func (m *Model) ConfirmArchiveProject(project *taskquery.ProjectView)
- func (m *Model) ConfirmCompleteProject(project *taskquery.ProjectView)
- func (m *Model) ConsumesTextInput() bool
- func (m *Model) ContextFilters() []string
- func (m *Model) ContextPalette() *ContextPalette
- func (m *Model) CurrentEntry() AgentEntry
- func (m *Model) CurrentItem() *store.Item
- func (m *Model) CurrentProject() *taskquery.ProjectView
- func (m *Model) CurrentView() string
- func (m *Model) CyclePanelMode(delta int)
- func (m *Model) CycleView(delta int)
- func (m *Model) DecideProposal(action application.ProposalAction)
- func (m *Model) DeferSelected()
- func (m *Model) DelegateSelected()
- func (m *Model) DeleteSelected()
- func (m *Model) DismissResponse()
- func (m *Model) ExpandAll()
- func (m *Model) ExpandSelected()
- func (m *Model) Flash(message string)
- func (m *Model) FlashMessage() string
- func (m *Model) FocusContext() string
- func (m *Model) FocusPrompt()
- func (m *Model) Footer() []string
- func (m *Model) Form() *QuickForm
- func (m *Model) HandleMouse(event tea.MouseMsg) bool
- func (m *Model) Header(width int) string
- func (m *Model) Init() tea.Cmd
- func (m *Model) InvokeCommand(id string) (tea.Cmd, error)
- func (m *Model) Layout() ScreenLayout
- func (m *Model) LinkOpener() Opener
- func (m *Model) Modal() *Modal
- func (m *Model) ModalFilterInput() string
- func (m *Model) ModalStartFilter()
- func (m *Model) Mode() Mode
- func (m *Model) MouseEnabled() bool
- func (m *Model) OpenActionPalette()
- func (m *Model) OpenAgentActivity()
- func (m *Model) OpenContextPalette()
- func (m *Model) OpenDatePopup()
- func (m *Model) OpenDetail()
- func (m *Model) OpenHelp()
- func (m *Model) OpenLink()
- func (m *Model) OpenModal(content ModalContent, kind ModalKind, filterable bool)
- func (m *Model) OpenRecurPopup()
- func (m *Model) OpenTaskCount() int
- func (m *Model) Overlay() *OverlayBox
- func (m *Model) Panel() *RightPanel
- func (m *Model) PasteRef()
- func (m *Model) PromptLines(width int) []string
- func (m *Model) PromptPaste(text string)
- func (m *Model) PromptText() string
- func (m *Model) PumpQueue()
- func (m *Model) Queue() *agent.Queue
- func (m *Model) QuitRequested() bool
- func (m *Model) ReadModel() *application.ReadModel
- func (m *Model) RedoLast()
- func (m *Model) Refresh()
- func (m *Model) RefreshRows()
- func (m *Model) RenameProject()
- func (m *Model) Render() string
- func (m *Model) ReorderSelected(action string)
- func (m *Model) ResizePanel(delta int)
- func (m *Model) ResponseLines() []string
- func (m *Model) Rows() []Row
- func (m *Model) Save()
- func (m *Model) ScrollResponse(delta int)
- func (m *Model) Selected() int
- func (m *Model) SelectedID() string
- func (m *Model) SessionState() SessionState
- func (m *Model) SetActionPalette(palette *ActionPalette)
- func (m *Model) SetContextPalette(palette *ContextPalette)
- func (m *Model) SetForm(form *QuickForm)
- func (m *Model) SetModal(modal *Modal)
- func (m *Model) SetMode(target Mode) error
- func (m *Model) SetTaskEditor(editor *TaskEditorSession)
- func (m *Model) SetWorkRefSelected()
- func (m *Model) ShowUnsupportedSchemaNotice()
- func (m *Model) StartTaskEdit(focus string)
- func (m *Model) SubmitPrompt()
- func (m *Model) SwitchView(view string)
- func (m *Model) TabStrip(width int) string
- func (m *Model) TaskEditor() *TaskEditorSession
- func (m *Model) ToggleDeferred()
- func (m *Model) ToggleModel()
- func (m *Model) UndoLast()
- func (m *Model) Update(message tea.Msg) (tea.Model, tea.Cmd)
- func (m *Model) View() tea.View
- func (m *Model) YankMarkdown()
- func (m *Model) YankRef()
- type Opener
- type Options
- type OverlayBox
- type PaletteOutcome
- type PanelView
- type PickerOption
- type PickerOptionKind
- type PickerResult
- type PickerResultKind
- type PlainStyler
- type QuickForm
- func (q *QuickForm) Cursor() int
- func (q *QuickForm) Error() string
- func (q *QuickForm) HandleKey(key string) QuickFormResult
- func (q *QuickForm) Hint(width int) string
- func (q *QuickForm) Paste(text string) QuickFormResult
- func (q *QuickForm) Popup(styler Styler, maxWidth, maxHeight int) FormRender
- func (q *QuickForm) SetText(text string)
- func (q *QuickForm) Submit() QuickFormResult
- func (q *QuickForm) Text() string
- func (q *QuickForm) Title() string
- type QuickFormKind
- type QuickFormOptions
- type QuickFormResult
- type ReturnMode
- type RightPanel
- func (p *RightPanel) FocusRow(row int)
- func (p *RightPanel) Replace(title, identity string, lines []string) *RightPanel
- func (p *RightPanel) ScrollHalf(direction, height int)
- func (p *RightPanel) ScrollLine(delta, height int)
- func (p *RightPanel) ScrollPage(direction, height int)
- func (p *RightPanel) View(styler Styler, height, width int) PanelView
- func (p *RightPanel) Viewport(height int) int
- type Row
- type RuntimeOptions
- type ScreenLayout
- func (l ScreenLayout) BodyRows() (int, int)
- func (l ScreenLayout) ContentBreakpoint() string
- func (l ScreenLayout) EditablePanel() bool
- func (l ScreenLayout) FooterRows() (int, int)
- func (l ScreenLayout) FooterSize() int
- func (l ScreenLayout) HasPanel() bool
- func (l ScreenLayout) HeaderRow() int
- func (l ScreenLayout) ListCols() (int, int)
- func (l ScreenLayout) PanelCols() (int, int)
- func (l ScreenLayout) PanelDividerCol() int
- func (l ScreenLayout) VisibleRows(rows []Row) []Row
- type SelectionMode
- type SessionState
- type Styler
- type SystemOpener
- type Tab
- type TaskEditForm
- func (t *TaskEditForm) AcceptCommit(fresh *EditSnapshot, token int) (termform.Transition, error)
- func (t *TaskEditForm) ExpectedFor(field string) string
- func (t *TaskEditForm) Form() *termform.Form
- func (t *TaskEditForm) PatchField(field string) store.PatchField
- func (t *TaskEditForm) ReadOnly() (id, closed string)
- func (t *TaskEditForm) RefreshSnapshot(fresh *EditSnapshot) error
- func (t *TaskEditForm) RejectCommit(fieldErrors map[string][]string, message string, token int) termform.Transition
- func (t *TaskEditForm) ReloadField(field string, fresh *EditSnapshot) error
- func (t *TaskEditForm) RevertField(field string)
- func (t *TaskEditForm) SemanticValue(field string, value any) (text string, typed *store.PatchValue)
- func (t *TaskEditForm) Snapshot() *EditSnapshot
- func (t *TaskEditForm) TargetID() string
- type TaskEditFormOptions
- type TaskEditorOptions
- type TaskEditorSession
- func (s *TaskEditorSession) CancelConfirmation() EditorOutcome
- func (s *TaskEditorSession) Confirm() EditorOutcome
- func (s *TaskEditorSession) Conflict() *EditorConflict
- func (s *TaskEditorSession) CopyValue() any
- func (s *TaskEditorSession) Dirty(field string) bool
- func (s *TaskEditorSession) EditForm() *TaskEditForm
- func (s *TaskEditorSession) Finish() EditorOutcome
- func (s *TaskEditorSession) FocusedKey() string
- func (s *TaskEditorSession) Form() *termform.Form
- func (s *TaskEditorSession) HandleKey(key string) EditorOutcome
- func (s *TaskEditorSession) HandleQuitConfirmation(key string) EditorOutcome
- func (s *TaskEditorSession) KeepForCopy() EditorOutcome
- func (s *TaskEditorSession) Missing() bool
- func (s *TaskEditorSession) Paste(text string) EditorOutcome
- func (s *TaskEditorSession) PendingConfirmation() *EditorConfirmationPrompt
- func (s *TaskEditorSession) PendingQuit() bool
- func (s *TaskEditorSession) PendingRevert() string
- func (s *TaskEditorSession) Refresh() EditorOutcome
- func (s *TaskEditorSession) ReloadConflict() EditorOutcome
- func (s *TaskEditorSession) RenderModel() termform.RenderModel
- func (s *TaskEditorSession) RequestQuit() EditorOutcome
- func (s *TaskEditorSession) Save() EditorOutcome
- func (s *TaskEditorSession) Snapshot() *EditSnapshot
- func (s *TaskEditorSession) Suspend() EditorOutcome
- func (s *TaskEditorSession) TargetID() string
- type TemporalControl
- type TemporalInput
- func (t *TemporalInput) CalendarDate() *temporal.Date
- func (t *TemporalInput) ControlLines(width int) []string
- func (t *TemporalInput) ControlOpen() bool
- func (t *TemporalInput) CursorFor(value any, context termform.Context) *int
- func (t *TemporalInput) HandleEvent(event termform.Event, value any, context termform.Context) *termform.Result
- func (t *TemporalInput) MetadataFor(value any, context termform.Context) map[string]any
- func (t *TemporalInput) PickerOpen() bool
- func (t *TemporalInput) Row() temporalRow
- func (t *TemporalInput) Value() *temporal.Value
- func (t *TemporalInput) ZoneSearch() *string
- type ViewQuery
- func (q ViewQuery) ContextMatch(item store.Item) bool
- func (q ViewQuery) Eligible(item store.Item) bool
- func (q ViewQuery) GroupKeys(item store.Item) []string
- func (q ViewQuery) GroupedNodes(nodes []*taskquery.Node) map[string][]*taskquery.Node
- func (q ViewQuery) Matching(item store.Item) bool
- func (q ViewQuery) Select(items []store.Item) []store.Item
- func (q ViewQuery) SelectNodes(nodes []*taskquery.Node) []*taskquery.Node
- func (q ViewQuery) Sort(items []store.Item) []store.Item
- func (q ViewQuery) SortNodes(nodes []*taskquery.Node) []*taskquery.Node
- func (q ViewQuery) SortedGroups(groups map[string][]*taskquery.Node) []Group
- func (q ViewQuery) ViewRule(item store.Item) bool
Constants ¶
const ( DelegatedGlyph = "→" ClaimedGlyph = "⇒" // DelegationAssigneeWidth is the cells an assignee may occupy before it is // cut back to `local@…`. Wide enough for pat@example.com, narrow enough to // leave the title readable in a split pane. DelegationAssigneeWidth = 16 )
The delegation row markers. A single arrow means "handed off and idle" — a person we are waiting on, or agent-ready work nobody has picked up. A doubled arrow means a worker is actively holding the task, and it is the one delegation state where acting on the row would collide with someone else's work, so it is deliberately the loudest.
The two are distinguishable WITHOUT color: different glyphs, and the accent slot resolves to bold in every monochrome theme while muted resolves to dim.
const ( FixedRows = 5 // borders, header, and the two rules outside the body/footer PanelRatio = 0.40 WidePanelRatio = 0.58 MinPanelWidth = 28 MinListWidth = 8 EditMinContentWidth = 32 InlineContentWidth = 48 EditPanelChromeRows = 2 // RightPanel title and divider EditMinVisibleRows = 1 // compact focused-field fallback )
The panel width ladder. Names and numbers are Ruby's.
const ( MinWidth = 8 MinHeight = 6 // TickInterval is the file-watch poll. Bubble Tea drives it as a command // rather than as an IO.select timeout; the interval is Ruby's. TickInterval = 250 * time.Millisecond // FlashDuration is how long a status message stays up. Ruby's three // seconds, unchanged: it is long enough to read one line and short enough // that a stale message never gets mistaken for a live one. FlashDuration = 3 * time.Second )
Minimum frame that can retain borders, margins, and content.
const ( PanelDetail = "detail" PanelProjectDetail = "project_detail" PanelSuspendedTaskEdit = "suspended_task_edit" )
Panel kinds. A panel's kind decides which refresh path keeps it current and which keys it answers.
const ( MarkExpanded = "▾ " MarkCollapsed = "▸ " MarkLeaf = " " )
The collapse markers, each exactly two terminal cells. Every tree-mode task row carries one so titles align regardless of whether a node has children.
const ( ViewAgenda = "agenda" ViewNext = "next" ViewQuadrants = "quadrants" ViewProjects = "projects" ViewOutline = "outline" ViewInbox = "inbox" )
The six tabs, in order. The number is part of the label because the number is also the key that jumps to the tab.
const AgendaStampWidth = 19
AgendaStampWidth is the fixed width of the agenda date column, so an undated rider's title lines up under its dated siblings.
const SessionVersion = 1
SessionVersion is the on-disk schema of the saved TUI state. A file naming any other version is ignored wholesale, exactly as Ruby ignores it.
Variables ¶
var PanelModes = []string{"compact", "standard", "wide", "focus"}
PanelModes is the promotion ladder, narrowest first.
var Tabs = []Tab{ {"1 Agenda", "1 Ag", "1", ViewAgenda}, {"2 Next", "2 Nx", "2", ViewNext}, {"3 Quadrants", "3 Q", "3", ViewQuadrants}, {"4 Projects", "4 Pr", "4", ViewProjects}, {"5 Outline", "5 Out", "5", ViewOutline}, {"6 Inbox", "6 In", "6", ViewInbox}, }
Tabs is the canonical tab order. Views, the jump keys and the session's saved view all read this one list.
Functions ¶
func AgentAvailability ¶ added in v1.1.0
AgentAvailability is the context-free submit-time provider probe.
func AgentFactory ¶ added in v1.1.0
func AgentFactory(paths config.Paths, env determinism.Env, conf llm.Config, dataDir, cliPath string) func(agent.Entry) (agent.Adapter, error)
AgentFactory creates a provider adapter with fresh Tasks system context when a queued request starts.
func EmbeddedSessionPath ¶ added in v1.1.0
func EmbeddedSessionPath(env determinism.Env, namespace string) string
EmbeddedSessionPath keeps a host's presentation state separate from the standalone TUI. The public adapter validates namespace before calling it.
func ExportMarkdown ¶
ExportMarkdown is the whole task as pasteable markdown. `notes` is the item's prose lines, already filtered.
func ExportReference ¶
ExportReference is the stable id to paste into the agent prompt.
It is the ID and not the title on purpose: an exact id stays unambiguous across duplicate titles and across a later retitle, which is exactly what a reference in a conversation has to survive.
func FormatTemporal ¶
FormatTemporal is ParseTemporal's inverse: the canonical spelling the editor buffer holds. Round-tripping matters — the buffer is what the user edits.
func KeySequence ¶
func KeySequence(message tea.KeyPressMsg) string
KeySequence turns a decoded Bubble Tea v2 key press into the raw byte sequence the shortcut registry and the text editor are both keyed by.
It is exported because the differential harness drives the model with the SAME sequences it feeds Ruby's key handler, which is the only way the two interaction traces are comparable. An external Bubble Tea v2 host can pass tea.KeyPressMsg values straight into Update without translation.
func MinimumEditTerminalHeight ¶
MinimumEditTerminalHeight is the shortest terminal that can host the editor with the given number of footer rows. Every footer or help row consumes another terminal row before the panel title, divider, and focused fallback.
func MinimumEditTerminalWidth ¶
func MinimumEditTerminalWidth() int
MinimumEditTerminalWidth is the narrowest terminal that can host the editor.
func NormalizeContextFilters ¶
NormalizeContextFilters is UiState.normalize_context_filters: keep the non-empty strings, give each a leading "@", drop anything shorter than two characters, deduplicate, and sort. Sorting is what makes the saved value stable across runs, so an unchanged filter set does not rewrite the file.
func ParseTemporal ¶
ParseTemporal reads the editor's date grammar: a date expression with an optional wall time and an optional trailing zone / floating / fold token.
func SaveEmbeddedSession ¶ added in v1.1.0
func SaveEmbeddedSession(state SessionState, env determinism.Env, namespace string) error
SaveEmbeddedSession writes a host-specific embedded session.
func SaveSession ¶
func SaveSession(state SessionState, env determinism.Env) error
SaveSession overwrites the saved state. Best-effort: a read-only state directory must not crash TUI exit, so the error is reported and ignorable.
func SessionPath ¶
func SessionPath(env determinism.Env) string
SessionPath is $XDG_STATE_HOME/tasks/tui.json, resolved against the caller's environment rather than the process environment — the same threading Wave 0 had to fix in config.parseFile, for the same reason: a harness that pins HOME must be obeyed.
func ZoneIdentifiers ¶
func ZoneIdentifiers() []string
ZoneIdentifiers is every IANA zone this host can load, Area/Location or UTC.
Go has no equivalent of TZInfo.all_identifiers, so the zoneinfo tree is walked. A host with no tree at all still gets the handful of zones the runtime always resolves, so the search is never empty.
Types ¶
type ActionPalette ¶
type ActionPalette struct {
// contains filtered or unexported fields
}
ActionPalette is the searchable projection of the actions available right now. It owns query and selection state only; the model executes the chosen registry entry.
func NewActionPalette ¶
func NewActionPalette(styler Styler, entries []shortcuts.Entry, returnMode ReturnMode, targetID string) *ActionPalette
NewActionPalette builds one over a set of available entries.
func (*ActionPalette) Fail ¶
func (a *ActionPalette) Fail(message string)
Fail attaches an error, so a failed action is reported in the palette the user chose it from rather than as a bare flash behind a closed overlay.
func (*ActionPalette) HandleKey ¶
func (a *ActionPalette) HandleKey(key string) PaletteOutcome
HandleKey routes one key and resolves an acceptance back to a registry entry.
func (*ActionPalette) Hit ¶
func (a *ActionPalette) Hit(rowOffset int) PaletteOutcome
Hit routes one click.
func (*ActionPalette) Move ¶
func (a *ActionPalette) Move(delta int) PaletteOutcome
Move steps the cursor.
func (*ActionPalette) Paste ¶
func (a *ActionPalette) Paste(text string) PaletteOutcome
Paste inserts pasted text into the query.
func (*ActionPalette) Picker ¶
func (a *ActionPalette) Picker() *ChoicePicker
Picker exposes the underlying picker for rendering and hit testing.
func (*ActionPalette) ReturnMode ¶
func (a *ActionPalette) ReturnMode() ReturnMode
ReturnMode and TargetID are what the model needs to close it correctly.
func (*ActionPalette) TargetID ¶
func (a *ActionPalette) TargetID() string
type AgentAdapter ¶
type AgentAdapter struct {
// contains filtered or unexported fields
}
AgentAdapter bridges one *llm.Agent to the queue's Adapter interface.
The two shapes differ in exactly one way that matters: llm.Agent is a long-running process with a Done channel, and the queue is a POLLED thing driven from the TUI's tick. Pump therefore must never block — a blocking read here would freeze the whole interface for as long as the model was thinking. So Pump asks the Done channel whether the process has finished and returns immediately either way; the transcript is read from the agent's own buffer, which its drain goroutine keeps filled.
It lives in internal/tui rather than in cmd/tasks-tui so it can be tested without a terminal, and it is deliberately thin: every decision about the process — argv, streaming, cancellation grace, signal handling — stays in internal/llm, which the CLI shares.
func NewAgentAdapter ¶
func NewAgentAdapter(built *llm.Agent) *AgentAdapter
NewAgentAdapter wraps a built agent.
func (*AgentAdapter) Available ¶
func (a *AgentAdapter) Available() bool
Available re-checks the provider at start time.
func (*AgentAdapter) Cancel ¶
func (a *AgentAdapter) Cancel() error
Cancel signals the process group and waits out the short grace period the llm layer owns.
func (*AgentAdapter) ExitStatus ¶
func (a *AgentAdapter) ExitStatus() (int, bool)
ExitStatus is the process exit code once it is known.
The second return is the whole contract: the queue turns `false` into an ABSENT exit status on the request snapshot, and llm.Agent reports -1 for both "has not exited" and "died on a signal". Reporting (-1, true) would put an exit code no process ever returns onto a cancelled request — which is exactly the path the TUI reaches every time a user presses escape on a running agent.
func (*AgentAdapter) Output ¶
func (a *AgentAdapter) Output() string
Output is the transcript captured so far.
func (*AgentAdapter) ProcessStatus ¶
func (a *AgentAdapter) ProcessStatus() agent.ProcessStatus
ProcessStatus is how the process ended, including the signal a cancellation delivered — which is what tells "the user cancelled it" apart from "it crashed".
func (*AgentAdapter) Pump ¶
func (a *AgentAdapter) Pump() (bool, error)
Pump reports whether the process has finished, without blocking.
func (*AgentAdapter) Start ¶
func (a *AgentAdapter) Start(prompt, model string) error
Start launches the process with streaming ON, so the activity modal and the footer can show the transcript as it arrives rather than only at the end.
func (*AgentAdapter) Success ¶
func (a *AgentAdapter) Success() bool
Success reports a clean exit that was not cancelled.
type AgentEntry ¶
type AgentEntry = agent.SimpleEntry
AgentEntry is one provider/model the prompt can be submitted to. It is the queue's Entry with a display label the header shows.
func BuildAgentQueue ¶ added in v1.1.0
func BuildAgentQueue(paths config.Paths, env determinism.Env) ([]AgentEntry, *agent.Queue, error)
BuildAgentQueue constructs the Tasks-owned provider/model registry and queue.
type BuildRequest ¶
type BuildRequest struct {
View string
Styler Styler
Queries *taskquery.Queries
Items []store.Item // already narrowed by the active `/` and `@` filters
Tree []*taskquery.Node
UseTree bool
Collapsed map[string]bool
ShowDeferred bool
UrgentDays int
ContextFilters []string
Projects []taskquery.ProjectView
IntakeCounts IntakeCounts
}
BuildRequest is everything the row builders need. It is a value, so building rows is a pure function of a read model plus the UI's own choices — which is what makes every row test a table test rather than a screen scrape.
type ChoicePicker ¶
type ChoicePicker struct {
// contains filtered or unexported fields
}
ChoicePicker is the stable, searchable overlay both palettes are built from.
"Stable" is the operative word and it is why this is one type rather than two ad-hoc lists: the box width comes from the FULL option set, the viewport follows the cursor rather than the match count, and the layout the mouse hit test reads is the layout the last paint produced. A palette whose rows moved between the paint and the click would run the wrong action.
func NewChoicePicker ¶
func NewChoicePicker(options ChoicePickerOptions) *ChoicePicker
NewChoicePicker builds one.
func (*ChoicePicker) Current ¶
func (p *ChoicePicker) Current() *PickerOption
Current is the option under the cursor, or nil.
func (*ChoicePicker) CursorIndex ¶
func (p *ChoicePicker) CursorIndex() int
func (*ChoicePicker) Error ¶
func (p *ChoicePicker) Error() string
func (*ChoicePicker) Fail ¶
func (p *ChoicePicker) Fail(message string)
Fail attaches an error to the picker without closing it, so a failed action is reported where the user chose it.
func (*ChoicePicker) HandleKey ¶
func (p *ChoicePicker) HandleKey(key string) PickerResult
HandleKey routes one raw key.
func (*ChoicePicker) Hit ¶
func (p *ChoicePicker) Hit(rowOffset int) PickerResult
Hit maps a popup-local row (0 = the top border) to a picker action, returning the SAME shapes HandleKey does so a click and a keypress cannot diverge.
func (*ChoicePicker) Input ¶
func (p *ChoicePicker) Input() string
func (*ChoicePicker) InputCursor ¶
func (p *ChoicePicker) InputCursor() int
func (*ChoicePicker) Move ¶
func (p *ChoicePicker) Move(delta int) PickerResult
Move steps the cursor and keeps it visible. Same step as ↑↓, for the wheel and for programmatic motion.
func (*ChoicePicker) Options ¶
func (p *ChoicePicker) Options() []PickerOption
func (*ChoicePicker) Paste ¶
func (p *ChoicePicker) Paste(text string) PickerResult
Paste inserts pasted text into the query.
func (*ChoicePicker) Popup ¶
func (p *ChoicePicker) Popup(styler Styler, maxWidth, maxHeight int, inlineInput func(string, int) string) []string
Popup renders the overlay at the given budget and records the layout the hit test reads.
The three tiers are deliberate. A palette that simply refused to render in a short terminal would take a capability away from a user whose window happened to be small; each tier keeps the one thing that tier can still show — the current option, the query, and the hint.
func (*ChoicePicker) RefreshOptions ¶
func (p *ChoicePicker) RefreshOptions(options []PickerOption, selection []string)
RefreshOptions swaps the option set while keeping the query, the staged selection and — where it still exists — the cursor's option.
func (*ChoicePicker) Results ¶
func (p *ChoicePicker) Results() []PickerOption
Results is the option set narrowed and RANKED by the live query.
The ranking is what makes typing three letters land on the thing you meant: exact match, then prefix, then a word-boundary prefix, then a substring — ties broken by declaration order, so the answer is the same on every run.
func (*ChoicePicker) Selected ¶
func (p *ChoicePicker) Selected(id string) bool
Selected reports whether an id is in the staged set.
func (*ChoicePicker) SelectionChanged ¶
func (p *ChoicePicker) SelectionChanged() bool
SelectionChanged reports whether the staged set differs from what the picker opened with. The context palette reads it to decide whether Return means "apply what I toggled" or "apply just the thing under the cursor".
func (*ChoicePicker) Staged ¶
func (p *ChoicePicker) Staged() []string
Staged is the selection as it stands, sorted for a stable answer.
func (*ChoicePicker) Title ¶
func (p *ChoicePicker) Title() string
Title, Input, CursorIndex, ViewportStart, Staged and Error are the accessors.
func (*ChoicePicker) ViewportStart ¶
func (p *ChoicePicker) ViewportStart() int
type ChoicePickerOptions ¶
type ChoicePickerOptions struct {
Title string
Options []PickerOption
Selection []string
Mode SelectionMode
AcceptLabel string
EmptyLabel string
MaxVisible int
PreferredID string
ToggleCommand func(option PickerOption, staged []string) ([]string, bool)
SearchNormalizer func(string) string
SelectedStyle string
}
ChoicePickerOptions builds a picker.
type ContextOutcome ¶
type ContextOutcome struct {
Kind PickerResultKind
// Contexts is the filter set to apply when Kind is PickerAccepted.
Contexts []string
Apply bool
}
ContextOutcome is what a context-palette key did.
type ContextPalette ¶
type ContextPalette struct {
// contains filtered or unexported fields
}
ContextPalette is the multiple-choice adapter over the TUI's global @context filters. The picker owns interaction; the model owns applying the result.
func NewContextPalette ¶
func NewContextPalette(contexts, current []string) *ContextPalette
NewContextPalette builds one over the contexts the store currently holds.
func (*ContextPalette) CurrentFilters ¶
func (c *ContextPalette) CurrentFilters() []string
CurrentFilters is the filter set the palette opened with.
func (*ContextPalette) HandleKey ¶
func (c *ContextPalette) HandleKey(key string) ContextOutcome
HandleKey routes one key.
func (*ContextPalette) Hit ¶
func (c *ContextPalette) Hit(rowOffset int) ContextOutcome
Hit routes one click.
func (*ContextPalette) Move ¶
func (c *ContextPalette) Move(delta int) ContextOutcome
Move steps the cursor.
func (*ContextPalette) Paste ¶
func (c *ContextPalette) Paste(text string) ContextOutcome
Paste inserts pasted text into the query.
func (*ContextPalette) Picker ¶
func (c *ContextPalette) Picker() *ChoicePicker
Picker exposes the underlying picker.
func (*ContextPalette) RefreshOptions ¶
func (c *ContextPalette) RefreshOptions(contexts, current []string)
RefreshOptions adopts a fresh context list without losing what is staged.
type DetailContent ¶
DetailContent is one panel's worth of content.
func BuildProjectDetails ¶
func BuildProjectDetails(styler Styler, queries *taskquery.Queries, project taskquery.ProjectView, tasks []store.Item, width int) DetailContent
BuildProjectDetails is the ProjectView counterpart — the port of lib/tui/project_details.rb. `tasks` is the resolved open task list; the builder never reaches back into a store or an application.
func BuildTaskDetails ¶
func BuildTaskDetails(styler Styler, queries *taskquery.Queries, item store.Item, width int, projectName string) DetailContent
BuildTaskDetails is the pure task-detail content builder — the port of lib/tui/task_details.rb. Its output is hosted by the right panel today and could be hosted by any other surface tomorrow, because it depends on no modal, no store, and no panel state.
type EditSnapshot ¶
type EditSnapshot struct {
ID string
Title string
Priority string
Deferred bool
// Scheduled and Deadline are nil when the task has no such date. A nil is
// meaningfully different from a zero date: it means "clear this".
Scheduled *temporal.Value
Deadline *temporal.Value
Recurrence string
Lead string
Contexts []string
Tags []string
Body string
State string
Closed string
// SubtreeIDs is the task and its descendants, in document order, so a
// completion confirmation can say how many tasks ride along.
SubtreeIDs []string
// contains filtered or unexported fields
}
EditSnapshot is one coherent read of a task PLUS the per-field baselines the store will compare a patch against.
STRUCTURAL NOTE, and the one place this packet had to build rather than port. Ruby has `Tasks::EditSnapshot`, produced by `application.edit_snapshot(id)`, which carries every field, its baseline and the task's revision. The Go application facade publishes the values and field expectations through one held ReadModel. This assembles the editor shape without taking a second store read, so every buffer and every expectation describes the same bytes.
The important property is preserved: every baseline in a snapshot comes from one moment, so a patch's conflict check compares against the value the user was actually looking at.
func NewEditSnapshot ¶
func NewEditSnapshot(app *application.Application, read *application.ReadModel, id string) (*EditSnapshot, bool)
NewEditSnapshot builds a snapshot for one task from a live read model, or reports that the task is not there.
func (*EditSnapshot) ExpectedFor ¶
func (s *EditSnapshot) ExpectedFor(field string) string
ExpectedFor is the baseline a patch on one field must match.
func (*EditSnapshot) OpenDescendantIDs ¶
func (s *EditSnapshot) OpenDescendantIDs(read *application.ReadModel) []string
OpenDescendantIDs is every open task strictly beneath this one — what a cascade completion would also close.
func (*EditSnapshot) Value ¶
func (s *EditSnapshot) Value(field string) any
Value is the snapshot's value for one editor field, in the shape the matching form field holds.
func (*EditSnapshot) Values ¶
func (s *EditSnapshot) Values() map[string]any
Values is every field's value.
type EditorConfirmationPrompt ¶
type EditorConfirmationPrompt struct {
Token string
Field string
Value any
Message string
Request *termform.CommitRequest
Finish bool
}
EditorConfirmationPrompt is a consequence the user must accept before a save lands. It is not a nicety: `state → DONE` on a parent cascades to its open descendants, and clearing the last date retires the recurrence with it.
type EditorConflict ¶
EditorConflict is a same-field external edit caught at save time.
type EditorOutcome ¶
type EditorOutcome struct {
Status EditorStatus
Transition termform.Transition
Message string
// Field is the field an outcome is about, when it is about one.
Field string
// Wrote reports that this outcome CHANGED the store. It is separate from
// the status because a finish and a save both may or may not have written,
// and the list has to be rebuilt for exactly the ones that did.
Wrote bool
}
EditorOutcome is one interaction's answer.
func (EditorOutcome) Handled ¶
func (o EditorOutcome) Handled() bool
Handled reports that the editor consumed the input.
type EditorStatus ¶
type EditorStatus string
EditorStatus is the outcome vocabulary one editor interaction produces.
const ( EditorUnhandled EditorStatus = "unhandled" EditorHandled EditorStatus = "handled" EditorChanged EditorStatus = "changed" EditorFocusChanged EditorStatus = "focus_changed" EditorInvalid EditorStatus = "invalid" EditorConfirmation EditorStatus = "confirmation" EditorConfirmCancelled EditorStatus = "confirmation_cancelled" EditorConflicted EditorStatus = "conflict" EditorConflictReloaded EditorStatus = "conflict_reloaded" EditorMissing EditorStatus = "missing" EditorFinished EditorStatus = "finished" EditorRefreshed EditorStatus = "refreshed" EditorRevertPending EditorStatus = "revert_pending" EditorReverted EditorStatus = "reverted" EditorSaved EditorStatus = "saved" EditorNoChange EditorStatus = "no_change" EditorQuitReady EditorStatus = "quit_ready" EditorQuitConfirmation EditorStatus = "quit_confirmation" EditorQuitConfirmed EditorStatus = "quit_confirmed" EditorQuitCancelled EditorStatus = "quit_cancelled" EditorSuspended EditorStatus = "suspended" EditorCopyKept EditorStatus = "copy_kept" )
The editor outcomes.
type ErrIllegalTransition ¶
type ErrIllegalTransition struct{ From, To Mode }
ErrIllegalTransition is what SetMode reports for a move the table forbids.
func (ErrIllegalTransition) Error ¶
func (e ErrIllegalTransition) Error() string
type FormRender ¶
type FormRender struct {
Lines []string
// FocusedContentRow is the row, within Lines' content area, that holds the
// caret — what a host needs to place a real terminal cursor. -1 when the
// focused row scrolled out of view.
FocusedContentRow int
}
FormRender is a rendered form box.
func RenderForm ¶
func RenderForm(styler Styler, request FormRenderRequest) FormRender
RenderForm paints a TermForm render model into a bordered box.
It is a pure function of the request: no terminal, no cursor addressing, no clock. That is what makes the fixed-size render fixtures in the tests meaningful — the same request produces the same bytes on every machine.
type FormRenderRequest ¶
type FormRenderRequest struct {
Model termform.RenderModel
Width int
Height int
Title string
Hint string
// Error is a host-level failure — a rejected save — which outranks the
// form's own validation messages, because it is the newer news.
Error string
Suffix string
}
FormRenderRequest is everything a render needs. The caller supplies the WHOLE cell budget; this renderer never samples terminal geometry.
type IntakeCounts ¶
IntakeCounts is what the Inbox tab badge and its section headers advertise.
type LayoutRequest ¶
type LayoutRequest struct {
Width int
Height int
Selected int
HasSelection bool
Panel bool
PanelMode string
PanelOffset int
Editing bool
}
LayoutRequest is what a caller knows before geometry is computed.
type Modal ¶
type Modal struct {
// contains filtered or unexported fields
}
Modal is one open overlay: content, scroll position, and an optional live line filter.
Three invariants it keeps for itself, all of them about NOT MOVING:
- the box width comes from the FULL content, title included, so scrolling or filtering never resizes it;
- View never yields more rows than fit — the border takes two rows of the body and the status line one more;
- while a filter is active the box keeps its full unfiltered height, so neither the box nor its centered position jumps as matches come and go.
A modal that resized while you typed into it would be unusable for the one thing filtering is for: reading a long list while narrowing it.
func NewModal ¶
func NewModal(options ModalOptions) *Modal
NewModal builds one. A filter-group slice that does not align with the lines is dropped rather than honoured, because a misaligned group map would hide the wrong lines — silently.
func (*Modal) Filterable ¶
Filterable reports whether `/` opens a line filter on this modal.
func (*Modal) Replace ¶
Replace swaps live content without discarding the user's filter or scroll intent. The next View clamps scroll against the refreshed match set.
func (*Modal) ScrollHalf ¶
func (*Modal) ScrollLine ¶
ScrollLine, ScrollHalf and ScrollPage are the three scroll gestures.
func (*Modal) ScrollPage ¶
func (*Modal) SetFilter ¶
SetFilter applies a query. An unchanged query keeps the memo AND the scroll position, so a repeated keystroke does not throw the reader back to the top.
func (*Modal) View ¶
View is the window at the current scroll, at most bodyHeight-2 lines so the boxed result fits the body. A non-empty filterLine — or an active filter — switches to the fixed-height filtered view.
type ModalContent ¶
ModalContent is a built overlay body: what a Modal is constructed from.
func HelpContent ¶
func HelpContent(styler Styler) ModalContent
HelpContent is the `?` overlay, generated ENTIRELY from the shortcut registry.
Generating it is the whole point: a hand-written help list is a second source of truth that goes stale the first time a binding moves, and a task list whose help lies about its keys is worse than one with no help at all.
The filter groups are the section titles, so filtering the modal keeps a matched binding's heading visible — a bare "x archive" with no section above it does not tell you where the key works.
type ModalKind ¶
type ModalKind string
ModalKind names what an overlay is for. The kind decides which keys the modal answers, so a confirmation cannot be dismissed by the key that scrolls help — and, more importantly, `y` cannot mean "archive" while a help modal is open.
const ( ModalHelp ModalKind = "help" ModalArchiveConfirm ModalKind = "archive_confirm" ModalArchiveBlocked ModalKind = "archive_blocked" ModalDeleteConfirm ModalKind = "delete_confirm" ModalDeleteCascadeConfirm ModalKind = "delete_cascade_confirm" ModalProjectCompleteConfirm ModalKind = "project_complete_confirm" ModalProjectArchiveConfirm ModalKind = "project_archive_confirm" ModalUnsupportedSchema ModalKind = "unsupported_schema" ModalTaskDraftQuitConfirm ModalKind = "task_draft_quit_confirm" ModalAgentQuitConfirm ModalKind = "agent_quit_confirm" ModalAgentActivity ModalKind = "agent_activity" ModalAgentQueueCancel ModalKind = "agent_queue_cancel_confirm" )
The modal kinds this build has.
type ModalOptions ¶
type ModalOptions struct {
Title string
Lines []string
Kind ModalKind
Filterable bool
FilterGroups []string
}
ModalOptions builds a Modal.
type Mode ¶
type Mode string
Mode is the interaction mode. The shell implements list and filter; the remaining modes are the seams the editor/forms/modals packet and the rendering/agent packet plug into. They are NAMED here rather than invented later so the two halves agree on the vocabulary at integration, and so an unimplemented mode is a visible absence rather than a silent branch.
const ( ModeList Mode = "list" ModePrompt Mode = "prompt" ModeFilter Mode = "filter" ModeModal Mode = "modal" ModeForm Mode = "form" ModePalette Mode = "palette" ModeContextPalette Mode = "context_palette" ModeTaskEdit Mode = "task_edit" )
The modes, in the order lib/tui/ui_state.rb declares them.
const ModeModalFilter Mode = "modal_filter"
ModeModalFilter is the live line filter inside a filterable modal. It is a mode of its own rather than a flag on ModeModal because the key routing is genuinely different: while it is active, `j` types a letter instead of scrolling.
type Model ¶
type Model struct {
// contains filtered or unexported fields
}
Model is the Bubble Tea root — the port of Tui::App's state, minus its event loop.
STRUCTURAL CHANGE from Ruby, deliberate and worth naming: Ruby's App is one 3,500-line object that owns the terminal, the read model, every key handler, and every cache, and invalidates the caches by hand from twenty places. Here the read model is rebuilt into `rows` by ONE function (refreshRows) from ONE value (BuildRequest), so there is no cache to invalidate and no way for two caches to disagree. Ruby needed the caches because it repainted on a 0.25s tick whether or not anything changed; Bubble Tea only calls View after an Update, so the pressure that justified them is gone.
func NewRuntime ¶ added in v1.1.0
func NewRuntime(options RuntimeOptions) (*Model, error)
NewRuntime wires the application, store, renderer, opener, provider list, and agent queue used by every shipping TUI host.
func (*Model) ActionPalette ¶
func (m *Model) ActionPalette() *ActionPalette
ActionPalette is the open action palette, or nil.
func (*Model) AgentEntries ¶
func (m *Model) AgentEntries() []AgentEntry
AgentEntries is the ordered provider/model list, for the same reason.
func (*Model) ApplyContextFilter ¶
ApplyContextFilter adopts an accepted context set and rebuilds the rows.
func (*Model) ArchiveSweep ¶
func (m *Model) ArchiveSweep()
ArchiveSweep is `x`: preview what a sweep would move, then ask.
It never sweeps directly. The preview the user is shown is PINNED and handed back on confirmation, so a list that changed while the modal was open refuses rather than archiving a set nobody saw.
func (*Model) BumpPriority ¶
BumpPriority is `K` / `J`: one step along the ladder, never past its end.
func (*Model) CancelQueuedAgentRequests ¶
func (m *Model) CancelQueuedAgentRequests()
CancelQueuedAgentRequests is the palette action behind the confirmation.
func (*Model) CaptureIntoProject ¶
func (m *Model) CaptureIntoProject()
CaptureIntoProject is `a` on a project header: append a new TODO to it.
func (*Model) ClearQuitRequest ¶ added in v1.1.0
func (m *Model) ClearQuitRequest()
ClearQuitRequest acknowledges an embedded quit request.
func (*Model) CloseActionPalette ¶
func (m *Model) CloseActionPalette()
CloseActionPalette dismisses it, returning where it came from.
func (*Model) CloseContextPalette ¶
func (m *Model) CloseContextPalette()
CloseContextPalette dismisses it.
func (*Model) CloseForm ¶
CloseForm dismisses the quick form, running its success effect on a successful submit.
func (*Model) CloseTaskEdit ¶
CloseTaskEdit leaves the editor.
func (*Model) CollapseAll ¶
func (m *Model) CollapseAll()
CollapseAll folds every task node that has task children, across the whole tree. The selection may have been on a now-hidden row, so rows are rebuilt and the selection reconciled.
func (*Model) CollapseSelected ¶
func (m *Model) CollapseSelected()
CollapseSelected folds the selected subtree. On an expandable, not-yet-folded node it folds and keeps the cursor there; otherwise it climbs to the parent task row, so a second press walks up the tree.
func (*Model) CommandAvailable ¶ added in v1.1.0
CommandAvailable reports whether a command exists in the current focus context and its live availability predicate passes.
func (*Model) CompleteSelected ¶
func (m *Model) CompleteSelected()
CompleteSelected is `c`: close the selected task, or confirm closing a whole project when a project header is selected.
func (*Model) ConfirmArchiveProject ¶
func (m *Model) ConfirmArchiveProject(project *taskquery.ProjectView)
ConfirmArchiveProject asks before archiving a whole section subtree, surfacing any open work it would take with it.
func (*Model) ConfirmCompleteProject ¶
func (m *Model) ConfirmCompleteProject(project *taskquery.ProjectView)
ConfirmCompleteProject asks before closing every open task in a section.
func (*Model) ConsumesTextInput ¶ added in v1.1.0
ConsumesTextInput reports whether printable keys belong to an input buffer.
func (*Model) ContextFilters ¶
ContextFilters is the active `@` filter set.
func (*Model) ContextPalette ¶
func (m *Model) ContextPalette() *ContextPalette
ContextPalette is the open context palette, or nil.
func (*Model) CurrentEntry ¶
func (m *Model) CurrentEntry() AgentEntry
CurrentEntry is the provider/model new requests go to.
func (*Model) CurrentItem ¶
CurrentItem is the selected task, or nil on a header or project row.
func (*Model) CurrentProject ¶
func (m *Model) CurrentProject() *taskquery.ProjectView
CurrentProject is the selected project header's view, or nil.
func (*Model) CurrentView ¶ added in v1.1.0
CurrentView is the stable active view key.
func (*Model) CyclePanelMode ¶
CyclePanelMode steps the panel width ladder.
func (*Model) DecideProposal ¶
func (m *Model) DecideProposal(action application.ProposalAction)
DecideProposal is `a` / `r` on a proposed task.
func (*Model) DeferSelected ¶
func (m *Model) DeferSelected()
DeferSelected is `z`, the OmniFocus-style availability action.
A fuzzy date atomically sets the available-from date AND clears this task's own hold; `someday` adds the indefinite marker; `now` clears only the blockers this task itself owns. All three are one changeset, so one keystroke costs one undo and no intermediate state is observable.
func (*Model) DeleteSelected ¶ added in v1.1.0
func (m *Model) DeleteSelected()
DeleteSelected is `#` / Delete: preview a hard delete, then confirm.
It never writes on the first keystroke. A leaf gets a simple confirm; a task with descendants gets a cascade confirm that names counts. Both refuse projects/sections (store rule: delete targets tasks) and both land in one journal step that `u` / ctrl-r already undo/redo.
func (*Model) ExpandSelected ¶
func (m *Model) ExpandSelected()
ExpandSelected unfolds the selected node if it is folded.
func (*Model) FlashMessage ¶
FlashMessage is the live flash, or "".
func (*Model) FocusContext ¶ added in v1.1.0
FocusContext is a stable host-facing name for the active interaction layer.
func (*Model) Footer ¶
Footer is the status rows under the list, in Ruby's order.
The order is the contract, not an accident. A running agent's transcript takes the top because it is the only thing on screen that is still changing; the prompt takes the bottom because it is where the caret is. And the prompt is SKIPPED in the modes that render their own input in an overlay, so a short terminal never shows two carets.
func (*Model) HandleMouse ¶
HandleMouse routes one mouse event. It reports whether the event was consumed, so the integration owner can layer a hit map above it without double-handling.
func (*Model) InvokeCommand ¶ added in v1.1.0
InvokeCommand executes one exact semantic command without replaying an ambiguous default key.
func (*Model) Layout ¶
func (m *Model) Layout() ScreenLayout
Layout exposes the geometry for tests and for the hit map the rendering packet builds.
func (*Model) LinkOpener ¶
LinkOpener is the injected launcher, or nil. It is exported so the entry point's own test can prove the shipping constructor wired one — the defect that made every valid link refuse in the real binary while the fake-injected model tests stayed green.
func (*Model) ModalFilterInput ¶
ModalFilterInput is the text in the modal's filter line.
func (*Model) ModalStartFilter ¶
func (m *Model) ModalStartFilter()
ModalStartFilter opens the live line filter inside a filterable modal.
func (*Model) MouseEnabled ¶
MouseEnabled reports whether the resolved config asks for mouse reporting. The entry point reads it so View can set MouseMode each frame; turning mouse tracking on takes the terminal's own text selection away from the user.
func (*Model) OpenActionPalette ¶
func (m *Model) OpenActionPalette()
OpenActionPalette shows every action available right now.
func (*Model) OpenContextPalette ¶
func (m *Model) OpenContextPalette()
OpenContextPalette shows the @context filter picker.
func (*Model) OpenDatePopup ¶
func (m *Model) OpenDatePopup()
OpenDatePopup is `d`: reschedule the task's own date — the deadline when it has one, otherwise the available-from date, and a new deadline when it has neither.
func (*Model) OpenDetail ¶
func (m *Model) OpenDetail()
OpenDetail opens the panel on the selection, or closes it if it is already showing that selection.
func (*Model) OpenLink ¶
func (m *Model) OpenLink()
OpenLink is `o`: open the selected task's first link.
func (*Model) OpenModal ¶
func (m *Model) OpenModal(content ModalContent, kind ModalKind, filterable bool)
OpenModal opens an overlay and enters modal mode.
func (*Model) OpenRecurPopup ¶
func (m *Model) OpenRecurPopup()
OpenRecurPopup is `r`: set or clear a recurrence, with a LIVE gloss of what the typed cookie means as the hint.
A recurrence rides a date stamp, so a task with no date cannot repeat. That is refused BEFORE the popup opens rather than after it is filled in: a form whose every submission must fail is worse than no form.
func (*Model) OpenTaskCount ¶
OpenTaskCount is the header's "N open".
func (*Model) Overlay ¶
func (m *Model) Overlay() *OverlayBox
Overlay is the popup the current mode wants painted, or nil.
func (*Model) PasteRef ¶
func (m *Model) PasteRef()
PasteRef is `p`: quote the selected task's stable reference into the prompt.
It is QUOTED because a bare id in a sentence is ambiguous to a model and to a human reading the transcript later; the quotes say "this is a handle".
func (*Model) PromptLines ¶
PromptLines is the prompt row, or the hint that names the key that opens it.
func (*Model) PromptPaste ¶
PromptPaste inserts bracketed-pasted text, from the prompt or from a modal.
func (*Model) PromptText ¶
PromptText is what the user has typed.
func (*Model) PumpQueue ¶
func (m *Model) PumpQueue()
PumpQueue is the per-tick drain: read whatever the running process produced, and pick up the next request when one finishes.
func (*Model) QuitRequested ¶ added in v1.1.0
QuitRequested reports an embedded quit request without terminating its host.
func (*Model) ReadModel ¶
func (m *Model) ReadModel() *application.ReadModel
ReadModel is the model's current read, for tests and for the packets that need the same snapshot the list was built from.
func (*Model) Refresh ¶
func (m *Model) Refresh()
Refresh rebuilds the read model and the rows from it. It is the ONLY path that changes what the list shows, so a refresh caused by an external write and a refresh caused by a keypress cannot behave differently.
func (*Model) RefreshRows ¶
func (m *Model) RefreshRows()
RefreshRows rebuilds the row list from the current read model, then reconciles the selection against it.
func (*Model) RenameProject ¶
func (m *Model) RenameProject()
RenameProject is `e` on a project header.
func (*Model) ReorderSelected ¶
ReorderSelected moves the selected subtree.
The placement is computed from the SIBLING LIST rather than from screen rows: the rows are a filtered, sorted projection, and moving a task by what is drawn above it would move it somewhere else entirely in the file.
func (*Model) ResizePanel ¶
ResizePanel nudges the panel by whole columns on top of its mode width.
func (*Model) ResponseLines ¶
ResponseLines is the visible window of the response pane.
func (*Model) Save ¶
func (m *Model) Save()
Save persists the session. Best effort — a read-only state directory must not keep the TUI from exiting.
func (*Model) ScrollResponse ¶
ScrollResponse is pgup/pgdn over the response pane.
func (*Model) SelectedID ¶
SelectedID is the durable identity the cursor follows.
func (*Model) SessionState ¶
func (m *Model) SessionState() SessionState
SessionState is the state to persist on exit. The collapsed set and the context filters are intersected with what the store actually still holds, so a saved id for a deleted task cannot accumulate forever.
func (*Model) SetActionPalette ¶
func (m *Model) SetActionPalette(palette *ActionPalette)
SetActionPalette opens or clears the action palette.
func (*Model) SetContextPalette ¶
func (m *Model) SetContextPalette(palette *ContextPalette)
SetContextPalette opens or clears the context palette.
func (*Model) SetMode ¶
SetMode moves to a mode, refusing a move the table forbids or whose overlay is missing.
The overlay checks are not defensive noise. Ruby raises here, and it raises because every one of these has been reachable: a modal dismissed by an external refresh while a palette opened over it, a form whose return mode points at a modal that is gone. Failing loudly at the transition is what keeps those from becoming a frozen screen.
func (*Model) SetTaskEditor ¶
func (m *Model) SetTaskEditor(editor *TaskEditorSession)
SetTaskEditor opens or clears the durable task editor.
func (*Model) SetWorkRefSelected ¶
func (m *Model) SetWorkRefSelected()
SetWorkRefSelected is `W`.
It refuses an undelegated task UP FRONT rather than opening a prompt whose every input must fail — the same shape as `r` refusing an undated task.
func (*Model) ShowUnsupportedSchemaNotice ¶
func (m *Model) ShowUnsupportedSchemaNotice()
ShowUnsupportedSchemaNotice opens the one modal that has no action: nothing this build can do makes a future schema readable.
func (*Model) StartTaskEdit ¶
StartTaskEdit is `e` in the detail panel: open the durable editor on the selected task, focused on one field.
func (*Model) SubmitPrompt ¶
func (m *Model) SubmitPrompt()
SubmitPrompt enqueues the typed prompt.
A REFUSED submission keeps the text. The prompt is the one place in the TUI where the user may have typed a paragraph, and losing it to a full queue or an unavailable provider would be the worst data loss the TUI can inflict.
func (*Model) SwitchView ¶
SwitchView moves to the named tab.
func (*Model) TabStrip ¶
TabStrip renders the tab cells, degrading labels when they do not fit.
Ruby's version drops tabs one at a time from the far end and re-measures at each of five degradation steps. This one degrades the LABELS in three steps (full, compact, minimum) and keeps every tab, because a tab that disappears from the strip is a view the user cannot see exists, and the number keys that jump to it keep working regardless. That is a genuine user-visible difference; it is recorded in the archived migration compatibility decisions.
func (*Model) TaskEditor ¶
func (m *Model) TaskEditor() *TaskEditorSession
TaskEditor is the open editor session, or nil.
func (*Model) ToggleDeferred ¶
func (m *Model) ToggleDeferred()
ToggleDeferred flips whether unavailable work is shown.
func (*Model) Update ¶
Update is the whole event surface. It is a plain method on a value the tests construct directly, so every interaction contract below is checked by driving messages, not by scraping a terminal.
func (*Model) View ¶
View renders one frame as a Bubble Tea v2 View. Alt screen and mouse mode live on the View (not program options), matching Sidecar so an external v2 host can host this model without translating tea.Msg values.
func (*Model) YankMarkdown ¶
func (m *Model) YankMarkdown()
YankMarkdown is `Y`: copy the task as a markdown checkbox line with its notes.
type Opener ¶
type Opener interface {
// Open launches the URL and reports whether a launcher could be spawned.
Open(url string) bool
}
Opener launches a URL. It is an INTERFACE, not a function call, because the alternative is a test suite that opens real browser windows.
type Options ¶
type Options struct {
App *application.Application
Paths config.Paths
Env determinism.Env
Styler Styler
Now func() time.Time
Session SessionState
// Opener launches a task's link. A nil one refuses out loud rather than
// reaching for a platform launcher, which is what keeps a test suite from
// opening browser windows.
Opener Opener
// CopyToClipboard is a test seam for yank actions. Nil uses the platform
// clipboard command; tests inject a recorder and never touch the real one.
CopyToClipboard func(string) bool
// Entries are the provider/model pairs the prompt can be submitted to, and
// Queue is the coordinator that runs them. Both are injected: a test and
// the differential supply fakes, and a nil queue refuses the prompt out
// loud rather than reaching for a real provider.
Entries []AgentEntry
Queue *agentQueue
// Embedded keeps nested quit commands inside the model. SuppressQuit turns
// the quit key into a refusal; otherwise QuitRequested surfaces it to the
// host. SuppressFooter lets the host own the shared footer row.
Embedded bool
SuppressQuit bool
// SaveSession overrides standalone persistence for a host namespace.
SaveSession func(SessionState) error
}
Options builds a Model. Every seam a test needs to pin is here: the clock, the environment, and the styler.
type OverlayBox ¶
type OverlayBox struct {
Lines []string
Row int
Col int
// FocusedContentRow is the row inside Lines carrying the caret, or -1.
FocusedContentRow int
}
OverlayBox is a popup positioned in the frame.
type PaletteOutcome ¶
type PaletteOutcome struct {
Kind PickerResultKind
// Entry is set when Kind is PickerAccepted: the action to run.
Entry shortcuts.Entry
Execute bool
}
PaletteOutcome is what a palette key did.
type PickerOption ¶
type PickerOption struct {
ID string
Label string
SearchText []string
Kind PickerOptionKind
// Metadata is the caller's own payload. The action palette hangs the whole
// shortcut entry here so it can execute what the user picked without
// re-deriving it from an id.
Metadata any
}
PickerOption is one choice. A command option (Kind == PickerCommand) is not a selection at all — it runs a mutation over the staged set, which is how "Clear all contexts" lives in the same list as the contexts it clears.
type PickerOptionKind ¶
type PickerOptionKind string
PickerOptionKind separates a selectable choice from a command.
const ( PickerChoice PickerOptionKind = "choice" PickerCommand PickerOptionKind = "command" )
The two option kinds.
type PickerResult ¶
type PickerResult struct {
Kind PickerResultKind
IDs []string
}
PickerResult is one outcome.
type PickerResultKind ¶
type PickerResultKind string
PickerResultKind is what one key or click did.
const ( PickerHandled PickerResultKind = "handled" PickerChanged PickerResultKind = "changed" PickerCancelled PickerResultKind = "cancelled" PickerAccepted PickerResultKind = "accepted" )
The picker outcomes. Accepted carries the ids the caller should apply.
type PlainStyler ¶
type PlainStyler struct{}
PlainStyler is the boring default: no color, and width measured in runes.
It exists so this package is testable and runnable before term/ lands, and so golden row fixtures are plain text rather than a wall of escape bytes. It is NOT the shipping styler — it counts a wide character as one cell, which is exactly the thing term/ is being written to get right.
func (PlainStyler) Paint ¶
func (PlainStyler) Paint(_, text string) string
Paint returns the text unchanged.
func (PlainStyler) Truncate ¶
func (PlainStyler) Truncate(text string, width int) string
Truncate cuts to width runes.
func (PlainStyler) Width ¶
func (PlainStyler) Width(text string) int
Width counts runes. See the type comment for why this is a placeholder.
type QuickForm ¶
type QuickForm struct {
Kind QuickFormKind
// TargetID is the row the form was opened for. A form outliving its target
// must not act on whatever the selection became.
TargetID string
ReturnMode ReturnMode
// Success is the effect to run after a successful submit, set by the submit
// callback itself. Ruby stores it on the UI state; keeping it on the form
// means closing the form cannot leave a stale callback behind.
Success func()
// contains filtered or unexported fields
}
QuickForm is the reusable lifecycle for the TUI's small single-field popups.
The caller supplies domain validation and the mutation; this owns input editing, paste, the error line, rendering and the return mode. The submit callback returns a MESSAGE on failure and "" on success, which is what lets every popup report its own refusal in its own words without the form knowing anything about tasks.
func (*QuickForm) HandleKey ¶
func (q *QuickForm) HandleKey(key string) QuickFormResult
HandleKey routes one raw key.
func (*QuickForm) Paste ¶
func (q *QuickForm) Paste(text string) QuickFormResult
Paste inserts pasted text.
func (*QuickForm) Popup ¶
func (q *QuickForm) Popup(styler Styler, maxWidth, maxHeight int) FormRender
Popup renders the form at the given budget.
func (*QuickForm) SetText ¶
SetText replaces the input through the engine, so a host-driven replacement participates in dirty-state rendering instead of mutating a second buffer.
func (*QuickForm) Submit ¶
func (q *QuickForm) Submit() QuickFormResult
Submit runs the caller's mutation.
type QuickFormKind ¶
type QuickFormKind string
QuickFormKind names which quick form is open, so a test and a hit test can both say which popup they mean.
const ( QuickFormDate QuickFormKind = "date" QuickFormRecurrence QuickFormKind = "recurrence" QuickFormDeferUntil QuickFormKind = "defer_until" QuickFormProjectRename QuickFormKind = "project_rename" QuickFormProjectCapture QuickFormKind = "project_capture" QuickFormDelegate QuickFormKind = "delegate" QuickFormWorkRef QuickFormKind = "work_ref" )
The quick forms this build has. The agent prompt is deliberately absent — it belongs to the agent packet.
type QuickFormOptions ¶
type QuickFormOptions struct {
Kind QuickFormKind
Title string
Prompt string
Hint string
HintFunc func(text string, width int) string
MinWidth int
ReturnMode ReturnMode
Initial string
// Suffix is the fixed gloss shown after the value — the recurrence popup
// uses it to say what the task repeats on right now.
Suffix string
TargetID string
// Submit returns "" on success and a user-visible message on refusal.
Submit func(text string) string
}
QuickFormOptions builds a QuickForm.
type QuickFormResult ¶
type QuickFormResult string
QuickFormResult is what one key did to a quick form.
const ( QuickFormHandled QuickFormResult = "handled" QuickFormChanged QuickFormResult = "changed" QuickFormCancelled QuickFormResult = "cancelled" QuickFormSubmitted QuickFormResult = "submitted" QuickFormError QuickFormResult = "error" )
The four outcomes.
type ReturnMode ¶
type ReturnMode string
ReturnMode is where an overlay goes when it closes. A palette opened from a modal must return TO that modal, or dismissing it would silently close two things at once.
const ( ReturnList ReturnMode = "list" ReturnModal ReturnMode = "modal" )
The two return modes an overlay can carry.
type RightPanel ¶
type RightPanel struct {
Title string
Kind string
Identity string
Lines []string
Scroll int
FocusedRow int
HasFocusedRow bool
}
RightPanel is the persistent panel on the right side — the port of lib/tui/right_panel.rb.
The behavior worth preserving is the scroll rule: replacing content for the SAME identity keeps the reader's place, and moving to another task starts the new content at the top. A refresh caused by an external file write must not throw a reader back to the first line of a long note.
func NewRightPanel ¶
func NewRightPanel(title, kind, identity string, lines []string) *RightPanel
NewRightPanel builds a panel showing content for one identity.
func (*RightPanel) FocusRow ¶
func (p *RightPanel) FocusRow(row int)
FocusRow asks the next view to reveal a specific content row. The editor packet uses this to keep the focused field on screen.
func (*RightPanel) Replace ¶
func (p *RightPanel) Replace(title, identity string, lines []string) *RightPanel
Replace swaps the content. Scroll resets only when the identity changes.
func (*RightPanel) ScrollHalf ¶
func (p *RightPanel) ScrollHalf(direction, height int)
ScrollHalf moves by half a viewport, at least one line.
func (*RightPanel) ScrollLine ¶
func (p *RightPanel) ScrollLine(delta, height int)
ScrollLine moves by whole lines.
func (*RightPanel) ScrollPage ¶
func (p *RightPanel) ScrollPage(direction, height int)
ScrollPage moves by a whole viewport.
func (*RightPanel) View ¶
func (p *RightPanel) View(styler Styler, height, width int) PanelView
View renders the panel into the given box. The title and divider consume two body rows. A status row appears only when the content overflows, and is included in the returned line budget.
func (*RightPanel) Viewport ¶
func (p *RightPanel) Viewport(height int) int
Viewport is the number of content lines visible at this height.
type Row ¶
type Row struct {
Text string
// Item is the task this row acts on, nil for headers, blanks, and project
// header rows.
Item *store.Item
// Node is the tree node behind a tree-mode task row, nil in flat mode.
Node *taskquery.Node
// Project is the rolled-up view behind a selectable Projects header row.
Project *taskquery.ProjectView
// MarkerSpan is the [begin, end) cell range of the collapse marker, for
// mouse hit testing. Zero-width when the row carries no marker.
MarkerBegin int
MarkerEnd int
}
Row is one painted line of the list — the port of Tui::Views::Row.
A row is SELECTABLE (actions apply to it) when it carries an item or a project; a row with neither is a header or a blank. In tree mode a task row also carries its tree node so the model can answer hierarchy questions (collapse, expand, jump to parent) without re-deriving them.
Rows never name a color. Builders paint through semantic slots so the active theme decides the final look, and the renderer highlights the selected row by reversing its text.
func BuildRows ¶
func BuildRows(request BuildRequest) []Row
BuildRows is the single entry point: `Views.rows`.
UseTree false is the flat path a `/` search always takes (its result shape is what filtering expects). UseTree true is the outliner, which nests each anchor's visible subtree beneath it with indent and markers.
func (Row) ID ¶
ID is the durable identity selection follows across re-renders: a task id or a section id. Both live in the same 8-hex space, so one field suffices.
func (Row) Selectable ¶
Selectable reports whether the cursor may land on this row.
type RuntimeOptions ¶ added in v1.1.0
type RuntimeOptions struct {
Paths config.Paths
Env determinism.Env
Session SessionState
Styler Styler
Embedded bool
SuppressQuit bool
SaveSession func(SessionState) error
}
RuntimeOptions configures the shared shipping constructor used by both the standalone executable and public embedding adapter.
type ScreenLayout ¶
type ScreenLayout struct {
Width int
Height int
BodyHeight int
BodyWidth int
ListWidth int
PanelWidth int
PanelContentWidth int
PanelMode string
RequestedMode string
PanelOffset int
Selected int
HasSelection bool
ViewportOffset int
SelectedScreenRow int
EditContentHeight int
Editing bool
}
ScreenLayout is pure geometry for ONE sampled terminal frame — the port of lib/tui/screen_layout.rb.
Ruby introduced it so a resize could not mix dimensions from two winsize reads. Bubble Tea removes that hazard (a WindowSizeMsg is one coherent value), but the type earns its keep for the other reason: rendering, panel placement, selection coordinates and mouse hit testing all have to agree about where row 3 is, and the only way to guarantee that is to compute it once.
func NewScreenLayout ¶
func NewScreenLayout(styler Styler, request LayoutRequest) ScreenLayout
NewScreenLayout computes one frame's geometry.
func (ScreenLayout) BodyRows ¶
func (l ScreenLayout) BodyRows() (int, int)
BodyRows is [begin, end) of the list body.
func (ScreenLayout) ContentBreakpoint ¶
func (l ScreenLayout) ContentBreakpoint() string
ContentBreakpoint is the responsive-width decision the editor renders against.
func (ScreenLayout) EditablePanel ¶
func (l ScreenLayout) EditablePanel() bool
EditablePanel reports whether the panel is large enough to host the editor. The editor packet owns what "editing" means; this is the geometry half of the contract, and it is here because the width ladder is here.
func (ScreenLayout) FooterRows ¶
func (l ScreenLayout) FooterRows() (int, int)
FooterRows is [begin, end) of the footer.
func (ScreenLayout) FooterSize ¶
func (l ScreenLayout) FooterSize() int
FooterSize is the number of footer rows this frame reserved.
func (ScreenLayout) HasPanel ¶
func (l ScreenLayout) HasPanel() bool
HasPanel reports whether the right panel occupies any columns.
func (ScreenLayout) HeaderRow ¶
func (l ScreenLayout) HeaderRow() int
HeaderRow is the row the tab strip paints on.
func (ScreenLayout) ListCols ¶
func (l ScreenLayout) ListCols() (int, int)
ListCols is [begin, end) of the list columns.
func (ScreenLayout) PanelCols ¶
func (l ScreenLayout) PanelCols() (int, int)
PanelCols is [begin, end) of the panel columns, empty with no panel.
func (ScreenLayout) PanelDividerCol ¶
func (l ScreenLayout) PanelDividerCol() int
PanelDividerCol is the column the split rule occupies, or -1 with no panel.
func (ScreenLayout) VisibleRows ¶
func (l ScreenLayout) VisibleRows(rows []Row) []Row
VisibleRows is the slice of rows this frame paints.
type SelectionMode ¶
type SelectionMode string
SelectionMode is single- or multiple-choice.
const ( SelectSingle SelectionMode = "single" SelectMultiple SelectionMode = "multiple" )
The two selection modes.
type SessionState ¶
type SessionState struct {
View string `json:"view,omitempty"`
Collapsed []string `json:"collapsed,omitempty"`
PanelMode string `json:"panel_mode,omitempty"`
PanelOffset int `json:"panel_offset,omitempty"`
ContextFilters []string `json:"context_filters,omitempty"`
// ContextFilter is the retired singular spelling. It is read so an existing
// state file keeps working, and never written.
ContextFilter string `json:"context_filter,omitempty"`
}
SessionState is the small bit of UI preference that survives a restart: the active view, the collapsed set, the panel geometry, and the context filters. It is the port of lib/tui/session.rb plus UiState's restore/serialize halves.
It is deliberately dumb. This is UI preference, not task data — one file per user, and losing it costs nothing but a default. EVERY read tolerates a missing, corrupt, or foreign-version file by returning the zero value: session state must never be able to keep the TUI from starting.
func LoadEmbeddedSession ¶ added in v1.1.0
func LoadEmbeddedSession(env determinism.Env, namespace string) SessionState
LoadEmbeddedSession reads a host-specific embedded session.
func LoadSession ¶
func LoadSession(env determinism.Env) SessionState
LoadSession reads the saved state, or the zero value when there is none to be had.
type Styler ¶
type Styler interface {
// Paint renders text in the named slot.
Paint(slot, text string) string
// Width is the DISPLAY width of text in terminal cells: escape sequences
// count zero and a wide character counts two.
Width(text string) int
// Truncate cuts text to at most width cells, preserving styling and never
// splitting a wide character across the boundary.
Truncate(text string, width int) string
// Wrap folds text to lines of at most width cells.
Wrap(text string, width int) []string
}
Styler is the ONLY thing this package needs from the rendering half of the TUI (`internal/tui/term`). It is deliberately tiny: four operations, no theme type, no color model, no escape-sequence vocabulary.
Rows and detail lines name a semantic SLOT (":title", ":muted", ":due_soon") exactly as the Ruby builders do; the styler decides what a slot looks like, including deciding that it looks like nothing at all under NO_COLOR.
Width, Truncate and Wrap are separate from Paint because a painted string contains bytes that occupy no cells, and every layout decision in this package is made in CELLS. A styler that paints must measure.
type SystemOpener ¶
type SystemOpener struct {
// Env is the environment the override is read from. A nil Env reads the
// process environment.
Env determinism.Env
}
SystemOpener launches a URL in the user's browser — the Go port of Tasks::Opener's behavior. In Ruby that module is shared by `tasks open` and the TUI's `o`; on this side it is TUI-OWNED, because the Go `open` command resolves its launcher itself. What is shared is the contract, not the code.
TASKS_OPENER overrides the platform launcher and is SHELL-SPLIT, so `TASKS_OPENER="open -a Safari"` works. That override is also how a test observes an open without a browser appearing, which is why it is honoured before the platform default rather than after it.
func (SystemOpener) Command ¶
func (o SystemOpener) Command() ([]string, bool)
Command is the launcher argv without the URL, and whether there is one to run at all.
A RAW non-empty override is AUTHORITATIVE: if the user set TASKS_OPENER, that is the launcher, and a malformed or empty-splitting value means there is no launcher — never a quiet fall back to the platform default. Falling back would silently open a browser the user had explicitly configured away from, which is the one outcome an override exists to prevent.
This is exactly what Ruby does, by a different route: `Shellwords.split` raises on an unmatched quote or NUL and `Opener.open_url` rescues ArgumentError into false; a whitespace-only or quoted-empty override splits to no usable launcher and the spawn fails. Both arrive at "no open, and say so".
func (SystemOpener) Open ¶
func (o SystemOpener) Open(url string) bool
Open launches the URL detached and reports whether the launcher could be spawned at all.
Output is DISCARDED: a TUI must not have a browser's stderr scribbled over it. And any spawn failure — a missing launcher, a non-executable TASKS_OPENER — returns false rather than propagating, because a bad opener must not take the interface down on a keystroke.
type TaskEditForm ¶
type TaskEditForm struct {
// contains filtered or unexported fields
}
TaskEditForm is the task-domain policy adapter around the neutral form engine. It owns field order, task-specific normalization and options, and the per-field expectations a patch is guarded by. The session owns effects.
func NewTaskEditForm ¶
func NewTaskEditForm(options TaskEditFormOptions) (*TaskEditForm, error)
NewTaskEditForm builds the editor over one snapshot.
func (*TaskEditForm) AcceptCommit ¶
func (t *TaskEditForm) AcceptCommit(fresh *EditSnapshot, token int) (termform.Transition, error)
AcceptCommit resolves a pending save against a fresh read.
func (*TaskEditForm) ExpectedFor ¶
func (t *TaskEditForm) ExpectedFor(field string) string
ExpectedFor is the baseline a patch on one field must match.
func (*TaskEditForm) Form ¶
func (t *TaskEditForm) Form() *termform.Form
Form is the underlying engine.
func (*TaskEditForm) PatchField ¶
func (t *TaskEditForm) PatchField(field string) store.PatchField
PatchField is the store field an editor field patches.
func (*TaskEditForm) ReadOnly ¶
func (t *TaskEditForm) ReadOnly() (id, closed string)
ReadOnly is the pair of facts the editor shows but cannot change.
func (*TaskEditForm) RefreshSnapshot ¶
func (t *TaskEditForm) RefreshSnapshot(fresh *EditSnapshot) error
RefreshSnapshot adopts a fresh read WITHOUT replacing any dirty buffer or its original expectation.
func (*TaskEditForm) RejectCommit ¶
func (t *TaskEditForm) RejectCommit(fieldErrors map[string][]string, message string, token int) termform.Transition
RejectCommit resolves a pending save with a refusal.
func (*TaskEditForm) ReloadField ¶
func (t *TaskEditForm) ReloadField(field string, fresh *EditSnapshot) error
ReloadField discards one local buffer and adopts the fresh persisted value.
func (*TaskEditForm) RevertField ¶
func (t *TaskEditForm) RevertField(field string)
RevertField throws away one field's unsaved edit.
func (*TaskEditForm) SemanticValue ¶
func (t *TaskEditForm) SemanticValue(field string, value any) (text string, typed *store.PatchValue)
SemanticValue converts a form value into the exact value the store's patch for that field owns.
Two spellings come back because the application facade carries both: a string for the fields whose value IS a string (with "" meaning "clear this" for the clearable ones), and a typed store.PatchValue for the three whose value is not — `deferred` is a bool, `contexts` and `tags` are ordered lists. Every field the editor SHOWS goes through one or the other; none refuses.
func (*TaskEditForm) Snapshot ¶
func (t *TaskEditForm) Snapshot() *EditSnapshot
Snapshot is the read the form's baselines came from.
func (*TaskEditForm) TargetID ¶
func (t *TaskEditForm) TargetID() string
TargetID is the task being edited.
type TaskEditFormOptions ¶
type TaskEditFormOptions struct {
Snapshot *EditSnapshot
Today func() temporal.Date
Context temporal.Context
ContextOptions func() []string
TagOptions func() []string
Focus string
}
TaskEditFormOptions builds one.
type TaskEditorOptions ¶
type TaskEditorOptions struct {
App *application.Application
Read func() *application.ReadModel
Operation func() *application.OperationContext
Today func() temporal.Date
Context temporal.Context
TargetID string
Focus string
// ContextOptions and TagOptions are the completions the two token fields
// offer.
ContextOptions func() []string
TagOptions func() []string
}
TaskEditorOptions builds a session.
type TaskEditorSession ¶
type TaskEditorSession struct {
// contains filtered or unexported fields
}
TaskEditorSession coordinates one durable task-edit pass: it translates form transitions into application-owned patches, and holds every piece of recoverable local state while it does.
The design rule throughout is that NOTHING the user typed is ever lost by a refusal. A rejected save keeps the buffer; a conflict keeps the buffer AND offers to copy it; escape asks twice before discarding a field.
func NewTaskEditorSession ¶
func NewTaskEditorSession(options TaskEditorOptions) (*TaskEditorSession, error)
NewTaskEditorSession opens an editor over one task.
func (*TaskEditorSession) CancelConfirmation ¶
func (s *TaskEditorSession) CancelConfirmation() EditorOutcome
CancelConfirmation declines a pending consequence, keeping the local value.
func (*TaskEditorSession) Confirm ¶
func (s *TaskEditorSession) Confirm() EditorOutcome
Confirm accepts a pending consequence and performs the write.
func (*TaskEditorSession) Conflict ¶
func (s *TaskEditorSession) Conflict() *EditorConflict
func (*TaskEditorSession) CopyValue ¶
func (s *TaskEditorSession) CopyValue() any
CopyValue is the value a missing-task editor still holds for the user to copy — the whole reason a vanished task does not simply close the editor.
func (*TaskEditorSession) Dirty ¶
func (s *TaskEditorSession) Dirty(field string) bool
Dirty reports unsaved edits, in the whole form or in one field.
func (*TaskEditorSession) EditForm ¶
func (s *TaskEditorSession) EditForm() *TaskEditForm
func (*TaskEditorSession) Finish ¶
func (s *TaskEditorSession) Finish() EditorOutcome
Finish leaves the editor: immediately when the focused field is clean, and only after that field is accepted when it is not. A refusal always leaves the editor open and recoverable.
func (*TaskEditorSession) FocusedKey ¶
func (s *TaskEditorSession) FocusedKey() string
FocusedKey is the field the caret is in.
func (*TaskEditorSession) Form ¶
func (s *TaskEditorSession) Form() *termform.Form
Form is the underlying engine, or nil for a missing task.
func (*TaskEditorSession) HandleKey ¶
func (s *TaskEditorSession) HandleKey(key string) EditorOutcome
HandleKey routes one raw key through the editor.
func (*TaskEditorSession) HandleQuitConfirmation ¶
func (s *TaskEditorSession) HandleQuitConfirmation(key string) EditorOutcome
HandleQuitConfirmation answers the quit prompt.
func (*TaskEditorSession) KeepForCopy ¶
func (s *TaskEditorSession) KeepForCopy() EditorOutcome
KeepForCopy preserves the local value as an explicit copy payload. The conflict stays active until a reload, so this can never become an overwrite.
func (*TaskEditorSession) Missing ¶
func (s *TaskEditorSession) Missing() bool
func (*TaskEditorSession) Paste ¶
func (s *TaskEditorSession) Paste(text string) EditorOutcome
Paste inserts pasted text into the focused field.
func (*TaskEditorSession) PendingConfirmation ¶
func (s *TaskEditorSession) PendingConfirmation() *EditorConfirmationPrompt
PendingConfirmation and Conflict expose the two blocking states.
func (*TaskEditorSession) PendingQuit ¶
func (s *TaskEditorSession) PendingQuit() bool
PendingQuit reports an armed quit confirmation.
func (*TaskEditorSession) PendingRevert ¶
func (s *TaskEditorSession) PendingRevert() string
PendingRevert is the field an Escape has armed for discard.
func (*TaskEditorSession) Refresh ¶
func (s *TaskEditorSession) Refresh() EditorOutcome
Refresh adopts a fresh read. Dirty buffers keep both their text and the expectation their eventual patch will be compared against.
func (*TaskEditorSession) ReloadConflict ¶
func (s *TaskEditorSession) ReloadConflict() EditorOutcome
ReloadConflict discards the conflicting local buffer and adopts the value that actually landed.
func (*TaskEditorSession) RenderModel ¶
func (s *TaskEditorSession) RenderModel() termform.RenderModel
RenderModel is what the panel paints.
func (*TaskEditorSession) RequestQuit ¶
func (s *TaskEditorSession) RequestQuit() EditorOutcome
RequestQuit asks whether an unsaved draft may be discarded. The DRAFT owns this protection so the same guard follows the editor whether it is visible or suspended by a resize.
func (*TaskEditorSession) Save ¶
func (s *TaskEditorSession) Save() EditorOutcome
Save persists the focused field in place, keeping focus on it.
func (*TaskEditorSession) Snapshot ¶
func (s *TaskEditorSession) Snapshot() *EditSnapshot
func (*TaskEditorSession) Suspend ¶
func (s *TaskEditorSession) Suspend() EditorOutcome
Suspend hides the editor without losing it. Every buffer and durable baseline survives; the transient one-key prompts are DISARMED, because a hidden editor must never retain a destructive action a read-mode key could accept.
func (*TaskEditorSession) TargetID ¶
func (s *TaskEditorSession) TargetID() string
TargetID, EditForm, Snapshot and the predicates are the read surface.
type TemporalControl ¶
TemporalControl is the control as the renderer sees it.
type TemporalInput ¶
TemporalInput is a date field that also opens the structured control.
It embeds the neutral DateInput so the typed path, the parse errors and the calendar are unchanged; what it adds is a second overlay that owns the keyboard while it is open.
func NewTemporalInput ¶
func NewTemporalInput(base termform.Base, hooks termform.DateHooks, today func() temporal.Date, suggestions []string, context temporal.Context) *TemporalInput
NewTemporalInput builds one.
func (*TemporalInput) CalendarDate ¶
func (t *TemporalInput) CalendarDate() *temporal.Date
CalendarDate is the day-picker's highlighted day, or nil.
func (*TemporalInput) ControlLines ¶
func (t *TemporalInput) ControlLines(width int) []string
ControlLines renders the control at a width.
func (*TemporalInput) ControlOpen ¶
func (t *TemporalInput) ControlOpen() bool
ControlOpen reports the structured control specifically.
func (*TemporalInput) CursorFor ¶
func (t *TemporalInput) CursorFor(value any, context termform.Context) *int
CursorFor hides the text caret while either overlay owns the keyboard.
func (*TemporalInput) HandleEvent ¶
func (t *TemporalInput) HandleEvent(event termform.Event, value any, context termform.Context) *termform.Result
HandleEvent routes one event: the control first when it is open, then the base field's typed and calendar behavior.
func (*TemporalInput) MetadataFor ¶
MetadataFor publishes the control for the form renderer.
func (*TemporalInput) PickerOpen ¶
func (t *TemporalInput) PickerOpen() bool
PickerOpen reports either overlay: the structured control or the calendar the base field opens.
func (*TemporalInput) Value ¶
func (t *TemporalInput) Value() *temporal.Value
Value is the control's working value.
func (*TemporalInput) ZoneSearch ¶
func (t *TemporalInput) ZoneSearch() *string
ZoneSearch is the live zone query, or nil when the search is not open.
type ViewQuery ¶
type ViewQuery struct {
View string
Queries *taskquery.Queries
UrgentDays int
ShowDeferred bool
ContextFilters []string
}
ViewQuery is the canonical semantic query for both the flat and the tree row builders — the port of Tui::Views::Query.
It owns per-view eligibility, classification and grouping, and item ordering. Tree builders only decide which matching nodes become anchors and then render their descendants; they never re-decide what a view means. That split is what keeps the Agenda tab and `tasks agenda` from drifting apart.
func NewViewQuery ¶
func NewViewQuery(view string, queries *taskquery.Queries, urgentDays int, showDeferred bool, contextFilters []string) ViewQuery
NewViewQuery builds the query for one view.
func (ViewQuery) ContextMatch ¶
ContextMatch is true when no context filter is active, or the item carries any selected context. Contexts are one OR facet; the view and text predicates compose by AND.
func (ViewQuery) Eligible ¶
Eligible is view-only eligibility: the per-view state/date rule, and then availability.
The active context filter is deliberately NOT folded in here. Agenda anchors a root when ANY subtree item is eligible, and an undated @work parent whose only dates sit on untagged children must keep that thread. Context is a separate predicate; Matching is the conjunction.
The two conjuncts are ordered cheap-first on purpose: the view rule reads fields already on the Item, while the availability test walks task ancestors.
func (ViewQuery) GroupKeys ¶
GroupKeys is the group or groups an item belongs to. A task with several contexts appears once per context in the Next view — which is exactly why selection has to follow an id AND an occurrence, not an id alone.
func (ViewQuery) GroupedNodes ¶
GroupedNodes buckets nodes by GroupKeys and sorts each bucket.
func (ViewQuery) SelectNodes ¶
SelectNodes and SortNodes are the tree-mode twins: the same policy applied to nodes through their items.
func (ViewQuery) Sort ¶
Sort orders items by the view's key. STABLE, deliberately: Ruby's sort_by is not, and Wave 1 already had to fix one list whose tie order was whatever introsort left behind. A list that permutes under an unrelated edit is how a user completes the wrong row.
func (ViewQuery) SortedGroups ¶
SortedGroups orders the buckets. Every view but Projects orders by key text; Projects orders by the soonest date anywhere in the bucket, then by key.
Source Files
¶
- actions.go
- agentadapter.go
- agentprompt.go
- bodies.go
- bootstrap.go
- build.go
- choicepicker.go
- commands.go
- delegation.go
- details.go
- editsnapshot.go
- export.go
- formrender.go
- keys.go
- layout.go
- listactions.go
- modal.go
- modals.go
- model.go
- mouse.go
- opener.go
- overlay.go
- palettes.go
- panel.go
- quickform.go
- recurpreview.go
- render.go
- rows.go
- session.go
- style.go
- taskeditform.go
- taskeditsession.go
- temporalpicker.go
- uistate.go
- viewquery.go
Directories
¶
| Path | Synopsis |
|---|---|
|
Package term is the seam between the TUI shell and the terminal primitives under term/.
|
Package term is the seam between the TUI shell and the terminal primitives under term/. |
|
agent
Package agent is the serial coordinator for autonomous TUI agent requests and the presentation of their transcripts.
|
Package agent is the serial coordinator for autonomous TUI agent requests and the presentation of their transcripts. |
|
ansi
Package ansi holds the SGR-aware, width-aware string helpers.
|
Package ansi holds the SGR-aware, width-aware string helpers. |
|
border
Package border is the single owner of box-drawing chrome: rounded corners plus an angled truecolor gradient swept across a container's border cells.
|
Package border is the single owner of box-drawing chrome: rounded corners plus an angled truecolor gradient swept across a container's border cells. |
|
charwidth
Package charwidth answers the terminal display width of Unicode codepoints and grapheme clusters.
|
Package charwidth answers the terminal display width of Unicode codepoints and grapheme clusters. |
|
clipboard
Package clipboard writes to the system clipboard via whatever tool the platform has, with no third-party dependency.
|
Package clipboard writes to the system clipboard via whatever tool the platform has, with no third-party dependency. |
|
frame
Package frame is a pure frame builder: given content, it returns one string per terminal row, each exactly `width` visible cells wide.
|
Package frame is a pure frame builder: given content, it returns one string per terminal row, each exactly `width` visible cells wide. |
|
hitmap
Package hitmap is pure geometry: it maps a screen (row, col) to a Hit zone using the rectangles a layout publishes.
|
Package hitmap is pure geometry: it maps a screen (row, col) to a Hit zone using the rectangles a layout publishes. |
|
input
Package input holds the terminal input primitives: the raw key sequences the TUI recognizes, a raw-bytes-to-semantic-event key map, and the grapheme-aware single-line/multi-line text editor used by the prompt and by form fields.
|
Package input holds the terminal input primitives: the raw key sequences the TUI recognizes, a raw-bytes-to-semantic-event key map, and the grapheme-aware single-line/multi-line text editor used by the prompt and by form fields. |
|
layout
Package layout is pure geometry for one sampled terminal frame.
|
Package layout is pure geometry for one sampled terminal frame. |
|
mouse
Package mouse is a pure SGR mouse-report decoder plus the (mode, zone, button, action) → intent table.
|
Package mouse is a pure SGR mouse-report decoder plus the (mode, zone, button, action) → intent table. |
|
shortcuts
Package shortcuts is the declarative registry for every keyboard action shown in help.
|
Package shortcuts is the declarative registry for every keyboard action shown in help. |
|
theme
Package theme is the semantic color layer.
|
Package theme is the semantic color layer. |
|
Package termform is the persistence-neutral form engine the TUI's editor and popups are built from — the Go port of Ruby's lib/term_form/.
|
Package termform is the persistence-neutral form engine the TUI's editor and popups are built from — the Go port of Ruby's lib/term_form/. |