diff options
| author | Paul Buetow <paul@buetow.org> | 2026-06-11 08:49:20 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-06-11 08:49:20 +0300 |
| commit | a5bd7dd1eb63a2be332ecda50fbeccfe5d5de0a8 (patch) | |
| tree | de9986add3f31b6af8b00c1cf99c5237416d8ed1 /internal/appconfig/app_feature_sections.go | |
| parent | 133ef49de26ae251c2c86417f9c673ebc7166f76 (diff) | |
appconfig: split FeatureConfig into cohesive per-subsystem structs
The FeatureConfig section was a grab-bag mixing five unrelated non-LLM
subsystems (ignore filtering, stats, tmux popup editor, tmux action menu,
MCP server). Decompose it into named per-subsystem structs
(IgnoreConfig, StatsConfig, TmuxEditConfig, TmuxActionConfig, MCPConfig)
embedded into FeatureConfig so the subsystem boundaries are explicit.
Embedding keeps Go field promotion intact, so existing flat read access
(e.g. cfg.MCPPromptsDir) and the JSON/TOML on-disk shape are unchanged;
only composite literals that set these leaf fields directly were updated
to the nested form.
Add fine-grained, defensive-copy section accessors on App
(IgnoreSection, StatsSection, TmuxEditSection, TmuxActionSection,
MCPSection) so consumers can depend on a single subsystem's config
instead of the whole App God-struct. Decouple slashcommands.NewSyncer
to accept appconfig.MCPConfig rather than appconfig.App.
All tests pass with -race; appconfig coverage 91.5%, total 86.2%.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Diffstat (limited to 'internal/appconfig/app_feature_sections.go')
| -rw-r--r-- | internal/appconfig/app_feature_sections.go | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/internal/appconfig/app_feature_sections.go b/internal/appconfig/app_feature_sections.go new file mode 100644 index 0000000..2513946 --- /dev/null +++ b/internal/appconfig/app_feature_sections.go @@ -0,0 +1,40 @@ +package appconfig + +import "slices" + +// This file provides fine-grained, read-only accessors for the individual +// feature subsystems embedded in FeatureConfig. They let a consumer depend on +// just the subsystem config it needs (e.g. the MCP server only needs MCPConfig) +// instead of receiving the whole App God-struct. Each accessor returns a deep +// copy so callers cannot mutate App's internal slices. + +// IgnoreSection returns a copy of the gitignore-aware filtering settings. +func (a *App) IgnoreSection() IgnoreConfig { + c := a.IgnoreConfig + c.IgnoreExtraPatterns = slices.Clone(a.IgnoreExtraPatterns) + return c +} + +// StatsSection returns the usage statistics settings. +func (a *App) StatsSection() StatsConfig { + return a.StatsConfig +} + +// TmuxEditSection returns a copy of the tmux popup editor settings. +func (a *App) TmuxEditSection() TmuxEditConfig { + c := a.TmuxEditConfig + c.TmuxEditAgents = append([]TmuxEditAgentCfg{}, a.TmuxEditAgents...) + return c +} + +// TmuxActionSection returns a copy of the tmux action menu settings. +func (a *App) TmuxActionSection() TmuxActionConfig { + c := a.TmuxActionConfig + c.TmuxActionMenu = append([]TmuxActionMenuEntry{}, a.TmuxActionMenu...) + return c +} + +// MCPSection returns the Model Context Protocol server settings. +func (a *App) MCPSection() MCPConfig { + return a.MCPConfig +} |
