Skip to content

TextView markdown: trailing-only debounce starves reparse under steady streaming updates #2634

Description

@robert-claypool

Summary

TextView's markdown reparse runs on a trailing debounce (~200ms, reset on every text change). A caller that commits streamed text on a steady cadence faster than the debounce window resets the timer every time, so the reparse never runs while the stream is live — the view can go the entire stream without painting an update.

Reproduce

Drive TextView::markdown with text updated every ~50-100ms (a typical LLM token stream commit cadence). Observed in our app: a 55ms reveal cadence never painted once until the stream ended; pacing our commits above the debounce window was the workaround.

Suggested shape

A trailing debounce is right for a human typing, but streaming needs one of:

  • a max-wait (leading-edge or throttle) bound so a continuously-updated view still reparses every N ms,
  • a configurable debounce on TextViewStyle or the builder, or
  • an explicit flush()/finalize seam the caller can invoke.

Any of the three would do; the max-wait throttle preserves current behavior for typing while fixing streaming.

v0.5.1, behavior unchanged on current main. Found while using the crate as a streaming chat renderer; happy to test a patch.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions