feat(history): add Atuin context scopes
This commit is contained in:
@@ -78,6 +78,11 @@ type KeybindingsConfig struct {
|
||||
NavigateRight string `toml:"navigate-right"`
|
||||
}
|
||||
|
||||
type HistoryConfig struct {
|
||||
// Scope controls Atuin filtering for non-empty history searches.
|
||||
Scope string `toml:"scope"`
|
||||
}
|
||||
|
||||
type SuggestOnEmptyConfig struct {
|
||||
Enabled bool `toml:"enabled"`
|
||||
DebounceMS int `toml:"debounce_ms"`
|
||||
@@ -125,6 +130,7 @@ type Config struct {
|
||||
Core CoreConfig `toml:"core"`
|
||||
UI UIConfig `toml:"ui"`
|
||||
Git GitConfig `toml:"git"`
|
||||
History HistoryConfig `toml:"history"`
|
||||
Updater UpdaterConfig `toml:"updater"`
|
||||
AI AIConfig `toml:"ai"`
|
||||
Keybindings KeybindingsConfig `toml:"keybindings"`
|
||||
@@ -282,6 +288,11 @@ func validate(cfg *Config) error {
|
||||
return fmt.Errorf("core.shell: invalid value %q (want: bash|zsh|fish)", cfg.Core.Shell)
|
||||
}
|
||||
|
||||
validHistoryScopes := map[string]bool{"global": true, "directory": true, "workspace": true, "hybrid": true}
|
||||
if !validHistoryScopes[cfg.History.Scope] {
|
||||
return fmt.Errorf("history.scope: invalid value %q (want: global|directory|workspace|hybrid)", cfg.History.Scope)
|
||||
}
|
||||
|
||||
validChannels := map[string]bool{"stable": true, "nightly": true}
|
||||
if !validChannels[cfg.Updater.Channel] {
|
||||
return fmt.Errorf("updater.channel: invalid value %q (want: stable|nightly)", cfg.Updater.Channel)
|
||||
|
||||
@@ -30,6 +30,9 @@ func TestDefaultConfigAndState(t *testing.T) {
|
||||
if !cfg.Core.CobraProbeEnabled {
|
||||
t.Errorf("expected cobra probing to be enabled by default")
|
||||
}
|
||||
if cfg.History.Scope != "global" {
|
||||
t.Errorf("expected global history scope, got %q", cfg.History.Scope)
|
||||
}
|
||||
|
||||
// test manual provider registration
|
||||
cfg.AI.Provider = "custom"
|
||||
@@ -207,6 +210,21 @@ func TestValidateAutoUpdateRange(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidateHistoryScope(t *testing.T) {
|
||||
cfg := DefaultConfig()
|
||||
for _, scope := range []string{"global", "directory", "workspace", "hybrid"} {
|
||||
cfg.History.Scope = scope
|
||||
if err := validate(cfg); err != nil {
|
||||
t.Errorf("expected history scope %q to be valid: %v", scope, err)
|
||||
}
|
||||
}
|
||||
|
||||
cfg.History.Scope = "session"
|
||||
if err := validate(cfg); err == nil {
|
||||
t.Error("expected unsupported history scope to be rejected")
|
||||
}
|
||||
}
|
||||
|
||||
func TestLoadSave(t *testing.T) {
|
||||
tmpDir, err := os.MkdirTemp("", "iris-config-test")
|
||||
if err != nil {
|
||||
|
||||
@@ -29,6 +29,9 @@ func DefaultConfig() *Config {
|
||||
FilterActiveBranch: true,
|
||||
DeduplicateBranches: true,
|
||||
},
|
||||
History: HistoryConfig{
|
||||
Scope: "global",
|
||||
},
|
||||
Updater: UpdaterConfig{
|
||||
CheckOnStartup: true,
|
||||
Channel: "stable",
|
||||
|
||||
Reference in New Issue
Block a user