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

settings

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package settings is the settings area of the native desktop: the 23 categories of the Web UI settings (web-ui/src/components/settings), their unsaved-changes guard and the "?section=" deep link. Plain config documents are data driven (form.go, specs.go); sections with their own UI (providers, MCP servers, LSP, skills, ...) live in their own files.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Doc

type Doc struct {
	Endpoint string
	// Sub is the dotted path of the edited object inside the response ("" =
	// the root, "config" for sandbox, "snapshots" for the services doc).
	Sub string
	// PutWhole sends the whole response with Sub replaced (services,
	// settings); otherwise only the Sub object is sent.
	PutWhole bool
	Groups   []Group
	// Head draws content before the groups; Tail after them.
	Head, Tail func(c *ui.Context, d *Doc)
	// Loaded runs after every (re)seed with the root document.
	Loaded func(d *Doc, root client.Obj)
	// Skip lists keys never sent back (UI-only values).
	Skip []string
	// SavedMsg is the success toast (default "Settings saved").
	SavedMsg string
	// contains filtered or unexported fields
}

Doc edits a JSON config document through GET / PUT of one endpoint, exactly as the Web UI stores do: unknown keys survive the round trip.

func (*Doc) Bool

func (d *Doc) Bool(path string) bool

Bool returns the current switch state of a field path.

func (*Doc) Build

func (d *Doc) Build(c *ui.Context)

Build draws the document.

func (*Doc) Dirty

func (d *Doc) Dirty() bool

Dirty reports edits not saved yet.

func (*Doc) Discard

func (d *Doc) Discard()

Discard drops the edits.

func (*Doc) Get

func (d *Doc) Get(path string) string

Get returns the current text value of a field path (for Enabled hooks).

func (*Doc) Load

func (d *Doc) Load()

Load fetches the document.

func (*Doc) Raw

func (d *Doc) Raw() client.Obj

Raw returns the last document from the server (root).

func (*Doc) Save

func (d *Doc) Save(done func(bool))

Save PUTs the document and reseeds from the answer.

func (*Doc) St

func (s *Doc) St() *status

St returns the state (part of the section interface).

type Field

type Field struct {
	Path  string // dotted path in the document ("server.port")
	Label string
	Desc  string
	Kind  Kind
	Opts  []Opt
	// Inverse stores !value (a "disabled" flag shown as an "enabled" switch).
	Inverse bool
	// Empty is the option whose value is stored as "" (KSelect).
	Empty string
	// Zero is the displayed text of an absent KInt/KFloat.
	Placeholder string
	// Enabled / Visible are evaluated against the current edits.
	Enabled, Visible func(d *Doc) bool
	// After runs when the value changed in the UI (coupled fields).
	After func(d *Doc)
	// Width of the control in DIPs (default 240).
	Width float32
}

Field describes one editable value of a JSON document. Label and Desc are i18n keys of the Web UI catalogs or literals (a.T returns an unknown key unchanged).

type Group

type Group struct {
	Title, Desc string
	Fields      []Field
}

Group is a titled card of fields.

type Kind

type Kind int

Kind is the editor of a Field.

const (
	KBool   Kind = iota // switch
	KText               // single-line text
	KInt                // whole number (text input, validated on save)
	KFloat              // decimal number
	KSelect             // drop-down over Opts
	KList               // list of strings (chips)
	KSecret             // password input
	KStatic             // read-only text
	KSlider             // 0..1 slider
)

Field kinds.

type Opt

type Opt struct{ V, L string }

Opt is an option of a KSelect: the stored value and its label (an i18n key or a literal).

type Settings

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

Settings is the area's state (UI thread only).

func New

func New(a *app.Context) *Settings

New returns the settings view.

func (*Settings) Build

func (s *Settings) Build(c *ui.Context, r *ui.Route)

Build draws the nav and the open category.

func (*Settings) ConfirmLeave

func (s *Settings) ConfirmLeave(proceed func()) bool

ConfirmLeave implements app.LeaveGuard: leaving the area with unsaved edits asks first.

func (*Settings) Select

func (s *Settings) Select(id string)

Select switches to a category, asking first when edits are unsaved.

func (*Settings) Title

func (s *Settings) Title() string

Title is the header title: the open category.

Jump to

Keyboard shortcuts

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