picker

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package picker provides reusable list picker components.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FilterTextModels

func FilterTextModels(models []api.Model) []api.Model

FilterTextModels filters models to only those with text input and output.

func FormatPricePerMillion

func FormatPricePerMillion(pricePerToken string) string

FormatPricePerMillion converts a price-per-token string to a formatted price per million tokens.

func GetModel

func GetModel(item list.Item) *api.Model

GetModel extracts the Model from a selected item.

func GetSessionSummary

func GetSessionSummary(item list.Item) *config.SessionSummary

GetSessionSummary extracts the SessionSummary from a selected item.

func HasTextModality

func HasTextModality(modalities []string) bool

HasTextModality checks if "text" is in the list of modalities.

func SetModels

func SetModels(m *Model, models []api.Model)

SetModels sets the models in the picker.

Types

type Config

type Config struct {
	Title  string
	Items  []list.Item
	Width  int
	Height int
}

Config holds configuration for creating a new picker.

type Item

type Item interface {
	list.Item
	Title() string
	Description() string
}

Item is the interface for items that can be displayed in a picker.

type ItemDelegate

type ItemDelegate struct{}

ItemDelegate renders items in the picker list.

func (ItemDelegate) Height

func (d ItemDelegate) Height() int

func (ItemDelegate) Render

func (d ItemDelegate) Render(w io.Writer, m list.Model, index int, listItem list.Item)

func (ItemDelegate) Spacing

func (d ItemDelegate) Spacing() int

func (ItemDelegate) Update

func (d ItemDelegate) Update(_ tea.Msg, _ *list.Model) tea.Cmd

type Model

type Model struct {
	List     list.Model
	Loading  bool
	Spinner  spinner.Model
	Err      error
	Width    int
	Height   int
	Quitting bool
}

Model is the Bubble Tea model for a generic picker.

func New

func New(cfg Config) Model

New creates a new picker Model.

func NewLoading

func NewLoading(width, height int) Model

NewLoading creates a new picker Model in loading state.

func NewModelPicker

func NewModelPicker(width, height int) Model

NewModelPicker creates a new picker for models in loading state.

func NewSessionPicker

func NewSessionPicker(summaries []config.SessionSummary, width, height int) Model

NewSessionPicker creates a new picker for sessions.

func (Model) Init

func (m Model) Init() tea.Cmd

Init initializes the picker.

func (Model) IsFiltering

func (m Model) IsFiltering() bool

IsFiltering returns true if the picker is in filter mode.

func (Model) SelectedItem

func (m Model) SelectedItem() list.Item

SelectedItem returns the currently selected item.

func (*Model) SetError

func (m *Model) SetError(err error)

SetError sets an error state.

func (*Model) SetItems

func (m *Model) SetItems(title string, items []list.Item)

SetItems sets the items in the picker list.

func (Model) Update

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

Update handles messages for the picker.

func (Model) View

func (m Model) View() string

View renders the picker.

type ModelItem

type ModelItem struct {
	Model api.Model
}

ModelItem wraps a Model for display in a picker.

func (ModelItem) Description

func (i ModelItem) Description() string

func (ModelItem) FilterValue

func (i ModelItem) FilterValue() string

func (ModelItem) Title

func (i ModelItem) Title() string

type SessionItem

type SessionItem struct {
	Summary config.SessionSummary
}

SessionItem wraps a SessionSummary for display in a picker.

func (SessionItem) Description

func (i SessionItem) Description() string

func (SessionItem) FilterValue

func (i SessionItem) FilterValue() string

func (SessionItem) Title

func (i SessionItem) Title() string

Jump to

Keyboard shortcuts

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