Add ordering for threads

This commit is contained in:
2026-07-28 09:52:57 +02:00
parent 80f24bcfa8
commit 60d64dedb2
6 changed files with 196 additions and 1 deletions

View File

@@ -33,6 +33,7 @@ type Config struct {
Endpoint string `toml:"endpoint"`
Display DisplayConfig `toml:"display"`
Paths PathConfig `toml:"paths"`
Threads ThreadConfig `toml:"threads"`
}
type DisplayConfig struct {
@@ -45,6 +46,11 @@ type PathConfig struct {
ScrollInterval configDuration `toml:"scroll_interval"`
}
type ThreadConfig struct {
StatusOrder []string `toml:"status_order"`
WithinStatus string `toml:"within_status"`
}
func defaultConfig() Config {
return Config{
Theme: "dark",
@@ -59,6 +65,10 @@ func defaultConfig() Config {
Scroll: false,
ScrollInterval: configDuration{350 * time.Millisecond},
},
Threads: ThreadConfig{
StatusOrder: []string{"unresolved", "outdated", "resolved"},
WithinStatus: "file",
},
}
}
@@ -129,8 +139,35 @@ func validateConfig(config Config) error {
if config.Display.ThreadListWidthPercent < 20 || config.Display.ThreadListWidthPercent > 60 {
return fmt.Errorf("display.thread_list_width_percent must be between 20 and 60")
}
if err := validateThreadStatusOrder(config.Threads.StatusOrder); err != nil {
return err
}
switch config.Threads.WithinStatus {
case "file", "timestamp":
default:
return fmt.Errorf("threads.within_status must be file or timestamp")
}
if config.ShowAll && config.Repository == "" {
return fmt.Errorf("show_all requires repository")
}
return nil
}
func validateThreadStatusOrder(order []string) error {
if len(order) != 3 {
return fmt.Errorf("threads.status_order must contain unresolved, outdated, and resolved exactly once")
}
seen := map[string]bool{}
for _, status := range order {
switch status {
case "unresolved", "outdated", "resolved":
if seen[status] {
return fmt.Errorf("threads.status_order contains %q more than once", status)
}
seen[status] = true
default:
return fmt.Errorf("threads.status_order contains unknown status %q", status)
}
}
return nil
}