tui

package module
v0.21.0 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

README

tui

The reusable terminal user interface for looprig. It keeps the Bubble Tea v2 presentation stack outside the core Harness.

The module has four public package boundaries:

  • the root tui package is the stable public facade for the interactive screen and contract
  • runtime owns process signals, logging, terminal capture, and Bubble Tea startup
  • sessionadapter adapts a Harness Session to the TUI contract
  • components and styles are reusable presentation leaves

The dependency is one-directional: TUI imports Harness, never the reverse.

Internal ownership is similarly one-directional:

  • internal/presentation owns the complete Bubble Tea state machine and behavioral tests
  • internal/input owns attachment parsing, validation, and file completion
  • internal/model owns independent value projections such as compaction and collapse state
  • internal/view owns reusable rendering primitives such as rails and width wrapping
  • internal/ttylog owns private terminal log capture

The transcript, interaction model, viewport, and Screen stay together in internal/presentation because they form one Bubble Tea state machine rather than independent reusable packages. Consumers continue to import only github.com/looprig/tui.

Tool-preparation approval

A tool call that needs approval renders as ONE combined prompt built from the typed gate.PermissionPayload (event.PermissionRequested.Request, a tool.Request narrowed to its unmet requirements, each carrying its exact reusable rule candidates). The TUI renders that typed payload verbatim — it never reconstructs a rule or parses tool arguments. The prompt offers exactly the three gate.ApprovalControls actions, keyed:

  • yApprove (gate.ApprovalApprove; grants once, persists nothing)
  • aApprove always for this workspace (gate.ApprovalApproveAlwaysWorkspace; persists the displayed candidates)
  • n / escDeny (gate.ApprovalDeny; fail-secure)

There is no session scope, user-global scope, per-capability sub-prompt, /access command, access tray, or mutable security level.

Session presentation metadata

Workspace path, the fixed access-profile name, and permission diagnostics are supplied synchronously by the consumer at screen construction via tui.WithSessionPresentation(tui.SessionPresentation{…}) — never queried asynchronously and never inferred from events. The fixed profile is shown as footer/session metadata (not a mutable control), and permission diagnostics for manual, out-of-catalogue allow families are committed in the startup metadata area so they are visible before the first permission gate.

Building & testing

Dependencies are pinned by go.mod/go.sum, not vendored. Use the Make targets for the standard verification path:

make secure
go build ./...
go test -race ./...

Documentation

Overview

Package tui exposes the reusable Looprig terminal interface.

Index

Constants

View Source
const (
	StatusIdle         = presentation.StatusIdle
	StatusRunning      = presentation.StatusRunning
	StatusInterrupting = presentation.StatusInterrupting
	StatusResetting    = presentation.StatusResetting

	ToolRunning   = presentation.ToolRunning
	ToolOK        = presentation.ToolOK
	ToolError     = presentation.ToolError
	ToolCancelled = presentation.ToolCancelled
)

Variables

This section is empty.

Functions

func AllLoopsEventFilter

func AllLoopsEventFilter() event.EventFilter

AllLoopsEventFilter subscribes to enduring and ephemeral events from every loop.

func RenderStatusLine

func RenderStatusLine(status Status) string

RenderStatusLine renders a standalone status indicator.

Types

type Agent

type Agent = presentation.Agent

Public presentation contracts retain their original type identity through aliases.

type AgentBanner

type AgentBanner = presentation.AgentBanner

Public presentation contracts retain their original type identity through aliases.

type AgentHolder

type AgentHolder = presentation.AgentHolder

Public presentation contracts retain their original type identity through aliases.

type AttachmentNotFoundError

type AttachmentNotFoundError = input.AttachmentNotFoundError

Attachment input errors remain available at the root for compatibility.

type AttachmentReadError

type AttachmentReadError = input.AttachmentReadError

Attachment input errors remain available at the root for compatibility.

type AttachmentTooLargeError

type AttachmentTooLargeError = input.AttachmentTooLargeError

Attachment input errors remain available at the root for compatibility.

type BinaryAttachmentError

type BinaryAttachmentError = input.BinaryAttachmentError

Attachment input errors remain available at the root for compatibility.

type DeniedAttachmentError

type DeniedAttachmentError = input.DeniedAttachmentError

Attachment input errors remain available at the root for compatibility.

type DisplayProjection

type DisplayProjection = presentation.DisplayProjection

Public presentation contracts retain their original type identity through aliases.

func FoldDisplay

func FoldDisplay(events []event.Event) DisplayProjection

FoldDisplay rebuilds the display projection from session events.

type EffortID

type EffortID = presentation.EffortID

Public presentation contracts retain their original type identity through aliases.

type EffortOption

type EffortOption = presentation.EffortOption

Public presentation contracts retain their original type identity through aliases.

type EmptyInputError

type EmptyInputError = input.EmptyInputError

Attachment input errors remain available at the root for compatibility.

type EventStream

type EventStream = presentation.EventStream

Public presentation contracts retain their original type identity through aliases.

type HandoffFinalizer

type HandoffFinalizer = presentation.HandoffFinalizer

Public presentation contracts retain their original type identity through aliases.

type ImageUnsupportedError

type ImageUnsupportedError = input.ImageUnsupportedError

Attachment input errors remain available at the root for compatibility.

type LoopRuntimeOptions

type LoopRuntimeOptions = presentation.LoopRuntimeOptions

Public presentation contracts retain their original type identity through aliases.

type ModeID

type ModeID = presentation.ModeID

Public presentation contracts retain their original type identity through aliases.

type ModeOption

type ModeOption = presentation.ModeOption

Public presentation contracts retain their original type identity through aliases.

type ModelID

type ModelID = presentation.ModelID

Public presentation contracts retain their original type identity through aliases.

type ModelOption

type ModelOption = presentation.ModelOption

Public presentation contracts retain their original type identity through aliases.

type OpenAgent

type OpenAgent = presentation.OpenAgent

Public presentation contracts retain their original type identity through aliases.

type Option

type Option = presentation.Option

Public presentation contracts retain their original type identity through aliases.

func WithSessionBrowser

func WithSessionBrowser(browser SessionBrowser) Option

func WithSessionPresentation

func WithSessionPresentation(p SessionPresentation) Option

WithSessionPresentation supplies the synchronous, consumer-filled session metadata (workspace root, fixed access profile name, permission diagnostics) the screen captures at construction and displays. Diagnostics are surfaced before the first permission gate; the profile is shown as session metadata, never a mutable control.

type RestoreBacklogError

type RestoreBacklogError = presentation.RestoreBacklogError

Public presentation contracts retain their original type identity through aliases.

type RuntimeCatalog

type RuntimeCatalog = presentation.RuntimeCatalog

Public presentation contracts retain their original type identity through aliases.

type RuntimeController

type RuntimeController = presentation.RuntimeController

Public presentation contracts retain their original type identity through aliases.

type Screen

type Screen = presentation.Screen

Public presentation contracts retain their original type identity through aliases.

func New

func New(ctx context.Context, agent Agent, open OpenAgent, banner AgentBanner, options ...Option) Screen

New constructs the interactive terminal screen.

type SessionBrowser

type SessionBrowser = presentation.SessionBrowser

Public presentation contracts retain their original type identity through aliases.

type SessionID

type SessionID = presentation.SessionID

Public presentation contracts retain their original type identity through aliases.

type SessionPresentation

type SessionPresentation = presentation.SessionPresentation

Public presentation contracts retain their original type identity through aliases.

type SessionPresenter

type SessionPresenter = presentation.SessionPresenter

Public presentation contracts retain their original type identity through aliases.

type SessionSummary

type SessionSummary = presentation.SessionSummary

Public presentation contracts retain their original type identity through aliases.

type Status

type Status = presentation.Status

Public presentation contracts retain their original type identity through aliases.

type TerminalErrorHolder

type TerminalErrorHolder = presentation.TerminalErrorHolder

Public presentation contracts retain their original type identity through aliases.

type ToolCallView

type ToolCallView = presentation.ToolCallView

Public presentation contracts retain their original type identity through aliases.

type ToolStatus

type ToolStatus = presentation.ToolStatus

Public presentation contracts retain their original type identity through aliases.

type UnsupportedAttachmentError

type UnsupportedAttachmentError = input.UnsupportedAttachmentError

Attachment input errors remain available at the root for compatibility.

Directories

Path Synopsis
internal
ttylog
Package ttylog keeps dependency logging off a full-screen TUI.
Package ttylog keeps dependency logging off a full-screen TUI.
Package restore provides a reusable, interactive session.RestoreDecider that an application embedding tui wires into its harness Rig via rig.WithRestoreDecider.
Package restore provides a reusable, interactive session.RestoreDecider that an application embedding tui wires into its harness Rig via rig.WithRestoreDecider.
Package runtime runs looprig TUI entry points.
Package runtime runs looprig TUI entry points.
Package sessionadapter adapts harness sessions to the terminal Agent contract.
Package sessionadapter adapts harness sessions to the terminal Agent contract.
Package styles holds the shared lipgloss styles and glamour helpers for the LoopRig TUI.
Package styles holds the shared lipgloss styles and glamour helpers for the LoopRig TUI.

Jump to

Keyboard shortcuts

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