dialog

package
v1.32.0 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2026 License: Apache-2.0 Imports: 47 Imported by: 0

Documentation

Index

Constants

View Source
const ToolRejectionDialogID = "tool-rejection-reason"

ToolRejectionDialogID is the unique identifier for the tool rejection reason dialog.

Variables

This section is empty.

Functions

func CenterPosition

func CenterPosition(screenWidth, screenHeight, dialogWidth, dialogHeight int) (row, col int)

CenterPosition calculates the centered position for a dialog given screen and dialog dimensions. Returns (row, col) suitable for use in Dialog.Position().

func CloseWithElicitationResponse

func CloseWithElicitationResponse(action tools.ElicitationAction, content map[string]any) tea.Cmd

CloseWithElicitationResponse returns a command that closes the dialog and sends an elicitation response.

func ContentEndRow

func ContentEndRow(dialogRow, dialogHeight int) int

ContentEndRow returns the absolute Y row of the last content line inside a dialog. dialogRow is the top-left row and dialogHeight is the total rendered height. The dialog frame (border + padding) is accounted for automatically using DialogStyle.

func ContentStartRow

func ContentStartRow(dialogRow int, headerContent string) int

ContentStartRow returns the absolute Y row where content begins inside a dialog. dialogRow is the top-left row of the dialog, and headerContent is the rendered header text above the target content area. The dialog frame (border + padding) is accounted for automatically using DialogStyle.

func HandleConfirmKeys

func HandleConfirmKeys(msg tea.KeyPressMsg, keyMap ConfirmKeyMap, onYes, onNo func() (layout.Model, tea.Cmd)) (layout.Model, tea.Cmd, bool)

HandleConfirmKeys handles Yes/No key presses for confirmation dialogs. Returns the command to execute and whether a key was matched.

func HandleQuit

func HandleQuit(msg tea.KeyPressMsg) tea.Cmd

HandleQuit checks for ctrl+c and returns tea.Quit if matched.

func RenderHelp

func RenderHelp(text string, contentWidth int) string

RenderHelp renders help text at the bottom of a dialog in italic muted style.

func RenderHelpKeys

func RenderHelpKeys(contentWidth int, bindings ...string) string

RenderHelpKeys renders key bindings in the same style as the main TUI's status bar. Each binding is a pair of [key, description] strings.

func RenderSeparator

func RenderSeparator(contentWidth int) string

RenderSeparator renders a horizontal separator line.

func RenderTitle

func RenderTitle(title string, contentWidth int, style lipgloss.Style) string

RenderTitle renders a dialog title with the given style and width.

Types

type BaseDialog

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

BaseDialog provides common functionality for dialog implementations. It handles size management, position calculation, and common UI patterns.

func (*BaseDialog) CenterDialog

func (b *BaseDialog) CenterDialog(renderedDialog string) (row, col int)

CenterDialog returns the (row, col) position to center a rendered dialog.

func (*BaseDialog) ComputeDialogWidth

func (b *BaseDialog) ComputeDialogWidth(percent, minWidth, maxWidth int) int

ComputeDialogWidth calculates dialog width based on screen percentage with bounds.

func (*BaseDialog) ContentWidth

func (b *BaseDialog) ContentWidth(dialogWidth, paddingX int) int

ContentWidth calculates the inner content width given dialog width and padding.

func (*BaseDialog) Height

func (b *BaseDialog) Height() int

Height returns the current height.

func (*BaseDialog) SetSize

func (b *BaseDialog) SetSize(width, height int) tea.Cmd

SetSize updates the dialog dimensions.

func (*BaseDialog) Width

func (b *BaseDialog) Width() int

Width returns the current width.

type CloseAllDialogsMsg

type CloseAllDialogsMsg struct{}

CloseAllDialogsMsg is sent to close all dialogs in the stack

type CloseDialogMsg

type CloseDialogMsg struct{}

CloseDialogMsg is sent to close the current (topmost) dialog

type CommandExecuteMsg

type CommandExecuteMsg struct {
	Command commands.Item
}

CommandExecuteMsg is sent when a command is selected

type ConfirmKeyMap

type ConfirmKeyMap struct {
	Yes key.Binding
	No  key.Binding
}

ConfirmKeyMap defines key bindings for confirmation dialogs (Yes/No).

func DefaultConfirmKeyMap

func DefaultConfirmKeyMap() ConfirmKeyMap

DefaultConfirmKeyMap returns the standard Yes/No key bindings.

type Content

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

Content helps build dialog content with consistent structure.

func NewContent

func NewContent(contentWidth int) *Content

NewContent creates a new dialog content builder.

func (*Content) AddContent

func (dc *Content) AddContent(content string) *Content

AddContent adds raw content to the dialog.

func (*Content) AddHelp

func (dc *Content) AddHelp(text string) *Content

AddHelp adds help text at the bottom.

func (*Content) AddHelpKeys

func (dc *Content) AddHelpKeys(bindings ...string) *Content

AddHelpKeys adds key binding help at the bottom.

func (*Content) AddQuestion

func (dc *Content) AddQuestion(question string) *Content

AddQuestion adds a styled question text.

func (*Content) AddSeparator

func (dc *Content) AddSeparator() *Content

AddSeparator adds a horizontal separator line.

func (*Content) AddSpace

func (dc *Content) AddSpace() *Content

AddSpace adds an empty line for spacing.

func (*Content) AddTitle

func (dc *Content) AddTitle(title string) *Content

AddTitle adds a styled title to the dialog.

func (*Content) Build

func (dc *Content) Build() string

Build returns the final dialog content as a vertical join.

type Dialog

type Dialog interface {
	layout.Model
	Position() (int, int) // Returns (row, col) for dialog placement
}

Dialog defines the interface that all dialogs must implement

func NewAttachmentPreviewDialog

func NewAttachmentPreviewDialog(preview editor.AttachmentPreview) Dialog

NewAttachmentPreviewDialog returns a dialog that shows attachment content in a scrollable view.

func NewCommandPaletteDialog

func NewCommandPaletteDialog(categories []commands.Category) Dialog

NewCommandPaletteDialog creates a new command palette dialog

func NewCostDialog

func NewCostDialog(sess *session.Session) Dialog

func NewElicitationDialog

func NewElicitationDialog(message string, schema any, meta map[string]any) Dialog

NewElicitationDialog creates a new elicitation dialog.

func NewExitConfirmationDialog

func NewExitConfirmationDialog() Dialog

NewExitConfirmationDialog creates a new exit confirmation dialog.

func NewFilePickerDialog

func NewFilePickerDialog(initialPath string) Dialog

NewFilePickerDialog creates a new file picker dialog for attaching files. If initialPath is provided and is a directory, it starts in that directory. If initialPath is a file, it starts in the file's directory with the file pre-selected.

func NewMCPPromptInputDialog

func NewMCPPromptInputDialog(promptName string, promptInfo mcptools.PromptInfo) Dialog

NewMCPPromptInputDialog creates a new MCP prompt input dialog

func NewMaxIterationsDialog

func NewMaxIterationsDialog(maxIterations int, appInstance *app.App) Dialog

NewMaxIterationsDialog creates a new max iterations confirmation dialog

func NewModelPickerDialog

func NewModelPickerDialog(models []runtime.ModelChoice) Dialog

NewModelPickerDialog creates a new model picker dialog.

func NewMultiChoiceDialog

func NewMultiChoiceDialog(config MultiChoiceConfig) Dialog

NewMultiChoiceDialog creates a new multi-choice dialog.

func NewOAuthAuthorizationDialog

func NewOAuthAuthorizationDialog(serverURL string, appInstance *app.App) Dialog

NewOAuthAuthorizationDialog creates a new OAuth authorization confirmation dialog

func NewPermissionsDialog

func NewPermissionsDialog(perms *runtime.PermissionsInfo, yoloEnabled bool) Dialog

NewPermissionsDialog creates a new dialog showing tool permission rules.

func NewSessionBrowserDialog

func NewSessionBrowserDialog(sessions []session.Summary) Dialog

NewSessionBrowserDialog creates a new session browser dialog

func NewThemePickerDialog

func NewThemePickerDialog(themes []ThemeChoice, originalThemeRef string) Dialog

NewThemePickerDialog creates a new theme picker dialog. originalThemeRef is the currently active theme ref (for restoration on cancel).

func NewToolConfirmationDialog

func NewToolConfirmationDialog(msg *runtime.ToolCallConfirmationEvent, sessionState *service.SessionState) Dialog

NewToolConfirmationDialog creates a new tool confirmation dialog

func NewToolRejectionReasonDialog

func NewToolRejectionReasonDialog() Dialog

NewToolRejectionReasonDialog creates a multi-choice dialog for selecting the reason for rejecting a tool call.

func NewURLElicitationDialog

func NewURLElicitationDialog(message, url string) Dialog

NewURLElicitationDialog creates a new URL elicitation dialog.

func NewWorkingDirPickerDialog

func NewWorkingDirPickerDialog(recentDirs, favoriteDirs []string, store *tuistate.Store, sessionWorkingDir string) Dialog

NewWorkingDirPickerDialog creates a new working directory picker dialog. recentDirs provides a list of recently used directories to show. favoriteDirs provides a list of pinned directories to show. store is used for persisting favorite directory changes (may be nil). sessionWorkingDir is the working directory of the active session; when non-empty it is used as the initial browse directory instead of the process working directory.

type ElicitationDialog

type ElicitationDialog struct {
	BaseDialog
	// contains filtered or unexported fields
}

ElicitationDialog implements Dialog for MCP elicitation requests.

When a schema is provided, fields are rendered as a form. When no schema is provided, a single free-form text input (responseInput) is shown so the user can type an answer.

func (*ElicitationDialog) Init

func (d *ElicitationDialog) Init() tea.Cmd

func (*ElicitationDialog) Position

func (d *ElicitationDialog) Position() (row, col int)

func (*ElicitationDialog) Update

func (d *ElicitationDialog) Update(msg tea.Msg) (layout.Model, tea.Cmd)

func (*ElicitationDialog) View

func (d *ElicitationDialog) View() string

type ElicitationField

type ElicitationField struct {
	Name, Title, Type, Description string
	Required                       bool
	EnumValues                     []string
	Default                        any
	MinLength, MaxLength           int
	Format, Pattern                string
	Minimum, Maximum               float64
	HasMinimum, HasMaximum         bool
}

ElicitationField represents a form field extracted from a JSON schema.

type ExitConfirmedMsg

type ExitConfirmedMsg struct{}

ExitConfirmedMsg is sent when the user confirms they want to exit.

type MCPPromptInputDialog

type MCPPromptInputDialog struct {
	BaseDialog
	// contains filtered or unexported fields
}

MCPPromptInputDialog implements Dialog for collecting MCP prompt parameters

func (*MCPPromptInputDialog) Init

func (d *MCPPromptInputDialog) Init() tea.Cmd

Init initializes the MCP prompt input dialog

func (*MCPPromptInputDialog) Position

func (d *MCPPromptInputDialog) Position() (row, col int)

Position calculates the position to center the dialog

func (*MCPPromptInputDialog) Update

func (d *MCPPromptInputDialog) Update(msg tea.Msg) (layout.Model, tea.Cmd)

Update handles messages for the MCP prompt input dialog

func (*MCPPromptInputDialog) View

func (d *MCPPromptInputDialog) View() string

View renders the MCP prompt input dialog

type Manager

type Manager interface {
	layout.Model

	GetLayers() []*lipgloss.Layer
	Open() bool
}

Manager manages the dialog stack and rendering

func New

func New() Manager

New creates a new dialog component manager

type MultiChoiceConfig

type MultiChoiceConfig struct {
	DialogID          string              // Unique identifier for this dialog instance
	Title             string              // Dialog title (used as the main header)
	Options           []MultiChoiceOption // List of options (max 10 for number selection 0-9)
	AllowCustom       bool                // Whether to allow custom text input
	AllowSecondary    bool                // Whether to allow secondary action (e.g., skip)
	SecondaryLabel    string              // Label for secondary button (default: "Skip")
	PrimaryLabel      string              // Label for primary button (default: "Continue")
	CustomPlaceholder string              // Placeholder for custom input
}

MultiChoiceConfig configures the multi-choice dialog.

type MultiChoiceOption

type MultiChoiceOption struct {
	ID    string // Stable identifier for the option
	Label string // Display label shown to user
	Value string // Value returned when selected (e.g., model-friendly sentence)
}

MultiChoiceOption represents a single selectable option in the dialog.

type MultiChoiceResult

type MultiChoiceResult struct {
	OptionID    string // ID of the selected option ("custom" for custom input, "skip" for no reason)
	Value       string // The value text (option's Value or custom text)
	IsCustom    bool   // True if user provided custom input
	IsSkipped   bool   // True if user chose to skip (no reason)
	IsCancelled bool   // True if user cancelled/escaped
}

MultiChoiceResult holds the result of user selection.

type MultiChoiceResultMsg

type MultiChoiceResultMsg struct {
	DialogID string
	Result   MultiChoiceResult
}

MultiChoiceResultMsg is the tea.Msg sent when the user makes a selection.

type OpenDialogMsg

type OpenDialogMsg struct {
	Model Dialog
}

OpenDialogMsg is sent to open a new dialog

type RuntimeResumeMsg

type RuntimeResumeMsg struct {
	Request runtime.ResumeRequest
}

func HandleToolRejectionResult

func HandleToolRejectionResult(result MultiChoiceResult) *RuntimeResumeMsg

HandleToolRejectionResult processes the result from the tool rejection dialog and returns the appropriate RuntimeResumeMsg. Returns nil if the result was cancelled (user should stay in confirmation dialog).

type ThemeChoice

type ThemeChoice struct {
	Ref       string // Theme reference ("default" for built-in default)
	Name      string // Display name
	IsCurrent bool   // Currently active theme
	IsDefault bool   // Built-in default theme ("default")
	IsBuiltin bool   // Built-in theme shipped with docker agent
}

ThemeChoice represents a selectable theme option

type ToolConfirmationResponse

type ToolConfirmationResponse struct {
	Response string // "approve", "reject", or "approve-session"
}

ToolConfirmationResponse represents the user's response to tool confirmation

type URLElicitationDialog

type URLElicitationDialog struct {
	BaseDialog
	// contains filtered or unexported fields
}

URLElicitationDialog handles URL-based MCP elicitation requests. It displays a URL for the user to visit and waits for confirmation.

func (*URLElicitationDialog) Init

func (d *URLElicitationDialog) Init() tea.Cmd

func (*URLElicitationDialog) Position

func (d *URLElicitationDialog) Position() (row, col int)

func (*URLElicitationDialog) Update

func (d *URLElicitationDialog) Update(msg tea.Msg) (layout.Model, tea.Cmd)

func (*URLElicitationDialog) View

func (d *URLElicitationDialog) View() string

Jump to

Keyboard shortcuts

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