fix(tui): handle CR in MCP SSE fields#2020
Open
cyq1017 wants to merge 3 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request improves the handling of carriage returns in Server-Sent Events (SSE) by updating the sse_field_value helper to strip trailing \r characters and adding comprehensive tests for mixed line endings. A review comment correctly identifies a redundant trim operation in the event processing loop that can be removed to simplify the code.
Comment on lines
701
to
702
| let line = line.trim_end_matches('\r'); | ||
| if let Some(value) = sse_field_value(line, "event:") { |
Contributor
There was a problem hiding this comment.
The explicit trimming of \r here is redundant because the sse_field_value helper has been updated to handle trailing carriage returns internally (see line 1092). Removing this line simplifies the loop and avoids unnecessary double-trimming of the string slice.
if let Some(value) = sse_field_value(line, "event:") {926b191 to
f16c545
Compare
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.
Fixes #1309
Summary
\rfrom MCP SSEevent:anddata:field values before dispatching endpoint/message eventsVerification
cargo fmt --all -- --checkcargo test -p codewhale-tui sse_git diff --check