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:
committed by
GitHub
parent
73d4d5ecb2
commit
460d2bf113
@@ -6,6 +6,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"slices"
|
"slices"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
_ "github.com/ncruces/go-sqlite3/driver"
|
_ "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)
|
fmt.Printf(" %s %s %s\n", ui.RenderWarnIcon(), ui.RenderWarn(fmt.Sprintf("%d.", i+1)), line)
|
||||||
}
|
}
|
||||||
if check.Fix != "" {
|
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 {
|
} else {
|
||||||
|
|||||||
@@ -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"
|
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") {
|
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
|
// GH#885: For status mismatches, provide specific guidance and include detail
|
||||||
if strings.Contains(strings.Join(issues, " "), "Status mismatch") {
|
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
|
detail = statusMismatchDetail
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ func CheckStaleClosedIssues(path string) DoctorCheck {
|
|||||||
Status: StatusWarning,
|
Status: StatusWarning,
|
||||||
Message: fmt.Sprintf("%d closed issue(s) older than %d days", cleanable, DefaultCleanupAgeDays),
|
Message: fmt.Sprintf("%d closed issue(s) older than %d days", cleanable, DefaultCleanupAgeDays),
|
||||||
Detail: "These issues can be cleaned up to reduce database size",
|
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,
|
Category: CategoryMaintenance,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -155,7 +155,7 @@ func CheckExpiredTombstones(path string) DoctorCheck {
|
|||||||
Status: StatusWarning,
|
Status: StatusWarning,
|
||||||
Message: fmt.Sprintf("%d tombstone(s) older than %d days", expiredCount, ttlDays),
|
Message: fmt.Sprintf("%d tombstone(s) older than %d days", expiredCount, ttlDays),
|
||||||
Detail: "Expired tombstones can be pruned to reduce JSONL file size",
|
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,
|
Category: CategoryMaintenance,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user