Skip to content

Fix poor dark-mode contrast in the code editor#21

Merged
vecnode merged 1 commit into
mainfrom
ace-dark-theme-fix
Jul 11, 2026
Merged

Fix poor dark-mode contrast in the code editor#21
vecnode merged 1 commit into
mainfrom
ace-dark-theme-fix

Conversation

@vecnode

@vecnode vecnode commented Jul 11, 2026

Copy link
Copy Markdown
Owner

Summary

  • The vendored Ace "textmate" theme hardcodes light-only syntax colours (plain blue keywords/numbers), which read poorly against the dark theme added in Add light/dark theme toggle #20.
  • Vendored a second Ace theme built for dark backgrounds (tomorrow_night, from ace-builds@1.44.0 - same version as the already-committed ace.js) instead of patching textmate's colours.
  • script.js now swaps the whole Ace theme (ACE_THEME_LIGHT/ACE_THEME_DARK) alongside the app's [data-theme] flip.
  • Fully local/offline: the new file is vendored into public/libs/, embedded into the binary at build time exactly like every other frontend asset - no runtime network fetch, same as the rest of the app.
  • Removed the now-dead .ace-tm dark CSS overrides from the previous round (dark mode uses a different theme's class now, not .ace-tm).

Test plan

  • node --check public/script.js passes.
  • Built and ran locally; loaded an example sketch and inspected computed colours:
    • Light theme: function/let keywords rgb(0,0,255) (unchanged, textmate's original blue - fine on white).
    • Dark theme: keywords rgb(178,148,187) (purple), numbers rgb(222,147,95) (orange), comments rgb(150,152,150) (grey), function names rgb(129,162,190) (blue-grey) - the tomorrow_night palette, all legible against the rgb(30,28,25) dark background.
    • Toggling back to light restores the original colours exactly.
  • No console errors after toggling and loading a sketch.

Generated with Claude Code

The vendored Ace "textmate" theme hardcodes light-only syntax colours (plain
blue #0000FF keywords/numbers), which read poorly against the dark theme's
background. Rather than patch textmate's colours, vendor a second Ace theme
actually designed for dark backgrounds and swap the whole theme alongside the
app's light/dark toggle:

- public/libs/theme-tomorrow_night.js: vendored from ace-builds@1.44.0 (same
  version as the already-committed ace.js), src-noconflict variant to match
  the existing theme-textmate.js. Fully local - embedded into the binary via
  cpp-embedlib at build time like every other file under public/, no runtime
  fetch.
- public/script.js: ACE_THEME_LIGHT/ACE_THEME_DARK constants; applyTheme()
  now calls aceEditor.setTheme(...) alongside the CSS [data-theme] flip, and
  initializeEditor() picks the right one on first load. Moved the aceEditor
  declaration earlier in the file so applyTheme() can read it at the app's
  very first (pre-editor-init) theme application without a temporal-dead-
  zone error.
- public/style.css: removed the now-dead [data-theme="dark"] .ace-tm
  overrides from the previous round (dark mode no longer uses the .ace-tm
  class at all, since it's a different theme now).
- AGENTS.md: updated to describe the theme-swap approach.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@vecnode vecnode merged commit b93b640 into main Jul 11, 2026
@vecnode vecnode deleted the ace-dark-theme-fix branch July 11, 2026 18:36
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.

1 participant