Repository navigation
fix: remove duplicate error toast on memory update failure - #16690
Conversation
📝 WalkthroughWalkthroughThe memory update hook now invalidates the detail query by memory id, and the message-state update flow now only treats the API call as successful when the response code indicates success. ChangesMemory cache and mutation success handling
Estimated code review effort: 2 (Simple) | ~10 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
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.
🧹 Nitpick comments (2)
web/src/pages/memory/memory-message/hook.ts (2)
74-88: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winSame unconditional success-toast issue exists in
handleDeleteMessage.This function still shows
message.successregardless of the responsecode/status, the same class of bug just fixed forhandleUpdateMessageState. Consider applying the same gating for consistency, since both mutations go throughmemoryServiceand follow the same response contract ({ data: { code, ... } }).🤖 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 `@web/src/pages/memory/memory-message/hook.ts` around lines 74 - 88, In handleDeleteMessage, the success toast is shown unconditionally after memoryService.deleteMemoryMessage, even when the response code indicates failure. Update this callback to inspect the returned response from deleteMemoryMessage and only call message.success and invalidateQueries when the nested data.code indicates success, matching the gating used in handleUpdateMessageState. Keep setShowDeleteDialog(false) behavior aligned with the mutation outcome, and use the existing handleDeleteMessage, memoryService.deleteMemoryMessage, and queryClient.invalidateQueries symbols to locate the change.
100-100: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valuePrefer a typed response over
data: any.The gating condition (
data.data.code) depends entirely on this shape; typing it loosely asanymeans a shape mismatch fails silently instead of at compile time. Also, naming the parameterdatawhen it represents the full response object (mirroringresinfetchMessageContent) is a bit confusing.🤖 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 `@web/src/pages/memory/memory-message/hook.ts` at line 100, The Promise handler in the memory message hook is using an untyped response and a misleading parameter name, which hides shape mismatches and makes the `data.data.code` check fragile. Update the `.then(...)` callback in the same flow as `fetchMessageContent` to use a properly typed response object instead of `any`, and rename the parameter to something like `res` so it clearly represents the full response. Make sure the gating logic still reads from the expected nested response shape through the typed object.
🤖 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 `@web/src/pages/memory/memory-message/hook.ts`:
- Around line 74-88: In handleDeleteMessage, the success toast is shown
unconditionally after memoryService.deleteMemoryMessage, even when the response
code indicates failure. Update this callback to inspect the returned response
from deleteMemoryMessage and only call message.success and invalidateQueries
when the nested data.code indicates success, matching the gating used in
handleUpdateMessageState. Keep setShowDeleteDialog(false) behavior aligned with
the mutation outcome, and use the existing handleDeleteMessage,
memoryService.deleteMemoryMessage, and queryClient.invalidateQueries symbols to
locate the change.
- Line 100: The Promise handler in the memory message hook is using an untyped
response and a misleading parameter name, which hides shape mismatches and makes
the `data.data.code` check fragile. Update the `.then(...)` callback in the same
flow as `fetchMessageContent` to use a properly typed response object instead of
`any`, and rename the parameter to something like `res` so it clearly represents
the full response. Make sure the gating logic still reads from the expected
nested response shape through the typed object.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 9867e5d9-81b3-4045-83c7-06f8e4d178e6
📒 Files selected for processing (1)
web/src/pages/memory/memory-message/hook.ts
Summary
fix: remove duplicate error toast on memory update failure