github / CopilotForXcode

Xcode extension for GitHub Copilot
MIT License
1.94k stars 37 forks source link

Copilot applies incorrectly styled theme to suggestions #9

Closed larsemig closed 3 weeks ago

larsemig commented 1 month ago

Describe the bug The code suggestions seem to be styled for the light theme of xcode. However I am using the Default Dark theme of Xcode. I just installed the tool. Switching the themes back and forth in xcode didn't help.

Versions

Steps to reproduce For me it was just:

  1. Install CopilotForXode
  2. Open Xcode
  3. Use it

Screenshots Bildschirmfoto 2024-10-30 um 09 04 07 Bildschirmfoto 2024-10-30 um 09 04 27 Bildschirmfoto 2024-10-30 um 09 07 23

Logs github-copilot-for-xcode.log

Additional context This is just a problem on my machine. For my colleagues, it works just fine.

devm33 commented 4 weeks ago

Hi thanks for trying out Copilot for Xcode and sharing your feedback!

To troubleshoot the background color issue, would you mind installing this debug build and sharing the logs (~/Library/Logs/GitHubCopilot/github-copilot-for-xcode.log) after running it?

https://github.com/github/CopilotForXcode/releases/download/0.27.92/GitHubCopilotForXcode_debugThemeLogging.dmg

armanarutiunov commented 3 weeks ago

Hello! I'm experiencing the same issue (copilot 0.27.92, xcode 16.1, macOS 15.1).

I have 2 custom built themes (light and dark) and I iterate between them frequently. Copilot extension always provides the same background that caters for my light theme even when I switch to the dark theme.

However, I noticed that instead of syncing with the current xcode theme, the extension syncs with the current macOS theme. I have an Automatic Appearance selected in macOS System Settings and right now it's daytime, hence the appearance is light (even though Xcode is selected to dark appearance in the general tab). Copilot has a light background that caters for the macOS appearance rather than xcode theme.

Once I switch the System Settings Appearance to dark, copilot extension also switches to dark.

I think instead of syncing with macOS Appearance it should ideally sync with how light/dark the background of the specific Xcode theme is (not even the Xcode Appearance setting) because the suggestions pop up on top of the editor background. If that's too cumbersome to implement, at least syncing it with the Xcode Appearance setting in the general tab of Xcode settings would be good enough because I doubt somebody would choose a dark xcode theme in light xcode appearance and vice versa.

Please see the logs from the debug app: github-copilot-for-xcode.log

Thanks!

larsemig commented 3 weeks ago

Hey there, hope this helps:

  1. I deleted all Logs
  2. Installed your linked dmg:
  3. Opened Xcode
  4. Waited for one suggestion
  5. Quit Xcode

I am in default dark theme, I got suggestion in light theme (like in the description of the issue)

Here are my logs: github-copilot-for-xcode.log

devm33 commented 3 weeks ago

@larsemig thank you! Could you confirm what your OS theme is set to? In the logs it looks like your OS is in light theme, but your Xcode UI (outside of the editor) looks like dark theme. Is that right? If so how did you set that up?

Image

@armanarutiunov thank you for the detailed report as well! Unfortunately, the way Xcode stores its current theme is coupled with the system appearance, see:

defaults read com.apple.dt.Xcode XCFontAndColorCurrentTheme
defaults read com.apple.dt.Xcode XCFontAndColorCurrentDarkTheme

Could you trying installing from this DMG and sharing the logs: https://github.com/github/CopilotForXcode/releases/download/0.27.92/GitHubCopilotForXcode_debugThemeLogging.dmg

Thanks!

armanarutiunov commented 3 weeks ago

@devm33 I see! It also seems weird because when I do

defaults read com.apple.dt.Xcode XCFontAndColorCurrentTheme

it returns the default light theme for the light appearance (even though right now I have both macOS and Xcode appearance on dark). That default light theme also happens to be the first in the folder with all the xcode color themes, maybe that's the reason? 🤔

Anyway, just ran the new debug app that you sent. Keep in mind that this time, it's an evening for me, so both my macOS and Xcode are in dark appearance, hence copilot uses the correct color. However, once I change the xcode theme manually to light, it still keeps the wrong (dark color for copilot suggestions). And only when I set macOS Appearance to light as well, copilot changes to light background for suggestions.

Here are the logs: github-copilot-for-xcode.log

devm33 commented 3 weeks ago

@armanarutiunov Yeah XCFontAndColorCurrentTheme should be the Xcode theme name when the system is in light mode, and conversely for dark mode for XCFontAndColorDarkTheme.

It looks like your logs are for the previous version. You may need to quit the Copilot background service (from the status menu icon) and restart it after installing from the dmg. You will also need to run the app manually once after installing from the dmg (to get past the downloaded from the internet warning).

Could you also share the output of the Xcode prefs with your logs:

defaults read com.apple.dt.Xcode XCFontAndColorCurrentTheme
defaults read com.apple.dt.Xcode XCFontAndColorCurrentDarkTheme
armanarutiunov commented 3 weeks ago

@devm33 gotcha! Here are the new logs: github-copilot-for-xcode.log

And this is my output for the command:

Arman (Light).xccolortheme
Arman (Dark).xccolortheme
devm33 commented 3 weeks ago

Thanks @armanarutiunov! So far I haven't been able to reproduce any broken state with light, dark, or auto 🤔

To clarify the issue you're seeing:

Is that all correct?

The next time you see it in a broken state can you send the logs again?

armanarutiunov commented 3 weeks ago

@devm33 no, that's not really what I'm experiencing.

As a user, ideally, I expect that Copilot would ignore the OS appearance and render the theme that is currently selected in the Themes tab of Xcode settings:

Screenshot 2024-11-04 at 23 41 51

Or, at least, that Copilot would ignore the OS appearance and render the theme that is associated with the Appearance that is set in the General tab of Xcode settings:

Screenshot 2024-11-04 at 23 44 37

To simplify my issue - I want to be able to have OS set to light during the day but Xcode to dark and Copilot to match Xcode, not the OS.

zenangst commented 3 weeks ago

I second what @armanarutiunov wrote, this is how I switch between light & dark mode. I switch within Xcode, not via System Settings.

devm33 commented 3 weeks ago

Thank you @armanarutiunov 🎉 That's what I was missing! Will update here once a fix is available

larsemig commented 3 weeks ago

To simplify my issue - I want to be able to have OS set to light during the day but Xcode to dark and Copilot to match Xcode, not the OS.

I think this is the same issue I am having: Copilot seems to only use the OS theme instead of the Xcode appearance.

-> Getting light theme suggestions

devm33 commented 3 weeks ago

This should now be fixed in 0.28.0. Update via the Check for Updates in the status menu or in the settings app. Please note Xcode must be restarted after updated for the extension to be enabled. You can also update via the DMG on the release page.

As a note, due to a limitation in observation (specifically KVO doesn't seem to work on UserDefaults(suiteName:), here) the Copilot appearance won't live update when the Xcode appearance is changed. The appearance will sync eventually or you can restart the extension to sync immediately.

Thank you all for the feedback and input here to get this figured out! I will close this now, but feel free to reopen if you see any issues.

larsemig commented 3 weeks ago

Thanks for your blazingly fast support and fix 👍 With version 2.28.0 it works as expected.