tui

package
v0.2.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ColorBgPrimary   = lipgloss.Color("#0d1117")
	ColorBgSecondary = lipgloss.Color("#161b22")
	ColorBgTertiary  = lipgloss.Color("#21262d")
	ColorBorder      = lipgloss.Color("#30363d")
	ColorTextPrimary = lipgloss.Color("#c9d1d9")
	ColorTextMuted   = lipgloss.Color("#6e7681")
	ColorBlue        = lipgloss.Color("#58a6ff")
	ColorGreen       = lipgloss.Color("#3fb950")
	ColorPurple      = lipgloss.Color("#a371f7")
	ColorOrange      = lipgloss.Color("#d29922")
	ColorRed         = lipgloss.Color("#f85149")
)

Colors matching the web dashboard dark theme

View Source
var (
	// Base styles
	BaseStyle = lipgloss.NewStyle().
				Background(ColorBgPrimary).
				Foreground(ColorTextPrimary)

	// Title bar
	TitleStyle = lipgloss.NewStyle().
				Bold(true).
				Foreground(ColorTextPrimary).
				Background(ColorBgSecondary).
				Padding(0, 1)

	// Sidebar navigation
	SidebarStyle = lipgloss.NewStyle().
					Width(24).
					Background(ColorBgSecondary).
					BorderStyle(lipgloss.NormalBorder()).
					BorderRight(true).
					BorderForeground(ColorBorder)

	NavItemStyle = lipgloss.NewStyle().
					Padding(0, 2).
					Foreground(ColorTextMuted)

	NavItemActiveStyle = lipgloss.NewStyle().
						Padding(0, 2).
						Foreground(ColorTextPrimary).
						Background(ColorBgTertiary).
						Bold(true)

	// Main content area
	ContentStyle = lipgloss.NewStyle().
					Padding(1, 2)

	// Cards/boxes
	CardStyle = lipgloss.NewStyle().
				BorderStyle(lipgloss.RoundedBorder()).
				BorderForeground(ColorBorder).
				Padding(1, 2).
				MarginBottom(1)

	CardTitleStyle = lipgloss.NewStyle().
					Bold(true).
					Foreground(ColorTextPrimary).
					MarginBottom(1)

	// Stats
	StatValueStyle = lipgloss.NewStyle().
					Bold(true).
					Foreground(ColorBlue)

	StatLabelStyle = lipgloss.NewStyle().
					Foreground(ColorTextMuted)

	// Tables
	TableHeaderStyle = lipgloss.NewStyle().
						Bold(true).
						Foreground(ColorTextMuted).
						BorderStyle(lipgloss.NormalBorder()).
						BorderBottom(true).
						BorderForeground(ColorBorder)

	TableRowStyle = lipgloss.NewStyle().
					Foreground(ColorTextPrimary)

	TableRowSelectedStyle = lipgloss.NewStyle().
							Foreground(ColorTextPrimary).
							Background(ColorBgTertiary)

	// Badges
	BadgeStyle = lipgloss.NewStyle().
				Padding(0, 1).
				Background(ColorBgTertiary).
				Foreground(ColorTextMuted)

	BadgeBlueStyle = lipgloss.NewStyle().
					Padding(0, 1).
					Background(lipgloss.Color("#1a3a5c")).
					Foreground(ColorBlue)

	BadgeGreenStyle = lipgloss.NewStyle().
					Padding(0, 1).
					Background(lipgloss.Color("#1a3d2a")).
					Foreground(ColorGreen)

	BadgePurpleStyle = lipgloss.NewStyle().
						Padding(0, 1).
						Background(lipgloss.Color("#2d1f4a")).
						Foreground(ColorPurple)

	BadgeOrangeStyle = lipgloss.NewStyle().
						Padding(0, 1).
						Background(lipgloss.Color("#3d2e1a")).
						Foreground(ColorOrange)

	// Help text
	HelpStyle = lipgloss.NewStyle().
				Foreground(ColorTextMuted).
				MarginTop(1)

	// Status bar
	StatusBarStyle = lipgloss.NewStyle().
					Background(ColorBgSecondary).
					Foreground(ColorTextMuted).
					Padding(0, 1)

	// Error/warning messages
	ErrorStyle = lipgloss.NewStyle().
				Foreground(ColorRed)

	SuccessStyle = lipgloss.NewStyle().
					Foreground(ColorGreen)

	// Input fields
	InputStyle = lipgloss.NewStyle().
				BorderStyle(lipgloss.RoundedBorder()).
				BorderForeground(ColorBorder).
				Padding(0, 1)

	InputFocusedStyle = lipgloss.NewStyle().
						BorderStyle(lipgloss.RoundedBorder()).
						BorderForeground(ColorBlue).
						Padding(0, 1)

	// List items
	ListItemStyle = lipgloss.NewStyle().
					Foreground(ColorTextPrimary)

	ListItemSelectedStyle = lipgloss.NewStyle().
							Foreground(ColorBlue).
							Bold(true)

	// Spinner
	SpinnerStyle = lipgloss.NewStyle().
					Foreground(ColorBlue)
)

Styles for the TUI components

Functions

func Run

func Run(
	ctx context.Context,
	store storage.Backend,
	know *knowledge.Engine,
	conv *conversation.Engine,
	ctxEng *ctxengine.Engine,
	ent *entity.Engine,
	cfg *Config,
) error

Run starts the TUI application

func StatColor

func StatColor(index int) lipgloss.Color

Stat colors for different stat types

Types

type CollectionWithStats

type CollectionWithStats struct {
	Collection *types.Collection
	Stats      *types.CollectionStats
}

CollectionWithStats holds collection with its stats

type Config

type Config struct {
	Namespace string
}

Config holds TUI configuration

type ConversationModel

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

ConversationModel handles the conversations view

func NewConversationModel

func NewConversationModel(parent *Model) *ConversationModel

NewConversationModel creates a new conversation model

func (*ConversationModel) LoadThreadDetail

func (m *ConversationModel) LoadThreadDetail(threadID string) tea.Cmd

LoadThreadDetail loads a single thread with messages

func (*ConversationModel) LoadThreads

func (m *ConversationModel) LoadThreads() tea.Cmd

LoadThreads loads all conversation threads

func (*ConversationModel) Update

func (m *ConversationModel) Update(msg tea.Msg) tea.Cmd

Update handles messages for the conversation view

func (*ConversationModel) View

func (m *ConversationModel) View() string

View renders the conversation view

type DashboardModel

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

DashboardModel handles the dashboard view

func NewDashboardModel

func NewDashboardModel(parent *Model) *DashboardModel

NewDashboardModel creates a new dashboard model

func (*DashboardModel) LoadStats

func (m *DashboardModel) LoadStats() tea.Cmd

LoadStats loads the dashboard statistics

func (*DashboardModel) Update

func (m *DashboardModel) Update(msg tea.Msg) tea.Cmd

Update handles messages for the dashboard view

func (*DashboardModel) View

func (m *DashboardModel) View() string

View renders the dashboard view

type DashboardStats

type DashboardStats struct {
	Collections   int
	Documents     int64
	Conversations int
	Entities      int
}

DashboardStats holds the dashboard overview statistics

type EntityModel

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

EntityModel handles the entities view

func NewEntityModel

func NewEntityModel(parent *Model) *EntityModel

NewEntityModel creates a new entity model

func (*EntityModel) LoadEntities

func (m *EntityModel) LoadEntities() tea.Cmd

LoadEntities loads all entities

func (*EntityModel) LoadEntityDetail

func (m *EntityModel) LoadEntityDetail(entityID string) tea.Cmd

LoadEntityDetail loads a single entity with relationships and mentions

func (*EntityModel) Update

func (m *EntityModel) Update(msg tea.Msg) tea.Cmd

Update handles messages for the entity view

func (*EntityModel) View

func (m *EntityModel) View() string

View renders the entity view

type KeyMap

type KeyMap struct {
	Up      key.Binding
	Down    key.Binding
	Left    key.Binding
	Right   key.Binding
	Enter   key.Binding
	Back    key.Binding
	Tab     key.Binding
	Search  key.Binding
	Refresh key.Binding
	Help    key.Binding
	Quit    key.Binding
	Nav1    key.Binding
	Nav2    key.Binding
	Nav3    key.Binding
	Nav4    key.Binding
	Nav5    key.Binding
}

KeyMap defines the key bindings for the TUI

func DefaultKeyMap

func DefaultKeyMap() KeyMap

DefaultKeyMap returns the default key bindings

type KnowledgeModel

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

KnowledgeModel handles the knowledge browser view

func NewKnowledgeModel

func NewKnowledgeModel(parent *Model) *KnowledgeModel

NewKnowledgeModel creates a new knowledge model

func (*KnowledgeModel) LoadCollectionDetail

func (m *KnowledgeModel) LoadCollectionDetail(id string) tea.Cmd

LoadCollectionDetail loads a single collection's details

func (*KnowledgeModel) LoadCollections

func (m *KnowledgeModel) LoadCollections() tea.Cmd

LoadCollections loads all collections

func (*KnowledgeModel) Update

func (m *KnowledgeModel) Update(msg tea.Msg) tea.Cmd

Update handles messages for the knowledge view

func (*KnowledgeModel) View

func (m *KnowledgeModel) View() string

View renders the knowledge view

type Model

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

Model is the main TUI application model

func New

func New(
	ctx context.Context,
	store storage.Backend,
	know *knowledge.Engine,
	conv *conversation.Engine,
	ctxEng *ctxengine.Engine,
	ent *entity.Engine,
	cfg *Config,
) *Model

New creates a new TUI model

func (*Model) Init

func (m *Model) Init() tea.Cmd

Init implements tea.Model

func (*Model) Update

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

Update implements tea.Model

func (*Model) View

func (m *Model) View() string

View implements tea.Model

type View

type View int

View represents different views in the TUI

const (
	ViewDashboard View = iota
	ViewKnowledge
	ViewConversations
	ViewContext
	ViewEntities
)

Jump to

Keyboard shortcuts

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