Skip to content

Fix invisible chat code block text when OS color scheme and app theme disagree#1735

Open
iyernaveenr wants to merge 1 commit into
eigent-ai:mainfrom
iyernaveenr:naveen_r_iyer/fix-markdown-code-block-invisible-text
Open

Fix invisible chat code block text when OS color scheme and app theme disagree#1735
iyernaveenr wants to merge 1 commit into
eigent-ai:mainfrom
iyernaveenr:naveen_r_iyer/fix-markdown-code-block-invisible-text

Conversation

@iyernaveenr

@iyernaveenr iyernaveenr commented Jul 4, 2026

Copy link
Copy Markdown

Problem

In the chat, fenced code block text can render invisible (blank until selected). Originally reported with the OS in dark mode and the app in light theme, but the same failure exists in the mirrored combination (OS light, app dark).

Root cause

github-markdown-css colors code text via --fgColor-default, keyed to the OS color scheme: its @media (prefers-color-scheme: ...) blocks apply the palette to bare .markdown-body, and .markdown-body pre { color: var(--fgColor-default) } picks it up (near-white when OS-dark, near-black when OS-light). The app's custom overrides in src/style/markdown-styles.css force code-block backgrounds per app theme (data-theme): light #f6f8fa, dark #161b22. Whenever the OS scheme and the app theme disagree, the OS-keyed text color lands on an app-keyed background of nearly the same color and becomes unreadable. Body prose is unaffected because a separate .markdown-body { color: inherit } override handles it, but that does not cascade into pre.

Fix

Pin the code text color alongside each forced background, so text and background are always keyed to the same (app) theme:

  • .markdown-body pre uses color: #1f2328 next to its forced light background.
  • [data-theme='dark'] .markdown-body pre uses color: #e6edf3 next to its forced dark background.
  • .markdown-body pre code uses color: inherit so block contents follow the block.

Inline .markdown-body code needs no pin: the stylesheet never sets a text color on it directly, so it correctly inherits the app-theme text color in both themes.

Testing

Verified all four OS-scheme x app-theme combinations on a chat response containing prose, inline code, and a fenced code block:

  • OS dark + app light (the reported bug): code text now readable.
  • OS light + app dark: code text now readable.
  • OS dark + app dark, OS light + app light: unchanged, still readable.

The imported markdown stylesheet colors code text based on the OS color
scheme, while the custom overrides force code block backgrounds based on
the app theme. When the two disagree, code text lands on a background of
nearly the same color and becomes unreadable. Pin the code text color
alongside each forced background so code stays readable in every OS
scheme and app theme combination, and let code inside blocks inherit it.

Signed-off-by: Naveen R. Iyer <iyernaveenr@gmail.com>
@iyernaveenr iyernaveenr force-pushed the naveen_r_iyer/fix-markdown-code-block-invisible-text branch from abf022f to 228b978 Compare July 5, 2026 00:14
@iyernaveenr iyernaveenr changed the title Fix invisible code block text in chat markdown (dark OS theme) Fix invisible chat code block text when OS color scheme and app theme disagree Jul 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants