Skip to content

core: lay out Markdown lists once every changed block shows - #2199

Merged
simonklee merged 1 commit into
mainfrom
tuireg/md-updatelist-ordinal
Nov 23, 2026
Merged

simonklee merged 1 commit into
mainfrom
tuireg/md-updatelist-ordinal

Conversation

@simonklee

Copy link
Copy Markdown
Member

OpenCode 2.4.0 users can see the TUI crash with undefined is not an object (evaluating 'c.ordinal=o++') while an answer with lists streams in.

When a Markdown update showed a block again in a new renderable, the block's lists were laid out at once, before the blocks added later in the same update were shown. A list that counted its items then read an item that was not shown yet and threw. Updates that reach this include a list item whose paragraph becomes a table as the next item arrives, a list a renderBlock renderer shows again as a nested item arrives, and a fence that a code block renderer takes over in a list item. OpenTUI 0.9.4 through 0.9.8 have it.

Showing a block again now adds its tables and lists to the update's single layout pass, which runs after every block of the update is shown. A style change uses the same pass. The change removes code; it adds no new state.

Two rows in an existing Markdown list test stream these updates. Before the fix both throw in the list layout; now they render as a fresh render does.

Fixes anomalyco/opencode#65766

A block shown again in a new default (a list a renderer shows again, a fence a code-block renderer takes over, or an item's paragraph that becomes a table) showed its descendants and laid out their lists at once, in the middle of the change. Blocks the change added later were not shown yet, so a list that counted its items read one that was missing and threw "undefined is not an object (evaluating 'shown.ordinal = count++')".

Showing descendants now adds their tables and lists to the caller's refresh, which runs after the change has shown every block; a style change runs the same refresh. The added show() parameter replaces the local refresh in showDescendants and restyle's own table and list arrays (source -1 line).

Fixes anomalyco/opencode#65766
@simonklee
simonklee requested a review from kommander as a code owner November 23, 2026 21:55
@simonklee
simonklee merged commit e45f43f into main Nov 23, 2026
22 checks passed
@simonklee
simonklee deleted the tuireg/md-updatelist-ordinal branch November 23, 2026 22:03
Dicklesworthstone pushed a commit to Dicklesworthstone/opentui that referenced this pull request Nov 23, 2026
…o#2199)

OpenCode 2.4.0 users can see the TUI crash with `undefined is not an
object (evaluating 'c.ordinal=o++')` while an answer with lists streams
in.

When a Markdown update showed a block again in a new renderable, the
block's lists were laid out at once, before the blocks added later in
the same update were shown. A list that counted its items then read an
item that was not shown yet and threw. Updates that reach this include a
list item whose paragraph becomes a table as the next item arrives, a
list a `renderBlock` renderer shows again as a nested item arrives, and
a fence that a code block renderer takes over in a list item. OpenTUI
0.9.4 through 0.9.8 have it.

Showing a block again now adds its tables and lists to the update's
single layout pass, which runs after every block of the update is shown.
A style change uses the same pass. The change removes code; it adds no
new state.

Two rows in an existing Markdown list test stream these updates. Before
the fix both throw in the list layout; now they render as a fresh render
does.

Fixes anomalyco/opencode#65766

(cherry picked from commit e45f43f)
simonklee added a commit that referenced this pull request Nov 26, 2026
Two models could not reach the Markdown list crash (#2199) or the stale
size after resume (#2181). Each now generates the input its bug needed
and finds the bug with the fix reverted. Builds on the duplicated code
block fix, which the new input found; merge that first.
The Markdown model switches `renderBlock` between four renderers, two of
which take over code blocks; it finds #2199 at seed 985. P7 and P8 now
also skip a line starting with "```" whose info string holds a backtick:
CommonMark makes that no fence, so the run may still close as a code
span while streaming.
The session simulation resizes the terminal while suspended, without a
SIGWINCH, and checks the resumed renderer's size; 31 of 170 rows fail
without the #2181 fix.
CI time grows by about 0.2 s.
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.

TUI crash: undefined is not an object (evaluating 'c.ordinal=o++')

1 participant