settings

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2026 License: MIT Imports: 40 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 settings stores the user's preferences in the prefs table and serves them to the UI.

Each preference is a typed key with a default, so a fresh database already has a complete set of settings. Setters validate their value before storing it and reject anything unknown with a sentinel error. Settings writes every key it declares, and the keys the trust, snooze, sensitive, notifyprefs, branchrules, reporules, integrationprefs, threadrules, and statusprefs packages declare and decode; see the prefs package for which package writes the others.

Index

Constants

View Source
const (
	KeyRefreshInbox         = "refresh.inbox"
	KeyRefreshChecks        = "refresh.checks"
	KeyRefreshReleaseChecks = "refresh.releaseChecks"
	KeyRefreshWorktrees     = "refresh.worktrees"
	KeyRefreshNotifications = "refresh.notifications"
	KeyRefreshServiceStatus = "refresh.serviceStatus"
)

The keys the refresh intervals are stored under, in seconds.

View Source
const (
	DefaultRefreshInbox         = 300
	DefaultRefreshChecks        = 45
	DefaultRefreshReleaseChecks = 45
	DefaultRefreshWorktrees     = 300
	DefaultRefreshNotifications = 300
	DefaultRefreshServiceStatus = 1800
)

The default refresh intervals, in seconds.

View Source
const (
	// KeyDefaultAgent is the coding agent launches use when no launch default names one.
	KeyDefaultAgent = "agent.default"

	// KeyWorktreeDefault is whether launches start in a worktree unless unticked.
	KeyWorktreeDefault = "launch.worktree"

	// KeyWorktreeAutoCleanup is whether a worktree is cleaned up on its own once its pull
	// request merges or its issue closes (see the worktrees package for what is checked).
	KeyWorktreeAutoCleanup = "worktrees.autoCleanup"

	// KeyTerminal is the terminal app launches open in.
	KeyTerminal = "launch.terminal"

	// KeyFollowSessions is whether the app follows the agent sessions it launches.
	KeyFollowSessions = "launch.followSessions"

	// KeyCodexEffort is whether a Codex launch passes the effort level it resolves to,
	// which Codex takes only as a config override.
	KeyCodexEffort = "agent.codex.effort"

	// KeyCodexFast is whether Codex launches start in Fast mode unless unticked.
	KeyCodexFast = "agent.codex.fast"

	// KeyCloneRoot is the directory whose children are the user's local clones, and the
	// one new clones go in. The other locations are under KeyCloneLocations.
	KeyCloneRoot = "clones.root"

	// KeyTrustedBots lists the bots whose items are trusted (see the trust package).
	KeyTrustedBots = trust.PrefBots

	// KeySnoozeDays is how many days an inbox row's Snooze button hides an item. The
	// wake rules are stored under the other snooze.* keys (see the snooze package).
	KeySnoozeDays = snooze.PrefDays
)

Preference keys.

View Source
const (
	// TerminalITerm2 opens launches in a new iTerm2 tab or window.
	TerminalITerm2 = terminal.ITerm2

	// TerminalApp opens launches in a new Terminal.app window.
	TerminalApp = terminal.TerminalApp
)

Terminal choices: the IDs of the terminal drivers.

View Source
const (
	DefaultAgent           = agent.Claude
	DefaultProfile         = profiles.DefaultName
	DefaultWorktreeDefault = true
	DefaultAutoCleanup     = true
	DefaultTerminal        = TerminalITerm2
	DefaultCloneRoot       = "~/projects"
	DefaultFollowSessions  = true
)

Defaults for a fresh database.

View Source
const (
	MinToastSeconds     = 5
	MaxToastSeconds     = 60
	DefaultToastSeconds = 12
)

The lengths a toast can be set to stay, in seconds, and the length of a fresh database. The frontend keeps the same three (frontend/src/components/Toast.tsx), and a test holds the two in step.

View Source
const (
	DefaultWindowWidth  = 1440
	DefaultWindowHeight = 900
	MinWindowWidth      = 800
	MinWindowHeight     = 520
	MaxWindowWidth      = 7680
	MaxWindowHeight     = 4320
)

Window sizes, in points. A fresh database opens the window at the default size; the minimum is the smallest the window can be resized to at the default text size, and grows with a larger one (MinWindowSizeFor).

View Source
const DefaultConversationOrder = ConversationOldest

DefaultConversationOrder is the order of a fresh database: oldest first, as GitHub lists a conversation.

View Source
const DefaultMenuBar = true

DefaultMenuBar is the menu bar setting of a fresh database.

View Source
const DefaultMergeMethod = MergeMethodRepo

DefaultMergeMethod is the merge method of a fresh database.

View Source
const DefaultNotificationsTab = NotificationsTabApp

DefaultNotificationsTab is the tab a fresh database opens the Notifications page on.

View Source
const DefaultReviewTab = ReviewTabFiles

DefaultReviewTab is the tab a fresh database opens the review sheet on.

View Source
const DefaultTextSize = TextSizeDefault

DefaultTextSize is the text size of a fresh database.

View Source
const DefaultTheme = ThemeSystem

DefaultTheme is the theme of a fresh database.

View Source
const KeyCloneLocations = "clones.locations"

KeyCloneLocations is the user's other repository locations, beside the clone root: a JSON list of {path, kind}, each path with ~ for home, in the order they were added.

View Source
const KeyConversationOrder = "ui.conversationOrder"

KeyConversationOrder is the order the sheets list a conversation in, the one the user last chose, stored as one of the ConversationOrder choices: the window's memory, which a backup never holds.

View Source
const KeyMenuBar = "ui.menuBar"

KeyMenuBar is whether the app shows its icon, with how many items need the user, in the menu bar; closing the window then keeps the app running there.

View Source
const KeyMergeMethod = "review.mergeMethod"

KeyMergeMethod is how the review sheet merges a pull request, stored as one of the MergeMethod choices.

View Source
const KeyNotificationsTab = "ui.notificationsTab"

KeyNotificationsTab is the Notifications page's tab the user last chose, stored as one of the NotificationsTab choices: the window's memory, which a backup never holds.

View Source
const KeyProjectsTipDismissed = "ui.projectsTipDismissed"

KeyProjectsTipDismissed is whether the user put away the inbox's tip about showing the GitHub projects an issue is in, which the inbox offers while the token lacks the read:project scope.

View Source
const KeyReviewTab = "ui.reviewTab"

KeyReviewTab is the review sheet's tab the user last chose, stored as one of the ReviewTab choices: the window's memory, which a backup never holds.

View Source
const KeyStatusOrder = "ui.statusOrder"

KeyStatusOrder is the order the user put project statuses in, such as "In progress" before "Blocked", as a JSON array of their names. A list sorted by status ranks each issue by the first of its projects' statuses here. Statuses not in it are placed by the window, which knows them from the inbox; an empty order leaves every one to it.

View Source
const KeyTextSize = "ui.textSize"

KeyTextSize is the size of the app's text, stored as TextSizeDefault, TextSizeLarge, or TextSizeLarger.

View Source
const KeyTheme = "ui.theme"

KeyTheme is the theme the app shows, stored as ThemeSystem, ThemeLight, or ThemeDark.

View Source
const KeyToastSeconds = "ui.toastSeconds"

KeyToastSeconds is how long, in seconds, a message at the bottom of the window (a toast, such as "Dismissed" with its Undo) stays before it closes itself.

View Source
const KeyWindowSize = "window.size"

KeyWindowSize is the size the window opens at, stored as "<width>x<height>".

Variables

View Source
var (
	// ErrInvalidTerminal is returned for a terminal that is not one of the choices.
	ErrInvalidTerminal = errors.New("unknown terminal")

	// ErrUnknownProfile is returned when a default profile names no stored profile.
	ErrUnknownProfile = errors.New("unknown profile")

	// ErrUnknownAgent is returned for a default agent this build does not know.
	ErrUnknownAgent = errors.New("unknown coding agent")

	// ErrInvalidCloneRoot is returned for a clone root that is not an existing directory.
	ErrInvalidCloneRoot = errors.New("invalid clone root")
)
View Source
var ErrInvalidCloneLocation = errors.New("invalid repository location")

ErrInvalidCloneLocation is returned for a repository location that can't be added: a path that isn't one, a folder that doesn't exist or can't be a location, or one the locations already cover.

View Source
var ErrInvalidConversationOrder = errors.New("unknown conversation order")

ErrInvalidConversationOrder is returned for a conversation order that is not one of the choices.

View Source
var ErrInvalidListKind = errors.New("unknown kind of item")

ErrInvalidListKind is returned for a kind that is not one a list can show.

View Source
var ErrInvalidMergeMethod = errors.New("unknown merge method")

ErrInvalidMergeMethod is returned for a merge method that is not one of the choices.

View Source
var ErrInvalidNotificationsTab = errors.New("unknown notifications tab")

ErrInvalidNotificationsTab is returned for a Notifications page tab that is not one of the choices.

View Source
var ErrInvalidRefresh = errors.New("unknown refresh interval")

ErrInvalidRefresh is returned for a refresh kind, or an interval, that isn't one of the choices.

View Source
var ErrInvalidReviewTab = errors.New("unknown review sheet tab")

ErrInvalidReviewTab is returned for a review sheet tab that is not one of the choices.

View Source
var ErrInvalidStatusOrder = errors.New("invalid status order")

ErrInvalidStatusOrder is returned for a status order that is too long, or holds a name that is.

View Source
var ErrInvalidTextSize = errors.New("unknown text size")

ErrInvalidTextSize is returned for a text size that is not one of the choices.

View Source
var ErrInvalidTheme = errors.New("unknown theme")

ErrInvalidTheme is returned for a theme that is not one of the choices.

View Source
var ErrInvalidToastSeconds = errors.New("unknown toast length")

ErrInvalidToastSeconds is returned for a toast length outside MinToastSeconds to MaxToastSeconds.

View Source
var ErrInvalidToolPath = errors.New("invalid tool path")

ErrInvalidToolPath is returned for a chosen copy of a tool that is not an executable file.

View Source
var ErrInvalidWindowSize = errors.New("invalid window size")

ErrInvalidWindowSize is returned for a window size outside the bounds.

View Source
var ErrUnknownSection = errors.New("unknown inbox section")

ErrUnknownSection is returned for a section that is not one of the inbox lists.

Functions

func IsDark

func IsDark(theme Theme, systemDark bool) bool

IsDark reports whether a theme shows the dark palette while the system appearance is dark (systemDark) or light. A theme that is not one of the choices counts as DefaultTheme.

func KeyDefaultProfile

func KeyDefaultProfile(id agent.ID) string

KeyDefaultProfile is the key of the agent's default profile, profile.default.<agent>.

Types

type BackupPart added in v0.2.0

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

BackupPart is the settings' part of a backup of the user's setup: their settings and, apart, their repositories, in portable form, and what importing each does. Core adapts it to a backup.Part; it is a type of its own, apart from the Service, so the window, which binds the Service, never reaches it.

func NewBackupPart added in v0.2.0

func NewBackupPart(s *Service) *BackupPart

NewBackupPart returns the backup's part over s.

func (*BackupPart) Announce added in v0.2.0

func (bp *BackupPart) Announce(ctx context.Context, plan PortablePlan)

Announce emits, once each, the events the setters of the settings plan changed emit, as they would had the user changed each one: the theme, the text size, the menu bar, the sessions followed, the integrations, the GitHub notification rules, the refresh intervals, the pinned and muted repositories, and what the service status check watches.

func (*BackupPart) ApplyPortable added in v0.2.0

func (bp *BackupPart) ApplyPortable(ctx context.Context, tx *sql.Tx, plan PortablePlan) (backup.Count, error)

ApplyPortable makes plan's writes inside tx, the import's transaction, and returns what it changed.

func (*BackupPart) PlanPortable added in v0.2.0

func (bp *BackupPart) PlanPortable(ctx context.Context, p Portable) (PortablePlan, error)

PlanPortable works out what importing p, a backup's settings, does, changing nothing: each setting p holds is checked as its setter checks it and set, and one p lacks is left as it is. A value the setter would refuse, a profile that isn't on this Mac, and a copy of a tool that isn't a program here are left out, each with a note. Both modes import settings the same way.

func (*BackupPart) PlanRepos added in v0.2.0

func (bp *BackupPart) PlanRepos(ctx context.Context, r PortableRepos, mode backup.Mode) (PortablePlan, error)

PlanRepos works out what importing r, a backup's repositories, does under mode, changing nothing. The clone folder is set when it exists here. Merge adds the file's locations that exist here, and pins or mutes each of the file's targets, its rule winning over this Mac's; Replace makes the locations exactly the file's that exist here, and each list the file holds exactly the file's. A location or a target that can't be added is left out with a note, as one the setters would refuse.

func (*BackupPart) Portable added in v0.2.0

func (bp *BackupPart) Portable(ctx context.Context) (Portable, error)

Portable returns the user's settings in portable form, every field set.

func (*BackupPart) PortableItems added in v0.2.0

func (bp *BackupPart) PortableItems(p Portable) int

PortableItems counts the settings p holds.

func (*BackupPart) PortableRepos added in v0.2.0

func (bp *BackupPart) PortableRepos(ctx context.Context) (PortableRepos, error)

PortableRepos returns the user's repositories in portable form, every field set.

type ConversationOrder added in v0.2.0

type ConversationOrder string

ConversationOrder is the order the issue sheet and the review sheet list a conversation's entries in, under its description.

const (
	ConversationOldest ConversationOrder = "oldest"
	ConversationNewest ConversationOrder = "newest"
)

The conversation's orders.

type InboxOrder added in v0.2.0

type InboxOrder struct {
	// StatusSorted lists the inbox lists sorted by project status, in the order the inbox
	// shows them. Every other list keeps its newest activity first.
	StatusSorted []ListKey `json:"statusSorted"`

	// StatusOrder is the user's order of project status names, first ranked highest. It
	// is empty until the user changes it.
	StatusOrder []string `json:"statusOrder"`

	// Kinds holds each list that shows only one kind of item on its own tab, with that
	// kind. A list it leaves out shows every one.
	Kinds map[ListKey]ListKind `json:"kinds"`
}

InboxOrder is how the inbox orders and narrows its lists: which are sorted by project status, the order of the statuses, and which show only one kind of item. Every field is a plain value.

type ListKey added in v0.2.0

type ListKey string

ListKey names an inbox list, as the inbox snapshot names it: each list is a section of the inbox the user can collapse.

const (
	ListReviewRequested ListKey = "reviewRequested"
	ListAuthored        ListKey = "authored"
	ListAssigned        ListKey = "assigned"
)

The inbox lists, in the order the inbox shows them.

type ListKind added in v0.2.0

type ListKind string

ListKind is which kind of item an inbox list shows on its own tab: every one, or only its pull requests, or only its issues.

const (
	ListKindAll    ListKind = "all"
	ListKindPRs    ListKind = "pr"
	ListKindIssues ListKind = "issue"
)

The kinds a list can show.

type MergeMethod added in v0.2.0

type MergeMethod string

MergeMethod is how the review sheet merges a pull request: as the repository offers first, or with one method wherever the repository allows it.

const (
	// MergeMethodRepo merges with the method GitHub offers first in each repository.
	MergeMethodRepo MergeMethod = "repo"

	// MergeMethodSquash, MergeMethodMerge, and MergeMethodRebase merge with that method
	// (squash, a merge commit, or a rebase) where the repository allows it, and as the
	// repository offers first elsewhere.
	MergeMethodSquash MergeMethod = "squash"
	MergeMethodMerge  MergeMethod = "merge_commit"
	MergeMethodRebase MergeMethod = "rebase_merge"
)

Merge method choices.

type NotificationsTab added in v0.2.0

type NotificationsTab string

NotificationsTab is a tab of the Notifications page: the app's own notifications, or the user's GitHub notifications.

const (
	NotificationsTabApp    NotificationsTab = "app"
	NotificationsTabGitHub NotificationsTab = "github"
)

The Notifications page's tabs.

type Option

type Option func(*Service)

Option configures a Service.

func WithClock added in v0.2.0

func WithClock(c clock.Clock) Option

WithClock stamps the stored preferences from c rather than from the system clock.

func WithEvents added in v0.2.0

func WithEvents(sink event.Sink) Option

WithEvents emits the theme, text size, and menu bar changes into sink once they are stored.

func WithGit added in v0.2.0

func WithGit(git execpath.Runner) Option

WithGit reads a clone location's origin with git, one read-only git config, for the preview and the check of the repository locations. Without it, they name no repository.

func WithLogger added in v0.2.0

func WithLogger(logger *slog.Logger) Option

WithLogger logs to logger what a setter cannot report as its error. Without it, or with nil, that is not logged.

func WithReader added in v0.2.0

func WithReader(reader *localrepos.Reader) Option

WithReader reads the other repository locations through reader, which bounds how long each read may take, so one that hangs reads as not answering rather than holding the check of the locations. Without it they are read directly.

type Portable added in v0.2.0

type Portable struct {
	DefaultAgent        *agent.ID            `json:"defaultAgent,omitempty"`
	DefaultProfiles     map[agent.ID]string  `json:"defaultProfiles,omitempty"`
	Terminal            *terminal.ID         `json:"terminal,omitempty"`
	WorktreeDefault     *bool                `json:"worktreeDefault,omitempty"`
	FollowSessions      *bool                `json:"followSessions,omitempty"`
	CodexEffort         *bool                `json:"codexEffort,omitempty"`
	CodexFast           *bool                `json:"codexFast,omitempty"`
	WorktreeAutoCleanup *bool                `json:"worktreeAutoCleanup,omitempty"`
	Branches            *branchrules.Rules   `json:"branches,omitempty"`
	TrustedBots         *[]string            `json:"trustedBots,omitempty"`
	SnoozeDays          *int                 `json:"snoozeDays,omitempty"`
	SnoozeWake          *snooze.Rules        `json:"snoozeWake,omitempty"`
	SensitiveScope      *sensitive.Scope     `json:"sensitiveScope,omitempty"`
	SensitiveOff        *[]string            `json:"sensitiveOff,omitempty"`
	SensitivePatterns   *[]string            `json:"sensitivePatterns,omitempty"`
	MenuBar             *bool                `json:"menuBar,omitempty"`
	BannersOff          *[]notifyprefs.Kind  `json:"bannersOff,omitempty"`
	GitHubNotifications *PortableThreadRules `json:"githubNotifications,omitempty"`
	Refresh             map[RefreshKind]int  `json:"refresh,omitempty"`
	ServiceStatus       *PortableStatus      `json:"serviceStatus,omitempty"`
	MergeMethod         *MergeMethod         `json:"mergeMethod,omitempty"`
	Theme               *Theme               `json:"theme,omitempty"`
	TextSize            *TextSize            `json:"textSize,omitempty"`
	ToastSeconds        *int                 `json:"toastSeconds,omitempty"`
	InboxOrder          *InboxOrder          `json:"inboxOrder,omitempty"`
	Integrations        *PortableIntegration `json:"integrations,omitempty"`
}

Portable is the user's settings in portable form, as a backup holds them: every setting but the repositories (see PortableRepos) and the window's memory (its size, the folded sections, the tips put away, the review sheet's tab, the Notifications page's tab, the conversations' order, and the Scripts tab's last page and clone). Each field is a pointer, or a map whose entries each stand alone, so a field a backup lacks is left as it is when the backup is imported.

func (*Portable) UnmarshalJSON added in v0.2.0

func (p *Portable) UnmarshalJSON(data []byte) error

UnmarshalJSON reads a backup's settings, taking an older backup's interval of the GitHub status check as the service status check's, unless the backup holds that too.

type PortableIntegration added in v0.2.0

type PortableIntegration struct {
	Switches        map[integrationprefs.ID]integrationprefs.Switch `json:"switches,omitempty"`
	Paths           map[integrationprefs.ID]string                  `json:"paths,omitempty"`
	RunsIn          *integrationprefs.RunsIn                        `json:"runsIn,omitempty"`
	OfferAfterMerge *bool                                           `json:"offerAfterMerge,omitempty"`
	MagexTargets    *bool                                           `json:"magexTargets,omitempty"`
	RepoFiles       *bool                                           `json:"repoFiles,omitempty"`
	ShowRuns        *bool                                           `json:"showRuns,omitempty"`
}

PortableIntegration is the integrations' settings in portable form, each left as it is when a backup lacks it: each integration's switch, the copy of each tool chosen, where the runs go, whether a merge offers a release, Repo scripts' sources, and whether a run it starts shows beside it.

type PortablePlan added in v0.2.0

type PortablePlan struct {
	backup.Plan
	// contains filtered or unexported fields
}

PortablePlan is what importing a backup's settings, or its repositories, does: the plan the window shows, and the writes it makes.

type PortableRepos added in v0.2.0

type PortableRepos struct {
	CloneRoot *string                `json:"cloneRoot,omitempty"`
	Locations *[]localrepos.Location `json:"locations,omitempty"`
	Pinned    *[]string              `json:"pinned,omitempty"`
	Muted     *[]string              `json:"muted,omitempty"`
}

PortableRepos is the user's repositories in portable form, as a backup holds them: the clone folder, the other repository locations, and the pinned and muted repositories and orgs. Each field is a pointer, so one a backup lacks is left as it is.

type PortableStatus added in v0.2.0

type PortableStatus struct {
	Off   *[]statusprefs.ProviderID `json:"off,omitempty"`
	Parts *[]statusprefs.PartID     `json:"parts,omitempty"`
}

PortableStatus is what the service status check watches in portable form, each left as it is when a backup lacks it: the status pages turned off, and every part watched, across the providers, by the app's own names for them (statusprefs.PartID).

type PortableThreadRules added in v0.2.0

type PortableThreadRules struct {
	Read        *bool                  `json:"read,omitempty"`
	Auto        *bool                  `json:"auto,omitempty"`
	Action      *threadrules.Action    `json:"action,omitempty"`
	TriggersOff *[]threadrules.Trigger `json:"triggersOff,omitempty"`
	Watching    *bool                  `json:"watching,omitempty"`
	BotActivity *bool                  `json:"botActivity,omitempty"`
}

PortableThreadRules are the rules for the user's GitHub notifications in portable form, each left as it is when a backup lacks it. The cleanup card's flag is the window's memory, and stays out.

type ProfileLookup added in v0.2.0

type ProfileLookup interface {
	Lookup(ctx context.Context, id agent.ID, name string) (profiles.Profile, error)
}

ProfileLookup finds an agent's stored profile by name, or returns profiles.ErrProfileNotFound. *profiles.Store implements it.

type RefreshChoices added in v0.2.0

type RefreshChoices struct {
	Inbox         []int `json:"inbox"`
	Checks        []int `json:"checks"`
	ReleaseChecks []int `json:"releaseChecks"`
	Worktrees     []int `json:"worktrees"`
	Notifications []int `json:"notifications"`
	ServiceStatus []int `json:"serviceStatus"`
}

RefreshChoices are the intervals each can be set to, in seconds, shortest first.

type RefreshIntervals added in v0.2.0

type RefreshIntervals struct {
	Inbox         int `json:"inbox"`
	Checks        int `json:"checks"`
	ReleaseChecks int `json:"releaseChecks"`
	Worktrees     int `json:"worktrees"`
	Notifications int `json:"notifications"`
	ServiceStatus int `json:"serviceStatus"`
}

RefreshIntervals are how often, in seconds, the app reads each thing again on its own. Both checks follows' 0 is off, and so is the service status check's.

func DefaultRefreshIntervals added in v0.2.0

func DefaultRefreshIntervals() RefreshIntervals

DefaultRefreshIntervals are the intervals of a fresh database.

func (RefreshIntervals) Every added in v0.2.0

func (r RefreshIntervals) Every(kind RefreshKind) time.Duration

Every returns how often the app reads kind again, as set in s; zero is off, and a kind this build doesn't know is off.

type RefreshKind added in v0.2.0

type RefreshKind string

RefreshKind names one of the things the app reads again on its own, on a timer.

const (
	// RefreshInbox is the whole inbox, from GitHub.
	RefreshInbox RefreshKind = "inbox"

	// RefreshChecks is the pull requests whose checks are running, from GitHub, all in one
	// request.
	RefreshChecks RefreshKind = "checks"

	// RefreshReleaseChecks is the Release page's repositories whose newest commit's checks
	// are running, read again from GitHub together.
	RefreshReleaseChecks RefreshKind = "releaseChecks"

	// RefreshWorktrees is the worktrees' sweep: each clone's worktrees, the pull requests
	// and issues they belong to, and the automatic cleanup.
	RefreshWorktrees RefreshKind = "worktrees"

	// RefreshNotifications is the user's GitHub notifications, listed from GitHub: one
	// conditional request, free when nothing changed, and never sooner than GitHub's own
	// poll interval asks.
	RefreshNotifications RefreshKind = "notifications"

	// RefreshServiceStatus is the status pages of the services the app depends on
	// (GitHub's, Claude's, and OpenAI's), which say whether a part the user watches has an
	// incident: one small request to each page watched, outside any API, so it costs no
	// point of the budget.
	RefreshServiceStatus RefreshKind = "serviceStatus"
)

What the app reads again on its own.

func RefreshKinds added in v0.2.0

func RefreshKinds() []RefreshKind

RefreshKinds returns every kind the app reads again on its own, in the order Settings lists them.

type ReviewTab added in v0.2.0

type ReviewTab string

ReviewTab is a tab of the review sheet's larger column: the files a pull request changes, beneath its description, or its conversation.

const (
	ReviewTabFiles    ReviewTab = "files"
	ReviewTabComments ReviewTab = "comments"
)

The review sheet's tabs.

type Service

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

Service reads and writes the preferences.

Each setter stores its change and reads the preferences back in one transaction, then returns the settings with the change, so a setter that fails has stored nothing. Only the check that the default profiles are still stored runs after the change is committed, and a failure there is logged rather than reported, since the change has happened.

func NewService

func NewService(pool *sql.DB, known ProfileLookup, home string, opts ...Option) *Service

NewService returns a Service over the preferences in pool. known looks up the stored profiles the default profile must name, and home expands a ~ clone root.

func (*Service) AddCloneLocations added in v0.2.0

func (s *Service) AddCloneLocations(ctx context.Context, dirs []string) (Settings, error)

AddCloneLocations adds each of dirs to the other repository locations, all or none, and returns the settings with them; one call serves a single add, the suggestions the preview offers, and a launch's clone found elsewhere. Each is trimmed, expanded, and stored with ~, as a folder (looked into one level deep) or a single clone, by what it is now (localrepos.Classify); a hidden folder, one inside the app's worktrees folder or a git folder, a linked worktree, the clone root, a clone the locations already hold, and a folder that doesn't answer within the Reader's limit (WithReader) are refused, in words the window shows. A location already listed is classified again, which is what Check again does. A folder added drops the clone locations directly inside it, which it now covers.

func (*Service) CheckCloneLocations added in v0.2.0

func (s *Service) CheckCloneLocations(ctx context.Context) ([]localrepos.LocationState, error)

CheckCloneLocations reads how the clone root and each of the other repository locations read now, the clone root first: whether each is there, a folder's clones, and a clone's origin (see localrepos.Check).

func (*Service) CollapsedSections

func (s *Service) CollapsedSections(ctx context.Context) ([]ListKey, error)

CollapsedSections returns the inbox sections the user collapsed, in the order the inbox shows them. None is collapsed on a fresh database, and a stored value that is not a boolean counts as open.

func (*Service) FollowSessions added in v0.2.0

func (s *Service) FollowSessions(ctx context.Context) (bool, error)

FollowSessions returns whether the app follows the agent sessions it launches: the stored setting, or DefaultFollowSessions when none is stored or it cannot be read.

func (*Service) Get

func (s *Service) Get(ctx context.Context) (Settings, error)

Get returns every preference, with the default for any that is unset or holds a value that is no longer valid.

func (*Service) InboxOrder added in v0.2.0

func (s *Service) InboxOrder(ctx context.Context) (InboxOrder, error)

InboxOrder returns how the inbox orders its lists. On a fresh database every list is newest activity first, and the status order is empty.

func (*Service) MatchSensitivePath

func (s *Service) MatchSensitivePath(ctx context.Context, path string) (sensitive.PathMatch, error)

MatchSensitivePath reports whether a path would count as sensitive under the stored settings, and which category and pattern it matches, for trying patterns out.

func (*Service) MenuBar

func (s *Service) MenuBar(ctx context.Context) (bool, error)

MenuBar returns whether the app shows its menu bar icon: the stored setting, or DefaultMenuBar when none is stored or the stored value cannot be read.

func (*Service) MergeMethod added in v0.2.0

func (s *Service) MergeMethod(ctx context.Context) (MergeMethod, error)

MergeMethod returns the stored merge method, or DefaultMergeMethod when none is stored or the stored value is no longer a choice.

func (*Service) PreviewCloneLocation added in v0.2.0

func (s *Service) PreviewCloneLocation(ctx context.Context, dir string) (localrepos.Preview, error)

PreviewCloneLocation says what adding dir as a repository location would add, and what the app suggests instead where it finds a better choice, before anything is stored (see localrepos.Survey). It reads the folder and its subfolders with stat alone, and a clone's origin with one read-only git command when the Service has git (WithGit).

func (*Service) RemoveCloneLocation added in v0.2.0

func (s *Service) RemoveCloneLocation(ctx context.Context, dir string) (Settings, error)

RemoveCloneLocation drops dir from the other repository locations, by its stored text or as the same folder, and returns the settings without it. A location that isn't listed is no error. Its clones and their worktrees are left as they are, but no listing or cleanup reaches them until the location is added again.

func (*Service) ResetTrustedBots

func (s *Service) ResetTrustedBots(ctx context.Context) (Settings, error)

ResetTrustedBots goes back to the default trusted bots, and returns the settings with them.

func (*Service) SetBranchRules added in v0.2.0

func (s *Service) SetBranchRules(ctx context.Context, rules branchrules.Rules) (Settings, error)

SetBranchRules stores the rules for deleting local branches, and returns the settings with them. Every rule is stored together, so the rules never mix two saves; a protected pattern that cannot match a branch is refused, and nothing is stored.

func (*Service) SetCloneRoot

func (s *Service) SetCloneRoot(ctx context.Context, root string) (Settings, error)

SetCloneRoot stores the clone root, and returns the settings with it. It must be an absolute or ~-relative path to an existing directory; it is stored as entered (trimmed and cleaned), so "~/projects" stays portable across machines.

func (*Service) SetCodexEffort added in v0.2.0

func (s *Service) SetCodexEffort(ctx context.Context, on bool) (Settings, error)

SetCodexEffort stores whether a Codex launch passes the effort level it resolves to, and returns the settings with it. Off, Codex uses the effort in its own config.

func (*Service) SetCodexFast added in v0.2.0

func (s *Service) SetCodexFast(ctx context.Context, on bool) (Settings, error)

SetCodexFast stores whether Codex launches start in Fast mode unless unticked, and returns the settings with it.

func (*Service) SetConversationOrder added in v0.2.0

func (s *Service) SetConversationOrder(ctx context.Context, order ConversationOrder) (Settings, error)

SetConversationOrder stores the order the sheets list a conversation in, ConversationOldest or ConversationNewest, and returns the settings with it.

func (*Service) SetDefaultAgent added in v0.2.0

func (s *Service) SetDefaultAgent(ctx context.Context, id agent.ID) (Settings, error)

SetDefaultAgent stores the coding agent launches use when no launch default names one, and returns the settings with it.

func (*Service) SetDefaultProfile

func (s *Service) SetDefaultProfile(ctx context.Context, id agent.ID, name string) (Settings, error)

SetDefaultProfile stores the agent's profile launches use when no launch default names one, and returns the settings with it. It must name one of the agent's stored profiles.

func (*Service) SetFollowSessions added in v0.2.0

func (s *Service) SetFollowSessions(ctx context.Context, on bool) (Settings, error)

SetFollowSessions stores whether the app follows the agent sessions it launches, and returns the settings with it. While it is off, no agent is asked about its sessions, and the window shows none; launches are still recorded. Once it is stored, an event.SessionsUpdated is emitted, so the window and the menu bar show the sessions, or stop showing them, at once.

func (*Service) SetGitHubCleanupCardDismissed added in v0.2.0

func (s *Service) SetGitHubCleanupCardDismissed(ctx context.Context, dismissed bool) (Settings, error)

SetGitHubCleanupCardDismissed stores whether the card that first offers to clean up the user's GitHub notifications is put away ("Not now"), and returns the settings with it. Only the window reads it, so nothing else hears of it.

func (*Service) SetGitHubNotificationAction added in v0.2.0

func (s *Service) SetGitHubNotificationAction(ctx context.Context, action threadrules.Action) (Settings, error)

SetGitHubNotificationAction stores what clearing a GitHub notification does, mark it done or mark it read, and returns the settings with it. An action this build does not know is refused.

func (*Service) SetGitHubNotificationSwitch added in v0.2.0

func (s *Service) SetGitHubNotificationSwitch(ctx context.Context, name threadrules.Switch, on bool) (Settings, error)

SetGitHubNotificationSwitch turns one of the GitHub notification rules' switches on or off (see threadrules.Switches), and returns the settings with it.

func (*Service) SetGitHubNotificationTrigger added in v0.2.0

func (s *Service) SetGitHubNotificationTrigger(ctx context.Context, trigger threadrules.Trigger, on bool,
) (Settings, error)

SetGitHubNotificationTrigger turns one of the moments that clear a GitHub notification on or off (see threadrules.Triggers), and returns the settings with it. Clearing by hand has no switch and is refused, as is a trigger this build does not know. The triggers that are off are read and written in one transaction, so two changes never lose either.

func (*Service) SetIntegrationEnabled added in v0.2.0

func (s *Service) SetIntegrationEnabled(ctx context.Context, id integrationprefs.ID, state integrationprefs.Switch,
) (Settings, error)

SetIntegrationEnabled stores how the user set an integration's switch, automatic, on, or off, and returns the settings with it. Once it is stored, an event.IntegrationsChanged is emitted, so the window hears that the tools' list changed.

func (*Service) SetIntegrationPath added in v0.2.0

func (s *Service) SetIntegrationPath(ctx context.Context, id integrationprefs.ID, path string) (Settings, error)

SetIntegrationPath stores the copy of a tool the user chose, and returns the settings with it: an absolute or ~-relative path to an executable file, stored cleaned and absolute, or "" to use the copy the user's shell finds. Once it is stored, an event.IntegrationsChanged is emitted, so the integrations detect the tools again.

func (*Service) SetIntegrationsAnnounced added in v0.2.0

func (s *Service) SetIntegrationsAnnounced(ctx context.Context, announced bool) (Settings, error)

SetIntegrationsAnnounced stores whether the window announced the Scripts tab, as it first appeared because a tool was found, and returns the settings with it, so the toast shows once rather than at every start. Nothing else hears of it.

func (*Service) SetListKind added in v0.2.0

func (s *Service) SetListKind(ctx context.Context, section ListKey, kind ListKind) (Settings, error)

SetListKind stores which kind of item an inbox list shows on its own tab, every one or only its pull requests or its issues, and returns the settings with it.

func (*Service) SetMenuBar

func (s *Service) SetMenuBar(ctx context.Context, on bool) (Settings, error)

SetMenuBar stores whether the app shows its menu bar icon, and returns the settings with it. Once it is stored, an event.MenuBarChanged is emitted, so the desktop shell adds or removes the icon.

func (*Service) SetMergeMethod added in v0.2.0

func (s *Service) SetMergeMethod(ctx context.Context, method MergeMethod) (Settings, error)

SetMergeMethod stores how the review sheet merges: MergeMethodRepo, MergeMethodSquash, MergeMethodMerge, or MergeMethodRebase, and returns the settings with it.

func (*Service) SetNotificationBanner

func (s *Service) SetNotificationBanner(ctx context.Context, kind notifyprefs.Kind, on bool) (Settings, error)

SetNotificationBanner turns the banners of one kind of notification on or off (see the notify package for the kinds), and returns the settings with it. The notification history keeps every kind either way.

A kind that starts on is stored in notifyprefs.KeyBannersOff once turned off, and one that starts off, such as the agent sessions' kinds, in notifyprefs.KeyBannersOn once turned on; both keys are written together.

func (*Service) SetNotificationsTab added in v0.2.0

func (s *Service) SetNotificationsTab(ctx context.Context, tab NotificationsTab) (Settings, error)

SetNotificationsTab stores the Notifications page's tab the user chose, NotificationsTabApp or NotificationsTabGitHub, which the page opens on from then on, and returns the settings with it.

func (*Service) SetOfferAfterMerge added in v0.2.0

func (s *Service) SetOfferAfterMerge(ctx context.Context, on bool) (Settings, error)

SetOfferAfterMerge stores whether merging a pull request in the review sheet offers to release its repository, and returns the settings with it. Nothing else hears of it: the review sheet asks Release whether to offer as each merge lands.

func (*Service) SetProjectsTipDismissed added in v0.2.0

func (s *Service) SetProjectsTipDismissed(ctx context.Context, dismissed bool) (Settings, error)

SetProjectsTipDismissed stores whether the inbox's tip about showing issue projects is put away, and returns the settings with it.

func (*Service) SetRefreshInterval added in v0.2.0

func (s *Service) SetRefreshInterval(ctx context.Context, kind RefreshKind, seconds int) (Settings, error)

SetRefreshInterval stores how often, in seconds, the app reads kind again on its own, one of its choices (RefreshChoices), and returns the settings with it. Once it is stored, an event.IntervalsChanged is emitted, so whatever reads kind again works its next wait out from the new interval at once.

func (*Service) SetRepoRule added in v0.2.0

func (s *Service) SetRepoRule(ctx context.Context, target string, rule reporules.Rule) (Settings, error)

SetRepoRule pins or mutes a repository ("owner/name") or an org ("owner"), or takes its rule off with reporules.RuleNone, and returns the settings with it. A target is in one list at most, so pinning a muted one unmutes it. The rules are read and written in one transaction, so two changes never lose either. Once they are stored, an event.RepoRulesChanged is emitted, so the inbox, the menu bar, and the Release page show the change at once.

func (*Service) SetReviewTab added in v0.2.0

func (s *Service) SetReviewTab(ctx context.Context, tab ReviewTab) (Settings, error)

SetReviewTab stores the review sheet's tab the user chose, ReviewTabFiles or ReviewTabComments, which the sheet opens on from then on, and returns the settings with it.

func (*Service) SetRunsIn added in v0.2.0

func (s *Service) SetRunsIn(ctx context.Context, place integrationprefs.RunsIn) (Settings, error)

SetRunsIn stores where the runs go, in the app or in the terminal chosen for launches, and returns the settings with it. Nothing else hears of it: what starts a run (a release, a hooks action, checks, or a script) reads the setting as it starts one.

func (*Service) SetScriptSources added in v0.2.0

func (s *Service) SetScriptSources(ctx context.Context, magexTargets, repoFiles bool) (Settings, error)

SetScriptSources stores which sources Repo scripts lists besides the user's own scripts, magex's targets and the commands in a repository's own files (t3.json and .vscode/tasks.json), and returns the settings with them. Nothing else hears of it: Repo scripts reads the setting as it lists a repository's scripts.

func (*Service) SetScriptsLastPage added in v0.2.0

func (s *Service) SetScriptsLastPage(ctx context.Context, page integrationprefs.ScriptsPage) (Settings, error)

SetScriptsLastPage stores the Scripts tab's page shown last, which the tab reopens on, and returns the settings with it. A page that isn't one of the tab's is refused.

func (*Service) SetScriptsLastRepo added in v0.2.0

func (s *Service) SetScriptsLastRepo(ctx context.Context, dir string) (Settings, error)

SetScriptsLastRepo stores the clone Repo scripts showed last, as the window names it (its folder, with ~), which Repo scripts reopens on, and returns the settings with it; "" forgets it. A folder that isn't an absolute or ~ path on one line is refused. Repo scripts checks the folder again as it lists it, as it does any the window names.

func (*Service) SetScriptsSectionOpen added in v0.2.0

func (s *Service) SetScriptsSectionOpen(ctx context.Context, section integrationprefs.ScriptsSection, open bool,
) (Settings, error)

SetScriptsSectionOpen stores whether one of the Scripts tab's sections is open, as the user opened or folded it, which the page shows it as from then on, across starts, and returns the settings with it. The others stay as they were. A section that isn't one of the tab's is refused.

func (*Service) SetSectionCollapsed

func (s *Service) SetSectionCollapsed(ctx context.Context, section ListKey, collapsed bool) (Settings, error)

SetSectionCollapsed stores whether an inbox section is collapsed, so the inbox opens the same way at the next launch, and returns the settings with it.

func (*Service) SetSensitiveCategory

func (s *Service) SetSensitiveCategory(ctx context.Context, id string, on bool) (Settings, error)

SetSensitiveCategory turns a built-in category of sensitive files on or off, and returns the settings with it. The agent configuration category cannot be turned off, since launches are held back by it.

func (*Service) SetSensitivePatterns

func (s *Service) SetSensitivePatterns(ctx context.Context, patterns []string) (Settings, error)

SetSensitivePatterns stores the user's own patterns of sensitive files, in order, and returns the settings with them. Each is trimmed, empty ones and repeats are dropped, and a pattern that cannot be used is refused with the reason (see the sensitive package for the syntax).

func (*Service) SetSensitiveScope

func (s *Service) SetSensitiveScope(ctx context.Context, scope sensitive.Scope) (Settings, error)

SetSensitiveScope stores whose pull requests have their changed files checked, sensitive.ScopeOutside or sensitive.ScopeCollaborators to check collaborators' too, and returns the settings with it.

func (*Service) SetShowRuns added in v0.2.0

func (s *Service) SetShowRuns(ctx context.Context, on bool) (Settings, error)

SetShowRuns stores whether a run Repo scripts starts shows beside its scripts at once, and returns the settings with it. Nothing else hears of it: the page reads the setting as a run starts.

func (*Service) SetSnoozeDays

func (s *Service) SetSnoozeDays(ctx context.Context, days int) (Settings, error)

SetSnoozeDays stores how many days the Snooze button hides an item, snooze.MinDays to snooze.MaxDays, and returns the settings with it.

func (*Service) SetSnoozeWake

func (s *Service) SetSnoozeWake(ctx context.Context, rules snooze.Rules) (Settings, error)

SetSnoozeWake stores which new activity ends a snooze early, and returns the settings with it. Every rule is stored together, so the rules never mix two saves.

func (*Service) SetStatusOrder added in v0.2.0

func (s *Service) SetStatusOrder(ctx context.Context, order []string) (Settings, error)

SetStatusOrder stores the user's order of project status names, first ranked highest, and returns the settings with it. Names are trimmed, and empty and repeated ones (ignoring case) are left out. An empty order puts every status back where the window would place it.

func (*Service) SetStatusPart added in v0.2.0

func (s *Service) SetStatusPart(ctx context.Context, id statusprefs.PartID, on bool) (Settings, error)

SetStatusPart ticks or unticks a part of a provider to watch (see statusprefs.Catalog), and returns the settings with it. A part this build doesn't know is refused. The list it is stored in is read and written in one update, so two quick changes never lose either.

func (*Service) SetStatusProvider added in v0.2.0

func (s *Service) SetStatusProvider(ctx context.Context, id statusprefs.ProviderID, on bool) (Settings, error)

SetStatusProvider turns a provider's status page on or off (see statusprefs.Catalog), and returns the settings with it. A provider this build doesn't know is refused. The providers off are read and written in one update, so two quick changes never lose either.

func (*Service) SetStatusSort added in v0.2.0

func (s *Service) SetStatusSort(ctx context.Context, section ListKey, on bool) (Settings, error)

SetStatusSort stores whether an inbox list is sorted by project status, rather than by newest activity, and returns the settings with it.

func (*Service) SetTerminal

func (s *Service) SetTerminal(ctx context.Context, id terminal.ID) (Settings, error)

SetTerminal stores the terminal launches open in, TerminalITerm2 or TerminalApp, and returns the settings with it.

func (*Service) SetTextSize added in v0.2.0

func (s *Service) SetTextSize(ctx context.Context, size TextSize) (Settings, error)

SetTextSize stores the size of the app's text: TextSizeDefault, TextSizeLarge, or TextSizeLarger, and returns the settings with it. The page shows the new size itself; once it is stored, an event.TextSizeChanged is emitted, so the desktop shell sets the window's smallest size to suit it.

func (*Service) SetTheme

func (s *Service) SetTheme(ctx context.Context, theme Theme) (Settings, error)

SetTheme stores the theme the app shows: ThemeSystem, ThemeLight, or ThemeDark, and returns the settings with it. Once it is stored, an event.ThemeChanged is emitted, so the desktop shell brings the window's native appearance along with it.

func (*Service) SetToastSeconds added in v0.2.0

func (s *Service) SetToastSeconds(ctx context.Context, seconds int) (Settings, error)

SetToastSeconds stores how long, in seconds, a toast stays before it closes itself, MinToastSeconds to MaxToastSeconds, and returns the settings with it. The window reads it from the settings, so the next toast stays that long.

func (*Service) SetTrustedBots

func (s *Service) SetTrustedBots(ctx context.Context, bots []string) (Settings, error)

SetTrustedBots stores the bots whose items are trusted, and returns the settings with them. Each login may be written as GitHub shows it ("dependabot", "dependabot[bot]", or "app/dependabot"); the list is stored normalized and sorted, and may be empty to trust no bot.

func (*Service) SetWindowSize

func (s *Service) SetWindowSize(ctx context.Context, size WindowSize) (Settings, error)

SetWindowSize stores the size the window opens at, which takes effect at the next launch: MinWindowWidth by MinWindowHeight up to MaxWindowWidth by MaxWindowHeight. It returns the settings with it.

func (*Service) SetWorktreeAutoCleanup

func (s *Service) SetWorktreeAutoCleanup(ctx context.Context, on bool) (Settings, error)

SetWorktreeAutoCleanup stores whether finished worktrees are cleaned up on their own, and returns the settings with it.

func (*Service) SetWorktreeDefault

func (s *Service) SetWorktreeDefault(ctx context.Context, on bool) (Settings, error)

SetWorktreeDefault stores whether launches start in a worktree unless unticked, and returns the settings with it.

func (*Service) TextSize added in v0.2.0

func (s *Service) TextSize(ctx context.Context) (TextSize, error)

TextSize returns the stored text size, or DefaultTextSize when none is stored or the stored value is no longer a choice. The desktop shell reads it to open the window at it.

func (*Service) Theme

func (s *Service) Theme(ctx context.Context) (Theme, error)

Theme returns the stored theme, or DefaultTheme when none is stored or the stored value is no longer a choice.

type Settings

type Settings struct {
	// DefaultAgent is the coding agent launches use when no launch default names one.
	DefaultAgent agent.ID `json:"defaultAgent"`

	// DefaultProfiles is each agent's profile launches use when no launch default names
	// one. It has an entry for every agent.
	DefaultProfiles map[agent.ID]string `json:"defaultProfiles"`

	// WorktreeDefault presets each row's "Start in a worktree" checkbox.
	WorktreeDefault bool `json:"worktreeDefault"`

	// WorktreeAutoCleanup cleans up a finished worktree on its own once its pull request
	// merges or its issue closes.
	WorktreeAutoCleanup bool `json:"worktreeAutoCleanup"`

	// Terminal is TerminalITerm2 or TerminalApp.
	Terminal terminal.ID `json:"terminal"`

	// FollowSessions follows each agent session a launch starts from its item: what it
	// is doing, and what it last said. Sessions are recorded either way.
	FollowSessions bool `json:"followSessions"`

	// CodexEffort passes Codex the effort level a launch resolves to, and CodexFast
	// presets each Codex launch's Fast mode. Codex takes both only as config overrides,
	// and runs a session started with either outside its shared app server, where the app
	// can't see that it waits for the user, so both start off.
	CodexEffort bool `json:"codexEffort"`
	CodexFast   bool `json:"codexFast"`

	// CloneRoot is the clone root as entered, e.g. "~/projects": the folder new clones go
	// in, and the first place clones are looked for.
	CloneRoot string `json:"cloneRoot"`

	// CloneLocations are the other repository locations, in the order they were added:
	// each a folder looked into one level deep, as the clone root is, or a single clone,
	// with ~ for home. Never nil.
	CloneLocations []localrepos.Location `json:"cloneLocations"`

	// TrustedBots lists the bots (GitHub Apps) whose pull requests and issues are trusted
	// like a collaborator's, by login, sorted. It starts as trust.DefaultBots.
	TrustedBots []string `json:"trustedBots"`

	// DefaultTrustedBots is the list ResetTrustedBots restores.
	DefaultTrustedBots []string `json:"defaultTrustedBots"`

	// SnoozeDays is how many days an inbox row's Snooze button hides an item; its menu
	// offers other lengths for one snooze.
	SnoozeDays int `json:"snoozeDays"`

	// SnoozeWake is which new activity ends a snooze early.
	SnoozeWake snooze.Rules `json:"snoozeWake"`

	// WindowSize is the size the window opens at.
	WindowSize WindowSize `json:"windowSize"`

	// DefaultWindowSize is the size a fresh database opens the window at.
	DefaultWindowSize WindowSize `json:"defaultWindowSize"`

	// SensitiveFiles is whose pull requests have their changed files checked, which
	// built-in categories are off, and the user's own patterns (see the sensitive
	// package).
	SensitiveFiles sensitive.Config `json:"sensitiveFiles"`

	// Branches are the rules for deleting local branches: which go with a worktree that
	// is removed or cleaned up, whether a merged pull request's branch starts checked in
	// the cleanup of merged branches, and which are never deleted. Each deletion is
	// confirmed with checkboxes that start from them.
	Branches branchrules.Rules `json:"branches"`

	// DefaultProtectedBranches is the protected list before the user changes it.
	DefaultProtectedBranches []string `json:"defaultProtectedBranches"`

	// RepoRules are the pinned and the muted repositories and orgs: a pinned one's items
	// count as pinned in the inbox, and a muted one's are set apart in each list's Muted
	// tab and on the Release page (see the reporules package).
	RepoRules reporules.Rules `json:"repoRules"`

	// SensitiveCategories are the built-in categories in matching order, with their
	// patterns, for the settings page to describe.
	SensitiveCategories []sensitive.Category `json:"sensitiveCategories"`

	// MenuBar shows the app's icon in the menu bar, with how many items need the user and
	// a short list of them; closing the window then keeps the app running there.
	MenuBar bool `json:"menuBar"`

	// BannersOff lists the kinds of notification (see the notify package) whose banners
	// are off, the agent sessions' kinds among them until turned on. The notification
	// history keeps every inbox kind either way.
	BannersOff []notifyprefs.Kind `json:"bannersOff"`

	// Theme is the palette the app shows.
	Theme Theme `json:"theme"`

	// TextSize is the size of the app's text, apart from the size of its window.
	TextSize TextSize `json:"textSize"`

	// ToastSeconds is how long, in seconds, a message at the bottom of the window stays
	// before it closes itself, MinToastSeconds to MaxToastSeconds.
	ToastSeconds int `json:"toastSeconds"`

	// CollapsedSections lists the inbox sections the user collapsed, in the order the
	// inbox shows them.
	CollapsedSections []ListKey `json:"collapsedSections"`

	// ProjectsTipDismissed is set once the user puts away the inbox's tip about showing
	// the GitHub projects an issue is in.
	ProjectsTipDismissed bool `json:"projectsTipDismissed"`

	// ReviewTab is the review sheet's tab the user last chose, which it opens on.
	ReviewTab ReviewTab `json:"reviewTab"`

	// NotificationsTab is the Notifications page's tab the user last chose, which it opens
	// on unless a quick view's View all asks for the other.
	NotificationsTab NotificationsTab `json:"notificationsTab"`

	// ConversationOrder is the order the sheets list a conversation in, the one the user
	// last chose.
	ConversationOrder ConversationOrder `json:"conversationOrder"`

	// InboxOrder is which inbox lists are sorted by project status, and the order of the
	// statuses.
	InboxOrder InboxOrder `json:"inboxOrder"`

	// MergeMethod is how the review sheet merges a pull request.
	MergeMethod MergeMethod `json:"mergeMethod"`

	// Integrations is each integration's switch, and the copy of each tool the user chose.
	Integrations integrationprefs.Config `json:"integrations"`

	// GitHubNotifications are the rules for the user's GitHub notifications: whether the app
	// reads them, and whether, how, and when it clears one once the work behind it is
	// finished (see the threadrules package).
	GitHubNotifications threadrules.Rules `json:"githubNotifications"`

	// Refresh is how often, in seconds, the app reads the inbox, the running checks, the
	// Release page's running checks, the worktrees, the GitHub notifications, and the
	// status pages again on its own, and RefreshChoices what each can be set to.
	Refresh        RefreshIntervals `json:"refresh"`
	RefreshChoices RefreshChoices   `json:"refreshChoices"`

	// ServiceStatus is what the service status check watches: which providers' status
	// pages are on, and which of each one's parts count (see the statusprefs package).
	ServiceStatus statusprefs.Config `json:"serviceStatus"`

	// StatusProviders are the providers the check can watch, with their parts, for the
	// settings page to list.
	StatusProviders []statusprefs.Provider `json:"statusProviders"`
}

Settings is the full set of preferences as the UI shows them. Every field is a plain value.

type TextSize added in v0.2.0

type TextSize string

TextSize is the size of the app's text, apart from the size of its window. A larger size scales the text and the spacing sized with it, as a browser's font size setting does; the frontend sets the scale for each choice.

const (
	// TextSizeDefault shows the text at the size the app is designed at (100%).
	TextSizeDefault TextSize = "default"

	// TextSizeLarge shows the text a step larger (115%).
	TextSizeLarge TextSize = "large"

	// TextSizeLarger shows the text two steps larger (130%).
	TextSizeLarger TextSize = "larger"
)

Text size choices.

func (TextSize) Percent added in v0.2.0

func (t TextSize) Percent() int

Percent is the scale the text size sets, as a percent of the size the app is designed at. A size that is not one of the choices counts as DefaultTextSize. The frontend keeps the same scales (frontend/src/lib/textSize.ts), and a test holds the two in step.

type Theme added in v0.2.0

type Theme string

Theme is the palette the app shows.

const (
	// ThemeSystem follows the system's light or dark appearance as it changes.
	ThemeSystem Theme = "system"

	// ThemeLight always shows the light palette.
	ThemeLight Theme = "light"

	// ThemeDark always shows the dark palette.
	ThemeDark Theme = "dark"
)

Theme choices.

type WindowSize

type WindowSize struct {
	Width  int `json:"width"`
	Height int `json:"height"`
}

WindowSize is the window's size, in points.

func DefaultWindowSize

func DefaultWindowSize() WindowSize

DefaultWindowSize returns the size the window opens at on a fresh database.

func MinWindowSizeFor added in v0.2.0

func MinWindowSizeFor(textSize TextSize) WindowSize

MinWindowSizeFor returns the smallest the window can be at a text size: MinWindowWidth by MinWindowHeight scaled by the text size, rounded up. The page's layout is then never narrower or shorter, in its own scaled units, than at the default text size.

func ReadWindowSize added in v0.2.0

func ReadWindowSize(ctx context.Context, store *prefs.Store) (WindowSize, error)

ReadWindowSize returns the size the window opens at, from the preferences in store: the stored size, or the default when none is stored or the stored one is no longer valid. Only the desktop shell reads the size on its own, so this is a function over the store rather than a method of the Service the window binds.

func WindowBounds added in v0.2.0

func WindowBounds(stored WindowSize, textSize TextSize, width, height int) (size, least WindowSize)

WindowBounds returns the size the window opens at, and the smallest it can be resized to, for the stored size at a text size on a screen area of the given width and height. The smallest is MinWindowSizeFor the text size, and the stored size grows to it; both then shrink, where needed, to fit the area (see Fit). A zero or negative area fits any size.

func (WindowSize) AtLeast added in v0.2.0

func (w WindowSize) AtLeast(least WindowSize) WindowSize

AtLeast returns the size grown, where needed, to least.

func (WindowSize) Fit

func (w WindowSize) Fit(width, height int) WindowSize

Fit returns the size shrunk, where needed, to fit a screen area of the given width and height, but never below the minimum. A zero or negative area leaves the size as it is.

Jump to

Keyboard shortcuts

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