Skip to content

fix(app): use resolved Shiki theme for code blocks#2467

Open
taneja-garvit wants to merge 2 commits into
different-ai:devfrom
taneja-garvit:fix/2440-shiki-dark-theme
Open

fix(app): use resolved Shiki theme for code blocks#2467
taneja-garvit wants to merge 2 commits into
different-ai:devfrom
taneja-garvit:fix/2440-shiki-dark-theme

Conversation

@taneja-garvit

Copy link
Copy Markdown

Fixes #2440

Summary

  • use the resolved app theme for Shiki code highlighting instead of hardcoding github-light
  • fix unreadable code blocks in dark mode
  • update shared markdown/code rendering paths so code blocks refresh when theme changes

Fixes #2440

Test plan

  • Switch to dark mode and render a code block in an assistant message
  • Confirm syntax colors use the dark Shiki palette
  • Switch back to light mode and confirm code blocks update correctly
  • pnpm typecheck
  • pnpm --filter @openwork/app exec bun test tests/theme.test.ts

@vercel

vercel Bot commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
openwork-landing Ready Ready Preview, Comment, Open in v0 Jul 8, 2026 7:57pm

@vercel

vercel Bot commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

@taneja-garvit is attempting to deploy a commit to the Different AI Team on Vercel.

A member of the Team first needs to authorize it.

@Pablosinyores Pablosinyores left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Read through this and the approach is right. useSyncExternalStore(subscribeToTheme, getResolvedShikiTheme) is the correct primitive for pulling theme into render without a hand-rolled listener, and adding shikiTheme to the highlight effect deps in both MarkdownBlockInner and CodeBlockCode is what actually makes blocks re-highlight on toggle. The theme ?? resolvedTheme fallback in CodeBlockCode keeps explicit-theme callers working while defaulting everything else to the resolved app theme — clean.

One minor thing in markdown.tsx: the cached-HTML shortcut

const html = !streaming && highlightedHtml?.text === text ? highlightedHtml.html : syncHtml;

is keyed on text only, not on theme. On a light/dark toggle where the text is unchanged, highlightedHtml.text === text stays true, so the previously highlighted (old-theme) HTML shows until the effect's async re-highlight resolves and replaces highlightedHtml. It self-corrects because the effect now depends on shikiTheme, so it is a brief flash rather than a stuck state — just flagging in case you want to also gate that memo on theme to kill the transient. Not a blocker.

Mapping resolved light/dark to github-light/github-dark is exactly the right scope for #2440. Nice fix.

@taneja-garvit

Copy link
Copy Markdown
Author

Good catch - makes sense, the memo should be theme-aware too so we don't even get the transient. Pushing a fix now to also gate highlightedHtml on shikiTheme

@taneja-garvit

taneja-garvit commented Jul 8, 2026

Copy link
Copy Markdown
Author

@Pablosinyores Pushed a small follow-up for this. I made the cached highlighted HTML theme-aware as well, so we don’t briefly reuse old-theme Shiki output during a light/dark toggle.

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.

Code block dark mode bug - Shiki theme hardcoded to github-light

2 participants