ui

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: BSD-3-Clause Imports: 9 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 (
	// 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 (
	SurfaceW = 1680
	SurfaceH = 940
)

Surface is the canvas size. Fixed: the graph, the table and the detail pane each sit in a fixed box and scroll or clip inside it.

Variables

This section is empty.

Functions

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.

Types

type Row

type Row struct {
	ID    string // session short id
	State string
	Repo  string
	Task  string
	Last  string
	Agent string // sub-agent count
}

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.

func NewScene

func NewScene(w, h int) *Scene

NewScene builds the View over a fresh ViewModel.

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.

func (*Scene) HandleClick

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

HandleClick dispatches a click at surface (x, y) to the widget under 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.

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).

func (*Scene) VM

func (s *Scene) VM() *ViewModel

VM is the ViewModel the host feeds snapshots to.

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]
	// 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) Snapshot

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

Snapshot is the last snapshot applied.

Jump to

Keyboard shortcuts

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