settingsapi

package
v0.1.4630 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: MIT Imports: 11 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 settingsapi is what the Settings page's save writes: the fields POST /api/settings takes from the page, how a value is checked, and the save itself. The window's handler and `magpie settings` both save through Apply, so a value the CLI sets is checked and kept exactly as one the page sets (#4745).

Index

Constants

This section is empty.

Variables

View Source
var Choices = map[string][]string{
	"theme":           settings.Themes,
	"lang":            settings.Langs,
	"tray":            settings.Trays,
	"currency":        settings.Currencies,
	"totalCurrency":   settings.TotalCurrencies,
	"trayCurrency":    settings.TotalCurrencies,
	"codexWarmup":     {"off", "week", "all"},
	"claudeWarmup":    {"off", "week", "all"},
	"trayUsageEvery":  ints(settings.TrayEvery),
	"dayStart":        {"0", "1", "2", "3", "4", "5", "6"},
	"updateChannel":   {settings.UpdateStable, settings.UpdateDaily},
	"updateSource":    {settings.UpdateSourceSite, settings.UpdateSourceGitHub},
	"updateEvery":     ints(settings.UpdateEveries),
	"searchFirst":     {settings.SearchFirstModel, settings.SearchFirstAPI},
	"replyModel":      settings.ReplyModels,
	"imageResolution": {"1K", "2K", "4K"},
}

Choices are the values a setting with a closed set takes, for `magpie settings list` to name: settings' own lists, which settings.Save checks a saved value against (a value outside them is refused there, from the window as from the CLI). A setting's "" is its default.

View Source
var Keys = []string{

	"theme", "accent", "colorblind", "reduceMotion", "noBird", "lang", "uiFont", "codeFont",

	"tray", "dock", "dockWindow", "dockNever", "lightweight", "keepAwake", "keepAwakeDisplay",
	"noWSLAgents", "sessionTerminal", "signInLinkOnly", "quitNoAsk", "restoreOnQuit", "name",

	"trayUsages", "trayUsage", "trayUsageEvery", "trayNoLogos", "trayAnthropicMark", "trayNoBird", "trayNoNumber", "trayPace", "trayNoCost", "trayWindows",

	"currency", "totalCurrency", "trayCurrency", "chineseUnits", "dayStart", "usageAlert", "balanceAlert", "resetReminder", "turnDoneAlert", "maskAlert",

	"proxy", "pluginProxy", "updateProxy", "updateSource",

	"redact", "redactPersonal", "redactKinds", "redactWords", "redactWordsAnyCase", "redactWordsWhole", "redactShape",
	"noStats", "noUsageStats", "otel",

	"codexWarmup", "claudeWarmup", "codexWarmAt", "claudeWarmAt", "codexWarmAts", "claudeWarmAts",
	"workbuddyCheckin", "traeCheckin", "minimaxCheckin", "qoderCheckin", "checkinAt",

	"replyModel", "noLoopGuard", "claudeLeanPrompt", "claudeNoExtraUsage", "claudeRegionHold", "claudePrintMode", "refusalRetries", "retryAfterCap",
	"vision", "visionEffort", "imageGen", "videoGen", "imageTimeout", "imageResolution", "classifyTimeout",

	"groupSink", "groupFirstToken", "groupPatience",
	"searcher", "searcherThen", "searcherEffort", "searchFirst",

	"noUpdatePill", "noAutoUpdate", "updateEvery", "noAutoDownload", "autoRestart", "updateChannel",
}

Keys are the settings POST /api/settings saves from what it is sent, by their JSON names, in the order `magpie settings list` shows them. Every other field of settings.Settings is carried from the file (Merge), set by a route of its own or kept by settings.Save. TestKeysAreWhatTheSaveWrites fails when a field the save writes is missing here, or one here isn't written.

Functions

func Apply

func Apply(body []byte, web bool) (in, cur settings.Settings, err error)

Apply is POST /api/settings: body read over the settings saved now (Merge), checked and saved. It returns what was saved and what was there before, for the caller's reactions to a change (the window's Dock, fonts, tray menu and alerts). web is a page served to a browser, whose fonts are another computer's and never saved.

func Body

func Body(cur settings.Settings, key string, value json.RawMessage) ([]byte, error)

Body is what the Settings page sends to set key to value (its JSON) and leave everything else as cur has it: cur whole, with key sent even when it is a zero value, which a field omitted would not be (an omitted noBird is "keep", false is "show the bird").

func Field

func Field(key string) (reflect.StructField, bool)

Field is the struct field of settings.Settings saved under the JSON name key, and whether there is one.

func Known

func Known(key string) bool

Known says whether key is one Apply saves.

func Merge

func Merge(body []byte, cur settings.Settings, web bool) (settings.Settings, error)

Merge is the settings body sets over cur: the page's own choices from body, and everything else as cur has it. It writes nothing.

func Value

func Value(s settings.Settings, key string) (any, bool)

Value is key's value in s, as it is saved.

Types

This section is empty.

Jump to

Keyboard shortcuts

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