fix(ai): clarify stale proposal reanchor conflicts#154
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThis PR improves error handling for AI proposal applications by extracting selection-matching logic into a reusable helper and prioritizing specific conflict errors. When ChangesReplace Selection Conflict Detection
Sequence DiagramsequenceDiagram
participant Client
participant applyAiProposal
participant findReplaceSelectionMatch
participant applyReplaceSelection
participant aiProposalConflict
Client->>applyAiProposal: POST /api/v1/ai/proposals/:id/apply
alt baseDraftRevision matches
applyAiProposal->>applyReplaceSelection: call with operation
applyReplaceSelection->>findReplaceSelectionMatch: locate originalText
alt originalText found uniquely
findReplaceSelectionMatch-->>applyReplaceSelection: return match index
applyReplaceSelection->>applyReplaceSelection: update body at index
applyReplaceSelection-->>applyAiProposal: success
applyAiProposal-->>Client: 200 OK
else originalText missing or ambiguous
findReplaceSelectionMatch-->>aiProposalConflict: emit selection details
aiProposalConflict-->>applyAiProposal: conflict error
applyAiProposal-->>Client: 409 AI_PROPOSAL_CONFLICT
end
else baseDraftRevision does not match
applyAiProposal->>findReplaceSelectionMatch: check if replace_selection still valid
alt originalText found uniquely
findReplaceSelectionMatch-->>applyAiProposal: match index
applyAiProposal->>applyReplaceSelection: proceed with stale revision
applyReplaceSelection-->>applyAiProposal: success
applyAiProposal-->>Client: 200 OK
else originalText missing or ambiguous
findReplaceSelectionMatch-->>aiProposalConflict: emit selection details
aiProposalConflict-->>applyAiProposal: selection conflict error
applyAiProposal-->>Client: 409 AI_PROPOSAL_CONFLICT
end
end
Estimated Code Review Effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint skipped: no ESLint configuration detected in root package.json. To enable, add Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
Test Plan
Summary by CodeRabbit
Bug Fixes
Tests