Skip to content

fix: refresh memory sidebar avatar immediately after update - #17401

Merged
wangq8 merged 1 commit into
infiniflow:mainfrom
euvre:fix/memory-avatar-refresh
Jul 27, 2026
Merged

wangq8 merged 1 commit into
infiniflow:mainfrom
euvre:fix/memory-avatar-refresh

Conversation

@euvre

@euvre euvre commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Summary

After uploading a new avatar on the memory configuration page and saving, the avatar shown in the memory detail sidebar was not updated until a full page refresh.

Root cause: a react-query key mismatch. The sidebar and the configuration page read data via useFetchMemoryBaseConfiguration, whose query key is ['fetchMemoryDetail', ...] (GET /api/v1/memories/:id/config), but useUpdateMemory only invalidated the unrelated ['memoryDetail', id] key on success. As a result, the sidebar's cached query was never refetched after an update.

This PR additionally invalidates the fetchMemoryDetail query key in useUpdateMemory's onSuccess, so the sidebar refetches and shows the new avatar immediately. It also removes a stale comment in the sidebar referring to an unimplemented refreshCount mechanism.

The memory detail sidebar reads its data via the fetchMemoryDetail
query key (GET /memories/:id/config), but useUpdateMemory only
invalidated the unrelated memoryDetail key on success, so the new
avatar was not shown until a full page refresh. Invalidate the
fetchMemoryDetail query as well and drop a stale comment.
@dosubot dosubot Bot added size:XS This PR changes 0-9 lines, ignoring generated files. 🐞 bug Something isn't working, pull request that fix bug. 🧰 typescript Pull requests that update Typescript code labels Jul 27, 2026
@euvre euvre added the ci Continue Integration label Jul 27, 2026
@coderabbitai

coderabbitai Bot commented Jul 27, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The memory update hook now invalidates detail queries through MemoryApiAction.FetchMemoryDetail, and an obsolete commented placeholder is removed from the memory sidebar.

Changes

Memory cache invalidation

Layer / File(s) Summary
Memory update cache invalidation
web/src/pages/memories/hooks.ts
Imports MemoryApiAction and changes the update success handler’s invalidation key from an ID-specific key to [MemoryApiAction.FetchMemoryDetail].

Sidebar cleanup

Layer / File(s) Summary
Sidebar placeholder removal
web/src/pages/memory/sidebar/index.tsx
Removes a commented-out refreshCount and avatar-sync placeholder before configuration loading.

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

Poem

I’m a bunny with a cache to refresh,
A new key now tidies the mesh.
The sidebar comment hopped away,
While memory details find their way.
Squeak, ship, and celebrate today!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately summarizes the main change: refreshing the memory sidebar avatar after update.
Description check ✅ Passed The description matches the template and provides a clear summary, background context, root cause, and fix.
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.

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

Actionable comments posted: 1

🤖 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 `@web/src/pages/memories/hooks.ts`:
- Around line 221-223: Define a same-file MemoryKeys query-key factory with as
const return values, following the existing query and invalidation key patterns,
then update the invalidateQueries call to use the factory instead of the inline
[MemoryApiAction.FetchMemoryDetail] key.
🪄 Autofix (Beta)

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: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 7e93976d-2cf7-4b1f-bb8c-b6e1cb0a8053

📥 Commits

Reviewing files that changed from the base of the PR and between 9d4847b and ecfdd86.

📒 Files selected for processing (2)
  • web/src/pages/memories/hooks.ts
  • web/src/pages/memory/sidebar/index.tsx
💤 Files with no reviewable changes (1)
  • web/src/pages/memory/sidebar/index.tsx

Comment on lines +221 to +223
queryClient.invalidateQueries({
queryKey: [MemoryApiAction.FetchMemoryDetail],
});

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.

📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Use the required query-key factory.

This invalidation is functionally correct, but it introduces another inline React Query key. Define a same-file MemoryKeys factory with as const return values and use it here, alongside the file’s other query and invalidation calls.

As per coding guidelines, React Query keys in web/src/**/*.{ts,tsx} must use a same-file {Domain}Keys factory with as const.

Suggested change
+const MemoryKeys = {
+  fetchMemoryDetail: () => [MemoryApiAction.FetchMemoryDetail] as const,
+};
+
       queryClient.invalidateQueries({
-        queryKey: [MemoryApiAction.FetchMemoryDetail],
+        queryKey: MemoryKeys.fetchMemoryDetail(),
       });
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
queryClient.invalidateQueries({
queryKey: [MemoryApiAction.FetchMemoryDetail],
});
const MemoryKeys = {
fetchMemoryDetail: () => [MemoryApiAction.FetchMemoryDetail] as const,
};
queryClient.invalidateQueries({
queryKey: MemoryKeys.fetchMemoryDetail(),
});
🤖 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/memories/hooks.ts` around lines 221 - 223, Define a same-file
MemoryKeys query-key factory with as const return values, following the existing
query and invalidation key patterns, then update the invalidateQueries call to
use the factory instead of the inline [MemoryApiAction.FetchMemoryDetail] key.

Source: Coding guidelines

@euvre
euvre requested a review from wangq8 July 27, 2026 03:15

@wangq8 wangq8 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Simple, correct fix. The react-query key mismatch (memoryDetail vs fetchMemoryDetail) is a textbook stale-cache bug — invalidating the correct key resolves it cleanly.

Also good housekeeping: removing the stale refreshCount comment in the sidebar component.

Approved.

@wangq8
wangq8 requested a review from dcc123456 July 27, 2026 06:04
@wangq8
wangq8 merged commit 58f6787 into infiniflow:main Jul 27, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐞 bug Something isn't working, pull request that fix bug. ci Continue Integration size:XS This PR changes 0-9 lines, ignoring generated files. 🧰 typescript Pull requests that update Typescript code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants