Skip to content

fix(tui): restyle streamed markdown lists on theme swap - #56323

Open
Finn763 wants to merge 3 commits into
anomalyco:devfrom
Finn763:theme-list-restyle
Open

Finn763 wants to merge 3 commits into
anomalyco:devfrom
Finn763:theme-list-restyle

Conversation

@Finn763

@Finn763 Finn763 commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Issue for this PR

Closes #55735

Type of change

  • Bug fix

What does this PR do?

A theme swap left list items on the previous theme's colors. opentui's MarkdownRenderable resolves each block's colors when the block is built, and its own style refresh skips list items whose raw text did not change, so reassigning syntaxStyle re-colors paragraphs, bold and inline code but not list markers or list item text.

  • mini scrollback (opencode run): rebuild the active Markdown tree on theme change, the same way setMono already does.
  • session view (routes/session/message-parts.tsx): remount the markdown element when the syntax style changes, which rebuilds the tree against the new theme.

How did you verify your code works?

  • theme swaps restyle streamed markdown lists (mini) fails on base, with the marker retaining the previous theme color, and passes with the fix.
  • rebuilds the markdown tree when the syntax style changes (session component) fails without the keyed remount and passes with it.
  • bun test test/markdown-streaming.test.tsx test/mini/scrollback.surface.test.ts — 23 pass, 1 pre-existing skip; bun run typecheck clean.

Screenshots / recordings

N/A (covered by the tests above).

Checklist

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

@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label Oct 17, 2026
@github-actions

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

@opencode-agent opencode-agent Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fixes the list colors in mini mode (opencode run), but it does not fix #55735 as reported. I ran the issue's reproduction script on the base and with this PR. In both runs, after switching from light to dark, the list text and - markers kept their light-mode colors in the normal session view (screenshots below). The reported bug happens there: packages/tui/src/routes/session/message-parts.tsx (and routes/session/index.tsx) render <markdown internalBlockMode="top-level"> directly, and they never use RunScrollbackStream.

The mini-mode change looks sound. It reuses the rebuild that setMono already does, your new test fails on the base and passes here, all 22 tests in scrollback.surface.test.ts pass, and typecheck is clean. To close #55735, the session view needs a fix too. That could be a remount or clearCache() of the markdown component when the theme changes, or a fix in opentui's MarkdownRenderable so a style refresh also refreshes list items, which would fix both places at once. Otherwise, please change Fixes #55735 to a reference and describe this as the mini-mode part.

The test reads opentui internals (_blockStates, child index paths), so it may break on opentui upgrades. A smaller check through the rendered frame would hold up better.

Public API: unchanged.

Before

After

return
}

if (active.renderable instanceof MarkdownRenderable) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This only covers the mini (opencode run) scrollback. The session view where #55735 was reproduced renders markdown in routes/session/message-parts.tsx. With this PR, the issue's reproduction there still shows stale list colors after a light/dark switch. The cause you describe (style refresh skipping unchanged list items) is in opentui's MarkdownRenderable, so fixing it there, or adding a rebuild on theme change in the session view as well, would be needed to close the issue.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks — right, the issue reproduces in the session view. Added the session-view fix: message-parts.tsx now remounts the markdown element when the syntax style changes (<Show keyed>), so the tree is rebuilt against the new theme the same way the mini scrollback now rebuilds its active entry. New component test covers it: the list marker keeps the previous theme color without the keyed remount and switches with it. Kept the mini fix as well since it had the same failure.

@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Oct 17, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

@opencode-agent opencode-agent Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My earlier concern is resolved: the session view is now fixed. I reran the #55735 reproduction on this head. List text and markers now follow light→dark and back to light, matching the paragraph (before = base, after = this PR). The remount only fires when the theme's syntax style changes, and streamed content comes back after a remount through the same content/streaming props. markdown-streaming and scrollback.surface tests pass (25), and typecheck is clean.

One gap: the compaction summary in routes/session/index.tsx (around line 2082) and feature-plugins/prompt/btw.tsx still render <markdown internalBlockMode="top-level"> directly. They will likely keep stale list colors after a theme swap. Switching them to ThemedMarkdown would cover the rest of the session UI.

Public API: unchanged.

Before

After

@Finn763

Finn763 commented Oct 17, 2026

Copy link
Copy Markdown
Contributor Author

Switched both remaining sites to the same component: the compaction summary in routes/session/index.tsx and feature-plugins/prompt/btw.tsx now render through ThemedMarkdown, so they remount on syntax-style changes too. Typecheck clean; markdown-streaming tests pass.

This branch has not been deployed

No deployments
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: markdown list text keeps old theme color after light/dark switch

1 participant