fix(amp): harden nmem thread sync (pagination, canonical append, long uploads) - #492
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 (3)
🚧 Files skipped from review as they are similar to previous changes (3)
📝 WalkthroughWalkthroughThe Amp plugin now retrieves complete transcripts through paginated SDK requests, handles existing-thread conflicts reported by 409 and matching 422 responses, and uses a 120-second default HTTP timeout. Amp Personal Plugins installation guidance and related tests were added. ChangesAmp plugin updates
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant readThreadMessagesViaSdk
participant AmpThreadsMessages
participant TranscriptConverter
readThreadMessagesViaSdk->>AmpThreadsMessages: Request pages with offset and limit 20
AmpThreadsMessages-->>readThreadMessagesViaSdk: Return message pages
readThreadMessagesViaSdk->>TranscriptConverter: Convert the complete transcript
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
nowledge-mem-amp-plugin/tests/http.test.ts (1)
123-131: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick winMake the timeout spy cleanup failure-safe.
If
nmemApirejects or the assertion on Line 130 fails,mockRestore()on Line 131 does not run. This can affect later tests unless the file already has a shared mock-cleanup hook. Move cleanup toafterEach, or wrap the request and assertion intry/finally.🤖 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 `@nowledge-mem-amp-plugin/tests/http.test.ts` around lines 123 - 131, Make the setTimeout spy cleanup failure-safe in the “allows two minutes for a request by default” test by moving mockRestore into an afterEach hook or a try/finally block surrounding the request and assertion. Ensure cleanup runs when nmemApi rejects or the expectation fails, and avoid leaving the spy active for later tests.
🤖 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 `@nowledge-mem-amp-plugin/src/sync.ts`:
- Around line 299-312: Update the conflict detection around responseData and
threadAlreadyExists to normalize the complete response payload, including string
and nested-object bodies, before matching. Lowercase the normalized content and
recognize both “already exists” and “thread exists” while retaining status 409
handling, so all qualifying 422 conflicts use the append fallback.
---
Nitpick comments:
In `@nowledge-mem-amp-plugin/tests/http.test.ts`:
- Around line 123-131: Make the setTimeout spy cleanup failure-safe in the
“allows two minutes for a request by default” test by moving mockRestore into an
afterEach hook or a try/finally block surrounding the request and assertion.
Ensure cleanup runs when nmemApi rejects or the expectation fails, and avoid
leaving the spy active for later tests.
🪄 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: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 749480c9-70d5-4f5b-bbe7-54b681f2bf11
📒 Files selected for processing (7)
nowledge-mem-amp-plugin/CHANGELOG.mdnowledge-mem-amp-plugin/src/http.tsnowledge-mem-amp-plugin/src/index.tsnowledge-mem-amp-plugin/src/sync.tsnowledge-mem-amp-plugin/tests/http.test.tsnowledge-mem-amp-plugin/tests/index.test.tsnowledge-mem-amp-plugin/tests/sync.test.ts
|
@coderabbitai review |
✅ Action performedReview finished.
|
Summary
Hardens the Amp
nmemthread sync path so long transcripts are complete, existing canonical threads append safely, and large uploads have enough time to finish. It also documents account-wide installation through Amp Personal Plugins.Changes
409 Conflictor a qualifying422response. The 422 check normalizes the complete payload, including string and nested-object bodies, and recognizesalready existsandthread existscase-insensitively.integrations.json.Summary by CodeRabbit
Bug Fixes
Documentation