app

package
v2.0.3 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2026 License: MIT Imports: 34 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	TopLeft     = "top-left"
	TopRight    = "top-right"
	BottomLeft  = "bottom-left"
	BottomRight = "bottom-right"
	DockTop     = "dock-top"
	DockBottom  = "dock-bottom"
	Beside      = "beside"
)

Places of what a chat shows around its transcript: over its four corners, in rows above it and in rows below it, and beside its bottom right in room the chat makes for them

View Source
const PlaceOf = "place:"

Start of the argument of the tools screen that opens the page of a place, such as place:telegram

View Source
const Screen = "tools"

Screen of the tools

View Source
const ToolOf = "tool:"

Start of the argument of the tools screen that opens the page of a tool's group with the tool in hand, such as tool:web_search

Variables

This section is empty.

Functions

func Arguments

func Arguments(raw string, width int, look theme.Theme) []string

Rows of the arguments a call was given as a person reads them, unfolded under its title: each argument a row of its name and value, a long text under its name as its lines. They are laid out once for each width and look, a chat drawing the call again reading them from memory

func Changed

func Changed(text string, look theme.Theme) string

Lines a diff adds and removes, as +3 -1 in their tones

func Clip

func Clip(rows []string, keep int, look theme.Theme) []string

The first rows, at most keep, and a last row counting the rest

func Diff

func Diff(text string, look theme.Theme) []string

Rows of a diff, at most six files and 80 lines of it, the rest counted in a last row; only the rows shown are painted

func Notes

func Notes(look theme.Theme, notes ...string) []string

Rows of notes the tool added for the model that the person should read too, such as a warning, in the accent tone

func Outline

func Outline(value any, width int, look theme.Theme) []string

Rows of a structured value as a person reads it, for a result whose shape icebath does not know, such as the structured content of an MCP tool: each field of an object a row of its name and value, a list of objects that share plain fields a table, a short list of plain values on one row, nested values indented under their name

func Register

func Register(host *app.App)

func Room

func Room(width, rows, cols, height int) (gutter, band int)

Room a stack of boxes cols wide and height high takes beside a transcript of the width and rows: the columns of a gutter at its right, the stack at its foot, while the transcript keeps 72 columns; else the rows of a band under it while it keeps 24 columns and 4 rows; none when it fits neither way

func Text

func Text(text string) []string

Rows of text as a chat shows them: escape sequences gone, each line as a program that drew over it with carriage returns left it, tabs as spaces, blank lines at its ends dropped; none for blank text

Types

type Ambient

type Ambient interface {
	// Rows of the place at the width: a stack of boxes for a corner, a transcript of the rows given under it; whole rows for a dock
	Rows(place string, width, rows int, t theme.Theme) []string
	// Count that moves each time what it shows changed, so the rows drawn of it are drawn again only then
	Version() uint64
	// Moves what turns on its own, such as the spinner of a part whose first lines are on their way, by the seconds passed: whether what
	// it shows changed. The chat in view steps it with its frames
	Animate(dt float64) bool
	// Whether the frames have to keep coming for it, as while such a spinner turns
	Awake() bool
}

What a chat shows around its transcript besides the docks of its session, such as the ambient widgets of extensions. Only the chat in view, the one focused last, shows it

type Ambienter

type Ambienter interface {
	Ambient(conn *connect.Client) Ambient
}

Registrant that shows things around the chats, reading them through the connection. A registrant that does says so by having this too

type Call

type Call struct {
	Arguments string
	// Text of the result, empty while the call runs: as the tool returned it, out of the block outside content is handed the model in, and
	// with the notes the agent added after it, which Decode reads past
	Result string
	Failed bool
	// The reply the call is part of has ended
	Ended bool
	// What the user is shown of the result in place of its text, such as the change a write made; empty when the text is all there is
	Display string
	// Values of the settings the view reads, by key, as YAML
	Settings map[string]string
}

Call of a tool as a chat has it

func (Call) Args

func (c Call) Args(into any) bool

Reads the arguments the model gave the call into the value; false when they are no JSON object

func (Call) Decode

func (c Call) Decode(into any) bool

Reads the JSON value the result starts with into the value, past the notes the agent added after it; false when the result holds none, such as one cut short

type Dock

type Dock struct {
	// Reads what the dock shows of the session, off the UI loop, for the profile of the chat that shows it, which may be another than its
	// window's; nil shows nothing
	Load func(ctx context.Context, profile, session string) (Docked, error)
}

What a chat docks above its prompt for the session it shows, such as the background processes its commands left running: read again every second and a half while the session works or something docked counts by the second, every ten seconds otherwise

type Docked

type Docked interface {
	// Rows at the width, at most limit of what it lists, one line when folded; none when there is nothing to show. Asked on the UI loop on
	// every frame the chat is drawn, so it lays out what Load read and reads nothing itself
	Rows(width, limit int, now time.Time, t theme.Theme, folded bool) []string
	// Whether something it shows counts by the second, such as a process still running
	Live(now time.Time) bool
}

What a dock shows of a session at a moment

type Docker

type Docker interface {
	Docks(conn *connect.Client) []Dock
}

Registrant that docks rows in the chats, reading them through the connection. A registrant that docks says so by having this too

type Liner

type Liner struct {
	// Mark the line starts with
	Mark string
	// What the empty prompt says of the mark, such as that it runs a line in the person's shell; empty says nothing
	Hint func(env *cards.Env) string
	// Starts the line for a chat, telling each change of what it printed and how it ended to told, off the UI loop, until it ends; stop
	// ends it. A line that prints fast tells as fast, and each telling holds all it printed so far, so a chat takes in the newest at most
	// once a frame
	Run func(ctx context.Context, run Run, told func(ran Ran)) (stop func())
	// Lines run in a session before, oldest first
	Kept func(ctx context.Context, session, profile string) ([]Ran, error)
	// What a chat shows of a line, as rows under a head that folds them, naming the key that stops a line still running
	Shown func(ran Ran, width int, t theme.Theme, stop string) *Shown
}

What runs a line a person types in a chat after a mark of its own: what it prints is shown in the chat as it comes, and kept with the session

type Lines

type Lines interface {
	Lines(conn *connect.Client) []Liner
}

Registrant that runs lines a person types in a chat. A registrant that does says so by having this too

type Picture

type Picture struct {
	// Small copy of it as PNG or JPEG bytes, and the file of it at full size, which only a chat on the machine that made it can read
	Data []byte
	Path string
	// The same as base64 text in place of Data, for a picture handed as text: its bytes are decoded off the UI loop, as a picture is laid out
	Encoded string
	// Row of the result's rows the picture is drawn before, past the last for after them all
	At int
}

Picture of a result and the row it is drawn before

func EncodedPicture

func EncodedPicture(text, file string, at int) *Picture

Picture of an image a result holds as base64 text, such as the content of an MCP tool, drawn as PictureOf draws one: the text is decoded off the UI loop as the picture is laid out

func PictureOf

func PictureOf(data []byte, file string, at int) *Picture

Picture of the bytes of an image a result holds, drawn before the row at of the result's rows, the file of it at full size named when that is a whole path; nil for no bytes. The chat draws it through the kit's picture element, as its terminal and Images draw pictures

func Pictures

func Pictures(pictures ...*Picture) []*Picture

The pictures given that are some, in order, for a result's Pictures

type Ran

type Ran struct {
	Time   time.Time
	Line   string
	Output string
	// Only the end of the output was kept
	Cut  bool
	Done bool
	Code int
	// The person stopped it
	Stopped bool
	// Why it could not run, empty when it ran
	Error string
	// Folder it ran in, once the server said it
	Folder string
}

A line run, or running, and what it printed so far

type Registrant

type Registrant interface {
	Views() []View
}

type Registry

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

func (*Registry) Ambients

func (r *Registry) Ambients(conn *connect.Client) []Ambient

What every registrant that has one shows around the chats, those of a registry registered into this one with them

func (*Registry) Docks

func (r *Registry) Docks(conn *connect.Client) []Dock

Docks of every registrant that docks, reading through the connection

func (*Registry) Lines

func (r *Registry) Lines(conn *connect.Client) []Liner

Liners of every registrant that runs lines, reaching what runs them through the connection

func (*Registry) Register

func (r *Registry) Register(registrant Registrant)

func (*Registry) Settings

func (r *Registry) Settings() []string

Keys of every setting the views read

func (*Registry) View

func (r *Registry) View(tool string) (View, bool)

View of the tool, false when it is shown as its text. Its Result reads the result as the tool returned it, and is never handed a failure it does not show, which reads as Failure tells it, nor a result saved to a file for being too long, which reads as Saved tells it, unless the tool put something of its own in Display to show in its place, such as a picture or the content an MCP server handed back; where it shows nothing, the text the tool put in Display shows as Displayed lays it out. The views are made once and kept by tool, made again only after another registrant came, and what a view makes of a call is kept by what the call holds, so a chat that draws a call again, as a resize or a reply going on does, draws it from memory; the pictures it shows the chat draws as the kit lays them out

func (*Registry) Views

func (r *Registry) Views() []View

type Run

type Run struct {
	// Session of the chat, empty before it has one, and its profile
	Session, Profile string
	// Folder of a chat that has no session yet
	Folder string
	Line   string
	// The person's shell, as this app knows it
	Shell string
}

A line to run, and the chat it is run for

type Seated

type Seated interface {
	Seated(x, y int, shown bool)
}

Ambient told the screen cell its boxes beside the transcript start at, their top left, each time the chat in view is drawn, and when they are not drawn: for an image the terminal places over them by position

type Shown

type Shown struct {
	Head string
	// Head while the rows are folded, Head when empty
	Folded string
	Rows   []string
	// The rows show until the user folds them
	Open bool
	// Pictures among the rows, each drawn before the row it names by the chat through the kit's picture element, as its terminal draws
	// pictures and Images asks; none for rows of text alone
	Pictures []*Picture
}

Result shown as rows under a head that folds them

func Content

func Content(result *mcp.CallToolResult, width int, look theme.Theme) *Shown

What a result shows of its content when icebath does not know the tool's shape, such as the result of an MCP server's tool or an extension's: by the content types of MCP, a text as its lines, or as an outline when it is JSON, each image drawn where it comes, audio and resources as what they are and where they are, and the structured content as an outline, all under a head counting what came back

func Displayed

func Displayed(call Call, look theme.Theme) *Shown

What the tool showed the person in place of its result when it is text, for a view that shows nothing else of it: its first line the head and the rest under it; nil for none

func Failure

func Failure(call Call, look theme.Theme) *Shown

A failed call as the sentence that says why, the lines after the first under it: what the tool told the person of it in Display, else the error its result names, else the message it gives, else its text when that is no JSON. A call that did not fail, whose result its view could not read, reads as where the result went when it was saved to a file for being too long, else as what the tool showed, else as its text when that is no JSON; nil when nothing of it is for a person to read

func Saved

func Saved(call Call, look theme.Theme) *Shown

A result saved to a file for being too long for the chat, as where it went; nil for a result kept whole, or one whose tool showed the person something of its own in its place

type Surround

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

What the ambients show around a chat: their rows kept and drawn again only once one of them changed, or at a size or look not drawn yet

func NewSurround

func NewSurround(ambients []Ambient) *Surround

func (*Surround) Animate

func (s *Surround) Animate(dt float64) bool

Moves what the ambients turn on their own by the seconds passed: whether any of them changed what it shows

func (*Surround) Awake

func (s *Surround) Awake() bool

Whether the frames have to keep coming for an ambient

func (*Surround) Band

func (s *Surround) Band(place string, width int, t theme.Theme) []string

Rows of a dock at the width, those of every ambient one after the other

func (*Surround) Beside

func (s *Surround) Beside(width, rows int, t theme.Theme) (stack []string, gutter, band int)

Boxes of every ambient beside a transcript of the width and rows, one after the other, each row as wide as the widest, and the room they take as Room says; none when they fit neither way

func (*Surround) Corners

func (s *Surround) Corners(body []string, width int, t theme.Theme) []string

Rows of a transcript with the boxes of every corner laid over them, a corner's stack cut to the rows there are; the rows given are left as they are

func (*Surround) Empty

func (s *Surround) Empty() bool

Whether nothing shows around the chats

func (*Surround) Seat

func (s *Surround) Seat(x, y int, shown bool)

Tells every ambient that is Seated where its boxes beside the transcript are drawn on the screen, the stack of them starting at the cell x, y, or that they are not drawn

type View

type View struct {
	// Tool shown this way, by name, or the view the tools of one kind name as theirs, such as those of MCP servers
	Tool string
	// Line next to the tool's title in place of its subject argument; empty keeps the subject
	Line func(call Call) string
	// What the result is shown as in place of its text; nil keeps the text
	Result func(call Call, width int, theme theme.Theme) *Shown
	// Result shows failed calls too, such as a command's output with how it exited; the failure of a call of any other view reads as the
	// sentence Failure makes of it
	Fails bool
	// Only the newest call of the tool in a reply shows its result, the others their line alone: for a tool whose every result holds all
	// it keeps, such as a task list
	Latest bool
	// Settings the view reads, by key, which a chat hands it in Call.Settings as they change
	Settings []string
	// How many tasks of its list a call of a tool that keeps one leaves done, and of how many; false for a call that tells none
	Tasks func(call Call) (done, total int, ok bool)
}

How a chat shows the calls of one tool, for a tool whose arguments and text are not the best way to read it

type Views

type Views struct {
	Registry
}

Views plugins register, read by the chats

func New

func New() *Views

Jump to

Keyboard shortcuts

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