Documentation
¶
Overview ¶
Package config handles loading, saving, and validating user configuration from JSON files, including project settings, plugin options, keymaps, and UI preferences.
Tasks plugin ¶
The embedded Tasks tab is off by default. It is turned on with the "tasks_plugin" feature flag, not with a plugin config key:
{
"features": { "flags": { "tasks_plugin": true } },
"plugins": { "tasks": { "position": "after-workspaces" } }
}
"position" is the anchor the Tasks tab is inserted after — either "after-workspaces" (the default) or "after-notes". Any other value is coerced back to the default by Validate. When the configured anchor is not registered, placement falls back to the other anchor, and then to the end of the tab list; see internal/plugins/assembly.
The resulting tab shortcut number is derived state. Tasks is not "tab N": disabling td-monitor, git-status, file-browser, conversations, or notes shifts it. Read the position from the registered plugin order, never from a hardcoded index.
There is deliberately no Tasks store or JSONL path here. The embedded Tasks package performs its own normal configuration resolution.
Index ¶
- Constants
- func AssertIsolatedPath(path string) error
- func CheckStateIsolation() error
- func ConfigPath() string
- func ExpandPath(path string) string
- func IsolationAsserted() bool
- func RealUserConfigDir() string
- func RealUserStateDir() string
- func ResetTestConfigPath()
- func ResetTestStateDir()
- func Save(cfg *Config) error
- func SaveCommunityTheme(communityName string, userOverrides map[string]interface{}) error
- func SaveGlobalTheme(tc ThemeConfig) error
- func SaveLastOpenInApp(projectPath, appID string) error
- func SaveProjectTheme(projectPath string, theme *ThemeConfig) error
- func SaveTheme(themeName string) error
- func SaveThemeWithOverrides(themeName string, overrides map[string]interface{}) error
- func SetConfigPath(path string)
- func SetTestConfigPath(path string)
- func SetTestStateDir(dir string)
- func StateDir() string
- type Config
- type ConversationsPluginConfig
- type FeaturesConfig
- type FileBrowserPluginConfig
- type GitStatusPluginConfig
- type KeymapConfig
- type NotesPluginConfig
- type PluginsConfig
- type ProjectConfig
- type ProjectsConfig
- type SidebarDisplayConfig
- type TDMonitorPluginConfig
- type TasksPluginConfig
- type ThemeConfig
- type UIConfig
- type WorkspacePluginConfig
- type WorktreeSetupConfig
Constants ¶
const ( // TasksPositionAfterWorkspaces places the Tasks tab immediately after the // workspaces tab. This is the default. TasksPositionAfterWorkspaces = "after-workspaces" // TasksPositionAfterNotes places the Tasks tab immediately after the notes // tab. TasksPositionAfterNotes = "after-notes" )
Tab positions for the Tasks plugin.
const AllowRealStateEnv = "SIDECAR_ALLOW_REAL_STATE"
AllowRealStateEnv opts a process out of the automatic isolation that applies to every `go test` binary. Set it to "1" only in a test that deliberately proves the ordinary, unisolated path still works — and only with HOME already pointed at a temp dir.
const IsolationEnv = "SIDECAR_ISOLATED_STATE"
IsolationEnv is the promise a harness makes: this process must never read or write the real user's Sidecar state. Set it to "1".
The promise exists because tmux isolation and state isolation are separate axes (td-8d18de). A proof run can hold a private tmux socket and still share ~/.local/state/sidecar with the developer's live Sidecar, in which case it rewrites a manifest that instance is watching. Asserting isolation turns every path that resolves back into the real tree into a hard error instead of a silent overwrite.
Variables ¶
This section is empty.
Functions ¶
func AssertIsolatedPath ¶ added in v0.93.0
AssertIsolatedPath returns an error when isolation is asserted and path resolves inside the real user state or config tree. It returns nil otherwise: an ordinary run is never blocked from writing its own real files.
func CheckStateIsolation ¶ added in v0.93.0
func CheckStateIsolation() error
CheckStateIsolation validates the paths this process actually resolved.
func IsolationAsserted ¶ added in v0.93.0
func IsolationAsserted() bool
IsolationAsserted reports whether this process claims isolated state.
A test binary asserts it by default. Isolation used to be opt-in, which meant the guard was silently inert in every package that had not thought about it, and `go test ./...` went on creating directories in the developer's real ~/.local/state/sidecar/projects tree — the same tree that holds the shell manifest td-8d18de destroyed. Defaulting to on makes forgetting to isolate a loud failure instead of a silent write.
func RealUserConfigDir ¶ added in v0.93.0
func RealUserConfigDir() string
RealUserConfigDir returns $HOME/.config/sidecar, likewise unoverridable.
func RealUserStateDir ¶ added in v0.93.0
func RealUserStateDir() string
RealUserStateDir returns the state directory an ordinary run would use, ignoring XDG_STATE_HOME and any test override: $HOME/.local/state/sidecar.
It deliberately derives the root from $HOME rather than from the pre-override value of XDG_STATE_HOME. A harness launches Sidecar as a subprocess with the override already in its environment, so the process has no way to observe what XDG_STATE_HOME was before isolation was applied. $HOME is the one anchor that is still visible from inside, and it is what the XDG default expands to.
func ResetTestConfigPath ¶
func ResetTestConfigPath()
ResetTestConfigPath clears the test config path override.
func ResetTestStateDir ¶ added in v0.75.0
func ResetTestStateDir()
ResetTestStateDir clears the test state directory override.
func Save ¶
Save writes the config to ~/.config/sidecar/config.json, preserving any keys it doesn't manage (e.g. "prompts").
func SaveCommunityTheme ¶
SaveCommunityTheme saves a community theme reference with optional user overrides. Only the scheme name is stored — the full palette is computed at runtime.
func SaveGlobalTheme ¶
func SaveGlobalTheme(tc ThemeConfig) error
SaveGlobalTheme saves a ThemeConfig as the global UI theme.
func SaveLastOpenInApp ¶ added in v0.75.0
SaveLastOpenInApp persists the last-used "open in" app ID. If projectPath matches a configured project, that project's LastOpenInApp is set. The global UI.LastOpenInApp is always set as a fallback.
func SaveProjectTheme ¶
func SaveProjectTheme(projectPath string, theme *ThemeConfig) error
SaveProjectTheme updates a specific project's theme in config and saves.
func SaveThemeWithOverrides ¶
SaveThemeWithOverrides saves a theme name and full overrides map to config.
func SetConfigPath ¶ added in v0.93.0
func SetConfigPath(path string)
SetConfigPath records the explicit config path (the -config flag) so that ConfigPath, and everything that derives a directory from it, follow it. Passing "" leaves the default in place.
func SetTestConfigPath ¶
func SetTestConfigPath(path string)
SetTestConfigPath sets a custom config path for testing. Call ResetTestConfigPath() in test cleanup to restore default behavior.
func SetTestStateDir ¶ added in v0.75.0
func SetTestStateDir(dir string)
SetTestStateDir sets a custom state directory for testing.
Types ¶
type Config ¶
type Config struct {
Projects ProjectsConfig `json:"projects"`
Plugins PluginsConfig `json:"plugins"`
Keymap KeymapConfig `json:"keymap"`
UI UIConfig `json:"ui"`
Features FeaturesConfig `json:"features"`
}
Config is the root configuration structure.
func LoadFrom ¶
LoadFrom loads configuration from a specific path. If path is empty, uses ~/.config/sidecar/config.json
func (*Config) WorktreeSetupForProject ¶ added in v0.94.0
func (c *Config) WorktreeSetupForProject(projectPath string) WorktreeSetupConfig
WorktreeSetupForProject returns the project override when present, otherwise the workspace-wide default.
type ConversationsPluginConfig ¶
type ConversationsPluginConfig struct {
Enabled bool `json:"enabled"`
ClaudeDataDir string `json:"claudeDataDir"`
// DefaultCategoryFilter sets the default session category filter on startup.
// Example: ["interactive"] hides cron/system sessions by default.
// Empty or omitted means show all sessions (no filter).
DefaultCategoryFilter []string `json:"defaultCategoryFilter,omitempty"`
}
ConversationsPluginConfig configures the conversations plugin.
type FeaturesConfig ¶
FeaturesConfig holds feature flag settings.
type FileBrowserPluginConfig ¶ added in v0.81.0
type FileBrowserPluginConfig struct {
// Enabled controls whether the file browser plugin is loaded. Default: true.
Enabled bool `json:"enabled"`
}
FileBrowserPluginConfig configures the file browser plugin.
type GitStatusPluginConfig ¶
type GitStatusPluginConfig struct {
Enabled bool `json:"enabled"`
RefreshInterval time.Duration `json:"refreshInterval"`
}
GitStatusPluginConfig configures the git status plugin.
type KeymapConfig ¶
KeymapConfig holds key binding overrides.
type NotesPluginConfig ¶
type NotesPluginConfig struct {
// DefaultEditor sets the default editor mode when pressing Enter on a note.
// Values: "builtin" (default), "vim", "nvim", or any $EDITOR value.
// When set to "vim"/"nvim", Enter opens the note in inline vim instead of built-in editor.
DefaultEditor string `json:"defaultEditor,omitempty"`
}
NotesPluginConfig configures the notes plugin.
type PluginsConfig ¶
type PluginsConfig struct {
GitStatus GitStatusPluginConfig `json:"git-status"`
TDMonitor TDMonitorPluginConfig `json:"td-monitor"`
FileBrowser FileBrowserPluginConfig `json:"file-browser"`
Conversations ConversationsPluginConfig `json:"conversations"`
Workspace WorkspacePluginConfig `json:"workspace"`
Notes NotesPluginConfig `json:"notes"`
Tasks TasksPluginConfig `json:"tasks"`
}
PluginsConfig holds per-plugin configuration.
type ProjectConfig ¶
type ProjectConfig struct {
Name string `json:"name"` // display name for the project
Path string `json:"path"` // absolute path to project root (supports ~ expansion)
Theme *ThemeConfig `json:"theme,omitempty"` // per-project theme (nil = use global)
LastOpenInApp string `json:"lastOpenInApp,omitempty"` // last app used to open this project (e.g. "vscode", "goland")
WorktreeSetup *WorktreeSetupConfig `json:"worktreeSetup,omitempty"` // optional per-project setup policy
}
ProjectConfig represents a single project in the project switcher.
type ProjectsConfig ¶
type ProjectsConfig struct {
Mode string `json:"mode"` // "single" for now
Root string `json:"root"` // "." default
List []ProjectConfig `json:"list"` // list of configured projects for switcher
}
ProjectsConfig configures project detection and layout.
type SidebarDisplayConfig ¶ added in v0.81.0
type SidebarDisplayConfig struct {
// HideRepoPrefix strips the repo name prefix from worktree names (e.g., "myrepo-feature" → "feature").
// Default: false (show full name).
HideRepoPrefix bool `json:"hideRepoPrefix"`
// HideAgent hides the agent type label (e.g., "claude") on the second line. Default: false.
HideAgent bool `json:"hideAgent"`
// HideTask hides the linked task ID (e.g., "td-abc123") on the second line. Default: false.
HideTask bool `json:"hideTask"`
// HideStats hides the +/- line change stats on the second line. Default: false.
HideStats bool `json:"hideStats"`
}
SidebarDisplayConfig controls visibility of workspace sidebar entry elements.
type TDMonitorPluginConfig ¶
type TDMonitorPluginConfig struct {
Enabled bool `json:"enabled"`
RefreshInterval time.Duration `json:"refreshInterval"`
DBPath string `json:"dbPath"`
}
TDMonitorPluginConfig configures the TD monitor plugin.
type TasksPluginConfig ¶ added in v0.95.0
type TasksPluginConfig struct {
// Position is the anchor the Tasks tab is inserted after. One of
// TasksPositionAfterWorkspaces (default) or TasksPositionAfterNotes.
// Unknown values are coerced back to the default by Validate.
//
// The resulting tab *number* is derived state: it depends on which
// preceding plugins are enabled, so no fixed shortcut number is promised.
Position string `json:"position,omitempty"`
}
TasksPluginConfig configures the embedded Tasks plugin.
Whether the plugin loads at all is governed by the "tasks_plugin" feature flag (default off), not by a field here — that keeps enablement on the same lever as the other opt-in surfaces (see internal/features).
There is deliberately no store/JSONL path: the embedded Tasks package uses Tasks' own configuration resolution.
type ThemeConfig ¶
type ThemeConfig struct {
Name string `json:"name"`
Community string `json:"community,omitempty"` // community scheme name (resolved at runtime)
Overrides map[string]interface{} `json:"overrides,omitempty"` // user customizations on top
}
ThemeConfig configures the color theme.
type UIConfig ¶
type UIConfig struct {
ShowClock bool `json:"showClock"`
Theme ThemeConfig `json:"theme"`
NerdFontsEnabled bool `json:"nerdFontsEnabled"` // enables Nerd Font glyphs (pill tabs, icons, etc.)
LastOpenInApp string `json:"lastOpenInApp,omitempty"` // global fallback for last app used to open projects
// TerminalTitle templates the terminal window/tab title. Supported
// variables: {project} {worktree} {plugin} {dir}. Empty disables retitling.
TerminalTitle string `json:"terminalTitle"`
}
UIConfig configures UI appearance.
type WorkspacePluginConfig ¶
type WorkspacePluginConfig struct {
// DirPrefix prefixes workspace directory names with the repo name (e.g., 'myrepo-feature-auth')
// This helps associate conversations with the repo after workspace deletion. Default: true.
DirPrefix bool `json:"dirPrefix"`
// DefaultAgentType sets the default agent family selected when creating a workspace.
// Uses workspace.AgentType values (e.g. "claude", "codex", "opencode", "grok").
DefaultAgentType string `json:"defaultAgentType,omitempty"`
// Agents is an ordered allowlist of agent type IDs shown in Create Shell, Create Worktree,
// and Start Agent pickers (e.g. ["claude","codex","grok"]). Empty/omitted shows all
// built-in UI agents. Unknown IDs are ignored. "None (attach only)" is always offered
// in pickers regardless of this list. Stored agent types on existing workspaces still
// resolve even if hidden from pickers.
Agents []string `json:"agents,omitempty"`
// AgentStart maps agent family (AgentType string) to default startup command.
// Example: {"claude":"claude", "opencode":"opencode --profile fast", "grok":"grok"}.
// Per-workspace .sidecar-agent-start still takes precedence when present.
AgentStart map[string]string `json:"agentStart,omitempty"`
// TmuxCaptureMaxBytes caps tmux pane capture size for the preview pane. Default: 2MB.
TmuxCaptureMaxBytes int `json:"tmuxCaptureMaxBytes"`
// AutoCreateShell creates a shell session the first time the workspaces tab is
// focused in a session, when no shell sessions exist yet. The shell honors
// DefaultAgentType; with none set it is a plain shell. Default: false.
AutoCreateShell bool `json:"autoCreateShell"`
// InteractiveExitKey is the keybinding to exit interactive mode. Default: "ctrl+\".
// Examples: "ctrl+]", "ctrl+\\", "ctrl+x"
InteractiveExitKey string `json:"interactiveExitKey,omitempty"`
// InteractiveAttachKey is the keybinding to attach from interactive mode. Default: "ctrl+]".
// When pressed in interactive mode, exits interactive and attaches to the tmux session.
InteractiveAttachKey string `json:"interactiveAttachKey,omitempty"`
// InteractiveCopyKey is the keybinding to copy selection in interactive mode. Default: "alt+c".
InteractiveCopyKey string `json:"interactiveCopyKey,omitempty"`
// InteractivePasteKey is the keybinding to paste clipboard in interactive mode. Default: "alt+v".
InteractivePasteKey string `json:"interactivePasteKey,omitempty"`
// CopyOnSelect copies terminal selections when a drag completes. Default: false.
CopyOnSelect bool `json:"copyOnSelect,omitempty"`
// SidebarDisplay controls what information is shown in the workspace sidebar entries.
SidebarDisplay SidebarDisplayConfig `json:"sidebarDisplay"`
// WorktreeSetup controls repository artifacts Sidecar may copy or execute when
// creating a worktree. The creation confirmation always names the discovered
// files and hook and requires an explicit per-operation selection.
WorktreeSetup WorktreeSetupConfig `json:"worktreeSetup"`
}
WorkspacePluginConfig configures the workspace plugin.
type WorktreeSetupConfig ¶ added in v0.94.0
type WorktreeSetupConfig struct {
CopyEnvFiles bool `json:"copyEnvFiles"`
EnvFiles []string `json:"envFiles,omitempty"`
RunHook bool `json:"runHook"`
HookPath string `json:"hookPath,omitempty"`
HookRequired bool `json:"hookRequired"`
}
WorktreeSetupConfig configures the optional setup phase after git creates a worktree. Paths are relative to the canonical main worktree.