Add more QoL and high prio features

This commit is contained in:
2026-07-28 10:17:18 +02:00
parent 43fa047765
commit fdaee6a69e
16 changed files with 2850 additions and 302 deletions

View File

@@ -34,12 +34,14 @@ type Config struct {
Display DisplayConfig `toml:"display"`
Paths PathConfig `toml:"paths"`
Threads ThreadConfig `toml:"threads"`
Cache CacheConfig `toml:"cache"`
}
type DisplayConfig struct {
FoldResolved bool `toml:"fold_resolved"`
ThreadListWidthPercent int `toml:"thread_list_width_percent"`
DashboardMode string `toml:"dashboard_mode"`
CompactReviews bool `toml:"compact_reviews"`
}
type PathConfig struct {
@@ -52,6 +54,12 @@ type ThreadConfig struct {
WithinStatus string `toml:"within_status"`
}
type CacheConfig struct {
Enabled bool `toml:"enabled"`
MaxAge configDuration `toml:"max_age"`
Directory string `toml:"directory"`
}
func defaultConfig() Config {
return Config{
Theme: "dark",
@@ -62,6 +70,7 @@ func defaultConfig() Config {
FoldResolved: true,
ThreadListWidthPercent: 33,
DashboardMode: "hotkey",
CompactReviews: true,
},
Paths: PathConfig{
Scroll: false,
@@ -71,6 +80,7 @@ func defaultConfig() Config {
StatusOrder: []string{"unresolved", "outdated", "resolved"},
WithinStatus: "file",
},
Cache: CacheConfig{Enabled: true, MaxAge: configDuration{7 * 24 * time.Hour}},
}
}
@@ -125,15 +135,15 @@ func loadConfig(path string, required bool) (Config, error) {
func validateConfig(config Config) error {
switch config.Theme {
case "dark", "light":
case "dark", "light", "no-color", "high-contrast":
default:
return fmt.Errorf("theme must be dark or light")
}
if config.RefreshInterval.Duration < 2*time.Second {
return fmt.Errorf("refresh_interval must be at least 2s")
}
if config.Limit < 1 || config.Limit > 100 {
return fmt.Errorf("limit must be between 1 and 100")
if config.Limit < 1 || config.Limit > 1000 {
return fmt.Errorf("limit must be between 1 and 1000")
}
if config.Paths.ScrollInterval.Duration < 50*time.Millisecond {
return fmt.Errorf("paths.scroll_interval must be at least 50ms")
@@ -157,9 +167,20 @@ func validateConfig(config Config) error {
if config.ShowAll && config.Repository == "" {
return fmt.Errorf("show_all requires repository")
}
if config.Cache.MaxAge.Duration < 0 {
return fmt.Errorf("cache.max_age must not be negative")
}
return nil
}
func defaultCacheDir() (string, error) {
base, err := os.UserCacheDir()
if err != nil {
return "", fmt.Errorf("find user cache directory: %w", err)
}
return filepath.Join(base, "gh-threads"), nil
}
func validateThreadStatusOrder(order []string) error {
if len(order) != 3 {
return fmt.Errorf("threads.status_order must contain unresolved, outdated, and resolved exactly once")