configui

package
v1.17.1 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2026 License: MIT Imports: 35 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 configui owns Sidecar's Configuration surface: its route model, its sidebar/detail presentation, and the shared controls every Configuration page composes. It renders and answers input; it decides nothing about persistence. Reading and writing settings stays behind internal/config, so a page can be filled in later without moving the surface.

Index

Constants

View Source
const (
	// CaptureLimitDefault is the safe default, matching config.Default().
	CaptureLimitDefault = 2 * 1024 * 1024
	// CaptureLimitMin is the smallest capture Sidecar accepts.
	CaptureLimitMin = 256 * 1024
	// CaptureLimitMax is the largest capture Sidecar accepts.
	CaptureLimitMax = 64 * 1024 * 1024
)

The embedded terminal's capture limit is surfaced twice — plainly on Terminal and among the technical controls on Advanced — so its bounds, its clamp, and the way it is written for a human live here rather than in either page.

The bounds are deliberate: below the minimum a preview loses the scrollback that makes it worth showing, and above the maximum a single capture costs more memory than any preview is worth. config.Validate already refuses a non-positive value; this narrows an accepted value to a range Sidecar is willing to stand behind, for typed and selected input alike.

View Source
const (
	// LabelColumn is the width of the fixed left label column. It is wide
	// enough for the longest label any page actually uses ("Split workspace
	// terminal", "Terminal preview capture"): a shared column that truncates a
	// real setting's name is a broken column, not a page's problem to work
	// around.
	LabelColumn = 26
	// RowIndent is the left inset shared by rows inside a section.
	RowIndent = 2
	// ControlColumn is the column every control starts at, measured from the
	// pane's content origin.
	ControlColumn = RowIndent + LabelColumn
	// MaxControlWidth is the widest any fixed-width control asks to be drawn.
	MaxControlWidth = 48
	// MaxRowWidth caps the width a row lays its content out in. A row that
	// right-aligns a control — the ON/OFF pill on every panel switch — would
	// otherwise pin it to the pane's right edge, so widening the window drags
	// the pill away from the label it belongs to until the two are reading as
	// separate columns. Capping at the control column plus the widest control
	// puts that right edge exactly where the widest form field already ends, so
	// pills and fields share one edge instead of the pills drifting past it.
	MaxRowWidth = ControlColumn + MaxControlWidth
)

The Configuration surface aligns every page against one grid: labels occupy a fixed left column and their controls start at one shared column, so help text, completions, and nested pickers can align to the control rather than to the pane edge.

View Source
const (
	// ContextConfig is sidebar navigation and page-level actions.
	ContextConfig = "config"
	// ContextConfigEdit is an active editor — Search, or any future field.
	// Registered in the host's isTextInputContext so typing never leaks.
	ContextConfigEdit = "config-edit"
	// ContextConfigConfirm is a consequential change awaiting confirmation.
	ContextConfigConfirm = "config-confirm"
)

Keymap contexts owned by Configuration. They are registered in internal/keymap/bindings.go, which is what drives the footer, the help modal, and the command palette.

View Source
const DefaultPage = PageSetup

DefaultPage is where the gear, the palette command, and `sidecar setup` all land. Configuration deliberately does not remember the last section.

View Source
const (

	// DocsURL is Sidecar's documentation site, the address the website itself
	// is published at (website/static/CNAME).
	DocsURL = "https://sidecar.haplab.com"
)

Variables

View Source
var CaptureLimitChoices = []int{
	256 * 1024,
	512 * 1024,
	1024 * 1024,
	2 * 1024 * 1024,
	4 * 1024 * 1024,
	8 * 1024 * 1024,
	16 * 1024 * 1024,
	32 * 1024 * 1024,
	64 * 1024 * 1024,
}

CaptureLimitChoices are the values the selector offers, smallest first. Every one of them is inside the accepted range. A configuration may still hold a value between two of them — Advanced accepts a typed size — which the list offers no rung for and the closed control reports as it is stored.

Functions

func BackBar

func BackBar(title, parent string, width int, state State) string

BackBar is the top row of a focused child route: the route's own title on the left and the visible parent-return control on the right. Escape does the same thing the control does.

func BackControl

func BackControl(parent string, state State) string

BackControl renders the parent-return control on its own, for callers that place it outside a bar.

func Badge

func Badge(text string, urgent bool) string

Badge renders a row's action label. A badge on a problem row is the accent call to action; a badge on a healthy row is a quiet way in, so it must not shout at a user who has nothing to fix.

func BetaBadge

func BetaBadge() string

BetaBadge marks an integration Sidecar is still shipping as a preview. It stays on the row after the integration is enabled: turning something on does not make it finished.

func Body

func Body(text string) string

Body renders ordinary primary text.

func Button

func Button(label string, primary bool, state State) string

Button renders an action pill. primary marks the action the page recommends.

func ButtonRow

func ButtonRow(buttons ...string) string

ButtonRow joins rendered buttons into one indented row.

func CaptureLimitRange

func CaptureLimitRange() string

CaptureLimitRange writes the accepted range the way the help line states it, so the documented bounds and the enforced ones are the same two numbers.

func Centered

func Centered(content string, width int) string

Centered places already-styled content in the middle of the pane, for the small amount of Configuration that is a signature rather than a control.

func ClampCaptureLimit

func ClampCaptureLimit(bytes int) int

ClampCaptureLimit narrows a value to the accepted range. A missing or nonsensical value becomes the safe default rather than the nearest bound: zero means "unset", not "as small as possible".

func CodeChip

func CodeChip(text string) string

CodeChip renders a command or a literal the user may copy or run.

func ControlWidth

func ControlWidth(inner, preferred int) int

ControlWidth is how wide a fixed-width control may actually be drawn: the width the page asked for, or everything the pane has left after the label column, whichever is smaller. A page that insists on its full width in a narrow terminal does not get a wide field — it gets a field with its right half cut off, which is the one thing the brief's narrow-terminal rule rules out.

func DropdownRow(label, desc string, width int, state State) string

DropdownRow paints one choice in an open list. The list is opaque — every row carries its own background — because it is drawn over content that is still there underneath.

func Field

func Field(input *textinput.Model, width int, state State) string

Field renders a text field at the shared control column. An editable field looks editable at rest and unmistakably active while it owns the keyboard.

func FormRow

func FormRow(label, control string, state State) string

FormRow renders a labelled control: the label in the fixed left column, the control starting at the shared column.

func FormatCaptureLimit

func FormatCaptureLimit(bytes int) string

FormatCaptureLimit writes a capture limit the way a person reads it.

func FormatKeyLabel

func FormatKeyLabel(key string) string

FormatKeyLabel writes a key string the way the mockups show it — Ctrl+\ — without changing the stored value, which stays in the form a key press produces.

func HelpLine

func HelpLine(text string) string

HelpLine renders muted help aligned to the control it belongs to, not to the pane edge.

func HighlightBlock

func HighlightBlock(content string, width int, state State) string

HighlightBlock applies HighlightRow to every line of a multi-line control.

func HighlightRow

func HighlightRow(content string, width int, state State) string

HighlightRow fills a list row so selection is the whole line, not just the label. Focused and hovered rows keep their existing text colour and sit on a darker surface, which is what makes the cursor readable on a dark theme.

func Indented

func Indented(text string) string

Indented renders body text at the shared row indent.

func IndentedMuted

func IndentedMuted(text string) string

IndentedMuted renders quieter text at the shared row indent.

func IndentedRaw

func IndentedRaw(content string) string

IndentedRaw places already-styled content at the shared row indent.

func ListRow

func ListRow(text string, width int, state State) string

ListRow renders a focusable row that fills the pane width, so the whole row is legibly the control.

func Muted

func Muted(text string) string

Muted renders quieter secondary text.

func NearestCaptureLimit

func NearestCaptureLimit(bytes int) int

NearestCaptureLimit is the rung a stored value sits on or just above: the largest choice no greater than it, or the smallest choice when it is below them all. It is what a list opens on when the configuration holds a size Advanced accepted as free text, so pressing Enter on an off-ladder value can only ever round it down to the next real rung rather than collapse it to the smallest one.

func PageTitle

func PageTitle(id PageID) string

PageTitle returns the display title for a page ID.

func PaneTitle

func PaneTitle(text string) string

PaneTitle is the page or pane title at the top of a pane, with the breathing room the design brief asks for supplied by the caller's blank line.

func PanelRow

func PanelRow(title, badge, detail, control string, width int, state State) string

PanelRow is one surface on Panels & Integrations: the whole two-line block is the control, with its ON/OFF state as a distinct pill at the right edge. The name and the pill share a line so the state is legible at a glance; the description sits underneath in the muted column so it never competes with the pill for space.

func ParseCaptureLimit

func ParseCaptureLimit(value string) int

ParseCaptureLimit reads a typed capture limit — "4 MB", "512kb", or a plain byte count — and returns a value inside the accepted range. Blank or unreadable input keeps the safe default rather than being refused: this setting has no meaningful "unset", and a technical control should not trap a user in an error state over a typo.

func RepairRow

func RepairRow(badge, title, detail string, width int, state State) string

RepairRow is Sidecar Setup's actionable row: a leading badge, the work stated as something to do, and a quieter line saying why. The whole two-line block is one control.

func RowWidth added in v1.4.0

func RowWidth(inner int) int

RowWidth is the width a row lays its content out in: everything the pane has to give, but never more than MaxRowWidth. Rows stay left-aligned in the pane and simply stop growing, which is what keeps a right-aligned control near its label on a wide terminal.

func SaveCmd

func SaveCmd(notice string, save func() error) tea.Cmd

SaveCmd wraps a Load→mutate→Save call as a command.

func SectionHeader

func SectionHeader(text string) string

SectionHeader titles a group of controls. It carries its own leading blank line so sections separate by whitespace rather than by divider lines.

func Selector

func Selector(value string, state State) string

Selector renders a value with a disclosure arrow.

func SelectorArrow

func SelectorArrow(value, arrow string, state State) string

SelectorArrow renders a selector whose arrow says which way it opens: ▾ for a closed disclosure, ▴ for one already expanded below the field.

func SelectorWidth

func SelectorWidth(value string, width int, state State) string

SelectorWidth renders a selector that fills a fixed width, so several selectors in a group share one right edge the way the mockups draw them.

func SelectorWidthArrow

func SelectorWidthArrow(value, arrow string, width int, state State) string

SelectorWidthArrow is SelectorWidth with the arrow the control's own state asks for: ▾ while its list is closed, ▴ while it is open over the page.

func StaticField

func StaticField(value string, width int, state State) string

StaticField renders a value that is edited elsewhere — a placeholder for an unfocused field, drawn like the field it becomes.

func StatusRow

func StatusRow(ok bool, label, detail, badge string, width int, state State) string

StatusRow renders a diagnostic row.

A healthy row with nothing to do is one quiet line: marker, label, and its detail in the shared control column. A row that offers an action carries a badge at the right edge and moves its detail to a second line, so the badge and the detail never compete for the same run of space. Both forms are one control: the caller registers the whole block.

func Swatch

func Swatch(colors []string) string

Swatch renders a theme's four identifying colors as solid blocks.

func Toggle

func Toggle(on bool, state State) string

Toggle renders an ON/OFF pill. The pill is the control; FormRow supplies the label column around it.

func ToggleWidth

func ToggleWidth(on bool, width int, state State) string

ToggleWidth renders an ON/OFF pill that fills a fixed width, so a group of toggles and selectors shares one right edge the way the mockups draw them.

func ValidateInteractiveKey

func ValidateInteractiveKey(value string) error

ValidateInteractiveKey reports whether a value is a key string Sidecar can match against a real key press. It requires a modifier: a bare character would be swallowed the moment the user typed it into the terminal.

func Warning

func Warning(text string) string

Warning states an observed problem in the repair route that fixes it.

func WrapAt

func WrapAt(text string, inner, indent int, style func(string) string) string

WrapAt lays a paragraph out inside a pane: every line is indented to the same column and no line runs past the pane's writable width. It returns one string with embedded newlines, which the pane builder splits into painted rows, so wrapped help still counts for hit regions and the height clamp.

Types

type CheckUpdatesMsg

type CheckUpdatesMsg struct{}

CheckUpdatesMsg asks the host to run its release check again, bypassing the per-product cache.

type ChecksMsg

type ChecksMsg struct {
	Results configchecks.Results
}

ChecksMsg carries a completed run back to the surface. The host forwards it; the surface owns the cache.

type ChildID

type ChildID string

ChildID identifies a focused route hosted by a page — a repair, an add form, an inline picker. Later phases add their own; the empty ChildID means "the page itself".

const (
	ChildRepairTmux              ChildID = "repair-tmux"
	ChildRepairTerminalColors    ChildID = "repair-terminal-colors"
	ChildRepairAgentInstructions ChildID = "repair-agent-instructions"
	ChildRepairConfiguration     ChildID = "repair-configuration"
)

Child route IDs. They are exported because later phases route to the same repairs from their own pages — the Agents page opens the agent-instructions route rather than building a second one.

const (
	ChildNotificationAgentRules ChildID = "notification-agent-rules"
	ChildNotificationOtherRules ChildID = "notification-other-rules"
	ChildNotificationQuietHours ChildID = "notification-quiet-hours"
	ChildNotificationSoundPaths ChildID = "notification-sound-paths"
	ChildNotificationStatus     ChildID = "notification-status"
	ChildNotificationSourceRule ChildID = "notification-source-rule"
	ChildNotificationSSH        ChildID = "notification-ssh"
)
const (
	ChildAddProject  ChildID = "add-project"
	ChildEditProject ChildID = "edit-project"
)
const (
	ChildAddRemote  ChildID = "add-remote"
	ChildEditRemote ChildID = "edit-remote"
)
const ChildAgentIntegrations ChildID = "agent-integrations"

ChildAgentIntegrations is the focused route listing agent integrations.

const ChildEnableIntegration ChildID = "enable-integration"

ChildEnableIntegration is the enable route.

const (
	// ChildNone is the page's own route.
	ChildNone ChildID = ""
)

type CloseConfigMsg added in v1.7.0

type CloseConfigMsg struct{}

CloseConfigMsg asks the host to put Configuration away; the chips' Close affordance has no page-local close to call.

type ConfigSavedMsg

type ConfigSavedMsg struct {
	// Notice is the toast text on success.
	Notice string
	// Err is a failure message, empty on success.
	Err string
}

ConfigSavedMsg reports a completed write. The host reloads the configuration, reapplies anything it snapshots at startup, and hands the surface fresh state — so this is the one message Configuration cannot handle by itself.

type CopyMsg

type CopyMsg struct {
	Text string
	// Notice is what the toast should say on success.
	Notice string
}

CopyMsg asks the host to put text on the clipboard and say so. Configuration does not own the clipboard or the toast, so it asks.

type Group

type Group struct {
	Title string
	Pages []Page
}

Group is a titled run of sidebar destinations.

func Groups

func Groups() []Group

Groups returns the sidebar's groups in order.

type HostState

type HostState struct {
	// Config is the configuration the app is running with.
	Config *config.Config
	// ProjectDir is the active working directory.
	ProjectDir string
	// OpenInApps are the applications the host can open a project in, in the
	// order it offers them. Configuration only names them; opening is the
	// host's job.
	OpenInApps []OpenInApp
	// ProjectPath is the configured project the working directory belongs to,
	// resolved through worktrees. Empty when the current directory is not one of
	// the user's configured projects — which is exactly when a project-scoped
	// setting must not be offered.
	ProjectPath string
	// Version is the version string the running Sidecar resolved for itself.
	Version string
	// Update is the release check the app already runs at startup. Configuration
	// reports it and hands an available update to the existing updater; it never
	// checks, downloads, or installs anything itself.
	Update UpdateStatus
	// RemoteHosts is each registered machine's condition as the running host
	// registry knows it. Configuration reports it and never probes: a settings
	// screen with its own ssh connection would be a second answer to a question
	// the registry is already answering, and the two would disagree the moment
	// one was slower than the other.
	//
	// Note the name. HostState above is about the Sidecar hosting this surface;
	// these are the other machines it watches. The two senses of "host" meet
	// only here, so everything about the remote sense says "remote".
	RemoteHosts []RemoteHost
}

HostState is what the running Sidecar tells Configuration about itself.

type IndexEntry

type IndexEntry struct {
	Page     PageID
	Label    string
	Keywords []string
}

IndexEntry is one searchable setting: the page it lives on, the label the user would recognize, and extra words they might type instead.

This is a hand-written static index, deliberately not a schema. A phase that adds real controls to a page appends its entries here — one entry per control the user could reasonably search for — and search keeps working with no other change.

func Index

func Index() []IndexEntry

Index returns the full settings index: the static entries above plus one per registered feature flag.

func Search(query string) []IndexEntry

Search returns the index entries matching a query, in index order. An empty or whitespace-only query matches nothing: search is a filter the user opts into, not a default view.

type Integration

type Integration struct {
	// ID is the plugin's descriptor ID, used for region IDs and probe lookups.
	ID string
	// Name is what the user calls it.
	Name string
	// Why is one line saying what enabling it gets the user.
	Why string
	// Descriptor names the command and the formula. A zero Descriptor means the
	// integration ships inside Sidecar and has nothing to install — Notes is
	// exactly that, and it must never reach the enable route.
	Descriptor version.Descriptor
}

Integration is the install half of a plugin descriptor: what the enable route needs to check a command, offer a confirmed install, and explain a failure. It is a projection of plugin.Descriptor rather than a second catalog — enablement itself belongs to the descriptor, which knows the config key.

func TasksIntegration

func TasksIntegration() Integration

TasksIntegration is the Tasks command suite: a real external product with a Homebrew formula, so enabling it can genuinely fail for a reason Sidecar can explain and offer to fix.

It exists apart from the injected catalog because probeCommands runs before anything has handed this surface a descriptor list, and what to look for on PATH cannot wait for that.

func (Integration) NeedsCommand

func (i Integration) NeedsCommand() bool

NeedsCommand reports whether enabling this integration depends on something outside Sidecar.

type Model

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

Model is the Configuration surface. It owns navigation, search, and the per-surface mouse hit map; it owns no configuration data.

func New

func New() *Model

New builds the surface. It performs no I/O, so it is safe on the startup path; nothing here runs until the user opens Configuration.

func (*Model) AddProjectLocation added in v1.3.0

func (m *Model) AddProjectLocation() string

PrefillAddProjectFromDir puts the current working directory in Location (and Name, if empty) so a first-run user can add this folder without hunting for it. Completions stay user-initiated: a prefilled path still asks for candidates. AddProjectLocation is the Location field on the open Add/Edit Project form.

func (*Model) ApplyChecks

func (m *Model) ApplyChecks(msg ChecksMsg)

ApplyChecks caches a completed run.

func (*Model) Back

func (m *Model) Back() bool

Back returns from a focused child route to its parent. It reports false when there is nothing to return to.

Returning restores the parent page's own state: the sidebar destination never moved, and the row cursor starts at the top of the page the user came from rather than at whatever index the child happened to leave behind.

func (*Model) Checks

func (m *Model) Checks() configchecks.Results

Checks are the cached results.

func (*Model) ChecksReady

func (m *Model) ChecksReady() bool

ChecksReady reports whether a run has completed.

func (*Model) ClearSearch

func (m *Model) ClearSearch()

ClearSearch drops the query and restores the full sidebar.

func (*Model) Close

func (m *Model) Close()

Close records the position Reopen restores. The host calls it as the surface goes away, which is the only moment that position is still known.

It also puts back a theme the surface was only previewing. A preview belongs to the screen that started it, and closing Configuration is one more way of leaving that screen: Escape restores it, moving to another page restores it, and closing must too, or a theme nobody saved outlives the surface that could have undone it.

func (*Model) Commands

func (m *Model) Commands() []plugin.Command

Commands describes what the footer and palette may advertise here. Keys come from the registered bindings, never from this list.

func (*Model) Config

func (m *Model) Config() *config.Config

Config is the running configuration, never nil.

func (*Model) DismissConfirm

func (m *Model) DismissConfirm() bool

DismissConfirm cancels a pending confirmation. Escape reaches it before it means "go back": the change on screen is what the user is answering.

func (*Model) Escape

func (m *Model) Escape() bool

Escape answers esc for everything the surface owns, innermost first: the field being typed into, a pending confirmation, an inline picker, the sidebar search, then a focused child route. It reports false when nothing on screen needed dismissing, which is the host's signal to close Configuration.

func (*Model) FocusContext

func (m *Model) FocusContext() string

FocusContext is the keymap context the surface owns right now.

func (*Model) FocusNotesPreference added in v1.2.0

func (m *Model) FocusNotesPreference()

FocusNotesPreference opens the page that owns Notes enablement and puts the detail cursor on its existing toggle. Setup surfaces use this rather than inventing a second Notes setting.

func (*Model) Handle

func (m *Model) Handle(msg Msg) tea.Cmd

Handle answers a surface-owned message.

func (*Model) Key

func (m *Model) Key(msg tea.KeyPressMsg) (bool, tea.Cmd)

Key handles a key press. It reports whether the surface consumed it; the host keeps unconsumed keys away from the plugin hidden underneath.

func (*Model) Mouse

func (m *Model) Mouse(msg tea.MouseMsg) tea.Cmd

Mouse handles a mouse event whose coordinates are local to the content area.

func (*Model) Navigate

func (m *Model) Navigate(page PageID)

Navigate moves to a sidebar destination, abandoning any child route.

func (*Model) Open

func (m *Model) Open(page PageID)

Open resets the surface onto a destination. Configuration always opens with the sidebar focused and no query, so Up/Down works immediately.

func (*Model) OpenAddProject

func (m *Model) OpenAddProject()

OpenAddProject opens the Add Project route with Location focused. The diagnostics "no projects" repair and Setup's "Add a project" row both land here, which is why focusing the field is part of opening it.

func (*Model) OpenAddRemote added in v1.11.0

func (m *Model) OpenAddRemote()

OpenAddRemote opens the Add host route with Target focused: the target is the one field with no useful default, and every other field can be left alone.

func (*Model) OpenAgentInstructions

func (m *Model) OpenAgentInstructions()

OpenAgentInstructions opens the agent-instructions repair as a child of the current page. The Agents page uses this in a later phase; Diagnostics uses it now. Both get the same route, with the same parent-return.

func (*Model) OpenAgentIntegrations added in v1.11.0

func (m *Model) OpenAgentIntegrations()

OpenAgentIntegrations pushes the route and starts discovery.

func (*Model) OpenEditProject

func (m *Model) OpenEditProject(path string)

OpenEditProject opens the same form over an existing project.

func (*Model) OpenEditRemote added in v1.11.0

func (m *Model) OpenEditRemote(id string)

OpenEditRemote opens the same form over a registered machine.

func (*Model) OpenRepair

func (m *Model) OpenRepair(repair configchecks.RepairID) bool

OpenRepair opens the focused route for a repair hint from the current page. It reports false for a hint with no route of its own — today, adding a project, which is a page rather than a repair.

func (*Model) Page

func (m *Model) Page() PageID

Page is the destination the sidebar highlights.

func (*Model) PluginDescriptors added in v1.14.0

func (m *Model) PluginDescriptors() []plugin.Descriptor

PluginDescriptors is the catalog this surface renders.

func (*Model) PrefillAddProjectFromDir added in v1.3.0

func (m *Model) PrefillAddProjectFromDir(dir string)

func (*Model) PreviewingTheme

func (m *Model) PreviewingTheme() bool

PreviewingTheme reports that a picker has a live preview on screen. The host must not apply the disk theme over it when some other setting is saved.

func (*Model) ProbeCmd

func (m *Model) ProbeCmd() tea.Cmd

ProbeCmd looks for the commands Configuration reports on. It runs through the same Env seam the readiness checks use, so a test describes a machine instead of having one.

func (*Model) PushChild

func (m *Model) PushChild(child ChildID, title string)

PushChild opens a focused child route with parent-return behavior. The parent's own selection is remembered here, which is what "returning restores the parent page" means in practice.

func (*Model) Query

func (m *Model) Query() string

Query is the live search query.

func (*Model) Recheck

func (m *Model) Recheck() tea.Cmd

Recheck runs every check in a command. It is explicit everywhere: no repair infers success from a shell closing or a file being saved.

func (*Model) RefreshNotificationProbe added in v1.11.0

func (m *Model) RefreshNotificationProbe()

RefreshNotificationProbe invalidates any in-flight result and queues a fresh capability and config check against the current host state. The app calls it after a successful save, including while an earlier probe is still running.

func (*Model) Reopen

func (m *Model) Reopen()

Reopen puts the surface back where it was when it last closed: the same section, the same place in the sidebar, and the same row in the detail pane. It is what the gear and the settings key ask for, so toggling Configuration off and on is not a way to lose your place. Nothing to resume — the first open of the session — starts on the default page.

func (*Model) Route

func (m *Model) Route() Route

Route is the visible route, including any focused child.

func (*Model) SearchActive

func (m *Model) SearchActive() bool

SearchActive reports that a query is still narrowing the sidebar, whether or not the input has focus. Escape clears that before it closes Configuration.

func (*Model) SearchFocused

func (m *Model) SearchFocused() bool

SearchFocused reports that Search has the keyboard, so every printable key belongs to it.

func (*Model) SetCheckInput

func (m *Model) SetCheckInput(in configchecks.Input)

SetCheckInput tells the surface what to check. The host supplies the running configuration and the active project each time Configuration opens, so a project switch cannot leave stale answers behind.

func (*Model) SetHostState

func (m *Model) SetHostState(state HostState)

SetHostState refreshes the surface's view of the running Sidecar. The host calls it when Configuration opens and after every save.

func (*Model) SetInstallEnvironment

func (m *Model) SetInstallEnvironment(env *version.Environment)

SetInstallEnvironment substitutes the process environment the enable route installs through.

func (*Model) SetIntegrationService added in v1.11.0

func (m *Model) SetIntegrationService(svc *agentintegration.Service)

SetIntegrationService overrides the application service this route uses.

It exists for tests, which must describe a machine rather than have one: without it every test of this route would inspect, and its mutation tests would rewrite, the developer's real provider configuration.

func (*Model) SetPluginDescriptors added in v1.14.0

func (m *Model) SetPluginDescriptors(descriptors []plugin.Descriptor)

SetPluginDescriptors gives the surface the plugin catalog it renders.

It is injected rather than read directly because the plugin packages import internal/app, which owns this surface, so importing the catalog here would be an import cycle. The host passes assembly.Descriptors().

func (*Model) SetRemoteHosts added in v1.11.0

func (m *Model) SetRemoteHosts(remotes []RemoteHost)

SetRemoteHosts refreshes only the registered machines' health. The app calls it whenever a host's condition changes while Configuration is open.

It is deliberately narrower than SetHostState: health changes on the registry's own cadence, several times a minute, and pushing a whole host state that often would re-run syncHostState — which would snap a live theme preview back to the saved theme while a user was still looking at it.

func (*Model) TakePending added in v1.3.0

func (m *Model) TakePending() tea.Cmd

TakePending returns commands queued outside a key handler — a directory listing, a git probe — so the host can run them after a programmatic open.

func (*Model) View

func (m *Model) View(width, height int) string

View renders the whole Configuration content area. It never returns more rows than height: the host's header and footer must stay on screen.

func (*Model) WheelAtBoundary

func (m *Model) WheelAtBoundary(msg tea.MouseWheelMsg) bool

WheelAtBoundary reports that a wheel event over Configuration cannot change anything currently under the pointer. The theme list and an open dropdown are the surfaces that scroll; everything else is unknown.

type Msg

type Msg interface {
	// contains filtered or unexported methods
}

Msg is a message the Configuration surface sends itself. The host forwards anything implementing it back into Handle without needing to know what it is, which keeps asynchronous work (a directory listing, a save) in commands without adding a host case per message.

type NoticeMsg

type NoticeMsg struct {
	Message string
}

NoticeMsg asks the host for a toast.

type NotificationConfigValidationMsg added in v1.11.0

type NotificationConfigValidationMsg struct {
	Generation uint64
	Err        string
}

NotificationConfigValidationMsg reports the asynchronous custom-path and notification-config validation requested by Delivery status. Validation may touch the filesystem, so it never runs from View.

type NotificationDeliveryStatusMsg added in v1.11.0

type NotificationDeliveryStatusMsg struct {
	Generation uint64
	Status     notifydelivery.Status
}

NotificationDeliveryStatusMsg carries a completed read-only probe back to the Configuration surface.

type NotificationTestResultMsg added in v1.11.0

type NotificationTestResultMsg struct{ Result notifydelivery.Result }

NotificationTestResultMsg carries one explicit test result back to the page.

type OpenFileMsg

type OpenFileMsg struct {
	Path string
}

OpenFileMsg asks the host to put a file in front of the user.

type OpenInApp

type OpenInApp struct {
	ID   string
	Name string
}

OpenInApp is one application in the host's "open in" list.

type OpenPaletteMsg

type OpenPaletteMsg struct{}

OpenPaletteMsg asks the host to open the command palette.

type OpenShellMsg

type OpenShellMsg struct {
	Command string
}

OpenShellMsg asks the host to open an ordinary Sidecar shell with a command typed into it. The command is never executed by Sidecar — the user reads it and presses Enter, or does not.

type OpenURLMsg

type OpenURLMsg struct {
	URL string
}

OpenURLMsg asks the host to open a URL with the desktop's opener.

type OpenUpdaterMsg

type OpenUpdaterMsg struct{}

OpenUpdaterMsg asks the host to open Sidecar's existing updater. Configuration does not own release notes, confirmation, progress, or install behavior, so it asks for the surface that does.

type Page

type Page struct {
	ID    PageID
	Title string
}

Page is one sidebar destination.

func AllPages

func AllPages() []Page

AllPages returns every destination in sidebar order.

type PageID

type PageID string

PageID identifies a Configuration destination. It is the stable name later phases route to, so it is deliberately independent of the sidebar's order and of the page's display title.

const (
	PageSetup         PageID = "setup"
	PageAppearance    PageID = "appearance"
	PageProjects      PageID = "projects"
	PageWorkspaces    PageID = "workspaces"
	PageRemotes       PageID = "remotes"
	PageAgents        PageID = "agents"
	PageNotifications PageID = "notifications"
	PageTerminal      PageID = "terminal"
	PagePanels        PageID = "panels"
	PageDiagnostics   PageID = "diagnostics"
	PageFlags         PageID = "flags"
	PageAdvanced      PageID = "advanced"
	PageAbout         PageID = "about"
)

func SearchPages

func SearchPages(query string) []PageID

SearchPages returns the pages that have at least one matching setting, in sidebar order.

type ProbeNotificationDeliveryMsg added in v1.11.0

type ProbeNotificationDeliveryMsg struct{ Generation uint64 }

ProbeNotificationDeliveryMsg asks the app host to run the lazy provider probes. It is emitted only after the Notifications page is entered.

type RemoteHost added in v1.11.0

type RemoteHost struct {
	// ID is the name the host is registered under.
	ID string
	// State is the health state's name, as hosts.State spells it.
	State string
	// Detail is what went wrong, when anything did.
	Detail string
	// Fix names what to do about the state, in the imperative. Empty for the
	// states that need nothing done.
	Fix string
	// Connected reports a machine whose rows are current, so a page can say
	// "watching" without having to know every state name.
	Connected bool
}

RemoteHost is one registered machine's live condition.

It carries the state's own fix line rather than leaving the page to write one, so the row a user reads in Configuration and the row they read in the Sessions browser say the same thing about the same machine.

type Route

type Route struct {
	Page  PageID
	Child ChildID
	// Title is what the child route calls itself. Empty for a page route.
	Title string
}

Route is one explicit Configuration state: a page, optionally with a focused child route open on top of it. Routes are a stack with parent-return, not stacked modals — a child knows the page it returns to, and Escape or the visible Back control returns there without applying anything.

func (Route) IsChild

func (r Route) IsChild() bool

IsChild reports that this route is a focused child of its page.

type State

type State struct {
	Focused bool
	Hovered bool
	// Disabled marks a control the current environment cannot offer.
	Disabled bool
}

State is the interaction state of a control. Every control renders rest, focus, and hover distinctly so keyboard and mouse describe the same surface.

type TestNotificationDeliveryMsg added in v1.11.0

type TestNotificationDeliveryMsg struct {
	Event  notifydelivery.TestEvent
	Source notify.SourceID
}

TestNotificationDeliveryMsg asks the host to exercise enabled channels through its shared delivery service. It never creates a centre record.

type UpdateStatus

type UpdateStatus struct {
	// Checked is true once a check has settled, successfully or not.
	Checked bool
	// Failed marks a check that could not complete.
	Failed bool
	// Available marks a real available update.
	Available bool
	// AnyPending marks any updater work worth opening the surface for:
	// another product's pending update included, not just Sidecar's own.
	AnyPending bool
	// LatestVersion is the release a user would move to.
	LatestVersion string
}

UpdateStatus is the app's release check as About needs to state it. It deliberately distinguishes "not checked yet" and "the check failed" from "up to date": an unknown answer must never be reported as reassurance.

Jump to

Keyboard shortcuts

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