dialogs

package
v0.3.35 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

View Source
const CommandsID = "commands"

CommandsID is the identifier for the commands dialog.

View Source
const ConfigID = "builder"
View Source
const DeployID = "deploy"
View Source
const InitID = "init"

InitID is the identifier for the init dialog.

View Source
const OAuthID = "oauth"

OAuthID is the identifier for the model selection dialog.

View Source
const QuitID = "quit"

QuitID is the identifier for the quit dialog.

View Source
const SessionsID = "sessions"

SessionsID is the identifier for the session selector dialog.

Variables

View Source
var CloseKey = key.NewBinding(
	key.WithKeys("esc", "alt+esc"),
	key.WithHelp("esc", "exit"),
)

CloseKey is the default key binding to close dialogs.

Functions

func Begin added in v0.3.28

func Begin(oidcProvider oidc.OidcProvider) tea.Cmd

Begin initiates the OAuth device flow.

func CloseAction added in v0.3.28

func CloseAction() tea.Cmd

CloseAction returns a command that closes the dialog and runs the given cleanup command.

func CopyCodeAndOpenURL added in v0.3.28

func CopyCodeAndOpenURL(deviceAuth *oidc.DeviceAuth) tea.Cmd

CopyCodeAndOpenURL copies the code and opens the URL in the browser.

func DialogTitle added in v0.3.28

func DialogTitle(t *styles.Styles, title string, width int, fromColor, toColor color.Color) string

DialogTitle renders a dialog title with a decorative line filling the remaining width. When the title alone exceeds the available width it is truncated with an ellipsis so it never wraps.

func DrawCenter added in v0.3.28

func DrawCenter(scr uv.Screen, area uv.Rectangle, view string)

DrawCenter draws the given string view centered in the screen area.

func DrawCenterCursor added in v0.3.28

func DrawCenterCursor(scr uv.Screen, area uv.Rectangle, view string, cur *tea.Cursor)

DrawCenterCursor draws the given string view centered in the screen area and adjusts the cursor position accordingly. Content larger than the area is clamped to fit.

func DrawOnboarding added in v0.3.28

func DrawOnboarding(scr uv.Screen, area uv.Rectangle, view string)

DrawOnboarding draws the given string view centered in the screen area.

func DrawOnboardingCursor added in v0.3.28

func DrawOnboardingCursor(scr uv.Screen, area uv.Rectangle, view string, cur *tea.Cursor)

DrawOnboardingCursor draws the given string view positioned at the bottom left area of the screen. Content larger than the area is clamped to fit.

func Finish added in v0.3.28

func Finish(oidcProvider oidc.OidcProvider, deviceAuth *oidc.DeviceAuth) tea.Cmd

Finish completes the OAuth device flow.

func InputCursor added in v0.3.28

func InputCursor(t *styles.Styles, cur *tea.Cursor) *tea.Cursor

InputCursor adjusts the cursor position for an input field within a dialog.

func NewSessionItemDelegate added in v0.3.28

func NewSessionItemDelegate(keys *delegateKeyMap, styles *styles.Styles, workspace workspaces.Workspace) list.DefaultDelegate

NewSessionItemDelegate returns a new session item delegate.

Types

type Action added in v0.3.28

type Action any

Action represents an action taken in a dialog after handling a message.

type ActionClose

type ActionClose struct{}

ActionClose is a message to close the current dialog.

type ActionCloseOAuth added in v0.3.28

type ActionCloseOAuth struct {
	Cmd tea.Cmd
}

ActionCloseOAuth closes the OAuth dialog and runs the given cleanup command, cancelling any in-flight authorization. It exists so a dismissed dialog does not leave a poller or loopback listener running in the background.

type ActionCmd added in v0.3.28

type ActionCmd struct {
	Cmd tea.Cmd
}

ActionCmd is a message to execute a command.

type ActionInitCompleted added in v0.3.28

type ActionInitCompleted struct{}

ActionInitCompleted is an action that is dispatched when the init flow completes successfully.

type ActionInitErrored added in v0.3.28

type ActionInitErrored struct{ Error error }

ActionInitErrored is an action that is dispatched when the init flow encounters an error.

type ActionInitiateBuilder added in v0.3.28

type ActionInitiateBuilder struct{ URL string }

ActionInitiateBuilder is sent when the OAuth builder is initiated.

type ActionNoop added in v0.3.28

type ActionNoop = struct{}

ActionNoop is a message to do nothing.

type ActionOAuthCompleted added in v0.3.28

type ActionOAuthCompleted struct {
	Token *oidc.Token
}

ActionOAuthCompleted is sent when the OAuth flow is completed successfully.

type ActionOAuthErrored added in v0.3.28

type ActionOAuthErrored struct {
	Error error
}

ActionOAuthErrored is sent when the device flow encounters an error.

type ActionOAuthInitialized added in v0.3.28

type ActionOAuthInitialized struct {
	DeviceAuth *oidc.DeviceAuth
}

ActionOAuthInitialized is sent when the OAuth flow is initialized.

type ActionOpenDialog

type ActionOpenDialog struct {
	DialogID string
}

ActionOpenDialog is a message to open a dialog.

type ActionQuit

type ActionQuit = tea.QuitMsg

ActionQuit is a message to quit the application.

type ActionToggleHelp added in v0.3.28

type ActionToggleHelp struct{}

ActionToggleHelp is a message to toggle the help dialog.

type CommandItem added in v0.3.28

type CommandItem struct {
	*list.Versioned
	// contains filtered or unexported fields
}

CommandItem wraps a uicmd.Command to implement the ListItem interface.

func NewCommandItem added in v0.3.28

func NewCommandItem(t *styles.Styles, id, title, shortcut string, action Action) *CommandItem

NewCommandItem creates a new CommandItem.

func (*CommandItem) Action added in v0.3.28

func (c *CommandItem) Action() Action

Action returns the action associated with the command item.

func (*CommandItem) Filter added in v0.3.28

func (c *CommandItem) Filter() string

Filter implements ListItem.

func (*CommandItem) Finished added in v0.3.28

func (c *CommandItem) Finished() bool

Finished implements list.Item. Command items are render-stable outside of explicit SetFocused / SetMatch.

func (*CommandItem) ID added in v0.3.28

func (c *CommandItem) ID() string

ID implements ListItem.

func (*CommandItem) InfoText added in v0.3.28

func (c *CommandItem) InfoText() string

InfoText implements infoColumnItem; the command shortcut is its info.

func (*CommandItem) Render added in v0.3.28

func (c *CommandItem) Render(width int) string

Render implements ListItem.

func (*CommandItem) SetFocused added in v0.3.28

func (c *CommandItem) SetFocused(focused bool)

SetFocused implements ListItem.

func (*CommandItem) SetHideInfo added in v0.3.28

func (c *CommandItem) SetHideInfo(v bool)

SetHideInfo controls whether the shortcut hint column is shown. The dialog hides it uniformly when it would crowd the command names.

func (*CommandItem) SetMatch added in v0.3.28

func (c *CommandItem) SetMatch(m fuzzy.Match)

SetMatch implements ListItem.

func (*CommandItem) Shortcut added in v0.3.28

func (c *CommandItem) Shortcut() string

Shortcut returns the shortcut associated with the command item.

func (*CommandItem) WithAliases added in v0.3.28

func (c *CommandItem) WithAliases(aliases ...string) *CommandItem

WithAliases returns the CommandItem with the given aliases for filtering.

func (*CommandItem) WithDescription added in v0.3.28

func (c *CommandItem) WithDescription(desc string) *CommandItem

WithDescription returns the CommandItem with a description displayed below the title.

type CommandType added in v0.3.28

type CommandType uint

CommandType represents the type of commands being displayed.

const (
	SystemCommands CommandType = iota
	UserCommands
)

func (CommandType) String added in v0.3.28

func (c CommandType) String() string

String returns the string representation of the CommandType.

type Commands added in v0.3.28

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

Commands represents a dialog that shows available commands.

func NewCommands added in v0.3.28

func NewCommands(ui *defaults.UI, sessionID string, hasSession, hasTodos, hasQueue bool) (*Commands, error)

NewCommands creates a new commands dialog.

func (*Commands) Cursor added in v0.3.28

func (c *Commands) Cursor() *tea.Cursor

Cursor returns the cursor position relative to the dialog.

func (*Commands) Draw added in v0.3.28

func (c *Commands) Draw(scr uv.Screen, area uv.Rectangle) *tea.Cursor

Draw implements Dialog.

func (*Commands) FullHelp added in v0.3.28

func (c *Commands) FullHelp() [][]key.Binding

FullHelp implements help.KeyMap.

func (*Commands) HandleMsg added in v0.3.28

func (c *Commands) HandleMsg(msg tea.Msg) Action

HandleMsg implements Dialog.

func (*Commands) ID added in v0.3.28

func (c *Commands) ID() string

ID implements Dialog.

func (*Commands) InitialCmd added in v0.3.28

func (c *Commands) InitialCmd() tea.Cmd

func (*Commands) ShortHelp added in v0.3.28

func (c *Commands) ShortHelp() []key.Binding

ShortHelp implements help.KeyMap.

func (*Commands) StartLoading added in v0.3.28

func (c *Commands) StartLoading() tea.Cmd

StartLoading implements LoadingDialog.

func (*Commands) StopLoading added in v0.3.28

func (c *Commands) StopLoading()

StopLoading implements LoadingDialog.

type ConfigDialog added in v0.3.28

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

ConfigDialog represents a builder configuration dialog.

func NewConfigDialog added in v0.3.28

func NewConfigDialog(ui *defaults.UI, url string) (*ConfigDialog, error)

NewConfigDialog creates a new ConfigDialog.

func (*ConfigDialog) Cursor added in v0.3.28

func (m *ConfigDialog) Cursor() *tea.Cursor

Cursor returns the cursor for the dialog.

func (*ConfigDialog) Draw added in v0.3.28

func (m *ConfigDialog) Draw(scr uv.Screen, area uv.Rectangle) *tea.Cursor

Draw implements Dialog.

func (*ConfigDialog) FullHelp added in v0.3.28

func (m *ConfigDialog) FullHelp() [][]key.Binding

FullHelp returns the full help view.

func (*ConfigDialog) HandleMsg added in v0.3.28

func (m *ConfigDialog) HandleMsg(msg tea.Msg) Action

HandleMsg implements Dialog.

func (*ConfigDialog) ID added in v0.3.28

func (m *ConfigDialog) ID() string

ID implements Dialog.

func (*ConfigDialog) ShortHelp added in v0.3.28

func (m *ConfigDialog) ShortHelp() []key.Binding

ShortHelp returns the short help view.

type DeployDialog added in v0.3.28

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

DeployDialog represents a deploy configuration dialog.

func NewDeploy added in v0.3.28

func NewDeploy(ui *defaults.UI) *DeployDialog

NewDeploy creates a new DeployDialog.

func (*DeployDialog) Cursor added in v0.3.28

func (m *DeployDialog) Cursor() *tea.Cursor

Cursor returns the cursor for the dialog.

func (*DeployDialog) Draw added in v0.3.28

func (m *DeployDialog) Draw(scr uv.Screen, area uv.Rectangle) *tea.Cursor

Draw implements Dialog.

func (*DeployDialog) FullHelp added in v0.3.28

func (m *DeployDialog) FullHelp() [][]key.Binding

FullHelp returns the full help view.

func (*DeployDialog) HandleMsg added in v0.3.28

func (m *DeployDialog) HandleMsg(msg tea.Msg) Action

HandleMsg implements Dialog.

func (*DeployDialog) ID added in v0.3.28

func (m *DeployDialog) ID() string

ID implements Dialog.

func (*DeployDialog) ShortHelp added in v0.3.28

func (m *DeployDialog) ShortHelp() []key.Binding

ShortHelp returns the short help view.

type Dialog added in v0.3.28

type Dialog interface {
	// ID returns the unique identifier of the dialog.
	ID() string
	// HandleMsg processes a message and returns an action. An [Action] can be
	// anything and the caller is responsible for handling it appropriately.
	HandleMsg(msg tea.Msg) Action
	// Draw draws the dialog onto the provided screen within the specified area
	// and returns the desired cursor position on the screen.
	Draw(scr uv.Screen, area uv.Rectangle) *tea.Cursor
}

Dialog is a component that can be displayed on top of the UI.

type HoverDialog added in v0.3.28

type HoverDialog interface {
	HandlesHover() bool
}

HoverDialog is a dialog that reacts to mouse hover. While one is open, the terminal must report all mouse motion events, not just clicks.

type InitDialog added in v0.3.28

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

InitDialog handles the initialization flow for the UI.

func NewInit added in v0.3.28

func NewInit(ui *defaults.UI) (*InitDialog, tea.Cmd)

NewInit creates a new init dialog.

func (*InitDialog) Draw added in v0.3.28

func (m *InitDialog) Draw(scr uv.Screen, area uv.Rectangle) *tea.Cursor

View renders the device flow dialog.

func (*InitDialog) FullHelp added in v0.3.28

func (m *InitDialog) FullHelp() [][]key.Binding

FullHelp returns the full help view.

func (*InitDialog) HandleMsg added in v0.3.28

func (m *InitDialog) HandleMsg(msg tea.Msg) Action

HandleMsg handles messages and state transitions.

func (*InitDialog) ID added in v0.3.28

func (m *InitDialog) ID() string

ID implements Dialog.

func (*InitDialog) ShortHelp added in v0.3.28

func (m *InitDialog) ShortHelp() []key.Binding

ShortHelp returns the full help view.

type InitState added in v0.3.28

type InitState int

InitState represents the current state of the init flow.

const (
	InitStateInitialized InitState = iota
	InitStateStarted
	InitStateFinished
	InitStateError
)

type ListItem added in v0.3.28

type ListItem interface {
	list.FilterableItem
	list.Focusable
	list.MatchSettable

	// ID returns the unique identifier of the item.
	ID() string
}

ListItem represents a selectable and searchable item in a dialog list.

type ListItemGenerator added in v0.3.28

type ListItemGenerator[S ~[]R, R any] func(s S) []R

ListItemGenerator is an interface for generating list items.

type ListItemStyles added in v0.3.28

type ListItemStyles struct {
	ItemBlurred     lipgloss.Style
	ItemFocused     lipgloss.Style
	InfoTextBlurred lipgloss.Style
	InfoTextFocused lipgloss.Style
}

ListItemStyles holds the styles for list items in a dialog.

type LoadingDialog added in v0.3.28

type LoadingDialog interface {
	StartLoading() tea.Cmd
	StopLoading()
}

LoadingDialog is a dialog that can show a loading state.

type OAuth added in v0.3.28

type OAuth struct {

	// State is the current state of the OAuth flow.
	State OAuthState
	// contains filtered or unexported fields
}

OAuth handles the OAuth flow authentication.

func NewOAuth added in v0.3.28

func NewOAuth(ui *defaults.UI, oidcProvider oidc.OidcProvider, name string) (*OAuth, tea.Cmd)

NewOAuth creates a new OAuth dialog.

func (*OAuth) Draw added in v0.3.28

func (m *OAuth) Draw(scr uv.Screen, area uv.Rectangle) *tea.Cursor

View renders the device flow dialog.

func (*OAuth) FullHelp added in v0.3.28

func (m *OAuth) FullHelp() [][]key.Binding

FullHelp returns the full help view.

func (*OAuth) HandleMsg added in v0.3.28

func (m *OAuth) HandleMsg(msg tea.Msg) Action

HandleMsg handles messages and state transitions.

func (*OAuth) ID added in v0.3.28

func (m *OAuth) ID() string

ID implements Dialog.

func (*OAuth) ShortHelp added in v0.3.28

func (m *OAuth) ShortHelp() []key.Binding

ShortHelp returns the full help view.

type OAuthState added in v0.3.28

type OAuthState int

OAuthState represents the current state of the device flow.

const (
	OAuthStateInitializing OAuthState = iota
	OAuthStateAuthenticating
	OAuthStateSuccess
	OAuthStateSaving
	OAuthStateError
)

type Overlay added in v0.3.28

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

Overlay manages multiple dialogs as an overlay.

func NewOverlay added in v0.3.28

func NewOverlay(dialogs ...Dialog) *Overlay

NewOverlay creates a new Overlay instance.

func (*Overlay) BringToFront added in v0.3.28

func (d *Overlay) BringToFront(dialogID string)

BringToFront brings the dialog with the specified ID to the front.

func (*Overlay) CloseDialog added in v0.3.28

func (d *Overlay) CloseDialog(dialogID string)

CloseDialog closes the dialog with the specified ID from the stack.

func (*Overlay) CloseFrontDialog added in v0.3.28

func (d *Overlay) CloseFrontDialog()

CloseFrontDialog closes the front dialog in the stack.

func (*Overlay) ContainsDialog added in v0.3.28

func (d *Overlay) ContainsDialog(dialogID string) bool

ContainsDialog checks if a dialog with the specified ID exists.

func (*Overlay) Dialog added in v0.3.28

func (d *Overlay) Dialog(id string) Dialog

Dialog returns the dialog with the specified ID, or nil if not found.

func (*Overlay) DialogLast added in v0.3.28

func (d *Overlay) DialogLast() Dialog

DialogLast returns the front dialog, or nil if there are no dialogs.

func (*Overlay) Draw added in v0.3.28

func (d *Overlay) Draw(scr uv.Screen, area uv.Rectangle) *tea.Cursor

Draw renders the overlay and its dialogs.

func (*Overlay) HandlesHover added in v0.3.28

func (d *Overlay) HandlesHover() bool

HandlesHover reports whether any open dialog reacts to mouse hover, in which case the terminal should report all mouse motion events.

func (*Overlay) HasDialogs added in v0.3.28

func (d *Overlay) HasDialogs() bool

HasDialogs checks if there are any active dialogs.

func (*Overlay) OpenDialog added in v0.3.28

func (d *Overlay) OpenDialog(dialog Dialog)

OpenDialog opens a new dialog to the stack.

func (*Overlay) OpenDialogWithGrace added in v0.3.28

func (d *Overlay) OpenDialogWithGrace(dialog Dialog)

OpenDialogWithGrace opens a dialog with an input grace period. All keystrokes are absorbed until either the input has been quiet for graceQuietPeriod or graceMaxDelay has elapsed since opening, whichever comes first. Use this for dialogs that open asynchronously (e.g. permission prompts) where in-flight keystrokes from a previously focused component could act on the dialog before the user sees it.

If the same dialog ID was just closed (within reopenGraceWindow), the grace period is skipped — the user is already focused on this dialog type and rapid successive prompts should not eat keystrokes.

func (*Overlay) StartLoading added in v0.3.28

func (d *Overlay) StartLoading() tea.Cmd

StartLoading starts the loading state for the front dialog if it implements LoadingDialog.

func (*Overlay) StopLoading added in v0.3.28

func (d *Overlay) StopLoading()

StopLoading stops the loading state for the front dialog if it implements LoadingDialog.

func (*Overlay) Update added in v0.3.28

func (d *Overlay) Update(msg tea.Msg) tea.Msg

Update handles dialog updates.

type Quit added in v0.3.28

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

Quit represents a confirmation dialog for quitting the application.

func NewQuit added in v0.3.28

func NewQuit(com *defaults.UI) *Quit

NewQuit creates a new quit confirmation dialog.

func (*Quit) Draw added in v0.3.28

func (q *Quit) Draw(scr uv.Screen, area uv.Rectangle) *tea.Cursor

Draw implements Dialog.

func (*Quit) FullHelp added in v0.3.28

func (q *Quit) FullHelp() [][]key.Binding

FullHelp implements help.KeyMap.

func (*Quit) HandleMsg added in v0.3.28

func (q *Quit) HandleMsg(msg tea.Msg) Action

HandleMsg implements [Model].

func (*Quit) HandlesHover added in v0.3.28

func (*Quit) HandlesHover() bool

HandlesHover implements HoverDialog.

func (*Quit) ID added in v0.3.28

func (*Quit) ID() string

ID implements [Model].

func (*Quit) ShortHelp added in v0.3.28

func (q *Quit) ShortHelp() []key.Binding

ShortHelp implements help.KeyMap.

type RenderContext added in v0.3.28

type RenderContext struct {
	// Styles is the styles to use for rendering.
	Styles *styles.Styles
	// TitleStyle is the style of the dialog title by default it uses Styles.Dialog.Title
	TitleStyle lipgloss.Style
	// ViewStyle is the style of the dialog title by default it uses Styles.Dialog.View
	ViewStyle lipgloss.Style
	// TitleGradientFromColor is the color the title gradient starts by default
	// its Styles.Dialog.TitleGradFromColor
	TitleGradientFromColor color.Color
	// TitleGradientToColor is the color the title gradient ends by default its
	// Styles.Dialog.TitleGradToColor
	TitleGradientToColor color.Color
	// Width is the total width of the dialog including any margins, borders,
	// and paddings.
	Width int
	// Gap is the gap between content parts. Zero means no gap.
	Gap int
	// Title is the title of the dialog. This will be styled using the default
	// dialog title style and prepended to the content parts slice.
	Title string
	// TitleInfo is additional information to display next to the title. This
	// part is displayed as is, any styling must be applied before setting this
	// field.
	TitleInfo string
	// Parts are the rendered parts of the dialog.
	Parts []string
	// Help is the fully rendered help footer line. Produce it with
	// renderDialogHelp so it is sized and padded consistently; it is
	// appended as-is without further styling.
	Help string
	// IsOnboarding indicates whether to render the dialog as part of the
	// onboarding flow. This means that the content will be rendered at the
	// bottom left of the screen.
	IsOnboarding bool
}

RenderContext is a dialog rendering context that can be used to render common dialog layouts.

func NewRenderContext added in v0.3.28

func NewRenderContext(t *styles.Styles, width int) *RenderContext

NewRenderContext creates a new RenderContext with the provided styles and width.

func (*RenderContext) AddPart added in v0.3.28

func (rc *RenderContext) AddPart(part string)

AddPart adds a rendered part to the dialog.

func (*RenderContext) Render added in v0.3.28

func (rc *RenderContext) Render() string

Render renders the dialog using the provided context.

type Session added in v0.3.28

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

Session is a session selector dialog.

func NewSessions added in v0.3.28

func NewSessions(ui *defaults.UI, selectedSessionID string) (*Session, error)

NewSessions creates a new Session dialog.

func (*Session) Draw added in v0.3.28

func (s *Session) Draw(scr uv.Screen, area uv.Rectangle) *tea.Cursor

Draw implements Dialog.

func (*Session) FullHelp added in v0.3.28

func (s *Session) FullHelp() [][]key.Binding

FullHelp implements help.KeyMap.

func (*Session) HandleMsg added in v0.3.28

func (s *Session) HandleMsg(msg tea.Msg) Action

HandleMsg implements Dialog.

func (*Session) ID added in v0.3.28

func (s *Session) ID() string

ID implements Dialog.

func (*Session) ShortHelp added in v0.3.28

func (s *Session) ShortHelp() []key.Binding

ShortHelp implements help.KeyMap.

type SessionItem added in v0.3.28

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

SessionItem represents a session item in the list.

func (SessionItem) Description added in v0.3.28

func (s SessionItem) Description() string

Description returns the description of the session item.

func (SessionItem) FilterValue added in v0.3.28

func (s SessionItem) FilterValue() string

FilterValue returns the filter value of the session item.

func (SessionItem) Title added in v0.3.28

func (s SessionItem) Title() string

Title returns the title of the session item.

Jump to

Keyboard shortcuts

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