config

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2026 License: MIT Imports: 7 Imported by: 0

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

View Source
const (
	// LaunchModeInPlace resumes sessions in the current terminal.
	LaunchModeInPlace = "in-place"
	// LaunchModeTab opens sessions in a new terminal tab.
	LaunchModeTab = "tab"
	// LaunchModeWindow opens sessions in a new terminal window.
	LaunchModeWindow = "window"
)

Launch mode constants.

Variables

This section is empty.

Functions

func Reset

func Reset() error

Reset deletes the config file, reverting to defaults on next Load.

func Save

func Save(cfg *Config) error

Save writes the given Config to disk as a JSON file. The parent directory is created if it does not already exist.

Types

type Config

type Config struct {
	// 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"`

	// 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 --yolo 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
	// Default is "tab" when unset.
	LaunchMode string `json:"launch_mode,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"`

	// 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"`

	// 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 []styles.ColorScheme `json:"schemes,omitempty"`
}

Config holds the user's preferences.

func Default

func Default() *Config

Default returns a Config populated with sensible default values.

func Load

func Load() (*Config, error)

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) EffectiveLaunchMode

func (c *Config) EffectiveLaunchMode() string

EffectiveLaunchMode returns the active launch mode, resolving the deprecated LaunchInPlace boolean when LaunchMode is unset.

Jump to

Keyboard shortcuts

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