fix: write back the CURRENT message text, not a copy taken before the… - #222
Merged
Conversation
… parse (回写当前消息文本,而非解析前的副本) (#221) * fix: write back the current message text, not a copy taken before the parse handleVariablesInMessage read chat_message.message into a local at the top of the function and wrote that local back at the end, four awaits later. setChatMessages has no append mode, so what reads as "append <StatusPlaceHolderImpl/>" is a wholesale overwrite of mes and the active swipe from a snapshot that can be seconds old. Any edit another extension made to the message during those awaits is silently reverted; nothing fails and nothing is logged. The dominant part of the window is updateVariables(), which emits VARIABLE_UPDATE_ENDED, and the emitter awaits every listener in turn. Measured 2832 ms between snapshot and write on a live chat. mag_before_message_update does not cover the case: it is emitted only when has_variable_modified is true, while the write is gated on the role alone, so a reply whose parse changed no variable is written back stale with no event to hook. Two changes: - Re-read the message after updateVariables(), so everything below - the event seam included - works from the current text. - Re-anchor once more at write time, and when the resulting text is identical to what is already there, call setChatMessages WITHOUT a `message` field. That drops the pointless overwrite while keeping the refresh: the variables were still replaced, and a status implementation that reads message_data at iframe init would otherwise keep showing the pre-update values. The seam still fires under exactly the same condition and still receives a mutable message_content; the placeholder is still appended once for non-user messages; the <status_current_variable> strip is untouched. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * misc: 缩短 await 距离,完善 BEFORE_MESSAGE_UPDATE 保证。增加测试用例。 * misc: 调整review意见 * misc: add changelog --------- Co-authored-by: Claude Fable 5 <noreply@anthropic.com> Co-authored-by: MagicalAstrogy <103271693+MagicalAstrogy@users.noreply.github.com>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Contributor
🔍 PR Test Report🧪 Test Results✅ All tests passed!
📊 Coverage Report
Coverage Thresholds
Generated at 2026-08-31T02:31:06.067Z |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1af7c66e7f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Owner
Author
|
LGFM |
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.
see #221