Skip to content

fix: remove duplicate error toast on memory update failure - #16690

Merged
wangq8 merged 3 commits into
infiniflow:mainfrom
dcc123456:fix/memory-error
Jul 7, 2026
Merged

wangq8 merged 3 commits into
infiniflow:mainfrom
dcc123456:fix/memory-error

Conversation

@dcc123456

Copy link
Copy Markdown
Collaborator

Summary

fix: remove duplicate error toast on memory update failure

@dosubot dosubot Bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label Jul 7, 2026
@coderabbitai

coderabbitai Bot commented Jul 7, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The 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.

Changes

Memory cache and mutation success handling

Layer / File(s) Summary
Fix cache invalidation query key
web/src/pages/memories/hooks.ts
The invalidateQueries call in useUpdateMemory now targets the memoryDetail query keyed by variables.id.
Gate message update success
web/src/pages/memory/memory-message/hook.ts
handleUpdateMessageState now checks data.data.code before showing the success toast and invalidating FetchMemoryMessage.

Estimated code review effort: 2 (Simple) | ~10 minutes

Poem

A memory hop, a message nudge,
The cache now waits for code to judge.
When codes say yes, the toasts appear,
Fresh data twitches, bright and clear. 🐰

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Title check ⚠️ Warning The title mentions duplicate error toasts, but the code changes focus on query invalidation and message-state success handling. Retitle it to reflect the actual fix, e.g. update memory/message update handling and related cache invalidation.
✅ Passed checks (4 passed)
Check name Status Explanation
Description check ✅ Passed The description matches the required template and includes a concise Summary of the PR intent.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@dosubot dosubot Bot added size:S This PR changes 10-29 lines, ignoring generated files. and removed size:XS This PR changes 0-9 lines, ignoring generated files. labels Jul 7, 2026
@wangq8 wangq8 added the ci Continue Integration label Jul 7, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
web/src/pages/memory/memory-message/hook.ts (2)

74-88: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Same unconditional success-toast issue exists in handleDeleteMessage.

This function still shows message.success regardless of the response code/status, the same class of bug just fixed for handleUpdateMessageState. Consider applying the same gating for consistency, since both mutations go through memoryService and 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 value

Prefer a typed response over data: any.

The gating condition (data.data.code) depends entirely on this shape; typing it loosely as any means a shape mismatch fails silently instead of at compile time. Also, naming the parameter data when it represents the full response object (mirroring res in fetchMessageContent) 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

📥 Commits

Reviewing files that changed from the base of the PR and between 80557f4 and c6e5fd0.

📒 Files selected for processing (1)
  • web/src/pages/memory/memory-message/hook.ts

@wangq8
wangq8 merged commit 5aa3e81 into infiniflow:main Jul 7, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Continue Integration size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants