-
Notifications
You must be signed in to change notification settings - Fork 2.6k
fix: convert escaped newlines to actual newlines in Claude Code output #6711
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -56,7 +56,7 @@ export class ClaudeCodeHandler extends BaseProvider implements ApiHandler { | |
| if (typeof chunk === "string") { | ||
| yield { | ||
| type: "text", | ||
| text: chunk, | ||
| text: chunk.replace(/\\n/g, "\n"), | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good fix! Though I'm wondering - should we also handle other escape sequences like or that might appear in Claude Code output? Currently we only handle . |
||
| } | ||
|
|
||
| continue | ||
|
|
@@ -100,7 +100,7 @@ export class ClaudeCodeHandler extends BaseProvider implements ApiHandler { | |
| case "text": | ||
| yield { | ||
| type: "text", | ||
| text: content.text, | ||
| text: content.text.replace(/\\n/g, "\n"), | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same consideration here - should we handle and as well? Also, a brief comment explaining why this transformation is necessary would help future maintainers understand the context (e.g., "Convert escaped newlines from Claude Code process output to actual newlines for proper rendering"). |
||
| } | ||
| break | ||
| case "thinking": | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent test coverage! The tests thoroughly verify the newline conversion behavior.
One minor suggestion: Consider adding a test case for edge cases like empty strings or null/undefined text content to ensure the replace operation handles these gracefully.