Skip to content

fix(core): add missing requestRender() in CodeRenderable streaming content setter - #965

Merged
simonklee merged 1 commit into
anomalyco:mainfrom
altendky:fix/code-renderable-streaming-request-render
Apr 23, 2026
Merged

simonklee merged 1 commit into
anomalyco:mainfrom
altendky:fix/code-renderable-streaming-request-render

Conversation

@altendky

Copy link
Copy Markdown
Contributor

Fixes #963

Summary

When streaming content into a CodeRenderable with _drawUnstyledText=false and an active _filetype, the content setter was returning early without calling requestRender(). If the renderer was otherwise idle (no animations, no input), no frame was ever scheduled, so renderSelf() never ran, startHighlight() never started, and the display stayed stale indefinitely.

Root Cause

The streaming optimization in the content setter:

if (this._streaming && !this._drawUnstyledText && this._filetype) {
  return  // no requestRender()
}

Stored the new content and marked highlights dirty, but never scheduled a render frame.

Fix

Added this.requestRender() before the early return:

if (this._streaming && !this._drawUnstyledText && this._filetype) {
  this.requestRender()
  return
}

Test

Added packages/core/src/renderables/__tests__/Code.test.ts with a test that verifies:

  1. Setting content in streaming mode schedules a render
  2. The subsequent render triggers startHighlight() (asserted via isHighlighting and mock client state)

Verification

  • New test: 1 pass
  • Existing LineNumberRenderable tests (which exercise CodeRenderable): 29 pass, 0 fail

@simonklee
simonklee merged commit 5e20a2e into anomalyco:main Apr 23, 2026
14 checks passed
m-pa pushed a commit to m-pa/opentui that referenced this pull request Apr 27, 2026
…ntent setter (anomalyco#965)

Fixes anomalyco#963

## Summary
When streaming content into a `CodeRenderable` with
`_drawUnstyledText=false` and an active `_filetype`, the `content`
setter was returning early without calling `requestRender()`. If the
renderer was otherwise idle (no animations, no input), no frame was ever
scheduled, so `renderSelf()` never ran, `startHighlight()` never
started, and the display stayed stale indefinitely.

## Root Cause
The streaming optimization in the `content` setter:
```ts
if (this._streaming && !this._drawUnstyledText && this._filetype) {
  return  // no requestRender()
}
```
Stored the new content and marked highlights dirty, but never scheduled
a render frame.

## Fix
Added `this.requestRender()` before the early return:
```ts
if (this._streaming && !this._drawUnstyledText && this._filetype) {
  this.requestRender()
  return
}
```

## Test
Added `packages/core/src/renderables/__tests__/Code.test.ts` with a test
that verifies:
1. Setting content in streaming mode schedules a render
2. The subsequent render triggers `startHighlight()` (asserted via
`isHighlighting` and mock client state)

## Verification
- New test: **1 pass**
- Existing `LineNumberRenderable` tests (which exercise
`CodeRenderable`): **29 pass, 0 fail**
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CodeRenderable streaming content updates stall when renderer is idle

2 participants