config

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package config provides application configuration from database.

Package config provides application configuration including keybindings.

Index

Constants

View Source
const (
	SettingProjectsDir      = "projects_dir"
	SettingTheme            = "theme"
	SettingDetailPaneHeight = "detail_pane_height"
	// SettingShellPaneWidth is the fallback shell pane width, used for tasks
	// that have never been resized. A task's own width lives under
	// ShellPaneWidthKey; see that function.
	SettingShellPaneWidth        = "shell_pane_width"
	SettingShellPaneHidden       = "shell_pane_hidden"
	SettingIdleSuspendTimeout    = "idle_suspend_timeout"
	SettingServerURL             = "server_url"
	SettingWorktreeCleanupMaxAge = "worktree_cleanup_max_age"
	// SettingTrashRetention is how long a soft-deleted (trashed) task stays
	// recoverable before the daemon sweep hard-deletes it. Value is a Go duration
	// string (e.g. "336h"); "0" or "disabled" turns the sweep off (trash kept
	// forever). See DefaultTrashRetention.
	SettingTrashRetention = "trash_retention"
	// SettingHTTPAPIPort is the port the daemon-hosted HTTP API listens on.
	SettingHTTPAPIPort = "http_api_port"
	// SettingHTTPAPIDisabled, when "true", stops the daemon from hosting the
	// HTTP API (for headless/security-sensitive boxes). The API is on by default.
	SettingHTTPAPIDisabled = "http_api_disabled"

	// SettingReapBlockedIdle is how long a task must show NO activity before
	// `ty sessions cleanup` will reap the side processes (dev servers, watchers)
	// running out of its worktree. Deliberately much longer than the done-task
	// grace: in ty, "blocked" usually means "waiting for a human to come look",
	// not "dead". Go duration string; "0"/"disabled" never reaps on staleness.
	// See reaper.DefaultBlockedIdle for the default and its rationale.
	SettingReapBlockedIdle = "reap_blocked_idle"

	// SettingReapOrphanMinAge is the minimum age for the no-worktree orphan
	// heuristic (a known dev server reparented to init with no terminal, which
	// nothing can tie back to a task). Go duration string.
	SettingReapOrphanMinAge = "reap_orphan_min_age"

	// SettingReapOrphanDevServers, when "false", disables that no-worktree
	// heuristic entirely, leaving the sweep to only touch processes it can map
	// to a task worktree. Enabled by default.
	SettingReapOrphanDevServers = "reap_orphan_dev_servers"

	// SettingBoardDisplayMode is how the board draws itself: BoardDisplayList for
	// one flat line per task, anything else for the kanban columns.
	SettingBoardDisplayMode = "board_display_mode"
	// SettingBoardFilter is the filter query the board had when it was last
	// closed, restored on launch so a filtered view actually persists.
	SettingBoardFilter = "board_filter"
	// SettingBoardView is the name of the saved view that filter came from, ""
	// when the filter was typed ad hoc. Only used to label the filter bar.
	SettingBoardView = "board_view"
	// SettingListGroupBy and SettingListSort are how the list view is arranged:
	// which field it breaks into sections on, and how tasks order inside a
	// section. See ui.ListOptions for the accepted values. Row height is not a
	// setting — see the note in listopts.go.
	SettingListGroupBy = "list_group_by"
	SettingListSort    = "list_sort"
)

Setting keys

View Source
const (
	BoardDisplayBoard = "board"
	BoardDisplayList  = "list"
)

Board display modes for SettingBoardDisplayMode.

View Source
const DefaultHTTPAPIPort = 8080

DefaultHTTPAPIPort is the port the daemon-hosted HTTP API binds by default. Matches the standalone `ty serve` default so existing clients (ty-web, the ty-chrome extension) keep working without reconfiguration.

View Source
const DefaultServerURL = "http://localhost"

DefaultServerURL is the default base URL for opening tasks in the browser.

Variables

This section is empty.

Functions

func DefaultKeybindingsConfigPath

func DefaultKeybindingsConfigPath() string

DefaultKeybindingsConfigPath returns the default path for the keybindings config file.

func GenerateDefaultKeybindingsYAML

func GenerateDefaultKeybindingsYAML() string

GenerateDefaultKeybindingsYAML generates a YAML string with all default keybindings. This can be used to create an example config file.

func ShellPaneWidthKey

func ShellPaneWidthKey(taskID int64) string

ShellPaneWidthKey is the settings key holding one task's shell pane width. Widths are per task: dragging the agent/shell split in one task must not move it in every other task. SettingShellPaneWidth remains the fallback for tasks with no width of their own.

Types

type Config

type Config struct {
	ProjectsDir string
	// contains filtered or unexported fields
}

Config holds application configuration loaded from database.

func New

func New(database *db.DB) *Config

New creates a config from database.

func (*Config) GetProjectDir

func (c *Config) GetProjectDir(project string) string

GetProjectDir returns the directory for a project name.

func (*Config) ProjectUsesWorktrees

func (c *Config) ProjectUsesWorktrees(project string) bool

ProjectUsesWorktrees returns whether a project uses git worktrees for task isolation. Returns true by default (for backward compatibility and unknown projects).

func (*Config) SetProjectsDir

func (c *Config) SetProjectsDir(dir string) error

SetProjectsDir sets the default projects directory.

type KeybindingConfig

type KeybindingConfig struct {
	Keys []string `yaml:"keys"` // Key(s) that trigger the action
	Help string   `yaml:"help"` // Help text displayed in the UI
}

KeybindingConfig represents a single keybinding configuration.

type KeybindingsConfig

type KeybindingsConfig struct {
	Left               *KeybindingConfig `yaml:"left,omitempty"`
	Right              *KeybindingConfig `yaml:"right,omitempty"`
	Up                 *KeybindingConfig `yaml:"up,omitempty"`
	Down               *KeybindingConfig `yaml:"down,omitempty"`
	Enter              *KeybindingConfig `yaml:"enter,omitempty"`
	Back               *KeybindingConfig `yaml:"back,omitempty"`
	New                *KeybindingConfig `yaml:"new,omitempty"`
	Edit               *KeybindingConfig `yaml:"edit,omitempty"`
	Queue              *KeybindingConfig `yaml:"queue,omitempty"`
	Retry              *KeybindingConfig `yaml:"retry,omitempty"`
	Close              *KeybindingConfig `yaml:"close,omitempty"`
	Archive            *KeybindingConfig `yaml:"archive,omitempty"`
	Delete             *KeybindingConfig `yaml:"delete,omitempty"`
	Refresh            *KeybindingConfig `yaml:"refresh,omitempty"`
	Settings           *KeybindingConfig `yaml:"settings,omitempty"`
	Routines           *KeybindingConfig `yaml:"routines,omitempty"`
	Plugins            *KeybindingConfig `yaml:"plugins,omitempty"`
	Help               *KeybindingConfig `yaml:"help,omitempty"`
	Quit               *KeybindingConfig `yaml:"quit,omitempty"`
	ChangeStatus       *KeybindingConfig `yaml:"change_status,omitempty"`
	CommandPalette     *KeybindingConfig `yaml:"command_palette,omitempty"`
	ToggleDangerous    *KeybindingConfig `yaml:"toggle_dangerous,omitempty"`
	QueueDangerous     *KeybindingConfig `yaml:"queue_dangerous,omitempty"`
	TogglePin          *KeybindingConfig `yaml:"toggle_pin,omitempty"`
	Filter             *KeybindingConfig `yaml:"filter,omitempty"`
	OpenWorktree       *KeybindingConfig `yaml:"open_worktree,omitempty"`
	ToggleShellPane    *KeybindingConfig `yaml:"toggle_shell_pane,omitempty"`
	JumpToNotification *KeybindingConfig `yaml:"jump_to_notification,omitempty"`
	FocusBacklog       *KeybindingConfig `yaml:"focus_backlog,omitempty"`
	FocusInProgress    *KeybindingConfig `yaml:"focus_in_progress,omitempty"`
	FocusBlocked       *KeybindingConfig `yaml:"focus_blocked,omitempty"`
	FocusDone          *KeybindingConfig `yaml:"focus_done,omitempty"`
	JumpToPinned       *KeybindingConfig `yaml:"jump_to_pinned,omitempty"`
	JumpToUnpinned     *KeybindingConfig `yaml:"jump_to_unpinned,omitempty"`
	CollapseBacklog    *KeybindingConfig `yaml:"collapse_backlog,omitempty"`
	CollapseDone       *KeybindingConfig `yaml:"collapse_done,omitempty"`
	OpenBrowser        *KeybindingConfig `yaml:"open_browser,omitempty"`
	OpenPR             *KeybindingConfig `yaml:"open_pr,omitempty"`
	ResumeSession      *KeybindingConfig `yaml:"resume_session,omitempty"`
	ToggleListView     *KeybindingConfig `yaml:"toggle_list_view,omitempty"`
	SavedViews         *KeybindingConfig `yaml:"saved_views,omitempty"`
	ListOptions        *KeybindingConfig `yaml:"list_options,omitempty"`
}

KeybindingsConfig holds all customizable keybindings.

func LoadKeybindings

func LoadKeybindings() (*KeybindingsConfig, error)

LoadKeybindings loads keybindings from the default config path. Returns nil if the file doesn't exist (not an error - just use defaults).

func LoadKeybindingsFromPath

func LoadKeybindingsFromPath(path string) (*KeybindingsConfig, error)

LoadKeybindingsFromPath loads keybindings from a specific path. Returns nil if the file doesn't exist (not an error - just use defaults).

Jump to

Keyboard shortcuts

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