Skip to content

Bug with constantly reverting back to light mode quicklook, even though OSX is in dark #309

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
seaders opened this issue Apr 11, 2025 · 6 comments

Comments

@seaders
Copy link

seaders commented Apr 11, 2025

I think this bug is best shown with a screenrecord:

darklight.mov.mp4

You can see that it's showing up as very bright light, despite me being in dark mode. When I then change to OSX's light mode, it changes to dark for a second (I think incorrectly?), and then back to light. Then I switch back to dark mode, and it does nothing. Then I go light mode, dark mode again, and it shows as dark mode, properly now, but when I go to another file, it's back in light mode again.

I looked in the code, as per the advice here https://developer.apple.com/documentation/uikit/supporting-dark-mode-in-your-interface which had this snippet

    observation = NSApp.observe(\.effectiveAppearance) { (app, _) in
        app.effectiveAppearance.performAsCurrentDrawingAppearance {
            // Invoke your non-view code that needs to be aware of the
            // change in appearance.
        }
    }

But the only reference to effectiveAppearance in the code is here,

    /// Check if the appearance is Dark
    lazy var isDarkMode: Bool = {
        // fixme: nell'estensione non sempre restituisce il valore aggiornato!
        if let appearance = self.view.effectiveAppearance.bestMatch(from: [.darkAqua, .aqua]) {
            return appearance == .darkAqua
        }
        return false
    }()

Which seems to be where the problem is. The fixme there is translated as

in the extension it does not always return the updated value

But yeah, for my experience, it's not a sometimes issue, this is never right, for me, when in dark mode.

@AWH1122
Copy link

AWH1122 commented Apr 24, 2025

I seem to be having the same issue too.

@sbarex
Copy link
Owner

sbarex commented Apr 24, 2025

Try using the HTML rendering engine. The RTF on the dark theme has some bugs, macOS automatically changes the background.
In a future release I think I will remove the choice and leave only the HTML engine.

@seaders
Copy link
Author

seaders commented Apr 24, 2025

This is the quicklook view I get when I switch to the HTML engine

Image

Which, for browsing through files, I'd absolutely hate to be forced into only having that @sbarex . For quickly scanning through files, the RTF view is essential IMO, even with the light mode issue / other bugs.

@sbarex
Copy link
Owner

sbarex commented Apr 24, 2025

this is unfortunately another limitation of macos, in gallery mode the html preview only shows the enlarged icon of the file (while the rtf preview shows the formatted text). Try to see in the quicklook window how it looks (press the space button)

@seaders
Copy link
Author

seaders commented Apr 24, 2025

Yeah no, that part is completely fine - including the dark mode issue. The popup view works 100% with HTML, but just checking now and the RTF issue seems to be backwards?

Image

Btw, I'm more than happy to spend a bit of time investigating this issue myself, I just wasn't totally sure how I go about installing the service locally from the XCode project. I was in there poking around the other day, but just don't have any of that specific MacOS app dev experience, on the services-ish side of things.

@sbarex
Copy link
Owner

sbarex commented Apr 24, 2025

I have not found any Apple documentation regarding RTF codes for managing dark mode. Theoretically it is possible to create RTF files that automatically adapt to the light/dark theme.

By the way, the creation of the RTF output is managed by the external Highlight engine, so it is not easy to intervene. I remember that even just setting the background color was not a simple thing years ago. However, as long as it is not clear which RTF codes are needed, the problem of how to implement the corrections does not arise.

Some ideas can be found in:

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

No branches or pull requests

3 participants