Help us shape the future of Go! Take the 2026 Go Developer Survey

view

package
v0.19.10 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2026 License: MIT Imports: 25 Imported by: 0

Documentation

Overview

Package view is the client every Orb app draws. It follows the conversations open on Bridge, this machine's and its peers', folds their events into rows ready to draw, and does what the app asks; an app only renders and sends intents, so every app behaves the same.

The wire is JSON. Intents come in as {"do": …} (with an "id" when they expect a reply). The app gets {"t":"state"} when what it draws outside conversations changes, {"t":"rows"} with the rows of a conversation from the first that changed, {"t":"home"} with the machines and their threads (larger, changing less often), {"t":"reply"} to an intent with an id, and {"t":"alert"} for what happened out of its sight.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account struct {
	Provider     string   `json:"provider"`
	ProviderName string   `json:"provider_name"`
	ID           string   `json:"id"`
	Name         string   `json:"name"`
	Active       bool     `json:"active,omitempty"`
	Plan         string   `json:"plan,omitempty"`
	Windows      []Window `json:"windows,omitempty"`
}

Account is a connected account and its plan limits, as `orb accounts --json` lists it.

type Action

type Action struct {
	Key    string `json:"k"`
	Verb   string `json:"verb"`
	Target string `json:"target"`
	Result string `json:"result,omitempty"`
	Live   bool   `json:"live,omitempty"`
	Failed bool   `json:"failed,omitempty"`
}

Action is one line of a run: a thought or a tool call, its target and what came of it. What it was given and returned in full comes with "detail".

type App

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

func New

func New(ctx context.Context, o Options) *App

New starts the view: it brings back the saved tabs and keeps machines and threads current.

func (*App) Do

func (a *App) Do(line []byte)

Do runs one intent. Those that wait on a machine run on their own; the rest apply at once and in order, so two messages sent one after the other arrive in that order.

type Ask

type Ask struct {
	ID      string   `json:"id"`
	Owner   string   `json:"owner"`
	Title   string   `json:"title"`
	Message string   `json:"message,omitempty"`
	Choices []string `json:"choices,omitempty"`
	Free    bool     `json:"free,omitempty"`
}

Ask is a plugin stopping the world until someone answers: an approval, or one question of a series; Free takes any text.

type Block

type Block struct {
	Type   string     `json:"type"`
	Level  int        `json:"level,omitempty"`
	Mark   string     `json:"mark,omitempty"`
	Depth  int        `json:"depth,omitempty"`
	Spans  []Span     `json:"spans,omitempty"`
	Lang   string     `json:"lang,omitempty"`
	Text   string     `json:"text,omitempty"`
	Blocks []Block    `json:"blocks,omitempty"`
	Rows   [][][]Span `json:"rows,omitempty"` // the first row is the header
}

Block is one block of markdown an app lays out: a paragraph (p), heading (h), list item (li), quote, code, a drawn diagram (art), table or rule. Items of nested lists and what follows their first paragraph carry a Depth; a quote holds blocks of its own.

func Blocks

func Blocks(md string, done bool) []Block

Blocks parses what a model wrote. A Mermaid block is drawn once its message is [done]; while it streams, and when it does not parse, it stays code.

type Claim

type Claim struct {
	Invitation string `json:"invitation"`
	Claimant   string `json:"claimant"`
}

Claim is a device that claimed this machine's invitation and waits for its owner's yes.

type Command

type Command struct {
	Name string `json:"name"`
	Hint string `json:"hint,omitempty"`
	Now  bool   `json:"now,omitempty"`
}

Command is one entry of the slash palette; Now runs on tap, the rest take an argument.

type Completion

type Completion struct {
	Text   string `json:"text"`
	Label  string `json:"label"`
	Detail string `json:"detail,omitempty"`
}

Completion is what an `@` token completes to: the text that replaces it, and how to show it.

type Entry

type Entry struct {
	Key       string `json:"key"`
	Title     string `json:"title"`
	Machine   string `json:"machine"`
	CWD       string `json:"cwd,omitempty"`
	Modified  int64  `json:"modified"`
	Live      bool   `json:"live,omitempty"`
	Asks      bool   `json:"asks,omitempty"`
	Open      bool   `json:"open,omitempty"`     // a tab follows it
	Unstored  bool   `json:"unstored,omitempty"` // its Orb has not stored the thread yet
	Deletable bool   `json:"deletable,omitempty"`
}

Entry is a row of Home: a thread, or an Orb whose thread is not stored yet, on some machine. Home lists them newest first, a live one as of now.

type Folder

type Folder struct {
	CWD      string `json:"cwd"`
	Threads  int    `json:"threads"`
	Modified int64  `json:"modified"`
	Live     bool   `json:"live,omitempty"`
}

Folder is where some of a machine's threads live, most recently worked in first.

type Invitation

type Invitation struct {
	Code    string `json:"code"`
	Expires int64  `json:"expires"` // seconds
	// contains filtered or unexported fields
}

Invitation is the code another device joins this machine with; it works once, until Expires.

type Login

type Login struct {
	Machine      string  `json:"machine"`
	Provider     string  `json:"provider"`
	State        string  `json:"state"` // starting · browser · code · asking · done · failed
	URL          string  `json:"url,omitempty"`
	Instructions string  `json:"instructions,omitempty"`
	Code         string  `json:"code,omitempty"`
	Detail       string  `json:"detail,omitempty"`
	Prompt       *Prompt `json:"prompt,omitempty"`
}

Login is a sign-in a machine runs for this app, as the TUI's /login runs it.

type Machine

type Machine struct {
	ID        string    `json:"id"`
	Name      string    `json:"name"`
	Self      bool      `json:"self,omitempty"`
	Connected bool      `json:"connected,omitempty"`
	Version   string    `json:"version,omitempty"`
	Launch    bool      `json:"launch,omitempty"` // it lets this app start Orb there
	Hue       int       `json:"hue,omitempty"`    // 1 to 6 for a peer, its own while hues last; 0 for this machine
	Running   []Running `json:"running,omitempty"`
	Folders   []Folder  `json:"folders,omitempty"`
}

Machine is a device on Bridge, this one first, as Home, the pickers and the Bridge screen show it.

type Method

type Method struct {
	Auth    string `json:"auth"` // oauth · api_key
	Label   string `json:"label"`
	About   string `json:"about,omitempty"`
	Account bool   `json:"account,omitempty"`
}

type Option

type Option struct {
	ID    string `json:"id"`
	Label string `json:"label"`
}

type Options

type Options struct {
	// Call reaches this machine's Bridge owner API, the calls `orb bridge pipe` takes.
	Call func(ctx context.Context, method string, params, result any) error
	// Run runs this machine's orb CLI and returns what it printed.
	Run func(ctx context.Context, args ...string) (string, error)
	// Tabs is what SaveTabs last kept, so the tabs come back when the app starts again.
	Tabs     []byte
	SaveTabs func([]byte)
	// Names is what SaveNames last kept: the names given to machines here, over their own.
	Names     []byte
	SaveNames func([]byte)
	// Latest is the newest Orb release, "" when unknown.
	Latest func(ctx context.Context) string
	// Name is what this machine is called in the app ("this phone"); CWD is where a new
	// conversation here starts.
	Name, CWD string
	// Emit sends one message to the app; it is called with the view's lock held, never concurrently.
	Emit func(any)
}

Options are what the host gives the view; the view itself touches no file, process or network.

type Prompt

type Prompt struct {
	Kind        string   `json:"kind"`
	Message     string   `json:"message"`
	Placeholder string   `json:"placeholder,omitempty"`
	Options     []Option `json:"options,omitempty"`
}

Prompt is what a sign-in asks: a menu, a line of text, a secret, or a pasted code or URL.

type Provider

type Provider struct {
	ID      string   `json:"id"`
	Name    string   `json:"name"`
	Methods []Method `json:"methods"`
	Models  int      `json:"models"`
	Ready   bool     `json:"ready,omitempty"`
	Holds   string   `json:"holds,omitempty"`  // where its credential lives, in words
	Status  string   `json:"status,omitempty"` // the credential's type
	Source  string   `json:"source,omitempty"`
}

Provider is one way to models on a machine, as `orb login --json` lists it: the TUI's /login.

type Row

type Row struct {
	Key     string   `json:"k"`
	Kind    string   `json:"kind"`
	Text    string   `json:"text,omitempty"`
	Via     string   `json:"via,omitempty"` // "bridge": a peer sent it, not this app
	Alarm   bool     `json:"alarm,omitempty"`
	Images  []string `json:"images,omitempty"` // references an app fetches with "image"
	Block   *Block   `json:"block,omitempty"`
	Live    bool     `json:"live,omitempty"`
	What    string   `json:"what,omitempty"` // a run in words: "2 thoughts · 3 commands"
	Now     string   `json:"now,omitempty"`  // what a run is doing now
	Failed  int      `json:"failed,omitempty"`
	Actions []Action `json:"actions,omitempty"`
}

Row is what an app draws of a conversation, one per line of it: what someone said (you), a block of what Orb wrote (md), a run of what it did (run: thoughts and tool calls, folded into one line past a single action), or a note.

type Running

type Running struct {
	Instance string `json:"instance"`
	Label    string `json:"label"`
	Busy     bool   `json:"busy,omitempty"`
}

Running is an Orb running on a machine, labelled for a picker.

type Span

type Span struct {
	Text   string `json:"t"`
	Bold   bool   `json:"b,omitempty"`
	Italic bool   `json:"i,omitempty"`
	Code   bool   `json:"c,omitempty"`
	Strike bool   `json:"s,omitempty"`
	Href   string `json:"h,omitempty"`
}

Span is a run of text in one style.

type State

type State struct {
	Self       string      `json:"self"`
	Up         bool        `json:"up"`
	Tabs       []Tab       `json:"tabs"`
	Claim      *Claim      `json:"claim,omitempty"`
	Invitation *Invitation `json:"invitation,omitempty"`
	Joining    string      `json:"joining,omitempty"`   // claiming · waiting (for the inviter's yes) · paired
	Launching  string      `json:"launching,omitempty"` // starting Orb on a machine, or why that failed
	Login      *Login      `json:"login,omitempty"`
	Acting     bool        `json:"acting,omitempty"` // a peer's prompt is running on this machine
	Summary    string      `json:"summary"`          // one line for a status bar or notification
	Latest     string      `json:"latest,omitempty"`
	Commands   []Command   `json:"commands"` // the app's own slash commands, before each Orb's
}

State is everything an app draws outside conversations.

type Tab

type Tab struct {
	ID        string    `json:"id"`
	Title     string    `json:"title"`
	Peer      string    `json:"peer"`
	Where     string    `json:"where"` // the machine's name
	Remote    bool      `json:"remote,omitempty"`
	CWD       string    `json:"cwd,omitempty"`
	Busy      bool      `json:"busy,omitempty"`
	Online    bool      `json:"online"`
	Loaded    bool      `json:"loaded,omitempty"` // an empty conversation is ready, not still coming
	Earlier   bool      `json:"earlier,omitempty"`
	Streaming bool      `json:"streaming,omitempty"`
	Status    string    `json:"status,omitempty"`
	Model     string    `json:"model,omitempty"` // provider/id
	Thinking  string    `json:"thinking,omitempty"`
	Levels    []string  `json:"levels,omitempty"`  // reasoning levels the model takes, lowest first
	Context   float64   `json:"context,omitempty"` // share of the context window in use
	Cost      float64   `json:"cost,omitempty"`
	Usage     *Usage    `json:"usage,omitempty"`
	Ask       *Ask      `json:"ask,omitempty"`
	Unread    int       `json:"unread,omitempty"` // answers that finished out of sight since it was last shown
	Commands  []Command `json:"commands,omitempty"`
	Models    []string  `json:"models,omitempty"`
}

Tab is a conversation an app has open, as it draws its header, strip and prompt box; its conversation comes as rows.

type Usage

type Usage struct {
	Plan    string   `json:"plan,omitempty"`
	At      int64    `json:"at"` // milliseconds
	Windows []Window `json:"windows"`
}

Usage is the plan limits of a conversation's provider account, as its Orb last read them; windows that reset since are left out.

type Window

type Window struct {
	Name   string  `json:"name"`
	Left   float64 `json:"left"`   // percent
	Resets int64   `json:"resets"` // milliseconds; 0 when unknown
}

Jump to

Keyboard shortcuts

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