dotnet / dotnet/aspnetcore

Components.AI: Parse streamed text incrementally

Open
#68,458 0 comments 0 reactions 0 assignees View on GitHub
area-blazor cost: M feature-blazor-builtin-components performance Priority:0
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 5h
Merged PRs (30d)
276

Description

### Problem

`TextBlockHandler.Handle` appends each streamed text update and calls `RebuildParagraphs`, which rescans all accumulated `RawText` and replaces the full paragraph collection for every update. Long responses perform repeated work and allocations as the response grows.

### Proposed fix

Maintain incremental paragraph parsing state and update only the trailing paragraph affected by each streamed chunk. Preserve the current blank-line and chunk-boundary behavior, and add focused tests for paragraph separators split across updates.

Contributes to #68227.

Contributor guide

Open the contributing guide

Research direction

Locate TextBlockHandler.Handle and RebuildParagraphs, then trace how streamed updates build RawText and replace the paragraph collection. Preserve blank-line and chunk-boundary behavior while maintaining incremental parsing state for only the trailing paragraph. Add focused tests covering paragraph separators split across updates and verify long streamed responses avoid rescanning all accumulated text.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
ai
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.