Skip to content

fix: preserve paragraph breaks between text blocks in bridge responses#144

Merged
op7418 merged 1 commit intoop7418:mainfrom
wujieli0207:fix/bridge-text-block-newlines
Mar 5, 2026
Merged

fix: preserve paragraph breaks between text blocks in bridge responses#144
op7418 merged 1 commit intoop7418:mainfrom
wujieli0207:fix/bridge-text-block-newlines

Conversation

@wujieli0207
Copy link
Contributor

Summary

  • Fixed .join('').join('\n\n') in conversation engine's text block assembly, which was causing multi-paragraph responses to render as a single wall of text in Telegram

Root cause

When Claude's response includes tool calls (Read, Edit, Bash, etc.), the SSE stream splits the response into multiple text content blocks:

Text Block 1: "Let me check the code..."  → tool_use: Read
Text Block 2: "Found the issue. Here's the fix..."  → tool_use: Edit  
Text Block 3: "Done. The changes are..."

These blocks were joined with .join('') (empty string), producing:

Let me check the code...Found the issue. Here's the fix...Done. The changes are...

Now joined with .join('\n\n'):

Let me check the code...

Found the issue. Here's the fix...

Done. The changes are...

Files changed

File Change
src/lib/bridge/conversation-engine.ts .join('').join('\n\n') in both normal and error-recovery paths

Test plan

  • Send a message that triggers tool usage (e.g. "read file X and explain it") → verify response paragraphs have proper line breaks in Telegram
  • Send a simple message with no tool calls → verify single text block still renders correctly
  • Verify the desktop UI is unaffected (it uses a different rendering path)

🤖 Generated with Claude Code

When Claude's response includes tool calls (Read, Edit, Bash, etc.),
the response text is split into multiple content blocks — one before
each tool call and one after. These blocks were joined with an empty
string (.join('')), causing all paragraphs to concatenate without
any spacing in the final Telegram message.

Changed .join('') to .join('\n\n') so paragraph breaks between text
blocks are preserved, matching how they appear in the desktop UI.
Copy link
Owner

@op7418 op7418 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Simple and correct fix.

.join('').join('\n\n') for text block assembly is the right call. When Claude's response spans multiple text blocks (interleaved with tool calls), joining without separators creates a wall of text. The \n\n separator preserves paragraph breaks.

Both the normal path and the error-recovery path are updated consistently. No side effects on the desktop UI (which uses a different rendering pipeline).

@op7418 op7418 merged commit 3f19290 into op7418:main Mar 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants