fix(doctor): improve diagnostic fix message output (#1187)

Problem:
- Diagnostic fix messages were restricted to single lines
- Inconsistent file path formatting in database sync issues
- Outdated cleanup command suggested in maintenance fixes

Solution:
- Implement multiline support for doctor fix messages
- Standardize issue file paths across database diagnostics
- Update maintenance fix instructions to use 'bd admin cleanup'

Impact:
- Clearer and more accurate recovery instructions for users
- Better readability of complex diagnostic output

Fixes: GH#1170, GH#1171, GH#1172
This commit is contained in:
Peter Chanthamynavong
2026-01-19 10:10:57 -08:00
committed by GitHub
parent 73d4d5ecb2
commit 460d2bf113
3 changed files with 14 additions and 5 deletions

View File

@@ -6,6 +6,7 @@ import (
"os"
"path/filepath"
"slices"
"strings"
"time"
_ "github.com/ncruces/go-sqlite3/driver"
@@ -774,7 +775,15 @@ func printDiagnostics(result doctorResult) {
fmt.Printf(" %s %s %s\n", ui.RenderWarnIcon(), ui.RenderWarn(fmt.Sprintf("%d.", i+1)), line)
}
if check.Fix != "" {
fmt.Printf(" %s%s\n", ui.MutedStyle.Render(ui.TreeLast), check.Fix)
// Handle multiline Fix messages with proper indentation
lines := strings.Split(check.Fix, "\n")
for i, line := range lines {
if i == 0 {
fmt.Printf(" %s%s\n", ui.MutedStyle.Render(ui.TreeLast), line)
} else {
fmt.Printf(" %s\n", line)
}
}
}
}
} else {

View File

@@ -542,11 +542,11 @@ func CheckDatabaseJSONLSync(path string) DoctorCheck {
fixMsg = "Run 'bd doctor --fix' to fix automatically, or manually run 'bd sync --import-only' or 'bd export' depending on which has newer data"
}
if strings.Contains(strings.Join(issues, " "), "Prefix mismatch") {
fixMsg = "Run 'bd import -i " + filepath.Base(jsonlPath) + " --rename-on-import' to fix prefixes"
fixMsg = "Run 'bd import -i .beads/issues.jsonl --rename-on-import' to fix prefixes"
}
// GH#885: For status mismatches, provide specific guidance and include detail
if strings.Contains(strings.Join(issues, " "), "Status mismatch") {
fixMsg = "Run 'bd export -o " + filepath.Base(jsonlPath) + "' to update JSONL from DB (DB is usually source of truth)"
fixMsg = "Run 'bd export -o .beads/issues.jsonl' to update JSONL from DB (DB is usually source of truth)"
detail = statusMismatchDetail
}

View File

@@ -93,7 +93,7 @@ func CheckStaleClosedIssues(path string) DoctorCheck {
Status: StatusWarning,
Message: fmt.Sprintf("%d closed issue(s) older than %d days", cleanable, DefaultCleanupAgeDays),
Detail: "These issues can be cleaned up to reduce database size",
Fix: "Run 'bd doctor --fix' to cleanup, or 'bd cleanup --force' for more options",
Fix: "Run 'bd doctor --fix' to cleanup, or 'bd admin cleanup --force' for more options",
Category: CategoryMaintenance,
}
}
@@ -155,7 +155,7 @@ func CheckExpiredTombstones(path string) DoctorCheck {
Status: StatusWarning,
Message: fmt.Sprintf("%d tombstone(s) older than %d days", expiredCount, ttlDays),
Detail: "Expired tombstones can be pruned to reduce JSONL file size",
Fix: "Run 'bd doctor --fix' to prune, or 'bd cleanup --force' for more options",
Fix: "Run 'bd doctor --fix' to prune, or 'bd admin cleanup --force' for more options",
Category: CategoryMaintenance,
}
}