In my experience, there have been several instances where Cursor will fail to notify the AI of the newly focused file. This results in changes being made to the previously focused file and not the new file.
I was able to mitigate this by wiping the composer, because this would only happen in long context sessions where the scrollbar became tiny. I’m chalking this up to context awareness issues with long-context chats.