tui

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2026 License: MIT Imports: 35 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package tui is jt's interactive terminal UI, built on Bubble Tea v2.

Index

Constants

This section is empty.

Variables

View Source
var BuiltinListNames = []string{"issues", "mine", "sprint", "backlog", "recent", "watching", "reported", "epics", "bugs", "updated"}

BuiltinListNames are the list commands offered in completion and help.

Functions

func IssueTypes

func IssueTypes() []*jira.IssueType

IssueTypes are the active project's issue types from the config.

func Run

func Run(b Backend, opts Options) error

Run starts the TUI and blocks until the user quits.

func SaveQuery

func SaveQuery(name, jql string) error

SaveQuery stores a named JQL query under saved_queries.

func SearchJQL

func SearchJQL(sess Session, input string) string

SearchJQL turns search input (with an optional mode prefix such as ">" or "#") into JQL, or "" if there is nothing to run. Saved-query input ("*") is resolved by name instead.

func SetTheme

func SetTheme(name string) error

SetTheme persists the theme choice.

Types

type App

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

App is the root Bubble Tea model: a stack of views, an optional floating popup, and a status bar.

func NewApp

func NewApp(sess Session, b Backend, opts Options) *App

NewApp builds the root model.

func (*App) Init

func (a *App) Init() tea.Cmd

Init starts the first view.

func (*App) Update

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

Update routes messages to the popup, global key handlers and views.

func (*App) View

func (a *App) View() tea.View

View renders the stack's top view, the status bar and any popup.

type Backend

type Backend interface {
	Search(jql string, from, limit uint) (*jira.SearchResult, error)
	Issue(key string) (*jira.Issue, error)
	FavouriteFilters() ([]*jira.SavedFilter, error)

	Transitions(key string) ([]*jira.Transition, error)
	Transition(key string, t *jira.Transition) error
	AssignableUsers(project, query string) ([]*jira.User, error)
	// Assign sets the assignee by username; jira.AssigneeNone unassigns.
	Assign(key, username string) error
	Comment(key, markdown string) error
	Worklog(key, timeSpent, comment string) error
	Edit(key string, req *jira.EditRequest) error
	Create(req *jira.CreateRequest) (*jira.CreateResponse, error)
	Watch(key, username string, watch bool) error
	LinkTypes() ([]*jira.IssueLinkType, error)
	Link(inward, outward, linkType string) error
	Delete(key string) error

	Board(boardID int) (*jira.BoardConfig, error)
	// Sprints lists sprints in the given comma separated states.
	Sprints(boardID int, states string) ([]*jira.Sprint, error)
	SprintIssues(sprintID int, jql string) (*jira.SearchResult, error)
	BoardIssues(boardID int, jql string) (*jira.SearchResult, error)
	MoveToSprint(sprintID int, keys []string) error
	MoveToBacklog(keys []string) error
	Rank(keys []string, before, after string) error
}

Backend is the slice of the Jira API the TUI needs. It is an interface so the UI can be driven by a fake in tests.

func NewJiraBackend

func NewJiraBackend(c *jira.Client) Backend

NewJiraBackend wraps a configured Jira client.

type Hint

type Hint struct {
	Key, Desc string
}

Hint is a key and what it does.

type ListSpec

type ListSpec struct {
	Name  string // command name, e.g. "mine"
	Title string
	JQL   string
}

ListSpec describes an issue list view: a title and the JQL behind it.

func BuiltinList

func BuiltinList(name string, s Session) (ListSpec, bool)

BuiltinList returns the spec for a built-in list name, or false.

func EpicChildren

func EpicChildren(key string) ListSpec

EpicChildren lists the issues of an epic (Jira DC "Epic Link").

func QueryList

func QueryList(title, jql string) ListSpec

QueryList wraps raw JQL as a list.

type Options

type Options struct {
	// Start is a ":" command to run first (e.g. "mine" or "DATA-12").
	Start string
	// Search opens the floating search with this input on startup.
	Search string
	// contains filtered or unexported fields
}

Options configure how the TUI starts.

func (Options) WithSearch

func (o Options) WithSearch(input string) Options

WithSearch opens the floating search with input on startup.

type Popup interface {
	Update(msg tea.Msg) (Popup, tea.Cmd)
	// Render returns the framed window sized for a screen of width x height.
	Render(st styles, width, height int) string
}

Popup is a floating window. While open it receives every key.

type Session

type Session struct {
	Server   string
	Login    string
	Name     string // saved project name (current_project)
	Project  string
	BoardID  int
	Projects []jtConfig.SavedProject
	Queries  map[string]string // saved_queries from config
	Theme    string

	// WatchInterval polls watched/assigned issues for changes (0 disables).
	WatchInterval time.Duration
	// Bell rings the terminal bell on watch notifications.
	Bell bool
}

Session is the user-facing state that survives view changes: who we are, which server, and which saved project is active.

func LoadSession

func LoadSession() Session

LoadSession snapshots the current viper state (after the project overlay).

func SwitchProject

func SwitchProject(name string) (Session, error)

SwitchProject persists name as the current project, re-applies it to viper and returns the refreshed session.

func (Session) BrowseURL

func (s Session) BrowseURL(key string) string

BrowseURL is the web URL of an issue.

func (Session) ExpandJQL

func (s Session) ExpandJQL(jql string) string

ExpandJQL substitutes {project}/{me} placeholders in saved queries.

func (Session) ProjectClause

func (s Session) ProjectClause() string

ProjectClause scopes a query to the active project, if any.

type View

type View interface {
	Init() tea.Cmd
	Update(msg tea.Msg) (View, tea.Cmd)
	Render(width, height int) string
	Title() string
	// Hints are the view's own keys, shown in the footer and in help.
	Hints() []Hint
	// Capturing is true while the view owns the keyboard (e.g. inline
	// filter input), so global keys are not intercepted.
	Capturing() bool
	// Selected is the issue under the cursor, if any; global issue actions
	// (open, copy, branch) act on it.
	Selected() *jira.Issue
	// Marked are the issues selected in visual mode; actions apply to all
	// of them when non-empty.
	Marked() []*jira.Issue
}

View is one screen on the view stack (issue list, issue detail, ...).

Jump to

Keyboard shortcuts

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