GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(session-ui): grow markdown live tail in place by dcerisano · Pull Request #48432 · anomalyco/opencode

Conversation

@dcerisano

@dcerisano dcerisano commented Sep 11, 2026

Copy link
Copy Markdown

Issue for this PR

Closes #36043 — jointly with the tui-delta-coalesce PR. Each applies
independently (different layer, no shared code, merge in either order);
only together do they remove O(n²) from both client-side stages of the
stream path and fully close the freeze. Builds on the freeze diagnosis in
#41472.

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

While streaming, the markdown projection re-parsed the entire accumulated text
on every delta, even when the previous text was unchanged and the new suffix
was small. Each re-lex is O(length), so a stream of n small deltas costs
O(n²) — the dominant cost in the TUI freeze once deltas are batched.

project() in markdown-stream.ts now grows the open live tail in place
instead of re-lexing, and only re-lexes when the new suffix contains a
blank-line block boundary or the raw text exceeds a 2048-char cap. A single
giant boundary-less paragraph/list/table therefore never re-parses per delta.

Because the projection lives in the shared session-ui package, web and
desktop also inherit the cheaper project() as a free performance win, even
though their per-token rendering is not the freeze described in #36043.

Counterpart on the store side: the tui-delta-coalesce PR (coalesces
message.part.delta events per part in a delta buffer, flushing to the store
on a 32 ms timer instead of once per event). Together they remove O(n²) from
both halves of the TUI stream path — the markdown projection here, the store
writes there.

How did you verify your code works?

  • bun test: 26 markdown-stream tests (incl. a new test growing a
    boundary-less oversized tail in place without splitting) — 86 tests, 0
    failures.
  • bun typecheck clean in packages/session-ui.
  • oxlint: 0 errors.
  • Micro-benchmark streaming 6–15 KB through project() in small deltas
    (Bun): paragraphs 1399 ms → 20 ms, single 15 KB paragraph 32345 ms → 161 ms,
    growing list 4467 ms → 60 ms.

Screenshots / recordings

N/A — no visual change; it's a rendering-perf fix (benchmark above).

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Tracking: #48430

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@dcerisano
fix(session-ui): grow markdown live tail in place with bounded re-lex
fc2acff
@dcerisano dcerisano mentioned this pull request Sep 11, 2026
[FEATURE]: Land two-stage TUI streaming freeze fix for #36043 #48430
Closed
3 tasks done
@github-actions github-actions Bot mentioned this pull request Sep 11, 2026
fix(tui): coalesce message.part.delta store writes #48431
Closed
4 of 6 tasks
@dcerisano
Merge branch 'dev' into live-tail
b4951bd
@opencode-agent opencode-agent Bot mentioned this pull request Oct 10, 2026
app: each visible streaming delta re-walks the whole markdown node array in the session-ui store #54305
Open
@thdxr

thdxr commented Oct 10, 2026

Copy link
Copy Markdown
Member

This branch has been upgraded to V2. We're no longer taking PRs for V1. If you think this is still relevant, please port it over and open it for V2.

— from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@thdxr thdxr closed this Oct 10, 2026
This was referenced Oct 11, 2026
refactor(session-ui): append to the markdown store by path #54427
Closed
app: a streaming delta re-parses the whole markdown block, and the DOM round-trip around it dominates the visible cost #54428
Closed
@dcerisano

dcerisano commented Oct 14, 2026

Copy link
Copy Markdown
Author

This branch has been upgraded to V2. We're no longer taking PRs for V1. If you think this is still relevant, please port it over and open it for V2.

— from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊

This is the dev branch which is still producing V1 binaries. V2 binary is still identified as beta. V1 is in LTS production environments and will be for many years. V1 requires maintenance PRs exactly like this one.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@dcerisano dcerisano mentioned this pull request Oct 15, 2026
fix(session-ui): optimize incremental markdown projection #55857
Closed
3 of 6 tasks
@dcerisano

dcerisano commented Oct 15, 2026

Copy link
Copy Markdown
Author

V2 port opened: #55857

Per the request to port this to V2, #55857 re-implements the live-tail optimization against the current packages/session-ui/src/components/markdown-stream.ts. project() grows the open mode: "live" tail in place and re-lexes only the tail past the 2048-char cap on a blank-line boundary, preserving frozen blocks. The V2 port adds the edges V1 did not need: late reference definitions, frozen display math, fence-open detection, and rebuilding the tail raw from source text. Micro-benchmark: 12.6 KB boundary-less paragraph 10.8 s → 91 ms (~119×).

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This was referenced Oct 15, 2026
fix(session-ui): reuse parsed DOM for live markdown #55480
Closed
app: markdown projection re-lexes the whole accumulated message on every streaming delta #56202
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

TUI scroll freezes for seconds during fast-streaming responses (message.part.delta applied per-chunk with no batching)

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@dcerisano @thdxr
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.