tui

package
v0.6.4 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Overview

Package tui provides the full-screen chat TUI for the default glean invocation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Model

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

Model is the Bubbletea model for the glean chat TUI.

func New

func New(cfg *config.Config, session *Session, identity, version string, ctx context.Context) (*Model, error)

New creates a fully-initialized TUI model.

func (*Model) Init

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

Init implements tea.Model.

func (*Model) Session

func (m *Model) Session() *Session

Session returns the current session (used by cmd/root.go for post-exit stats).

func (*Model) StatsLine

func (m *Model) StatsLine() string

StatsLine builds a brief session summary printed to stdout after the TUI exits. Format: "N turns · 5m 30s · Thanks for using Glean"

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 Session

type Session struct {
	Turns []Turn `json:"turns"`
}

Session holds conversation history and can be persisted to disk.

func LoadLatest

func LoadLatest() *Session

LoadLatest loads the last saved session, or returns an empty session if none exists.

func (*Session) AddTurn

func (s *Session) AddTurn(role, content string, sources []Source)

AddTurn appends a turn to the session and saves immediately.

func (*Session) AppendTurn

func (s *Session) AppendTurn(turn Turn)

AppendTurn appends a complete Turn (including Elapsed and any other fields) to the session and saves immediately.

func (*Session) Save

func (s *Session) Save() error

Save persists the session to ~/.glean/sessions/latest.json.

type Source

type Source struct {
	Title      string `json:"title"`
	URL        string `json:"url"`
	Datasource string `json:"datasource"`
}

Source is a cited document reference shown below an AI response.

type Turn

type Turn struct {
	Role    string   `json:"role"`              // "user" or "assistant"
	Content string   `json:"content"`           // full text of the message
	Sources []Source `json:"sources,omitempty"` // cited documents
	Elapsed string   `json:"elapsed,omitempty"` // response time, e.g. "4.2s"
}

Turn holds one exchange in the conversation history.

Jump to

Keyboard shortcuts

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