Skip to content

Conversation

@sshtomar
Copy link
Contributor

When external agents (e.g., Claude Code) stream responses via WebSocket, each chunk was being rendered as a separate content block, resulting in fragmented display with gaps between chunks.

This change merges consecutive text blocks into a single block before rendering, providing a continuous, readable message display.

Fixes #6834

Solution

Added a mergeConsecutiveTextBlocks() helper function in frontend/src/components/chat/acp/blocks.tsx that:

  1. Iterates through all content blocks from streamed chunks
  2. Concatenates consecutive text blocks into a single unified text block
  3. Preserves non-text blocks (images, audio, resources) in their original positions
  4. Returns merged content for continuous display

Modified AgentMessagesBlock component to use this function before rendering, ensuring streamed text appears as a single, readable message.

Technical Details

  • File modified: frontend/src/components/chat/acp/blocks.tsx
  • Lines added: 47 (40 for the helper function + 7 for integration)
  • Algorithm: Simple text accumulation with flush-on-non-text-block logic
  • Backward compatible: Does not affect existing functionality or other message types

Additional Changes

The linter auto-fixed 12 other files for code style consistency (naming conventions, type syntax, numeric separators, copyright headers). These are purely formatting changes with no functional impact.

Checklist


When external agents (e.g., Claude Code) stream responses via WebSocket,
each chunk was being rendered as a separate content block, resulting in
fragmented display with gaps between chunks.

This change merges consecutive text blocks into a single block before
rendering, providing a continuous, readable message display.

Fixes marimo-team#6834
@vercel
Copy link

vercel bot commented Oct 19, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
marimo-docs Ready Ready Preview Comment Oct 19, 2025 5:38am

💡 Enable Vercel Agent with $100 free credit for automated AI reviews

@github-actions
Copy link


Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just posting a Pull Request Comment same as the below format.


I have read the CLA Document and I hereby sign the CLA


Shubham Singh Tomar seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot.

@sshtomar
Copy link
Contributor Author

I have read the CLA Document and I hereby sign the CLA

@mscolnick mscolnick merged commit 66b47b9 into marimo-team:main Oct 22, 2025
23 of 29 checks passed
@dmadisetti dmadisetti added the bug Something isn't working label Oct 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Agents panel splits streamed messages into many lines when connected to Claude Code via WebSocket

3 participants