Documentation
¶
Overview ¶
Package configweb is a page in the browser for editing config.toml: every setting the TUI's Settings screen has, and the ones it only names (actions, permission rules, check commands), as a form.
It listens on 127.0.0.1 only, and the API answers only a request that carries the token handed out with the address — in the URL's fragment, which a browser never sends anywhere — in a header of its own. A page on another site can reach 127.0.0.1 but cannot read the fragment, and cannot set the header without a preflight this server never grants; the Host check stops a name that resolves to 127.0.0.1 being used to the same end. Anything else running as you could edit config.toml anyway.
Index ¶
Constants ¶
const ( KindBool = "bool" KindString = "string" KindSecret = "secret" // a string shown as dots until asked for KindText = "text" // a string of several lines, or a long command KindInt = "int" KindFloat = "float" KindSelect = "select" // one of Options; "" is allowed when Options has it KindList = "list" // a list of strings KindInts = "ints" // a list of integers KindMap = "map" // string keys to string values KindTables = "tables" // an array of tables, each with Fields KindKeyed = "keyed" // tables keyed by name, each with Fields KindTable = "table" // one nested table, [trackers.linear], with Fields )
Kinds of field.
const TokenHeader = "X-Conch-Token"
TokenHeader carries the token on every API request.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Choices ¶
type Choices struct {
// Cloud is whether Conch Cloud is enabled (config.CloudEnabled), which
// the server works out from the file it reads: while it is not, its
// section offers only the switch.
Cloud bool
Themes []Option
// LightThemes are the ones drawn on a light background, which is all
// light_theme offers: it is the theme for macOS's light appearance,
// and a dark one there turned the window dark as the system went light.
LightThemes []Option
Accents []string
Agents []Option
// Providers are the sandbox providers this build knows, offered as
// tables to add; a table for one it does not is kept and shown too.
Providers []string
// ZshThemes are the Oh My Zsh themes installed here, offered for
// [shell] omz_theme; any other name can still be typed.
ZshThemes []string
// Scenes are the scene files of your own ($CONCH_HOME/scenes), offered
// for [app] background after the built-in ones.
Scenes []string
}
Choices are what the select fields offer that only the caller knows: the TUI's themes, the agents this build has.
type Field ¶
type Field struct {
Key string `json:"key"` // within its section's table
Label string `json:"label"`
Help string `json:"help,omitempty"`
Kind string `json:"kind"`
Options []Option `json:"options,omitempty"`
Placeholder string `json:"placeholder,omitempty"`
// Default is what an absent key means, for a field that may be left
// out (a pointer in config.Config): the page shows it, and writes the
// key only once it is changed.
Default any `json:"default,omitempty"`
Min *int `json:"min,omitempty"`
Max *int `json:"max,omitempty"`
Fields []Field `json:"fields,omitempty"` // for tables and keyed
// KeyLabel names the key of a keyed or map entry ("Provider", "Project").
KeyLabel string `json:"keyLabel,omitempty"`
Suggest []string `json:"suggest,omitempty"` // names a keyed field offers to add, or a string field offers to pick
}
Field is one setting.
type Payload ¶
type Payload struct {
// Config is config.toml as TOML reads it, defaults filled in: tables
// by their keys, so the page and the file use the same names.
Config map[string]any `json:"config"`
Raw string `json:"raw"` // the file as it is
Version string `json:"version"` // what the file was when read; a save names it
Path string `json:"path"`
Exists bool `json:"exists"`
Schema []Section `json:"schema"`
Problems []string `json:"problems,omitempty"` // what conch will not use as written
}
Payload is what the page is given, and what a save answers with.
type Running ¶
type Running struct {
URL string
// contains filtered or unexported fields
}
Running is a server listening.
type Section ¶
type Section struct {
ID string `json:"id"`
Key string `json:"key"` // the table; "" for the top level
Title string `json:"title"`
Description string `json:"description"`
Icon string `json:"icon"` // a lucide icon name the page knows
Fields []Field `json:"fields"`
}
Section is one table of config.toml — [ui], [notify] — or, for Key "", the top level, where the arrays of tables are.
type Server ¶
type Server struct {
Choices Choices
OnSave func(config.Config)
// contains filtered or unexported fields
}
Server is the editor. OnSave, when set, is told about every saved configuration — the TUI takes it at once rather than writing its own older copy over it the next time it saves.