tui

package
v0.3.4 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Overview

Package tui renders a gateway's live event stream and captures the operator's input, driving it through the narrow Backend interface. It is the terminal gateway's frontend: the daemon hub treats that gateway like any other; the TUI is what makes it a human-usable pane. Depending on Backend (not the concrete gateway) keeps this package importable by the gateway without a cycle.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(ctx context.Context, cancel context.CancelFunc, tm Backend) error

Run starts the TUI bound to the given gateway backend, blocking until the user quits; quitting cancels ctx (wired by the caller) so the daemon shuts down cleanly.

Types

type Attachment

type Attachment struct {
	Name string
	Path string
	Mime string
	Size int64
}

Attachment is a file staged to send with the next message (and echoed under the user's transcript entry once sent). Path is a local filesystem path; the terminal gateway hands it to the host as a file:// URL.

type Backend

type Backend interface {
	Frontend() <-chan RoutedEvent
	Submit(channel, text string, attachments []Attachment)
	Sessions() []contracts.SessionInfo
	Dispatch(args []string) (string, error)
	// Close tears a session down by name through the typed control seam, so the
	// UI's close action never assembles "session close" flag argv.
	Close(name string, force bool) (string, error)
	// Commands lists the operator commands the palette advertises, scoped to the
	// verbs this backend will actually accept.
	Commands() []CommandSpec
	// Scrollback returns a session's recorded history lines, so a reopened tab is
	// seeded with the conversation before live events arrive. Empty when none.
	Scrollback(name string) []contracts.ScrollbackLine
	// Resume revives an archived session by name (backend resumed via its stored
	// token), for the /resume picker. Returns a human-readable result or an error.
	Resume(name string) (string, error)
	// Interrupt cancels a session's in-flight turn (esc-to-interrupt). Reports
	// false when nothing was interrupted (no live turn by that name).
	Interrupt(name string) bool
}

Backend is the narrow view of the terminal gateway the TUI drives: it reads routed outbound events to render, submits the lines the operator types into a specific channel, enumerates the hub's sessions for tab labels, and dispatches operator slash-commands to the hub. Taking an interface keeps this package free of any dependency on the terminal plugin.

type ChoiceOption

type ChoiceOption struct {
	Label string
	Value string
}

ChoiceOption is one selectable answer in a permission menu: Label is shown to the operator, Value is the frame value submitted to the backend when chosen.

type CommandSpec

type CommandSpec struct {
	Name string
	Args string
	Desc string
}

CommandSpec is one operator command advertised in the palette. Name is the verb path without the leading slash (e.g. "session create").

type PendingChoice

type PendingChoice struct {
	Question string
	Options  []ChoiceOption
	Channel  string
}

PendingChoice is an active allow/deny permission menu awaiting a selection. Question frames what is being permitted (e.g. "run Bash(rm -rf build/)"); Channel is the session the answer is submitted back to.

type RoutedEvent

type RoutedEvent struct {
	Conv  contracts.Conversation
	Event contracts.Event
}

RoutedEvent is a turn event tagged with the conversation (session channel) it belongs to, so the TUI can route it to the right tab.

Jump to

Keyboard shortcuts

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