tui

package
v0.0.0-...-343c8d2 Latest Latest
Warning

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

Go to latest
Published: May 7, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package tui provides a terminal user interface for apimgr

Package tui provides a terminal user interface for apimgr

Index

Constants

View Source
const (
	FormFieldAlias = iota
	FormFieldAPIKey
	FormFieldAuthToken
	FormFieldBaseURL
	FormFieldModel
	FormFieldModels
	FormFieldCount // Total number of fields
)

FormField represents the index of each form field

Variables

This section is empty.

Functions

func FormHints

func FormHints() []string

FormHints returns the hint text for each form field

func FormInputs

func FormInputs() []textinput.Model

FormInputs creates and initializes form input fields Requirements: 5.2, 6.2

func FormLabels

func FormLabels() []string

FormLabels returns the labels for each form field

func NextFormField

func NextFormField(inputs []textinput.Model, currentFocus int) int

NextFormField moves focus to the next form field

func PrevFormField

func PrevFormField(inputs []textinput.Model, currentFocus int) int

PrevFormField moves focus to the previous form field

func RenderForm

func RenderForm(inputs []textinput.Model, focusIndex int, title string, errorMsg string) string

RenderForm renders the form view with inputs Requirements: 5.2, 6.2

func Run

func Run() error

Run starts the TUI interface

func SetFormData

func SetFormData(inputs []textinput.Model, data FormData)

SetFormData populates form inputs with existing data Requirements: 6.2

Types

type CompatCheck

type CompatCheck struct {
	Name     string
	Passed   bool
	Message  string
	Critical bool
}

CompatCheck represents a single compatibility check result

type CompatResultMsg

type CompatResultMsg struct {
	Result *compatibility.TestResult
	Err    error
}

CompatResultMsg is sent when compatibility test completes

type CompatTestResult

type CompatTestResult struct {
	Success            bool
	CompatibilityLevel string // "full", "partial", "none"
	Checks             []CompatCheck
	ResponseTime       string
	Error              string
}

CompatTestResult holds compatibility test result data

type ConfigAddedMsg

type ConfigAddedMsg struct {
	Config models.APIConfig
	Err    error
}

ConfigAddedMsg is sent when a config is added

type ConfigDeletedMsg

type ConfigDeletedMsg struct {
	Alias string
	Err   error
}

ConfigDeletedMsg is sent when a config is deleted

type ConfigSwitchedMsg

type ConfigSwitchedMsg struct {
	Alias   string
	IsLocal bool // true for local switch, false for global switch
	Err     error
}

ConfigSwitchedMsg is sent when active config is switched

type ConfigUpdatedMsg

type ConfigUpdatedMsg struct {
	Alias string
	Err   error
}

ConfigUpdatedMsg is sent when a config is updated

type ConfigsLoadedMsg

type ConfigsLoadedMsg struct {
	Configs     []models.APIConfig
	ActiveAlias string
}

ConfigsLoadedMsg is sent when configs are loaded

type FormData

type FormData struct {
	Alias     string
	APIKey    string
	AuthToken string
	BaseURL   string
	Model     string
	Models    string // Comma-separated list of models
}

FormData represents the data collected from the form Requirements: 5.3, 5.4, 6.3, 6.4

func GetFormData

func GetFormData(inputs []textinput.Model) FormData

GetFormData extracts FormData from form inputs

func (*FormData) ParseModels

func (f *FormData) ParseModels() []string

ParseModels parses the comma-separated models string into a slice

func (*FormData) Validate

func (f *FormData) Validate() error

Validate validates the form data Requirements: 5.4, 6.4

type KeyMap

type KeyMap struct {
	Up           key.Binding // k - move up
	Down         key.Binding // j - move down
	Top          key.Binding // g - jump to top
	Bottom       key.Binding // G - jump to bottom
	Select       key.Binding // Enter - select
	SwitchLocal  key.Binding // s - switch local (Claude Code only)
	SwitchGlobal key.Binding // S - switch global active config
	Add          key.Binding // a - add config
	Edit         key.Binding // e - edit config
	Delete       key.Binding // d - delete config
	Ping         key.Binding // p - ping test
	Test         key.Binding // t - compatibility test
	Model        key.Binding // m - switch model
	Help         key.Binding // ? - help
	Quit         key.Binding // q - quit
	Cancel       key.Binding // Esc - cancel
	Confirm      key.Binding // Enter - confirm (in form)
}

KeyMap defines all keyboard shortcuts

func DefaultKeyMap

func DefaultKeyMap() KeyMap

DefaultKeyMap returns the default key bindings

func (KeyMap) FullHelp

func (k KeyMap) FullHelp() [][]key.Binding

FullHelp returns full help text

func (KeyMap) ShortHelp

func (k KeyMap) ShortHelp() []key.Binding

ShortHelp returns short help text

type Model

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

Model is the core state model for TUI

func NewModel

func NewModel(cm *config.Manager) Model

NewModel creates a new TUI model

func (Model) Init

func (m Model) Init() tea.Cmd

Init initializes the model and returns initial commands

func (Model) RenderCompatResultView

func (m Model) RenderCompatResultView() string

RenderCompatResultView renders the compatibility test result view Requirements: 9.3, 9.4, 11.2

func (Model) RenderCompatTestingView

func (m Model) RenderCompatTestingView() string

RenderCompatTestingView renders the compatibility testing in progress view Requirements: 9.2, 11.2

func (Model) RenderDeleteConfirm

func (m Model) RenderDeleteConfirm() string

RenderDeleteConfirm renders the delete confirmation dialog Requirements: 7.1, 7.2, 11.2

func (Model) RenderDetailView

func (m Model) RenderDetailView() string

RenderDetailView renders the detail view Requirements: 3.1, 3.2, 3.3, 3.4, 11.2

func (Model) RenderFormView

func (m Model) RenderFormView() string

RenderFormView renders the form view (add/edit)

func (Model) RenderFormViewFull

func (m Model) RenderFormViewFull() string

RenderFormViewFull renders the complete form view Requirements: 5.2, 6.2

func (Model) RenderHelpView

func (m Model) RenderHelpView() string

RenderHelpView renders the help panel with scrolling support Requirements: 10.2, 10.3, 10.4, 11.2

func (Model) RenderMainView

func (m Model) RenderMainView() string

RenderMainView renders the main list view Requirements: 11.1, 11.2, 11.3

func (Model) RenderModelSelectView

func (m Model) RenderModelSelectView() string

RenderModelSelectView renders the model selection view Requirements: 12.1, 12.2, 11.3

func (Model) RenderPingResultView

func (m Model) RenderPingResultView() string

RenderPingResultView renders the ping test result view Requirements: 8.3, 8.4, 11.2

func (Model) RenderPingTestingView

func (m Model) RenderPingTestingView() string

RenderPingTestingView renders the ping testing in progress view Requirements: 8.2, 11.2

func (Model) RenderStatusBar

func (m Model) RenderStatusBar() string

RenderStatusBar renders the bottom status bar

func (Model) Update

func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd)

Update handles messages and updates the model

func (Model) View

func (m Model) View() string

View renders the UI

type ModelSwitchedMsg

type ModelSwitchedMsg struct {
	Alias    string
	Model    string
	IsLocal  bool
	Activate bool
	Err      error
}

ModelSwitchedMsg is sent when model is switched

type PingResultMsg

type PingResultMsg struct {
	Success  bool
	Duration time.Duration
	Err      error
}

PingResultMsg is sent when ping test completes

type SwitchType

type SwitchType int

SwitchType represents the type of switch operation

const (
	SwitchTypeNone SwitchType = iota
	SwitchTypeLocal
	SwitchTypeGlobal
)

type TestResult

type TestResult struct {
	Success  bool
	Message  string
	Duration string
}

TestResult holds test result data

type ViewState

type ViewState int

ViewState represents the current view state

const (
	ViewMain          ViewState = iota // Main list view
	ViewDetail                         // Detail view
	ViewAdd                            // Add config form
	ViewEdit                           // Edit config form
	ViewDelete                         // Delete confirmation dialog
	ViewHelp                           // Help panel
	ViewModelSelect                    // Model selection list
	ViewPingTesting                    // Ping test in progress
	ViewPingResult                     // Ping test result
	ViewCompatTesting                  // Compatibility test in progress
	ViewCompatResult                   // Compatibility test result
)

Jump to

Keyboard shortcuts

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