fix(ci): resolve lint errors and test failures
- Fix errcheck: handle watcher.Close() and Set() return values - Fix unparam: remove always-nil error from NewActivityWatcher - Fix unparam: remove unused sinceTime param, delete dead code - Fix version mismatch: update MCP __init__.py to 0.48.0 - Fix routing tests: change CWD so routing can find town root Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
committed by
Steve Yegge
parent
8807a171d3
commit
83e3c75635
@@ -185,13 +185,8 @@ func runActivityFollow(sinceTime time.Time) {
|
||||
// Create filesystem watcher for near-instant wake-up
|
||||
// Falls back to polling internally if fsnotify fails
|
||||
beadsDir := filepath.Dir(dbPath)
|
||||
watcher, err := NewActivityWatcher(beadsDir, activityInterval)
|
||||
if err != nil {
|
||||
// Watcher creation failed entirely - fall back to legacy polling
|
||||
runActivityFollowPolling(sinceTime, lastPoll)
|
||||
return
|
||||
}
|
||||
defer watcher.Close()
|
||||
watcher := NewActivityWatcher(beadsDir, activityInterval)
|
||||
defer func() { _ = watcher.Close() }()
|
||||
|
||||
// Start watching
|
||||
watcher.Start(rootCtx)
|
||||
@@ -261,69 +256,6 @@ func runActivityFollow(sinceTime time.Time) {
|
||||
}
|
||||
}
|
||||
|
||||
// runActivityFollowPolling is the legacy polling-based follow mode.
|
||||
// Used as fallback when ActivityWatcher cannot be created.
|
||||
func runActivityFollowPolling(sinceTime time.Time, lastPoll time.Time) {
|
||||
ticker := time.NewTicker(activityInterval)
|
||||
defer ticker.Stop()
|
||||
|
||||
consecutiveFailures := 0
|
||||
const failureWarningThreshold = 5
|
||||
lastWarningTime := time.Time{}
|
||||
|
||||
for {
|
||||
select {
|
||||
case <-rootCtx.Done():
|
||||
return
|
||||
case <-ticker.C:
|
||||
newEvents, err := fetchMutations(lastPoll)
|
||||
if err != nil {
|
||||
consecutiveFailures++
|
||||
if consecutiveFailures >= failureWarningThreshold {
|
||||
if time.Since(lastWarningTime) >= 30*time.Second {
|
||||
if jsonOutput {
|
||||
errorEvent := map[string]interface{}{
|
||||
"type": "error",
|
||||
"message": fmt.Sprintf("daemon unreachable (%d failures)", consecutiveFailures),
|
||||
"timestamp": time.Now().Format(time.RFC3339),
|
||||
}
|
||||
data, _ := json.Marshal(errorEvent)
|
||||
fmt.Fprintln(os.Stderr, string(data))
|
||||
} else {
|
||||
timestamp := time.Now().Format("15:04:05")
|
||||
fmt.Fprintf(os.Stderr, "[%s] %s daemon unreachable (%d consecutive failures)\n",
|
||||
timestamp, ui.RenderWarn("!"), consecutiveFailures)
|
||||
}
|
||||
lastWarningTime = time.Now()
|
||||
}
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
if consecutiveFailures > 0 {
|
||||
if consecutiveFailures >= failureWarningThreshold && !jsonOutput {
|
||||
timestamp := time.Now().Format("15:04:05")
|
||||
fmt.Fprintf(os.Stderr, "[%s] %s daemon reconnected\n", timestamp, ui.RenderPass("✓"))
|
||||
}
|
||||
consecutiveFailures = 0
|
||||
}
|
||||
|
||||
newEvents = filterEvents(newEvents)
|
||||
for _, e := range newEvents {
|
||||
if jsonOutput {
|
||||
data, _ := json.Marshal(formatEvent(e))
|
||||
fmt.Println(string(data))
|
||||
} else {
|
||||
printEvent(e)
|
||||
}
|
||||
if e.Timestamp.After(lastPoll) {
|
||||
lastPoll = e.Timestamp
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// fetchMutations retrieves mutations from the daemon
|
||||
func fetchMutations(since time.Time) ([]rpc.MutationEvent, error) {
|
||||
var sinceMillis int64
|
||||
|
||||
Reference in New Issue
Block a user