tui

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package tui provides an offline terminal UI for browsing local corpus data.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Data

type Data struct {
	Repositories   []Item `json:"repositories"`
	Threads        []Item `json:"threads"`
	Clusters       []Item `json:"clusters"`
	Investigations []Item `json:"investigations"`
	Opportunities  []Item `json:"opportunities"`
}

Data is the offline dataset loaded by the reader.

type Facet

type Facet struct {
	Name     string `json:"name"`
	Present  bool   `json:"present"`
	Complete bool   `json:"complete"`
	AsOf     string `json:"as_of,omitempty"`
}

Facet describes coverage for one data facet.

type Item

type Item struct {
	Kind     string  `json:"kind"`
	ID       string  `json:"id"`
	Ref      string  `json:"ref"`
	Title    string  `json:"title"`
	Subtitle string  `json:"subtitle,omitempty"`
	Detail   string  `json:"detail,omitempty"`
	Source   string  `json:"source,omitempty"`
	AsOf     string  `json:"as_of,omitempty"`
	Coverage []Facet `json:"coverage,omitempty"`
}

Item is one browsable record.

type Model

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

Model is the TUI state.

func New

func New(reader Reader, opts ...Option) Model

New creates a Model for the given reader.

func Run

func Run(ctx context.Context, reader Reader, input io.Reader, output io.Writer) (Model, error)

Run starts the TUI program with the provided local reader and I/O.

It is suitable for later CLI wiring: the caller supplies a context, a Reader, and input/output streams. The TUI loads local data on start and never performs network I/O on its own.

func (Model) Init

func (m Model) Init() tea.Cmd

Init triggers an asynchronous local load. No network I/O is performed here.

func (Model) String

func (m Model) String() string

String returns a short human-readable identifier for the current selection.

func (Model) Update

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

Update processes messages and returns the updated model and any commands.

func (Model) View

func (m Model) View() string

View renders the current model state.

type Option

type Option func(*Model)

Option customizes a Model.

func WithActionHandler

func WithActionHandler(fn func(context.Context, Item) tea.Cmd) Option

WithActionHandler registers an optional handler for explicit side-effecting actions such as refresh/hydration. The TUI never invokes it on initial load or search.

func WithSize

func WithSize(w, h int) Option

WithSize sets the initial terminal size.

type Reader

type Reader interface {
	Load(ctx context.Context) (Data, error)
}

Reader is a narrow local data source for the TUI. Implementations must not perform network I/O.

type Runner

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

Runner adapts the TUI to the CLI boundary.

func NewRunner

func NewRunner(reader Reader, input io.Reader, output io.Writer) *Runner

func (*Runner) Run

func (r *Runner) Run(ctx context.Context, opts cli.TUIOptions) error

Jump to

Keyboard shortcuts

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