forms

package
v1.14.0 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package forms provides beautiful huh-based forms for the hex TUI. ABOUTME: Huh-based tool approval form for interactive tool permission requests ABOUTME: Provides beautiful select-based approval UI with multiple options

Package forms provides beautiful huh-based forms for the hex TUI. ABOUTME: Huh-based onboarding flow for first-run experience ABOUTME: Guides new users through setup with welcome, API key, model selection, and tutorial

Package forms provides beautiful huh-based forms for the hex TUI. ABOUTME: Integration layer for onboarding flow with Model ABOUTME: Provides async command for running first-time onboarding

Package forms provides beautiful huh-based forms for the hex TUI. ABOUTME: Huh-based quick actions menu for keyboard-driven command palette ABOUTME: Provides beautiful select-based action UI with fuzzy search

Package forms provides beautiful huh-based forms for the hex TUI. ABOUTME: Integration layer between old QuickActionsRegistry and new huh forms ABOUTME: Converts registry actions to form actions and runs the form

Package forms provides beautiful huh-based forms for the hex TUI. ABOUTME: Huh-based settings wizard for interactive configuration ABOUTME: Provides multi-step settings form with model selection and API configuration

Package forms provides beautiful huh-based forms for the hex TUI. ABOUTME: Integration layer for settings wizard with Model ABOUTME: Provides async command for running settings wizard

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsFirstRun

func IsFirstRun(configPath string) bool

IsFirstRun checks if this is the first time running Hex by checking if the config file exists

func RunOnboardingFormAsync

func RunOnboardingFormAsync(configPath string) tea.Cmd

RunOnboardingFormAsync runs the onboarding wizard in a goroutine and returns a tea.Cmd that will send the result when complete

func RunQuickActionsFormAsync

func RunQuickActionsFormAsync(actions []*QuickAction) tea.Cmd

RunQuickActionsFormAsync runs the quick actions form in a goroutine and returns a tea.Cmd that will send the result when complete

func RunSettingsFormAsync

func RunSettingsFormAsync(currentModel, currentAPIKey, configPath string) tea.Cmd

RunSettingsFormAsync runs the settings wizard in a goroutine and returns a tea.Cmd that will send the result when complete

Types

type ApprovalDecision

type ApprovalDecision string

ApprovalDecision represents the user's decision on tool approval

const (
	// DecisionApprove approves this single tool execution
	DecisionApprove ApprovalDecision = "approve"
	// DecisionDeny denies this single tool execution
	DecisionDeny ApprovalDecision = "deny"
	// DecisionAlwaysAllow always allows this tool without future prompts
	DecisionAlwaysAllow ApprovalDecision = "always_allow"
	// DecisionNeverAllow blocks this tool permanently
	DecisionNeverAllow ApprovalDecision = "never_allow"
)

type ApprovalFormResult

type ApprovalFormResult struct {
	Decision ApprovalDecision
	ToolUse  *core.ToolUse
}

ApprovalFormResult contains the result of the approval form

type OldQuickAction

type OldQuickAction struct {
	Name        string
	Description string
	Usage       string
	Handler     func(args string) error
}

OldQuickAction represents the old action structure for conversion

type OnboardingForm

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

OnboardingForm creates a first-run onboarding experience using huh

func NewOnboardingForm

func NewOnboardingForm(configPath string) *OnboardingForm

NewOnboardingForm creates a new onboarding wizard

func (*OnboardingForm) GetSampleConversation

func (f *OnboardingForm) GetSampleConversation() string

GetSampleConversation returns a sample conversation to start with

func (*OnboardingForm) GetTutorialText

func (f *OnboardingForm) GetTutorialText() string

GetTutorialText returns the tutorial content to display

func (*OnboardingForm) Run

Run displays the onboarding flow and returns the result

type OnboardingFormResult

type OnboardingFormResult struct {
	Model        string
	APIKey       string
	ShowTutorial bool
	StartSample  bool
	Completed    bool
	Skipped      bool
}

OnboardingFormResult contains the result of the onboarding flow

type OnboardingResultMsg

type OnboardingResultMsg struct {
	Result *OnboardingFormResult
	Error  error
}

OnboardingResultMsg is sent when the onboarding flow completes

type QuickAction

type QuickAction struct {
	Name        string
	Description string
	Category    string // Tools, Navigation, Settings
	KeyBinding  string // Optional keyboard shortcut
	Handler     func(args string) error
}

QuickAction represents a single quick action

func ConvertOldActions

func ConvertOldActions(oldActions []*OldQuickAction) []*QuickAction

ConvertOldActions converts old-style actions to new form actions

func ConvertRegistryAction

func ConvertRegistryAction(name, description, category, keyBinding string, handler func(string) error) *QuickAction

ConvertRegistryAction converts an old-style action to a new form action This is used to bridge the gap between the existing registry and the new forms

type QuickActionCategory

type QuickActionCategory string

QuickActionCategory represents a category of actions

const (
	// CategoryTools for tool-related actions
	CategoryTools QuickActionCategory = "Tools"
	// CategoryNavigation for navigation actions
	CategoryNavigation QuickActionCategory = "Navigation"
	// CategorySettings for settings and configuration
	CategorySettings QuickActionCategory = "Settings"
)

type QuickActionError

type QuickActionError struct {
	ActionName string
	Err        error
}

QuickActionError wraps an error with context about which action failed

func (*QuickActionError) Error

func (e *QuickActionError) Error() string

func (*QuickActionError) Unwrap

func (e *QuickActionError) Unwrap() error

type QuickActionsForm

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

QuickActionsForm creates a beautiful huh form for quick actions

func NewQuickActionsForm

func NewQuickActionsForm(actions []*QuickAction) *QuickActionsForm

NewQuickActionsForm creates a new quick actions form

func (*QuickActionsForm) Run

func (f *QuickActionsForm) Run() (string, error)

Run displays the form and returns the selected action name

type QuickActionsResultMsg

type QuickActionsResultMsg struct {
	ActionName string
	Error      error
}

QuickActionsResultMsg is sent when the quick actions form completes

type RiskLevel

type RiskLevel int

RiskLevel represents the risk level of a tool operation

const (
	// RiskSafe indicates a tool operation is safe and requires no approval
	RiskSafe RiskLevel = iota
	// RiskCaution indicates a tool operation should be reviewed before execution
	RiskCaution
	// RiskDanger indicates a tool operation is potentially dangerous
	RiskDanger
)

func AssessRiskLevel added in v1.7.0

func AssessRiskLevel(toolUse *core.ToolUse) RiskLevel

AssessRiskLevel determines the risk level of a tool operation (exported for view.go)

type SettingsForm

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

SettingsForm creates a multi-step settings wizard using huh

func NewSettingsForm

func NewSettingsForm(currentModel, currentAPIKey string, configPath string) *SettingsForm

NewSettingsForm creates a new settings wizard form

func (*SettingsForm) Run

func (f *SettingsForm) Run() (*SettingsFormResult, error)

Run displays the multi-step settings wizard and returns the result

func (*SettingsForm) SaveToFile

func (f *SettingsForm) SaveToFile() error

SaveToFile saves the settings to a configuration file

type SettingsFormResult

type SettingsFormResult struct {
	Model       string
	APIKey      string
	Temperature float64
	MaxTokens   int
	Preferences map[string]interface{}
	Cancelled   bool
}

SettingsFormResult contains the result of the settings wizard

type SettingsResultMsg

type SettingsResultMsg struct {
	Result *SettingsFormResult
	Error  error
}

SettingsResultMsg is sent when the settings wizard completes

type ToolApprovalForm

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

ToolApprovalForm creates a beautiful huh form for tool approval

func NewToolApprovalForm

func NewToolApprovalForm(toolUse *core.ToolUse) *ToolApprovalForm

NewToolApprovalForm creates a new tool approval form

func (*ToolApprovalForm) BuildForm

func (f *ToolApprovalForm) BuildForm() *huh.Form

BuildForm creates and returns the huh form as a tea.Model for embedding Use this instead of Run() to avoid terminal control conflicts with bubbletea

func (*ToolApprovalForm) GetDecision

func (f *ToolApprovalForm) GetDecision() ApprovalFormResult

GetDecision returns the user's decision after form completion

func (*ToolApprovalForm) GetRiskLevel added in v1.7.0

func (f *ToolApprovalForm) GetRiskLevel() RiskLevel

GetRiskLevel returns the assessed risk level for this tool use

func (*ToolApprovalForm) GetToolUse added in v1.7.0

func (f *ToolApprovalForm) GetToolUse() *core.ToolUse

GetToolUse returns the tool use being approved

func (*ToolApprovalForm) Init

func (f *ToolApprovalForm) Init() tea.Cmd

Init implements tea.Model

func (*ToolApprovalForm) IsComplete

func (f *ToolApprovalForm) IsComplete() bool

IsComplete checks if the form has been completed

func (*ToolApprovalForm) Run

Run displays the form and returns the user's decision Deprecated: Use BuildForm() instead to avoid terminal conflicts

func (*ToolApprovalForm) Update

func (f *ToolApprovalForm) Update(msg tea.Msg) (tea.Model, tea.Cmd)

Update implements tea.Model

func (*ToolApprovalForm) View

func (f *ToolApprovalForm) View() string

View implements tea.Model

Jump to

Keyboard shortcuts

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