Skip to content

Dark mode doesn't switch on and off when the OS automatically switches #158314

Closed

Description

Type: Bug

  1. Set macOS to automatically switch between light mode and dark mode.
  2. Set VS Code to use different themes for light and dark mode.
  3. Before sunset, ensure you are in light mode. Lock your screen and leave your computer.
  4. Have a nice dinner, go for a bike ride, reconnect with friends and family, enjoy a beautiful sunset, and walk your dog.
  5. Later that night, return to your computer. Note the computer has automatically set dark mode, but VS Code is still on light mode.

You'll have to manually switch macOS back to light mode and back again to dark mode for Code to pick up teh dark mode.

VS Code version: Code 1.70.1 (Universal) (6d9b74a, 2022-08-10T06:09:06.916Z)
OS version: Darwin arm64 21.6.0
Modes:

System Info
Item Value
CPUs Apple M1 Ultra (20 x 24)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
metal: disabled_off
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_renderer: enabled_on
video_decode: enabled
video_encode: enabled
webgl: enabled
webgl2: enabled
Load (avg) 6, 6, 5
Memory (System) 128.00GB (2.24GB free)
Process Argv --crash-reporter-id 04103f14-c8dc-42a8-b7b2-1ffef3657f3f
Screen Reader no
VM 0%
Extensions (30)
Extension Author (truncated) Version
vscode-zonefile Com 0.0.4
systemd-unit-file coo 1.0.6
doxdocgen csc 1.4.0
copilot Git 1.40.6471
vscode-pull-request-github Git 0.48.1
vscode-graphql Gra 0.7.3
vscode-graphql-syntax Gra 1.0.4
better-cpp-syntax jef 1.15.19
cmake-language-support-vscode jos 0.0.4
ldif jta 0.2.0
bash-ide-vscode mad 1.14.0
vscode-docker ms- 1.22.1
vscode-dotnet-runtime ms- 1.5.0
python ms- 2022.12.0
vscode-pylance ms- 2022.8.20
jupyter ms- 2022.7.1102252217
remote-containers ms- 0.245.0
remote-ssh ms- 0.84.0
remote-ssh-edit ms- 0.80.0
remote-wsl ms- 0.66.3
cmake-tools ms- 1.11.26
cpptools ms- 1.12.1
cpptools-extension-pack ms- 1.2.0
vsliveshare ms- 1.0.5683
vsliveshare-audio ms- 0.1.91
sqltools mtx 0.23.0
sqltools-driver-pg mtx 0.2.0
vetur oct 0.36.0
cmake twx 0.0.17
vscode-arduino vsc 0.4.12

(3 theme extensions excluded)

A/B Experiments
vsliv368:30146709
vsreu685:30147344
python383:30185418
vspor879:30202332
vspor708:30202333
vspor363:30204092
vslsvsres303:30308271
pythonvspyl392:30443607
vserr242cf:30382550
pythontb:30283811
vsjup518:30340749
pythonptprofiler:30281270
vsdfh931:30280409
vshan820:30294714
vstes263:30335439
vscorecescf:30445987
pythondataviewer:30285071
vscod805:30301674
binariesv615:30325510
bridge0708:30335490
bridge0723:30353136
cmake_vspar411cf:30542925
vsaa593cf:30376535
vsc1dst:30438360
pythonvs932:30410667
wslgetstarted:30449410
vscscmwlcmt:30465135
cppdebug:30492333
pylanb8912cf:30529770
vsclangdf:30486550
c4g48928:30535728
hb751961:30541207
dsvsc012cf:30540253

Activity

  1. aeschli commented on Aug 26, 2022

    @aeschli
    Contributor

    Did you set "window.autoDetectColorScheme": true ?

  2. added
    info-needed
    on Aug 26, 2022
  3. capnajax commented on Aug 26, 2022

    @capnajax
    Author

    Yes I did. The colour changes as it should if I change the OS colour scheme manually, but if the colour scheme automatically changes while the screen is locked, e.g I leave for dinner when it's in light mode, but when I unlock my screen that night OS has switched to dark mode, VSCode does not change its colour scheme. The workaround is I change the OS scheme to light and back to dark; then VSCode picks it up.

  4. darknoon commented on Sep 28, 2022

    @darknoon

    Having the same issue, will try the OS theme workaround!

  5. added
    themes
    and removed
    info-needed
    on Dec 15, 2022
  6. aeschli commented on Dec 16, 2022

    @aeschli
    Contributor

    This is vey likely an Electron issue. VS Code listens to the OS color theme changes that come from Electron, and I suspect one is missing while the screen is locked.

    I you have a chance (and have node and git installed on your machine), can you validate my theory by running this:

    • git clone https://github.com/aeschli/electron-theme-test.git
    • cd electron-theme-test, npm i && npm start
    • a simple electron window opens
    • enjoy your evening
    • when you come back, check the output of the command and paste it here
      There should be some messages showing that the event has been sent
  7. jamieorc commented on May 1, 2023

    @jamieorc

    Having same problem

  8. philoserf commented on May 5, 2023

    @philoserf
    shouldUseDarkColors: false, shouldUseHighContrastColors: false, shouldUseInvertedColorScheme: false
    shouldUseDarkColors: true, shouldUseHighContrastColors: false, shouldUseInvertedColorScheme: false
    

    I see vscode did also adjust. Still, some behavior has changed. If vscode wasn't listening to the change, it remains in the last active theme even after shutdown and restart.

  9. jamieorc commented on May 5, 2023

    @jamieorc

    The latest release 1.78 seems to have fixed this

  10. 8 remaining items

  11. giuliospinozzi commented on Jan 21, 2024

    @giuliospinozzi

    Same for me. macOS Sonoma (latest updates) and VSCode:
    Version: 1.85.2
    Commit: 8b37750
    Date: 2024-01-18T06:40:11.430Z
    Electron: 25.9.7
    ElectronBuildId: 26354273
    Chromium: 114.0.5735.289
    Node.js: 18.15.0
    V8: 11.4.183.29-electron.0
    OS: Darwin arm64 23.2.0

  12. gsimons-nzme commented on Feb 4, 2024

    @gsimons-nzme

    What helped for me was to open up the settings.json manually and changing some lines. It was like this:

    {
        "window.systemColorTheme": "auto",
        "window.autoDetectColorScheme": true,
    }
    

    I removed the systemColorTheme line, saved the file (Cmd+S) and then it did immediataly change colors correctly. It also changed the settings.json to this, though obviously that could also be Dark something if you run it in the evening.

    {
        "window.autoDetectColorScheme": true,
        "workbench.colorTheme": "Default Light Modern",
    }
  13. giuliospinozzi commented on Feb 11, 2024

    @giuliospinozzi

    gsimons-nzme you are right. Now the problem seems fixed! I think that should be included in the app, to solve definitely this issue on Mac.

  14. danawoodman commented on Mar 22, 2024

    @danawoodman

    Seems like VSCode should remove the window.systemColorTheme setting when auto detect is turned on or at least warn a user about it. As it stands now if you set a color scheme and try to use auto, nothing will work unless you figure this bit out.

  15. 247arjun commented on Mar 22, 2024

    @247arjun
    Member

    Did you set "window.autoDetectColorScheme": true ?

    Is there a reason that window.autoDetectColorScheme is not set to true out-of-the-box? Pretty much every other application on my Mac has this default, and toggles based on system preference (including Teams, Outlook and other MSFT apps).

  16. squarewave24 commented on Apr 19, 2024

    @squarewave24
    "window.systemColorTheme": "auto",

    +1

    for me just removing this line was the fix:

    "window.systemColorTheme": "auto",

  17. aeschli commented on Apr 22, 2024

    @aeschli
    Contributor

    I created #210902 for the issue with "window.systemColorTheme": "auto

  18. added
    plan-item
    on Apr 22, 2024
  19. aeschli commented on Apr 22, 2024

    @aeschli
    Contributor

    Marking as fixed. I made the following changes:

    • When window.autoDetectColorScheme is not enabled, we use workbench.colorTheme (as before)
    • When window.autoDetectColorScheme is enabled, we use workbench.preferredDarkColorTheme and workbench.preferredLightColorTheme. workbench.colorTheme is ignored, and also not changed
    • Caveat: window.autoDetectColorScheme is ignored it the system color is hardcoded by window.systemColorTheme
  20. danawoodman commented on Apr 22, 2024

    @danawoodman
  21. aeschli commented on Apr 23, 2024

    @aeschli
    Contributor

    Marking as fixed.

  22. locked and limited conversation to collaborators on Jun 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugon-testplanplan-itemthemes

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions