fix(composer): refresh @ mention picker on workspace/project switch (#3601)#3606
Merged
esengine merged 1 commit intoJun 9, 2026
Merged
Conversation
…sengine#3601) When switching between projects, the @ mention picker retained stale candidates from the previous project because dirCache/searchCache keys did not include workspace context and the ListDir/SearchFileRefs effects did not depend on cwd. Changes: - Add cwdRef snapshot pattern to detect workspace switches in async openPastChats callback, discarding stale ListSessions responses - Add useEffect([cwd]) to invalidate all @ mention state (caches, entries, past chats, loading, active index) when cwd changes - Use prevCwdRef to skip the effect on initial mount, avoiding unnecessary re-renders with empty-array references - Add cwd to ListDir and SearchFileRefs effect dependencies so the picker re-fetches when the workspace changes while the menu is open - Conditionally reset loadingPastChats in openPastChats finally block to prevent stale async responses from overwriting new workspace state Closes esengine#3601
esengine
approved these changes
Jun 9, 2026
esengine
left a comment
Owner
There was a problem hiding this comment.
Reviewed the diff: the fix is correct, focused, and CI is green. Approving for merge.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #3601 — @ mention picker not refreshing when switching between projects.
Problem
When switching from project A to project B, the @ mention picker still showed project A's file candidates because:
dirCache/searchCachekeys didn't include workspace context — switching projects hit stale cache entriesListDir/SearchFileRefseffect dependencies didn't includecwd— no re-fetch on workspace switchopenPastChatshad no race condition protection — stale async responses could overwrite new workspace stateReproduction
@→ see A's files@→ Bug: still shows A's filesChanges (1 file:
Composer.tsx)cwdRefsnapshot pattern: Detect workspace switches in asyncopenPastChats, discard staleListSessionsresponsesuseEffect([cwd]): Invalidate all @ mention state (caches, entries, past chats, loading, active index) when cwd changesprevCwdRef: Skip the effect on initial mount, avoiding unnecessary re-renderscwdto effect deps:ListDirandSearchFileRefseffects re-fetch when workspace changes while menu is openfinally: Only resetloadingPastChatswhen cwd hasn't changed, preventing stale async from overwriting new stateVerification
@shows A-only files@shows B-only files, no A files@open while switching: candidates auto-refresh to new project@past:chatsentry still present and functionalSecurity Review
No exploitable issues found. The change is security-enhancing — prevents cross-project data leakage by invalidating caches on workspace switch.