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.
Rendering is split by concern: tui.go maps bus events onto transcript roles, render.go draws one entry per role, markdown.go runs the agent's prose through the markdown engine (and its diffs by hand), chrome.go frames the flow, and status.go derives what the session has cost and how full its context is. The palette lives in theme.go, so no render site names a colour.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Attachment ¶
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 ¶
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 ¶
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.