You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: merge streamed agent message chunks to prevent fragmentation (#6835)
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
- I have read the
https://github.com/marimo-team/marimo/blob/main/CONTRIBUTING.md.
- For large changes, or changes that affect the public API: this change
was discussed or approved through an issue, on
https://marimo.io/discord?ref=pr, or the community
https://github.com/marimo-team/marimo/discussions (Link:
#6834)
- I have added tests for the changes made. (Note: This is a UI fix for
streaming behavior; manual testing performed with local marimo instance)
- I have run the code and verified that it works as expected.
- Frontend builds successfully (make fe)
- Linting and type checking pass (pnpm lint, pnpm typecheck)
- Manual testing with local marimo server
---
---------
Co-authored-by: Shubham Singh Tomar <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
0 commit comments