ui

package
v0.13.1 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: BSD-3-Clause Imports: 15 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

Overview

Package ui is the agentscope screen: a ViewModel that holds ALL state as go-widgets/mvvm primitives and never references a widget, and a View (scene.go) that builds toolkit widgets and binds them to it. Both are tagless, so a native `go test` covers them; the browser host is cmd/agentscope-web.

Index

Constants

View Source
const (
	StateAll = iota
	StateActive
	StateIdle
)

The state filter's choices.

View Source
const (
	// MaxGraphSessions is how many session clusters are drawn, newest first.
	MaxGraphSessions = 64
	// MaxGraphAgents is how many sub-agent nodes a session cluster shows; the
	// rest are one "+N more" node.
	MaxGraphAgents = 6
	// MaxGraphRepos is how many repositories the "other repositories" cluster
	// shows (held repositories are always drawn, inside their holder).
	MaxGraphRepos = 200

	// NodeWidth is the width of a node box, and NodeChars the number of
	// characters a label is cut to so that it fits in it.
	NodeWidth = 170
	NodeChars = 22
)

The GraphView sizes each cluster by its own members and scrolls when they overflow, so these are safety bounds on what is drawn, not a fit to the screen. They are the screen's, not the collector's: the table and the detail pane list everything.

View Source
const (
	GColName = iota
	GColTotal
	GColLast
	GColDecision
	GColGate
	GColAfter
	GColFlag
)

The columns of the lessons table.

View Source
const (
	PanelMinW       = 320
	PanelDefaultW   = 420
	PanelMaxPercent = 70
)

The side panel's width, in logical pixels: it opens at PanelDefaultW, the owner may drag its left edge, and it stays between PanelMinW and PanelMaxPercent of the surface.

View Source
const (
	SpanShort = iota // the 5 hour window
	SpanWeek         // the 7 day window
	SpanWeeks        // four 7 day windows, aligned on the weekly reset
)

The spans the Quota tab can show, in the order of the selector.

View Source
const (
	KindOutput = iota
	KindCacheRead
)

The token kinds the weeks view can show, in the order of the selector.

View Source
const (
	DefaultW = 1280
	DefaultH = 800
)

DefaultW and DefaultH are the size a Scene has before the host tells it the viewport's.

View Source
const (
	TabGraph = iota
	TabQuota
	TabGuardrails
)

The tabs.

View Source
const (
	SplitScale   = 1000 // the two panes' shares add up to this
	SplitDefault = 550  // Sessions 55 %, Details 45 %: what a double-click on the divider restores
	SplitLo      = 100  // a stored or set share is held between these
	SplitHi      = 900
	PaneMinH     = 120 // the least height, in logical pixels, either pane keeps

)

The split between the Sessions table and the Details pane inside the side panel: the owner drags the divider between them. Split is the Sessions pane's share of the two, in thousandths; each pane keeps at least PaneMinH logical pixels.

View Source
const GraphMinW = 320

GraphMinW is the least width, in logical pixels, the graph keeps beside the open panel: the splitter squeezes the panel before it takes more.

View Source
const GuardChipSlots = 4

GuardChipSlots is how many headline chips the tab shows.

View Source
const MaxBackingPixels = 8_000_000

MaxBackingPixels bounds the canvas's backing store, in device pixels: a full-surface canvas at a high devicePixelRatio is hundreds of megabytes of pixels that a browser's compositor keeps copies of (a 5K display at 2x is 30 M pixels, 120 MB per copy).

View Source
const ModelChipSlots = 3

ModelChipSlots is how many model families the header shows chips for.

View Source
const ModelFilterSlots = 6

ModelFilterSlots is how many model names the filter row offers a check box for: the most used ones present.

Variables

View Source
var (
	ColMin     = []int{40, 50, 80, 50, 60, 60, 30, 44}
	ColDefault = []int{56, 72, 104, 68, 96, 130, 40, 56}
)

The sessions table's columns: their titles, the least width each may be dragged to, and the width each starts at, in logical pixels.

View Source
var (
	Themes = []string{"system", "light", "dark"}
	Langs  = []string{"en", "fr"}
)

Themes are the theme selector's choices, in the order of its options; Langs the language selector's, after its "Auto" option. A theme is kept as the word the server stores (model.ParseTheme), a language as its catalog tag.

View Source
var Brand = toolkit.RGB(0x00, 0x79, 0xA8)

Brand is agentscope's accent: the go-authn account page's brand colour.

View Source
var Catalog = toolkit.NewCatalog("en").Add("en", enAll).Add("fr", frAll)

Catalog is every locale of the interface; English answers for a missing key.

View Source
var LastLimits = []time.Duration{0, 10 * time.Minute, time.Hour, 6 * time.Hour, 24 * time.Hour}

LastLimits is the age each LastNames option keeps (0: any).

Functions

func AccountOptions added in v0.8.0

func AccountOptions(u *model.Usage) []string

AccountOptions are the selector's options: All, then every account, the active one marked.

func AllAccounts added in v0.8.0

func AllAccounts() string

AllAccounts is the first option of the account selector: every account, aggregated.

func AllRepos added in v0.9.0

func AllRepos() string

AllRepos is the first option of the repository drop-down, in the language in use.

func CapDPR added in v0.10.1

func CapDPR(cssW, cssH int, dpr float64) float64

CapDPR is the device pixel ratio to draw a cssW by cssH viewport at: dpr, or less when the backing store would exceed MaxBackingPixels. A ratio that is not a positive number, or a viewport with no area, gives 1.

func ClampColW added in v0.9.0

func ClampColW(col, w int) int

ClampColW is w, a column's width, held between that column's least width and a bound that keeps a hostile stored value from making a table of a million pixels. An unknown column keeps w as it is.

func ClampPanelW added in v0.9.0

func ClampPanelW(w, viewW int) int

ClampPanelW is w held between PanelMinW and PanelMaxPercent of viewW (both logical pixels). A surface too narrow for the minimum gets the minimum: the panel never becomes unusable.

func ClampSplit added in v0.10.2

func ClampSplit(v int) int

ClampSplit is a Sessions share held between SplitLo and SplitHi. The panes' minimum heights are applied by the layout, against the height the panel has.

func ColTitles added in v0.9.0

func ColTitles() []string

ColTitles are the sessions table's column titles, in the language in use.

func DecisionNames added in v0.10.0

func DecisionNames() []string

DecisionNames are the filter's options: "All decisions" in the language in use, then the ledger's words.

func GuardTitles added in v0.10.0

func GuardTitles() []string

GuardTitles are the lessons table's column titles, in the language in use; the columns are sortable.

func KindNames added in v0.7.0

func KindNames() []string

KindNames are the token kinds, in the language in use.

func LangNames added in v0.13.0

func LangNames() []string

func LastNames added in v0.9.0

func LastNames() []string

LastNames are the last-activity drop-down's options, in the language in use; LastLimits the age each keeps (0: any), in the same order.

func Palette added in v0.6.0

func Palette(dark bool) []toolkit.RGBA

Palette is the graph's category palette: the Okabe-Ito order, which is safe under the common colour-vision deficiencies, with its lightness tuned to the page: eased toward the Slate ground in light, lifted a little in dark so a pill keeps its contrast against the dark card. The order is what the legend and the colour assignment (by first appearance) rely on, so it is never reordered.

func PressureColor added in v0.9.0

func PressureColor(band int, dark bool) toolkit.RGBA

PressureColor is the colour of a pressure band in the light or the dark theme.

func RepoLabel added in v0.3.0

func RepoLabel(key string, max int) string

RepoLabel is org/repo cut to at most max characters. When it does not fit, the ORG is shortened (with an ellipsis) and the repo is kept whole; only a repo name longer than the room itself is cut.

func SpanNames added in v0.7.0

func SpanNames() []string

SpanNames and KindNames label the selectors.

func StackColors added in v0.7.0

func StackColors(dark bool) []toolkit.RGBA

StackColors are the families' colours, in the order of model.Usage.Families: four of the Okabe-Ito set, which stays apart under colour-vision deficiency.

func StateNames added in v0.9.0

func StateNames() []string

StateNames are the state drop-down's options, indexed by StateAll..., in the language in use.

func T added in v0.13.0

func T(key string) string

T is the text of key in the language in use. It reads the toolkit's global localizer, which the ViewModel points at Catalog whenever the language changes, and answers the English text before any language is chosen.

func Tf added in v0.13.1

func Tf(key string, args ...any) string

Tf is T with fmt verbs filled in; i18ntest.Check keeps every locale's verbs the same as English's, so the arguments fit whichever language is in force.

func ThemeNames added in v0.13.0

func ThemeNames() []string

ThemeNames and LangNames are the selectors' options in the language in use: "Auto" (follow the system, or the browser's languages) first.

func Tokens added in v0.7.0

func Tokens(v float64) string

Tokens writes a token count as "1.2M" or "340k".

Types

type CapRow added in v0.8.0

type CapRow struct {
	Account, Plan, Session, Weekly, Left, Resets, Active string
}

CapRow is one line of the capacity table.

func (CapRow) Cells added in v0.8.0

func (r CapRow) Cells() []string

Cells are the row's cells.

type ColorState added in v0.12.0

type ColorState struct {

	// Open is whether the dialog is up; Pick the picker's colour (bound two ways to
	// the toolkit's ColorPicker); Err why the last attempt failed ("" when it did
	// not); Busy while the server has the request.
	Open *mvvm.Observable[bool]
	Pick *mvvm.Observable[toolkit.RGBA]
	Err  *mvvm.Observable[string]
	Busy *mvvm.Observable[bool]
	// Begin opens the dialog on the selected account; Confirm sends the picked
	// colour; Reset asks for the automatic one back; Cancel closes it. Begin can
	// run only with an account selected.
	Begin, Confirm, Reset, Cancel *mvvm.Command

	// Send asks the server to give account key the colour ("#rrggbb", or "" for
	// the automatic one); the host sets it and it must not block, reporting back
	// through Done.
	Send func(key, color string)
	// contains filtered or unexported fields
}

ColorState is the Colour action of the accounts table: a dialog with the toolkit's colour picker that gives the selected account a colour of its own, as RenameState gives it a name. It holds all of the dialog's state; the Scene only shows it. Nothing is saved until Confirm, and Reset restores the automatic colour. The colour is sent, and stored, as "#rrggbb": the picker's alpha is never kept, a line is always opaque.

func (*ColorState) Done added in v0.12.0

func (c *ColorState) Done(err error)

Done is the server's answer to Send: the dialog closes on success and says why on failure, keeping the colour the owner picked.

type CtxRow added in v0.9.0

type CtxRow struct {
	Name  string
	Text  string  // "212k / 300k"
	Ratio float64 // context / window, 0 when unknown
	Band  int     // model.PressureBand of Ratio
}

CtxRow is one gauge of the Details pane: a session or a sub-agent and how full its context is.

func (CtxRow) Cells added in v0.9.0

func (r CtxRow) Cells() []string

Cells are the row as the Details table shows it; the gauge is drawn under the text of the second cell.

type Feed added in v0.10.1

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

Feed puts snapshots on the screen as sparingly as the owner can see: nothing is applied while the tab is hidden (the latest one is kept and shown once, when it is visible again), and a snapshot that changes nothing the screen shows repaints nothing (the Scene is only dirty when something it draws changed).

func NewFeed added in v0.10.1

func NewFeed(scene *Scene) *Feed

NewFeed feeds scene.

func (*Feed) Hidden added in v0.10.1

func (f *Feed) Hidden() bool

Hidden is whether the feed is paused.

func (*Feed) Offer added in v0.10.1

func (f *Feed) Offer(s model.Snapshot) bool

Offer is a snapshot from the server. It reports whether it was applied now.

func (*Feed) SetHidden added in v0.10.1

func (f *Feed) SetHidden(hidden bool) (applied bool)

SetHidden is the page's visibility changing. Becoming visible applies the snapshot held while it was hidden, and reports whether there was one: the host repaints once, whatever the answer.

type Filters added in v0.9.0

type Filters struct {
	// State is StateAll, StateActive or StateIdle; Last indexes LastLimits.
	State, Last *mvvm.Observable[int]
	// Repo is the repository drop-down's choice: 0 is AllRepos, i the i-th of
	// RepoOptions. It follows its repository by name when the options change.
	Repo        *mvvm.Observable[int]
	RepoOptions *mvvm.ObservableList[string]
	// StateOpts and LastOpts are the State and Last drop-downs' options, in the
	// language in use.
	StateOpts, LastOpts *mvvm.ObservableList[string]
	// ModelLabels and ModelOn are the model check boxes: slot i is the i-th most
	// used model present, "" when there are fewer. None checked is no model
	// filter; checked ones are OR-ed among themselves, AND-ed with the rest.
	ModelLabels [ModelFilterSlots]*mvvm.Observable[string]
	ModelOn     [ModelFilterSlots]*mvvm.Observable[bool]
	// Clear puts every filter back to "all".
	Clear *mvvm.Command
	// contains filtered or unexported fields
}

Filters is what narrows the sessions table: every filter is MVVM state, and they combine with AND (and with the search text).

func (*Filters) Active added in v0.9.0

func (f *Filters) Active() bool

Active reports whether any filter is not "all".

type GuardRow added in v0.10.0

type GuardRow struct {
	Name     string
	Total    int
	Last     string
	Decision string
	Gate     string // truncated text
	After    int
	// AfterInferred of After have a year `recur` inferred.
	AfterInferred int
	Silent        bool
}

GuardRow is one lesson of the table.

func (GuardRow) Cells added in v0.10.0

func (r GuardRow) Cells() []string

Cells are the row as the table shows it.

type GuardState added in v0.10.0

type GuardState struct {
	Data *mvvm.Observable[*model.Guardrails]
	Rows *mvvm.ObservableList[GuardRow]
	// Sel is the selected table row, Detail the pane showing that lesson.
	Sel    *mvvm.Observable[int]
	Detail *mvvm.ObservableList[string]
	// Decision indexes DecisionNames; SortCol and SortAsc order the table.
	Decision *mvvm.Observable[int]
	// DecisionOpts are the decision drop-down's options, in the language in use.
	DecisionOpts *mvvm.ObservableList[string]
	SortCol      *mvvm.Observable[int]
	SortAsc      *mvvm.Observable[bool]
	// Chips are the headline chips; Notes the line under the tab, which says what
	// is not measured.
	Chips [GuardChipSlots]*mvvm.Observable[string]
	Notes *mvvm.Observable[string]
	// contains filtered or unexported fields
}

GuardState is the Guardrails tab's state: the data, the table (filtered by decision and sorted), the selection and what it shows, and the headline chips.

func (*GuardState) SetSort added in v0.10.0

func (g *GuardState) SetSort(col int, asc bool)

SetSort is what a header click does: it orders the table by col.

type PrefsState added in v0.13.0

type PrefsState struct {

	// Manager answers whether the screen is dark: the chosen theme, or the system's
	// preference (SetSystemDark) while the choice is "system".
	Manager *toolkit.ThemeManager
	// ThemeSel is the theme drop-down's index into Themes; LangSel the language
	// drop-down's: 0 is automatic, i the i-th of Langs.
	ThemeSel, LangSel *mvvm.Observable[int]
	// ThemeOpts and LangOpts are those drop-downs' options, in the language in use.
	ThemeOpts, LangOpts *mvvm.ObservableList[string]
	// Lang is the language in force ("en", "fr"): the chosen one, else the best of
	// NavLangs, else English.
	Lang *mvvm.Observable[string]
	// NavLangs are the browser's languages, most wanted first (navigator.languages).
	NavLangs []string
	// Send asks the server to keep the choice (theme "system", "light" or "dark";
	// lang "" for automatic); the host sets it, and it must not block.
	Send func(theme, lang string)
	// contains filtered or unexported fields
}

PrefsState is the viewer's theme and language: the two selectors' choices, the toolkit's ThemeManager that turns a theme choice (and the system's preference) into light or dark, and the language in force. A choice the owner makes is sent to the server through Send; one that comes from the server (a snapshot's Prefs) is applied without being sent back.

func (*PrefsState) Apply added in v0.13.0

func (p *PrefsState) Apply(in model.Prefs)

Apply shows the prefs the server holds. An empty or unknown value is "not chosen" (system, automatic); nothing is sent back.

func (*PrefsState) SetNavLangs added in v0.13.0

func (p *PrefsState) SetNavLangs(langs []string)

SetNavLangs gives the browser's languages and applies the negotiation again.

func (*PrefsState) SetSystemDark added in v0.13.0

func (p *PrefsState) SetSystemDark(dark bool)

SetSystemDark tells the manager what the system prefers (the browser's prefers-color-scheme), now and whenever it changes.

type RenameState added in v0.9.0

type RenameState struct {

	// Open is whether the dialog is up; Text the entry's content; Err why the last
	// attempt failed ("" when it did not); Busy while the server has the request.
	Open *mvvm.Observable[bool]
	Text *mvvm.Observable[string]
	Err  *mvvm.Observable[string]
	Busy *mvvm.Observable[bool]
	// Begin opens the dialog on the selected account; Confirm sends the name;
	// Cancel closes it. Begin can run only with an account selected.
	Begin, Confirm, Cancel *mvvm.Command

	// Send asks the server to rename account key to name; the host sets it and it
	// must not block (the browser's event loop must run for the request to go
	// out), reporting back through Done.
	Send func(key, name string)
	// contains filtered or unexported fields
}

RenameState is the Rename action of the accounts table: a dialog that gives the selected account a display name. It holds all of the dialog's state; the Scene only shows it. Nothing is saved until Confirm: a suggestion (the organisation's name, when the server was started with --show-org) is only the text the entry starts with.

func (*RenameState) Done added in v0.9.0

func (r *RenameState) Done(err error)

Done is the server's answer to Send: the dialog closes on success and says why on failure, keeping what the owner typed.

type Row

type Row struct {
	ID    string // session short id
	State string
	Repo  string
	Task  string
	Last  string
	Agent string // sub-agent count
	Model string // short family name ("Opus 5.5"), or "?" when unknown or unseen
	// CtxText is "212k / 300k", Ratio the context over the compaction window, and
	// Band its pressure band (model.PressureBand): what the Context column's
	// gauge draws.
	CtxText string
	Ratio   float64
	Band    int
	// Repos is every repository the session holds or sits in, one per line: what
	// the Repository filter matches (a session can hold several). Active and Age
	// are what the State and Last-activity filters read.
	Repos  string
	Active bool
	Age    time.Duration
}

Row is one line of the sessions table.

func (Row) Cells

func (r Row) Cells() []string

Cells is the row as the table shows it.

func (Row) Text

func (r Row) Text() string

Text is the row's whole text, which is what the query is matched against.

type Scene

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

Scene is the View: the widgets, their layout, and the bindings to the ViewModel. It never assigns a widget's state field itself, and draws nothing by hand: every surface is a toolkit widget (Frame cards, Chips, the graph, the charts, the side panel in a toolkit Overlay).

func NewScene

func NewScene(w, h int) *Scene

NewScene builds the View over a fresh ViewModel, at 1x.

func (*Scene) Cursor added in v0.9.0

func (s *Scene) Cursor(x, y int) string

Cursor is the CSS cursor the pointer at surface (x, y) should show: a horizontal resize over the panel's divider and while it is held, "" (the host's default) elsewhere.

func (*Scene) Dirty

func (s *Scene) Dirty() bool

Dirty reports, and clears, the repaint-needed flag.

func (*Scene) Draw

func (s *Scene) Draw(buf []byte)

Draw paints the scene onto buf, an RGBA row-major slice of w*h pixels.

func (*Scene) HandleChar

func (s *Scene) HandleChar(ch string) bool

HandleChar routes a printable character to the focused widget; "t" outside the search box toggles the side panel.

func (*Scene) HandleClick

func (s *Scene) HandleClick(x, y int) bool

HandleClick dispatches a click at surface (x, y) to the widget under it. A click on the open panel never reaches the graph beneath it.

func (*Scene) HandleKeyDown

func (s *Scene) HandleKeyDown(code string) bool

HandleKeyDown routes a named key to the focused widget.

func (*Scene) HandleMove

func (s *Scene) HandleMove(x, y int) bool

HandleMove routes pointer motion to the widget grabbed on press; with nothing grabbed it tracks the pointer over the panel's divider (which lights up). It reports whether the picture changed.

func (*Scene) HandleRelease

func (s *Scene) HandleRelease(x, y int) bool

HandleRelease routes a button release to the grabbed widget and drops it.

func (*Scene) HandleScroll

func (s *Scene) HandleScroll(x, y, delta int) bool

HandleScroll routes a wheel scroll (Delta in rows, positive = down) to the scrollable under the pointer.

func (*Scene) PanelVisible added in v0.7.0

func (s *Scene) PanelVisible() bool

PanelVisible is whether the side panel is on screen: open, over the graph.

func (*Scene) Resize added in v0.7.0

func (s *Scene) Resize(w, h int, scale float64)

Resize makes the scene w by h device pixels at the given device pixel ratio and lays it out again: the graph takes every pixel the header and the tabs do not, and its clusters flow into as many columns as the width holds. A resize may re-lay-out the graph; an edge update never does.

func (*Scene) SetStore added in v0.9.0

func (s *Scene) SetStore(st Store)

SetStore restores the viewer's layout from st and keeps it there as it changes. What is stored is untrusted (another page of the same origin could have written it): it is parsed strictly and clamped, and anything else is ignored.

func (*Scene) Size added in v0.7.0

func (s *Scene) Size() (w, h int)

Size is the scene's size in device pixels.

func (*Scene) VM

func (s *Scene) VM() *ViewModel

VM is the ViewModel the host feeds snapshots to.

type Store added in v0.9.0

type Store interface {
	Get(key string) (value string, ok bool)
	Set(key, value string)
}

Store is where a viewer's layout is kept between visits: the browser's localStorage, through the host. A host whose storage is unavailable passes none, or one that does nothing: the layout is then the default each time.

type ViewModel

type ViewModel struct {
	// Graph is what the GraphView shows; its Selected and Filter are the
	// widget's own observables.
	Graph *toolkit.GraphViewModel
	// Query is the search entry's text. It dims the graph (Graph.Filter) and
	// narrows the table.
	Query *mvvm.Observable[string]
	// Rows is the sessions table; TableSel is its selected row index.
	Rows     *mvvm.ObservableList[Row]
	TableSel *mvvm.Observable[int]
	// Detail is the detail pane: the selection's facts, or the anomalies when
	// nothing is selected.
	Detail *mvvm.ObservableList[string]
	// Status is the one-line summary; Conn is the connection state.
	Status *mvvm.Observable[string]
	Conn   *mvvm.Observable[string]
	// ShowExpired draws the edges to a selected session's expired leases
	// (hidden by default: the detail pane lists them). Expanded is the orgs of
	// the "other repositories" cluster that are open.
	ShowExpired *mvvm.Observable[bool]
	Expanded    *mvvm.ObservableList[string]
	// Dark is the system's colour-scheme preference, set by the host (a
	// browser's prefers-color-scheme) and followed when it changes.
	Dark *mvvm.Observable[bool]
	// ModelChips are the header's model-count chips: the three most used model
	// families ("Sonnet 29"), "" for a slot with none.
	ModelChips [ModelChipSlots]*mvvm.Observable[string]

	// Guard is the Guardrails tab's state (see guardrails.go).
	Guard *GuardState
	// Tab is the shown tab: TabGraph, TabQuota or TabGuardrails.
	Tab *mvvm.Observable[int]
	// PanelOpen is whether the side panel (the sessions table and the details)
	// is open over the graph; it starts closed, TogglePanel flips it, and
	// selecting a node opens it.
	PanelOpen   *mvvm.Observable[bool]
	TogglePanel *mvvm.Command
	// Span is the Quota tab's span (SpanShort, SpanWeek, SpanWeeks) and Kind the
	// token kind its 4 x 7 days charts show.
	Span, Kind *mvvm.Observable[int]
	// Usage is the Quota tab's data, from the last snapshot.
	Usage *mvvm.Observable[*model.Usage]
	// QuotaNotes is the line under the Quota charts: what is not available, what
	// is not recorded, where the reset came from.
	QuotaNotes *mvvm.Observable[string]
	// Account is the account selector's choice: 0 is AllAccounts, i is the i-th
	// account of the usage. AccountOptions are its options and Capacity the
	// capacity table's rows, both rebuilt when the usage changes; the selection
	// follows its account (by key) across a rebuild.
	Account        *mvvm.Observable[int]
	AccountOptions *mvvm.ObservableList[string]
	Capacity       *mvvm.ObservableList[CapRow]

	// Filters narrow the sessions table (AND, with the query).
	Filters *Filters
	// Contexts are the Details pane's gauges: the selected session and each of its
	// sub-agents, or the selected sub-agent.
	Contexts *mvvm.ObservableList[CtxRow]
	// ViewW is the surface's width in logical pixels (set by the Scene), PanelW the
	// side panel's, kept between PanelMinW and PanelMaxPercent of it; ColW the
	// sessions table's column widths. All three are persisted per viewer (SetStore).
	ViewW, PanelW *mvvm.Observable[int]
	ColW          *mvvm.ObservableList[int]
	// Split is the Sessions pane's share, in thousandths, of the Sessions and Details
	// panes stacked in the side panel (see vsplit.go); persisted per viewer too.
	Split *mvvm.Observable[int]

	// The Rename action of the accounts table: CapSel is the selected row, and
	// Rename the dialog's state (see rename.go).
	CapSel *mvvm.Observable[int]
	Rename *RenameState
	// Color is the Colour action of the same table: the dialog that gives the
	// selected account a colour of its own (see colorstate.go).
	Color *ColorState
	// Prefs is the viewer's theme and language (see prefs.go): Dark below follows
	// it, and so does every text the screen shows.
	Prefs *PrefsState
	// contains filtered or unexported fields
}

ViewModel is the whole screen's state.

func NewViewModel

func NewViewModel() *ViewModel

NewViewModel returns a ViewModel showing nothing yet.

func (*ViewModel) Apply

func (vm *ViewModel) Apply(s model.Snapshot)

Apply shows a snapshot. A list is replaced only when it differs, so a graph whose members did not change does not lay itself out again.

func (*ViewModel) CollapseAll added in v0.4.0

func (vm *ViewModel) CollapseAll()

CollapseAll folds every org again (Escape).

func (*ViewModel) EffectivePanelW added in v0.9.0

func (vm *ViewModel) EffectivePanelW() int

EffectivePanelW is the width the panel is shown at: the chosen PanelW held to the bounds of the surface as it is now.

func (*ViewModel) SetColWidth added in v0.9.0

func (vm *ViewModel) SetColWidth(col, w int)

SetColWidth is the owner dragging column col to w logical pixels: the width is held at the column's minimum and recorded; a column that does not exist is ignored.

func (*ViewModel) SetConn added in v0.13.0

func (vm *ViewModel) SetConn(key, detail string)

SetConn shows the connection state: key is one of "connecting", "connected", "dial", "lost" or "ended" (the catalog's conn.<key>), detail what went wrong, if anything. It is kept, so a change of language says it again in the new one.

func (*ViewModel) Snapshot

func (vm *ViewModel) Snapshot() (model.Snapshot, bool)

Snapshot is the last snapshot applied.

func (*ViewModel) ToggleOrg added in v0.4.0

func (vm *ViewModel) ToggleOrg(selection string)

ToggleOrg expands or collapses an org of the "other repositories" cluster: what activating (Enter, a second click on) its node does. selection is the graph's Selected value; anything that is not an org node is ignored.

Jump to

Keyboard shortcuts

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