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
- Variables
- func Palette(dark bool) []toolkit.RGBA
- func RepoLabel(key string, max int) string
- type Row
- type Scene
- func (s *Scene) Dirty() bool
- func (s *Scene) Draw(buf []byte)
- func (s *Scene) HandleChar(ch string) bool
- func (s *Scene) HandleClick(x, y int) bool
- func (s *Scene) HandleKeyDown(code string) bool
- func (s *Scene) HandleMove(x, y int) bool
- func (s *Scene) HandleRelease(x, y int) bool
- func (s *Scene) HandleScroll(x, y, delta int) bool
- func (s *Scene) VM() *ViewModel
- type ViewModel
Constants ¶
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.
const ( SurfaceW = 1680 SurfaceH = 940 )
Surface is the canvas size. Fixed: the graph, the table and the detail pane each sit in a fixed card and scroll or clip inside it.
const ModelChipSlots = 3
ModelChipSlots is how many model families the header shows chips for.
Variables ¶
var Brand = toolkit.RGB(0x00, 0x79, 0xA8)
Brand is agentscope's accent: the go-authn account page's brand colour.
Functions ¶
func Palette ¶ added in v0.6.0
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.
Types ¶
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
}
Row is one line of the sessions table.
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).
func (*Scene) HandleChar ¶
HandleChar routes a printable character to the focused widget.
func (*Scene) HandleClick ¶
HandleClick dispatches a click at surface (x, y) to the widget under it.
func (*Scene) HandleKeyDown ¶
HandleKeyDown routes a named key to the focused widget.
func (*Scene) HandleMove ¶
HandleMove routes pointer motion to the widget grabbed on press.
func (*Scene) HandleRelease ¶
HandleRelease routes a button release to the grabbed widget and drops it.
func (*Scene) HandleScroll ¶
HandleScroll routes a wheel scroll (Delta in rows, positive = down).
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]
// 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 ¶
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).