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 ¶
- type Doc
- func (d *Doc) Bool(path string) bool
- func (d *Doc) Build(c *ui.Context)
- func (d *Doc) Dirty() bool
- func (d *Doc) Discard()
- func (d *Doc) Get(path string) string
- func (d *Doc) Load()
- func (d *Doc) Raw() client.Obj
- func (d *Doc) Save(done func(bool))
- func (d *Doc) Set(path, value string)
- func (s *Doc) St() *status
- type Field
- type Group
- type Kind
- type Opt
- type Settings
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) Get ¶
Get returns the current text value of a field path (for Enabled hooks). A KSelect holds its stored value, never its label.
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
// Plain shows a KModel as a plain text input while it returns true.
Plain func(d *Doc) bool
// Picked runs when a KModel suggestion is chosen.
Picked func(d *Doc, m client.Model)
// Control replaces the editor of a field: it edits *value (text kinds),
// or draws an action (KStatic rows, which are never saved).
Control func(c *ui.Context, d *Doc, value *string, w float32) ui.Element
// Extra draws content below the row, across the whole width.
Extra func(c *ui.Context, d *Doc)
}
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 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 KModel // model id with autosuggest over GET /api/v1/models )
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 (*Settings) ConfirmLeave ¶
ConfirmLeave implements app.LeaveGuard: leaving the area with unsaved edits asks first.