Documentation
¶
Overview ¶
Package config manages user preferences for copilot-dispatch.
Configuration is stored as a JSON file inside the platform-specific config directory. When the file does not exist, sensible defaults are returned so the application can run without prior configuration.
Index ¶
Constants ¶
const ( // PaneDirectionAuto lets Windows Terminal choose the best split direction. PaneDirectionAuto = "auto" // PaneDirectionRight splits the pane to the right (vertical split). PaneDirectionRight = "right" // PaneDirectionDown splits the pane downward (horizontal split). PaneDirectionDown = "down" // PaneDirectionLeft splits the pane to the left. PaneDirectionLeft = "left" // PaneDirectionUp splits the pane upward. PaneDirectionUp = "up" )
PaneDirection constants control the split direction for pane mode.
const ( // PreviewPositionRight places the preview to the right of the session list. PreviewPositionRight = "right" // PreviewPositionBottom places the preview below the session list. PreviewPositionBottom = "bottom" // PreviewPositionLeft places the preview to the left of the session list. PreviewPositionLeft = "left" // PreviewPositionTop places the preview above the session list. PreviewPositionTop = "top" )
PreviewPosition constants control where the preview panel is displayed.
const ( // SortOrderAsc sorts results in ascending order. SortOrderAsc = "asc" // SortOrderDesc sorts results in descending order. SortOrderDesc = "desc" )
Sort order constants for DefaultSortOrder.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ColorScheme ¶ added in v0.10.7
type ColorScheme struct {
Name string `json:"name"`
Foreground string `json:"foreground"`
Background string `json:"background"`
CursorColor string `json:"cursorColor,omitempty"`
SelectionBackground string `json:"selectionBackground,omitempty"`
// Standard 8 ANSI colors.
Black string `json:"black"`
Red string `json:"red"`
Green string `json:"green"`
Yellow string `json:"yellow"`
Blue string `json:"blue"`
Purple string `json:"purple"`
Cyan string `json:"cyan"`
White string `json:"white"`
// Bright variants.
BrightBlack string `json:"brightBlack"`
BrightRed string `json:"brightRed"`
BrightGreen string `json:"brightGreen"`
BrightYellow string `json:"brightYellow"`
BrightBlue string `json:"brightBlue"`
BrightPurple string `json:"brightPurple"`
BrightCyan string `json:"brightCyan"`
BrightWhite string `json:"brightWhite"`
}
ColorScheme mirrors the Windows Terminal color scheme JSON object. All color values must be #RRGGBB hex strings.
func (*ColorScheme) Palette ¶ added in v0.10.7
func (cs *ColorScheme) Palette() [16]string
Palette returns the 16 ANSI colors in index order: [0]=Black, [1]=Red, …, [7]=White, [8]=BrightBlack, …, [15]=BrightWhite.
func (*ColorScheme) Validate ¶ added in v0.10.7
func (cs *ColorScheme) Validate() error
Validate checks that all required color fields are valid #RRGGBB values.
type Config ¶
type Config struct {
// ConfigVersion tracks the schema version of this config file. Used to
// detect and apply migrations when the config schema changes across
// dispatch releases. The current version is set by [currentConfigVersion].
ConfigVersion int `json:"config_version,omitempty"`
// DefaultShell is the preferred shell name (e.g. "pwsh", "bash", "zsh").
DefaultShell string `json:"default_shell"`
// DefaultTerminal is the preferred terminal emulator name
// (e.g. "Windows Terminal", "alacritty", "iTerm2").
DefaultTerminal string `json:"default_terminal"`
// DefaultTimeRange is the default time filter applied to session lists.
// Valid values: "1h", "1d", "7d", "all".
DefaultTimeRange string `json:"default_time_range"`
// DefaultSort is the field used to order session lists.
// Valid values: "updated", "created", "turns", "name", "folder".
DefaultSort string `json:"default_sort"`
// DefaultSortOrder is the direction used to order session lists.
// Valid values: "asc", "desc".
DefaultSortOrder string `json:"default_sort_order,omitempty"`
// DefaultPivot is the default grouping applied to session lists.
// Valid values: "none", "folder", "repo", "branch", "date".
DefaultPivot string `json:"default_pivot"`
// ShowPreview controls whether the detail/preview panel is visible.
ShowPreview bool `json:"show_preview"`
// MaxSessions is the maximum number of sessions to load initially.
MaxSessions int `json:"max_sessions"`
// YoloMode enables the --allow-all flag when resuming sessions,
// allowing the Copilot CLI to run commands without confirmation prompts.
YoloMode bool `json:"yoloMode"`
// Agent specifies the --agent <name> flag passed to the Copilot CLI
// when resuming sessions. Empty string means no agent override.
Agent string `json:"agent"`
// Model specifies the --model <name> flag passed to the Copilot CLI
// when resuming sessions. Empty string means no model override.
Model string `json:"model"`
// LaunchMode controls how sessions are opened:
// "in-place" — resume in the current terminal (replaces the TUI)
// "tab" — open in a new tab of the current terminal
// "window" — open in a new terminal window
// "pane" — open in a split pane (Windows Terminal only)
// Default is "tab" when unset.
LaunchMode string `json:"launch_mode,omitempty"`
// PaneDirection controls the split direction when LaunchMode is "pane":
// "auto" — let Windows Terminal choose (default)
// "right" — split to the right (vertical)
// "down" — split downward (horizontal)
// "left" — split to the left
// "up" — split upward
// Only used when LaunchMode is "pane" and the terminal is Windows Terminal.
PaneDirection string `json:"pane_direction,omitempty"`
// LaunchInPlace is deprecated; kept for backward compatibility.
// When LaunchMode is unset and LaunchInPlace is true, the effective
// mode is "in-place". New code should use LaunchMode.
LaunchInPlace bool `json:"launchInPlace"`
// ExcludedDirs is a list of directory paths to exclude from session
// listings. Sessions whose Cwd starts with any of these paths are hidden.
ExcludedDirs []string `json:"excluded_dirs,omitempty"`
// CustomCommand is a user-defined command that replaces the default
// copilot CLI resume command. The placeholder {sessionId} is replaced
// with the actual session ID at launch time. When set, YoloMode, Agent,
// and Model are ignored (they only apply to the default copilot CLI).
// Terminal and Shell settings are still used.
CustomCommand string `json:"custom_command,omitempty"`
// HiddenSessions is a list of session IDs that the user has chosen to
// hide from the main session list. They can be revealed with the
// "show hidden" toggle and unhidden individually.
HiddenSessions []string `json:"hiddenSessions,omitempty"`
// FavoriteSessions is a list of session IDs that the user has starred
// as favorites. They can be filtered with the "filter favorites" toggle.
FavoriteSessions []string `json:"favoriteSessions,omitempty"`
// AISearch enables Copilot SDK-powered AI search. When false (the
// default), only the local FTS5 index is used. Set to true to also
// query the Copilot backend for semantically relevant sessions.
AISearch bool `json:"ai_search,omitempty"`
// AttentionThreshold is the duration string (e.g. "15m", "1h") after
// which a running session with no activity is classified as "stale"
// instead of "waiting" or "active". Default is "15m".
AttentionThreshold string `json:"attention_threshold,omitempty"`
// Theme is the active color scheme name. "auto" (or empty) means
// detect from the terminal; any other value is looked up in Schemes
// and then the built-in scheme list.
Theme string `json:"theme,omitempty"`
// Schemes is a list of user-defined color schemes in Windows Terminal
// format. Users can paste any WT scheme JSON directly here.
Schemes []ColorScheme `json:"schemes,omitempty"`
// PreviewPosition controls where the session detail/preview panel
// is displayed relative to the session list.
// Valid values: "right", "bottom", "left", "top".
// Default is "right" when unset.
PreviewPosition string `json:"preview_position,omitempty"`
// DefaultCollapsed controls whether session header rows start in
// collapsed (single-line) or expanded (multi-line) state. When false
// (default), sessions are expanded showing full details. When true,
// sessions start collapsed showing only the compact indicator row.
DefaultCollapsed bool `json:"default_collapsed,omitempty"`
// ConversationNewestFirst controls the turn display order in the
// preview panel's Conversation section. When true (default), turns
// are shown newest-first (descending). When false, turns are shown
// oldest-first (ascending by TurnIndex).
ConversationNewestFirst bool `json:"conversation_newest_first"`
// WorkspaceRecovery enables detection of sessions interrupted by
// crash/reboot. When false, stale lock files are ignored. Default true.
WorkspaceRecovery bool `json:"workspace_recovery"`
}
Config holds the user's preferences.
func Default ¶
func Default() *Config
Default returns a Config populated with sensible default values.
func Load ¶
Load reads the configuration file from disk and returns the parsed Config. If the file does not exist, Load returns Default values with a nil error.
func (*Config) EffectiveAttentionThreshold ¶ added in v0.1.3
EffectiveAttentionThreshold returns the configured attention threshold as a time.Duration, defaulting to 15 minutes when unset or invalid.
func (*Config) EffectiveLaunchMode ¶
EffectiveLaunchMode returns the active launch mode, resolving the deprecated LaunchInPlace boolean when LaunchMode is unset.
func (*Config) EffectivePaneDirection ¶ added in v0.1.1
EffectivePaneDirection returns the configured pane direction, defaulting to "auto" when unset.
func (*Config) EffectivePreviewPosition ¶ added in v0.4.0
EffectivePreviewPosition returns the configured preview panel position, defaulting to "right" when unset or invalid.
func (*Config) EffectiveSortOrder ¶ added in v0.11.0
EffectiveSortOrder returns the configured sort order, defaulting to "desc" when unset or invalid.
type LaunchMode ¶ added in v0.1.1
type LaunchMode = string
LaunchMode describes how sessions are opened in the terminal.
const ( // LaunchModeInPlace resumes sessions in the current terminal. LaunchModeInPlace LaunchMode = "in-place" // LaunchModeTab opens sessions in a new terminal tab. LaunchModeTab LaunchMode = "tab" // LaunchModeWindow opens sessions in a new terminal window. LaunchModeWindow LaunchMode = "window" // LaunchModePane opens sessions in a split pane (Windows Terminal only). LaunchModePane LaunchMode = "pane" )
Launch mode constants.