[PR #6197] Theme Toggle that bypasses the auto detector on demand if needed #11776

Closed
opened 2026-02-16 18:16:43 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/6197

State: closed
Merged: No


This pull request adds support for a persistent light/dark theme mode in the app. The main changes include reading and storing the user's preferred theme mode in localStorage, updating the HTML root attribute accordingly, and providing a UI button to toggle between light and dark modes.

Theme mode persistence and initialization:

  • Both packages/app/index.html and packages/desktop/index.html now read the theme-mode value from localStorage and set the data-theme-mode attribute on the HTML root element if the value is "light" or "dark". [1] [2]
  • In packages/app/src/pages/layout.tsx, the initial theme mode is determined by checking localStorage or falling back to the user's system preference using window.matchMedia.

Theme mode UI and logic:

  • A new button is added to the sidebar that displays the current theme mode and allows users to toggle between light and dark modes. Toggling updates the signal, persists the choice in localStorage, and updates the data-theme-mode attribute. [1] [2]
  • The theme mode is also applied on mount to ensure the correct mode is set when the app loads.
**Original Pull Request:** https://github.com/anomalyco/opencode/pull/6197 **State:** closed **Merged:** No --- This pull request adds support for a persistent light/dark theme mode in the app. The main changes include reading and storing the user's preferred theme mode in `localStorage`, updating the HTML root attribute accordingly, and providing a UI button to toggle between light and dark modes. Theme mode persistence and initialization: * Both `packages/app/index.html` and `packages/desktop/index.html` now read the `theme-mode` value from `localStorage` and set the `data-theme-mode` attribute on the HTML root element if the value is `"light"` or `"dark"`. [[1]](diffhunk://#diff-1c3e4795eed89a967885c61f661769c943aaddf5a0e9fe4784d7a0e98f03d879R22-R25) [[2]](diffhunk://#diff-e374c253598417df1787639698f6f59c558d077cf790b50e880c39b59a42f371R22-R25) * In `packages/app/src/pages/layout.tsx`, the initial theme mode is determined by checking `localStorage` or falling back to the user's system preference using `window.matchMedia`. Theme mode UI and logic: * A new button is added to the sidebar that displays the current theme mode and allows users to toggle between light and dark modes. Toggling updates the signal, persists the choice in `localStorage`, and updates the `data-theme-mode` attribute. [[1]](diffhunk://#diff-13d10ff2accc89b815ef7cf33e89f5a7f21766d940d487a68960a814f7898165R771-R781) [[2]](diffhunk://#diff-13d10ff2accc89b815ef7cf33e89f5a7f21766d940d487a68960a814f7898165R92-R113) * The theme mode is also applied on mount to ensure the correct mode is set when the app loads.
yindo added the pull-request label 2026-02-16 18:16:43 -05:00
yindo closed this issue 2026-02-16 18:16:43 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#11776