fix: recover watcher rebuilds and optional doctor clients - #646
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughDoctor now treats uninstalled optional agents as informational. Automatic rebuild failures trigger bounded retries while the watcher continues running. Tests cover Claude-only health, stale agent configuration, and transient rebuild recovery. The changelog documents both fixes. ChangesDoctor health evaluation
Watcher rebuild recovery
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant Watcher
participant AutomaticRebuild
participant WatcherState
participant UserNotification
Watcher->>AutomaticRebuild: attempt rebuild
AutomaticRebuild-->>Watcher: return failure
Watcher->>WatcherState: persist retry state
Watcher->>UserNotification: report retry-specific failure
Watcher->>Watcher: schedule bounded retry
Watcher->>AutomaticRebuild: retry rebuild
AutomaticRebuild-->>Watcher: return success
Watcher->>WatcherState: persist stopped, complete state
Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/infrastructure/doctor.ts`:
- Around line 561-563: Update the Gemini command-selection branch in the doctor
flow to handle both partial and stale Gemini MCP statuses, matching the existing
stale-MCP handling for Claude, Cursor, and Copilot while preserving madar gemini
install for partial status. Add a regression test covering Claude configured
alongside stale Gemini MCP state and assert that the Gemini install command is
emitted.
In `@src/infrastructure/watch.ts`:
- Around line 1103-1109: The reconciliation loop around runNotify and
recordSuccessfulReconciliation must preserve failed freshness until the
scheduled rebuild succeeds. Update the retry scheduling flow to keep
state.coverage incomplete and failure_reason intact, synchronize local
nextReconciliationAt with persisted state.next_reconciliation_at, and ensure
retry processing precedes normal reconciliation or prevents it from clearing the
failure while rebuilt is false. Clear the failure and restore complete coverage
only after a successful rebuild, and add a regression assertion covering
persisted state during the retry window.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 1733a008-5e18-49b2-aa33-ddfb42b76be4
📒 Files selected for processing (5)
CHANGELOG.mdsrc/infrastructure/doctor.tssrc/infrastructure/watch.tstests/unit/doctor.test.tstests/unit/watch.test.ts
724abb7 to
3adc289
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
tests/unit/watch.test.ts (1)
779-781: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winMake the retry test state-driven.
The fixed delays do not identify watcher readiness or the retry transition. The second rebuild also aborts the watcher before the test observes the successful state. Wait for the persisted failed state, let the second rebuild return without aborting, assert
coverage: 'complete'andfailure_reason: nullwhile the watcher is active, then abort and assertstatus: 'stopped'.Based on learnings: hosted CI tests should focus on correctness and portability rather than cold, single-sample wall-clock timing assertions.
Also applies to: 796-818
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/unit/watch.test.ts` around lines 779 - 781, Update the retry test around the later Git visibility snapshot failure to use state-driven waits instead of fixed delays: wait for the persisted failed state, allow the second rebuild to complete without aborting, assert the active watcher has coverage set to complete and failure_reason set to null, then abort it and assert status stopped.Source: Learnings
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@tests/unit/watch.test.ts`:
- Around line 779-781: Update the retry test around the later Git visibility
snapshot failure to use state-driven waits instead of fixed delays: wait for the
persisted failed state, allow the second rebuild to complete without aborting,
assert the active watcher has coverage set to complete and failure_reason set to
null, then abort it and assert status stopped.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: eef648ff-c792-4f2d-a048-fcdb5ecf9c60
📒 Files selected for processing (4)
src/infrastructure/doctor.tssrc/infrastructure/watch.tstests/unit/doctor.test.tstests/unit/watch.test.ts
🚧 Files skipped from review as they are similar to previous changes (2)
- tests/unit/doctor.test.ts
- src/infrastructure/watch.ts
Closes #619.
Closes #645.
What changed:
Validation:
Summary by CodeRabbit
Bug Fixes
Documentation