diff --git a/cmd/bd/feedback.go b/cmd/bd/feedback.go index 764a1102d..490a6a74b 100644 --- a/cmd/bd/feedback.go +++ b/cmd/bd/feedback.go @@ -24,17 +24,15 @@ func formatFeedbackIDParen(id, title string) string { } // applyTitleConfig applies the output.title-length config to a title string. -// Returns empty string when titles should be hidden. +// Returns empty string when titles should be hidden (<= 0). func applyTitleConfig(title string) string { if title == "" { return "" } maxLen := config.GetInt("output.title-length") switch { - case maxLen == 0: + case maxLen <= 0: return "" // hide titles - case maxLen < 0: - return title // full title default: return truncateTitle(title, maxLen) } diff --git a/cmd/bd/feedback_test.go b/cmd/bd/feedback_test.go index b68dd450c..632c366f4 100644 --- a/cmd/bd/feedback_test.go +++ b/cmd/bd/feedback_test.go @@ -9,6 +9,8 @@ import ( "github.com/steveyegge/beads/internal/types" ) +const defaultTitleLength = 255 + func TestFormatFeedbackID(t *testing.T) { // Ensure config is initialized with defaults config.ResetForTesting() @@ -34,7 +36,7 @@ func TestFormatFeedbackID(t *testing.T) { t.Run("title-length=0 hides title", func(t *testing.T) { config.Set("output.title-length", 0) - t.Cleanup(func() { config.Set("output.title-length", -1) }) + t.Cleanup(func() { config.Set("output.title-length", defaultTitleLength) }) got := formatFeedbackID("bd-abc", "Add user authentication") if got != "bd-abc" { @@ -44,7 +46,7 @@ func TestFormatFeedbackID(t *testing.T) { t.Run("title-length truncates with ellipsis", func(t *testing.T) { config.Set("output.title-length", 10) - t.Cleanup(func() { config.Set("output.title-length", -1) }) + t.Cleanup(func() { config.Set("output.title-length", defaultTitleLength) }) got := formatFeedbackID("bd-abc", "Add user authentication") want := "bd-abc — Add user …" @@ -55,7 +57,7 @@ func TestFormatFeedbackID(t *testing.T) { t.Run("title within limit not truncated", func(t *testing.T) { config.Set("output.title-length", 50) - t.Cleanup(func() { config.Set("output.title-length", -1) }) + t.Cleanup(func() { config.Set("output.title-length", defaultTitleLength) }) got := formatFeedbackID("bd-abc", "Short title") want := "bd-abc — Short title" @@ -89,7 +91,7 @@ func TestFormatFeedbackIDParen(t *testing.T) { t.Run("title-length=0 hides title", func(t *testing.T) { config.Set("output.title-length", 0) - t.Cleanup(func() { config.Set("output.title-length", -1) }) + t.Cleanup(func() { config.Set("output.title-length", defaultTitleLength) }) got := formatFeedbackIDParen("bd-abc", "Write tests") if got != "bd-abc" { @@ -124,7 +126,7 @@ func TestApplyTitleConfig(t *testing.T) { t.Run("unicode truncation is rune-safe", func(t *testing.T) { config.Set("output.title-length", 3) - t.Cleanup(func() { config.Set("output.title-length", -1) }) + t.Cleanup(func() { config.Set("output.title-length", defaultTitleLength) }) // 4-rune title: truncated to 2 runes + ellipsis (maxLen-1 reserves space for …) got := applyTitleConfig("日本語文") @@ -133,4 +135,14 @@ func TestApplyTitleConfig(t *testing.T) { t.Errorf("got %q, want %q", got, want) } }) + + t.Run("negative values hide title", func(t *testing.T) { + config.Set("output.title-length", -1) + t.Cleanup(func() { config.Set("output.title-length", defaultTitleLength) }) + + got := applyTitleConfig("Hidden title") + if got != "" { + t.Errorf("got %q, want empty", got) + } + }) } diff --git a/cmd/bd/init_templates.go b/cmd/bd/init_templates.go index 789508336..4bd9a37d8 100644 --- a/cmd/bd/init_templates.go +++ b/cmd/bd/init_templates.go @@ -45,6 +45,11 @@ func createConfigYaml(beadsDir string, noDbMode bool, prefix string) error { # Enable JSON output by default # json: false +# Feedback title formatting for mutating commands (create/update/close/dep/edit) +# 0 = hide titles, N > 0 = truncate to N characters +# output: +# title-length: 255 + # Default actor for audit trails (overridden by BD_ACTOR or --actor) # actor: "" diff --git a/docs/CONFIG.md b/docs/CONFIG.md index c600f42de..b3889b21a 100644 --- a/docs/CONFIG.md +++ b/docs/CONFIG.md @@ -199,6 +199,11 @@ directory: packages/agency: agency packages/io: io +# Feedback title formatting for mutating commands (GH#1384) +# 0 = hide titles, N > 0 = truncate to N characters +output: + title-length: 255 + # Cross-project dependency resolution (bd-h807) # Maps project names to paths for resolving external: blocked_by references # Paths can be relative (from cwd) or absolute diff --git a/internal/config/config.go b/internal/config/config.go index 8fb76cdc0..9298eb8aa 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -198,8 +198,8 @@ func Initialize() error { // Output configuration (GH#1384) // Controls title display in command feedback messages. - // -1 = full title, 0 = hide title, N > 0 = truncate to N chars with "…" - v.SetDefault("output.title-length", -1) + // 0 = hide title, N > 0 = truncate to N chars with "…" + v.SetDefault("output.title-length", 255) // External projects for cross-project dependency resolution (bd-h807) // Maps project names to paths for resolving external: blocked_by references