ui

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2026 License: MIT Imports: 25 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ColorPrimary   = lipgloss.AdaptiveColor{Light: "#C96442", Dark: "#E07856"} // terracotta
	ColorSecondary = lipgloss.AdaptiveColor{Light: "#7C9E6E", Dark: "#90B882"} // sage green
	ColorMuted     = lipgloss.AdaptiveColor{Light: "#8E8178", Dark: "#A89888"} // warm gray
	ColorFaint     = lipgloss.AdaptiveColor{Light: "#B8B0A8", Dark: "#685E56"} // subtle — version tags
	ColorBorder    = lipgloss.AdaptiveColor{Light: "#D8CDC0", Dark: "#4A3B30"} // border / panel frames
	ColorBg        = lipgloss.AdaptiveColor{Light: "#FDF8F3", Dark: "#1A1614"} // background
	ColorSuccess   = lipgloss.AdaptiveColor{Light: "#5A8A5A", Dark: "#70A870"} // muted green
	ColorWarning   = lipgloss.AdaptiveColor{Light: "#B8832A", Dark: "#D4983A"} // amber
	ColorError     = lipgloss.AdaptiveColor{Light: "#B84040", Dark: "#D05050"} // muted red
	ColorHighlight = lipgloss.AdaptiveColor{Light: "#E8D5C4", Dark: "#3D2A1E"} // selected row bg

	// ColorSubtle is a warm brown used for secondary/breadcrumb text.
	ColorSubtle = lipgloss.AdaptiveColor{Light: "#5C4A3C", Dark: "#BCA898"}
	// ColorTeal — cultural-influence tags and "wet" ingredient bars.
	ColorTeal = lipgloss.AdaptiveColor{Light: "#4A8A8A", Dark: "#5AACAC"}
	// ColorPurple — dietary tags and "starter" ingredient bars.
	ColorPurple = lipgloss.AdaptiveColor{Light: "#7A6E9E", Dark: "#9A8EC0"}
	// ColorHighlightFg is the foreground text colour used on highlighted (selected) rows.
	ColorHighlightFg = lipgloss.AdaptiveColor{Light: "#2D1810", Dark: "#F5EAE0"}

	// Status badge colors.
	StatusColors = map[string]lipgloss.TerminalColor{
		"published":         ColorSuccess,
		"review":            ColorWarning,
		"processing":        ColorPrimary,
		"processing_failed": ColorError,
		"draft":             ColorMuted,
		"rejected":          ColorError,
	}
)

Palette — warm, food-inspired earth tones. Each color uses AdaptiveColor so values are chosen for both light and dark terminal backgrounds.

View Source
var (
	TitleStyle = lipgloss.NewStyle().
				Bold(true).
				Foreground(ColorPrimary).
				MarginBottom(1)

	SubtitleStyle = lipgloss.NewStyle().
					Foreground(ColorMuted).
					Italic(true)

	BoldStyle = lipgloss.NewStyle().Bold(true)

	MutedStyle = lipgloss.NewStyle().Foreground(ColorMuted)

	ErrorStyle = lipgloss.NewStyle().
				Foreground(ColorError).
				Bold(true)

	SuccessStyle = lipgloss.NewStyle().
					Foreground(ColorSuccess).
					Bold(true)

	HighlightStyle = lipgloss.NewStyle().
					Background(ColorHighlight).
					Foreground(ColorHighlightFg)
)

Text styles.

View Source
var (
	BoxStyle = lipgloss.NewStyle().
				Border(lipgloss.RoundedBorder()).
				BorderForeground(ColorBorder).
				Padding(0, 1)

	HeaderStyle = lipgloss.NewStyle().
				Bold(true).
				Foreground(ColorPrimary).
				Border(lipgloss.NormalBorder(), false, false, true, false).
				BorderForeground(ColorBorder).
				MarginBottom(1).
				PaddingBottom(0)

	SectionLabelStyle = lipgloss.NewStyle().
						Bold(true).
						Foreground(ColorSecondary).
						MarginTop(1)
)

Layout styles.

View Source
var BreadPill = lipgloss.NewStyle().
	Background(ColorPrimary).
	Foreground(lipgloss.Color("#FFFFFF")).
	Padding(0, 1).
	Margin(0, 1, 0, 0).
	Render("🍞 bread/dough")

BreadPill renders the 🍞 bread/dough pill shown on bread recipes.

Functions

func RunAddUI

func RunAddUI(pasteMode bool, initialURL string, fn PipelineLaunchFn) (recipeID int64, goHome bool, goAdd bool, goManual bool, pipeErr error)

RunAddUI runs the full-screen add recipe TUI. Returns the new recipe ID (>0 on pipeline success), navigation signals, and any pipeline error. A non-nil pipeErr means the error was already shown in the TUI.

func RunConfigUI

func RunConfigUI(cfg *config.Config, configPath, logPath string) (saved bool, err error)

RunConfigUI opens the interactive configuration editor. If the user saves, cfg's fields are updated in-place and saved=true is returned; the caller should call cfg.Save() to persist the changes to disk.

func RunEditUI

func RunEditUI(recipe *models.Recipe, data EditData) (
	toSave *models.Recipe,
	tagNames map[string][]string,
	goHome bool,
	err error,
)

RunEditUI runs the edit form. recipe=nil → blank new-recipe form. Returns toSave (non-nil when Ctrl+S pressed), tagNames, goHome, and error. The caller must call db.SaveRecipe(toSave, tagNames) when toSave != nil.

func RunManageAIRunsUI

func RunManageAIRunsUI(sqlDB *db.DB) (retryRecipeID int64, err error)

RunManageAIRunsUI runs the AI runs management TUI. Returns retryRecipeID > 0 if the user confirmed a retry, 0 for normal exit.

func RunManageIngredientsUI

func RunManageIngredientsUI(sqlDB *db.DB) error

RunManageIngredientsUI runs the ingredients management TUI.

func RunManageTagsUI

func RunManageTagsUI(sqlDB *db.DB) error

RunManageTagsUI runs the tags management TUI.

func RunManageUnitsUI

func RunManageUnitsUI(sqlDB *db.DB) error

RunManageUnitsUI runs the serving-units management TUI.

func RunPrintUI

func RunPrintUI(recipe *models.Recipe, opts export.Options) (bool, error)

RunPrintUI runs the interactive print preview TUI for the given recipe. opts controls export behaviour, notably Credits for file footer attribution.

func RunRetryUI

func RunRetryUI(pasteMode bool, fn PipelineLaunchFn) error

RunRetryUI runs the retry extraction progress TUI. The provided fn should call RunPipeline on the existing recipe.

func RunScaleUI

func RunScaleUI(recipe *models.Recipe, opts export.Options) (goPrint bool, scaledRecipe *models.Recipe, err error)

RunScaleUI runs the interactive scale TUI for the given recipe. Returns (goPrint, scaledRecipe, error). When goPrint is true, scaledRecipe is a fully prepared copy (scaled ingredients + directions note) ready to pass directly to RunPrintUI.

func StatusBadge

func StatusBadge(status string) string

func TagStyle

func TagStyle(context string) lipgloss.Style

Types

type AddModel

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

AddModel is a Bubbletea model for the full-screen add recipe flow. It shares the same banner / footer chrome as the list and detail views.

func NewAddModel

func NewAddModel(pasteMode bool, initialURL string, fn PipelineLaunchFn) AddModel

NewAddModel constructs an AddModel. If initialURL is non-empty the model skips the mode screen and immediately launches the pipeline. pasteMode=true skips the mode screen and goes to paste input.

func NewAddModelForRetry

func NewAddModelForRetry(pasteMode bool, fn PipelineLaunchFn) AddModel

NewAddModelForRetry constructs an AddModel that immediately starts the pipeline in retry mode. The provided fn should call RunPipeline on an existing recipe ID (ignoring sourceURL/sourceText). pasteMode controls which step label is shown.

func (AddModel) GoAdd

func (m AddModel) GoAdd() bool

func (AddModel) GoHome

func (m AddModel) GoHome() bool

func (AddModel) GoManual

func (m AddModel) GoManual() bool

func (AddModel) Init

func (m AddModel) Init() tea.Cmd

func (AddModel) PipeErr

func (m AddModel) PipeErr() error

func (AddModel) RecipeID

func (m AddModel) RecipeID() int64

func (AddModel) Update

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

func (AddModel) View

func (m AddModel) View() string

type ConfigModel

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

ConfigModel is a full-screen interactive configuration editor.

func (ConfigModel) Init

func (m ConfigModel) Init() tea.Cmd

func (ConfigModel) Saved

func (m ConfigModel) Saved() bool

Saved returns true if the user pressed ctrl+s to save changes.

func (ConfigModel) Update

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

func (ConfigModel) View

func (m ConfigModel) View() string

type DetailModel

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

DetailModel is a full-screen interactive recipe detail viewer that mirrors the visual structure of ListModel: banner, scrollable content, footer. When the user presses "/" the right pane opens with the same filter panel as the list view.

func NewDetailModel

func NewDetailModel(recipe *models.Recipe, initial FilterState, sd SearchData) DetailModel

NewDetailModel creates a DetailModel for the given recipe. initial carries any active filter from the calling context (e.g. list view). sd provides autocomplete suggestions for the filter pane. It detects the terminal background colour and pre-renders content before the TUI starts so the first frame and any resize redraws are instant.

func (DetailModel) DeleteConfirmed

func (m DetailModel) DeleteConfirmed() bool

DeleteConfirmed returns true when the user confirmed deletion of the recipe.

func (DetailModel) GoAdd

func (m DetailModel) GoAdd() bool

GoAdd returns true when the user pressed "a" to add a new recipe.

func (DetailModel) GoEdit

func (m DetailModel) GoEdit() bool

GoEdit returns true when the user pressed "e" to edit the recipe.

func (DetailModel) GoHome

func (m DetailModel) GoHome() bool

GoHome returns true when the user selected "home".

func (DetailModel) GoManage

func (m DetailModel) GoManage() bool

GoManage returns true when the user pressed "m" to open the manage screen.

func (DetailModel) GoPrint

func (m DetailModel) GoPrint() bool

GoPrint returns true when the user pressed "p" to open print preview.

func (DetailModel) GoQuery added in v1.7.0

func (m DetailModel) GoQuery() bool

GoQuery returns true when the user pressed "x" to open the query screen.

func (DetailModel) GoRetry

func (m DetailModel) GoRetry() bool

GoRetry returns true when the user pressed "r" to retry a failed extraction.

func (DetailModel) GoScale

func (m DetailModel) GoScale() bool

GoScale returns true when the user pressed "s" to open the scale screen.

func (DetailModel) Init

func (m DetailModel) Init() tea.Cmd

func (DetailModel) NewNotes

func (m DetailModel) NewNotes() string

NewNotes returns the saved notes text.

func (DetailModel) NewRating

func (m DetailModel) NewRating() *int

NewRating returns the pending rating value (nil = clear).

func (DetailModel) ReturnFilter

func (m DetailModel) ReturnFilter() FilterState

ReturnFilter returns the filter state the user had when leaving (for passing back to the list).

func (DetailModel) Update

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

func (DetailModel) UpdateNotes

func (m DetailModel) UpdateNotes() bool

UpdateNotes returns true when the user saved new notes text.

func (DetailModel) UpdateRating

func (m DetailModel) UpdateRating() bool

UpdateRating returns true when the user set or cleared a rating.

func (DetailModel) View

func (m DetailModel) View() string

type EditData

type EditData struct {
	TagsByContext   map[string][]string
	IngredientNames []string
	Units           []string
}

EditData carries autocomplete options loaded from the database.

type EditModel

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

EditModel is a Bubbletea model for the recipe edit / create form.

func (EditModel) Init

func (m EditModel) Init() tea.Cmd

func (EditModel) Update

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

func (EditModel) View

func (m EditModel) View() string

type FilterState

type FilterState struct {
	Query      string
	Courses    []string
	Influences []string
	Status     string // "" = all; else "draft", "review", "published"
	IsBread    bool   // false = all recipes; true = bread/dough only
	MinRating  int    // 0 = any; 1–5 = minimum rating
}

FilterState is the complete search/filter state passed in and out of RunListUI.

func RunDetailUI

func RunDetailUI(recipe *models.Recipe, initial FilterState, sd SearchData) (goHome bool, goAdd bool, goEdit bool, goPrint bool, goScale bool, goManage bool, goQuery bool, goRetry bool, deleteConfirmed bool, updateRating bool, newRating *int, updateNotes bool, newNotes string, returnFilter FilterState, err error)

RunDetailUI runs the interactive recipe detail TUI. initial carries the active filter from the calling context; sd provides autocomplete suggestions. Returns navigation signals, rating/notes updates, the return filter state, and any error.

func RunListUI

func RunListUI(
	recipes []models.Recipe,
	initial FilterState,
	sd SearchData,
	queryResult ...RunListUIQuery,
) (selectedID int64, goAdd bool, goHome bool, searchConfirmed bool,
	filter FilterState, deleteID int64, editID int64, goManage bool, goQuery bool, err error)

type ListModel

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

ListModel is a Bubbletea model for the interactive recipe browser.

func NewListModel

func NewListModel(recipes []models.Recipe, initial FilterState, sd SearchData) ListModel

NewListModel creates a ListModel from a slice of recipes.

func (ListModel) DeleteTargetID

func (m ListModel) DeleteTargetID() int64

DeleteTargetID returns the recipe ID the user confirmed for deletion (0 if none).

func (ListModel) EditID

func (m ListModel) EditID() int64

EditID returns the recipe ID the user wants to edit (0 if none).

func (ListModel) Filter

func (m ListModel) Filter() FilterState

Filter returns the current FilterState.

func (ListModel) GoAdd

func (m ListModel) GoAdd() bool

GoAdd returns true when the user pressed "a" to add a new recipe.

func (ListModel) GoHome

func (m ListModel) GoHome() bool

GoHome returns true when the user pressed "h" to go home (clear filter).

func (ListModel) GoManage

func (m ListModel) GoManage() bool

GoManage returns true when the user pressed "m" to open the manage screen.

func (ListModel) GoQuery added in v1.7.0

func (m ListModel) GoQuery() bool

GoQuery returns true when the user pressed "x" to open the query screen.

func (ListModel) Init

func (m ListModel) Init() tea.Cmd

func (ListModel) Query

func (m ListModel) Query() string

Query returns the current text search query.

func (ListModel) SearchConfirmed

func (m ListModel) SearchConfirmed() bool

SearchConfirmed returns true when the user pressed Enter to confirm a search.

func (ListModel) SelectedID

func (m ListModel) SelectedID() int64

SelectedID returns the recipe ID the user selected (0 if none).

func (ListModel) Update

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

func (ListModel) View

func (m ListModel) View() string

type ManageModel

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

ManageModel is the landing page for the manage section.

func (ManageModel) Init

func (m ManageModel) Init() tea.Cmd

func (ManageModel) Update

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

func (ManageModel) View

func (m ManageModel) View() string

type ManageSection

type ManageSection int

ManageSection identifies which section the user selected on the manage landing page.

const (
	ManageSectionBack ManageSection = iota
	ManageSectionConfig
	ManageSectionTags
	ManageSectionIngredients
	ManageSectionUnits
	ManageSectionAIRuns
)

func RunManageUI

func RunManageUI() (ManageSection, error)

RunManageUI runs the manage landing page TUI and returns which section was selected.

type PipelineLaunchFn

type PipelineLaunchFn func(
	ctx context.Context,
	sourceURL, sourceText string,
	onStep func(step int, label string),
) (recipeID int64, err error)

PipelineLaunchFn is called by AddModel when the user submits the form. sourceURL and sourceText are mutually exclusive (one will be empty). onStep is invoked at the start of each pipeline step with its 1-based index and label. Returns the newly created recipe ID and any pipeline error.

type PrintModel

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

PrintModel is a full-screen print preview with integrated export/print dialog.

func (PrintModel) Init

func (m PrintModel) Init() tea.Cmd

func (PrintModel) Quitting

func (m PrintModel) Quitting() bool

Quitting returns true when the user explicitly pressed q or ctrl+c to exit.

func (PrintModel) Update

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

func (PrintModel) View

func (m PrintModel) View() string

type QueryModel added in v1.7.0

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

QueryModel is the two-column query TUI:

Left 66%:  Messages pane (top) + Editor pane (bottom)
Right 33%: Schema pane (full height)

func (QueryModel) Init added in v1.7.0

func (m QueryModel) Init() tea.Cmd

func (QueryModel) Update added in v1.7.0

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

func (QueryModel) View added in v1.7.0

func (m QueryModel) View() string

type QueryResult added in v1.7.0

type QueryResult struct {
	RecipeIDs []int64
	QueryText string // the NL question (empty for raw SQL)
	SQL       string // the generated/executed SQL
	Err       error
}

QueryResult is returned by RunQueryUI when the query screen closes.

func RunQueryUI added in v1.7.0

func RunQueryUI(sqlDB *db.DB, client services.AIClient, model string) QueryResult

RunQueryUI runs the interactive query screen and returns the result.

type RunListUIQuery added in v1.7.0

type RunListUIQuery struct {
	Recipes []models.Recipe
	Text    string // NL question (empty for raw SQL)
	SQL     string
	ModeNL  bool
}

RunListUI runs the interactive recipe browser. Returns the selected recipe ID (or 0), navigation signals, the active filter state, the recipe ID confirmed for deletion (or 0), the recipe ID to edit (or 0), whether the user pressed "m" to open manage, and any error. RunListUIQuery holds query metadata to display in the filter pane.

type ScaleModel

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

ScaleModel is a two-phase TUI for scaling recipe ingredients.

  • scalePhaseInput: user enters a scale factor or target dough weight.
  • scalePhaseView: the full recipe rendered with scaled quantities (same layout as the detail view), plus bread metrics when available.

func (ScaleModel) GoBack

func (m ScaleModel) GoBack() bool

GoBack returns true when the user dismissed the scale screen.

func (ScaleModel) GoPrint

func (m ScaleModel) GoPrint() bool

GoPrint returns true when the user pressed p to print/export the scaled recipe.

func (ScaleModel) Init

func (m ScaleModel) Init() tea.Cmd

func (ScaleModel) Update

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

func (ScaleModel) View

func (m ScaleModel) View() string

type SearchData

type SearchData struct {
	Courses    []string
	Influences []string
}

SearchData holds autocomplete suggestions for the filter panel.

type StepUpdate

type StepUpdate struct {
	Step  int
	Label string
}

StepUpdate is sent by the pipeline goroutine to advance the progress display.

Jump to

Keyboard shortcuts

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