tui

package
v0.9.3 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2026 License: MIT Imports: 46 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChatMessage

type ChatMessage struct {
	Role      string
	Content   string
	Name      string // tool name, for Role == "tool"
	Arguments string // marshaled call args, for Role == "tool"
	AgentID   string // issuing sub-agent, for Role == "tool" (empty = root agent)
	// Transient marks a turn-level error line: it stays in the transcript so
	// the failure is visible, but is dropped as soon as a reply arrives (a
	// successful turn, or a parked reply) so a recovered run doesn't carry
	// the old error for the rest of the session.
	Transient bool
	// Meta, Status and Diff decorate a tool entry's header and body; see
	// render.Message. Set by toolMessage.
	Meta   string
	Status render.ToolStatus
	Diff   *textdiff.Diff
}

ChatMessage represents a message in the chat history

type Model

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

Model represents the TUI state

func NewModel

func NewModel(ctx context.Context, cfg types.Config, height int, shellJobs *wizmcp.ShellJobs, p render.Presenter, transports ...mcp.Transport) Model

NewModel creates a new TUI model

func (Model) Init

func (m Model) Init() tea.Cmd

Init initializes the model

func (Model) Output

func (m Model) Output() string

Output returns any command that should be output to the shell

func (Model) SessionUsage added in v0.7.0

func (m Model) SessionUsage() chat.SessionUsage

SessionUsage reports what the session spent, for the exit summary RunTUI prints once the program has stopped rendering.

func (Model) Shutdown added in v0.9.2

func (m Model) Shutdown()

Shutdown stops the work that would otherwise outlive the program, and saves a session the program did not save itself. RunTUI calls it once the program has exited.

quit() saves and closes the session, but an external SIGINT or SIGTERM unwinds the program without it, and the session went unsaved. Detached sub-agents and shell jobs do not stop with a turn: they used to die only with the process, and a shell job's children could outlive nib.

func (Model) Update

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

Update handles messages and updates the model

func (Model) View

func (m Model) View() string

View renders the TUI.

func (Model) WithBell added in v0.9.2

func (m Model) WithBell(w io.Writer) Model

WithBell returns m ringing the terminal bell on w whenever the TUI hands control back to the user: a turn ended, the run parked, or a tool approval or an ask is waiting. A nil w (the default) never rings.

This is the only idle signal a host watching the terminal can use. nib is never silent while idle - the footer clock repaints every second - so "no output for a while" never happens, and a host that waits for it sees a session that finished minutes ago as still working.

w must be the terminal the program renders to. The bell is written straight to it from Update rather than through the renderer, which has no way to emit a raw byte. That is safe because the renderer writes each frame in a single Write, so a one-byte write lands between frames and never inside an escape sequence.

Directories

Path Synopsis
full
Package full implements render.Presenter for nib's full-screen surface: the alt-screen mode with mouse reporting enabled.
Package full implements render.Presenter for nib's full-screen surface: the alt-screen mode with mouse reporting enabled.
inline
Package inline implements render.Presenter for nib's default surface: the fzf-style inline widget that lives in the normal terminal scrollback (no alt screen, no mouse reporting).
Package inline implements render.Presenter for nib's default surface: the fzf-style inline widget that lives in the normal terminal scrollback (no alt screen, no mouse reporting).

Jump to

Keyboard shortcuts

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