Repository navigation
fix: summarize a chat with its own memory prompt, not the open chat's - #6936
Open
Karanvir1729 wants to merge 1 commit into
Open
Karanvir1729 wants to merge 1 commit into
Karanvir1729 wants to merge 1 commit into
Conversation
summarizeSession(refreshTitle, targetSession) took the memory prompt from getMemoryPrompt(), which reads the chat on screen. When a reply finished after the user had opened another chat, the finished chat's new summary was built from the other chat's memory and its own earlier summary was dropped. getMemoryPrompt now takes an optional session; summarizeSession passes the chat it summarizes and getMessagesWithMemory the chat it read the messages from.
3 of 10 tasks
This branch has not been deployed
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.
💻 变更类型 | Change Type
🔀 变更说明 | Description of Change
Fixes #6935
summarizeSession(refreshTitle, targetSession)summarizestargetSession, but it took the memory prompt fromgetMemoryPrompt(), which reads the chat on screen (currentSession()). It runs when a reply finishes, so if the user has opened another chat by then, the finished chat's new summary is built from the other chat's memory, and its own earlier summary is lost.getMemoryPrompttakes an optional session. With no argument it still reads the current chat.summarizeSessionpasses the chat it summarizes.getMessagesWithMemorypasses the chat it read the messages from. It callsgetMemoryPromptafterawait isMcpEnabled(), so it had the same problem if the chat changed during that await. That path was not reproduced.test/summarize-session-memory.test.ts: two chats with different memory prompts, chat B open,summarizeSession(false, chatA). The summary request must carry chat A's memory and not chat B's.📝 补充信息 | Additional Information
Checks run locally (Node 22):
jest --ci(thetest:ciscript): 37 suites, 175 tests pass.eslintandprettier --checkon the two changed files: clean.summarizeSessionreads the captured session object andupdateTargetSessiondrops the result, as before. With no argument,getMemoryPrompt()behaves as before.Reproduction and measurements are in the issue: with the steps there, chat A's summary request carried chat B's memory in 10 of 10 runs, against 0 of 10 when chat B was opened only after the summary was done. With this change applied to the same local setup, the same steps gave 0 of 10.
AI assistance: Claude (Claude Code) investigated this, reproduced it with the measurements above, wrote the fix and the test, ran the checks above, and drafted this description. I have not reproduced it by hand, run the tests or reviewed the fix myself yet.