intitni / CopilotForXcode

The missing GitHub Copilot, Codeium and ChatGPT Xcode Source Editor Extension
Other
7.34k stars 347 forks source link

Tab completion can't work #528

Open koi646 opened 1 month ago

koi646 commented 1 month ago

Before Reporting

Describe your issue

Previously, after subscribing to Plus, the Tab key could be used for autocompletion. Now, the Tab key no longer completes code. I'm unsure if this is related to the Xcode upgrade.

zenangst commented 1 month ago

I’m seeing the same thing.

intitni commented 1 month ago

It maybe that the app is failing to register event tap. Can you still accept suggestion with key bindings, buttons and the menu item?

If so, please open Console.app, click start streaming and set the filter to

category:Service any:CopilotForXcodeExtensionService

Let me know if you see the following logs when you activate an Xcode window:

Screenshot 2024-04-18 at 23 08 59
intitni commented 1 month ago

Similar issue: #500

Sometimes a reboot will fix it.

zenangst commented 1 month ago

I attached my logs for Console.app after launching Xcode. Unsure if it is the register tap that goes wrong because it seems to swallow the event because nothing happens when Real-time suggestion is enabled. Normally it should accept the regular Xcode auto-complete, but nothing ends up happening.

image
intitni commented 1 month ago

@zenangst it looks like another unresolvable issue #344. The app loses Accessibility API permission for some reasons. A reboot is needed to fix it.

zenangst commented 1 month ago

@intitni Oooh, yeah. I've seen this from time to time in my own application Keyboard Cowboy. I'll do a restart right now to see if that fixes things an report back to you.

You reckon I'll need to give the extension accessibility permissions again after I've done that?

intitni commented 1 month ago

@zenangst I don't think you need to do it again, but who knows.

zenangst commented 1 month ago

Hmm, a simple reboot didn't help. Have I screwed something up in my settings (again)? 🤔

image image image
intitni commented 1 month ago

@zenangst What about regranting permissions and turn the toggle "observe to AXNotification with default mode" on in advanced settings?

zenangst commented 1 month ago

Thanks for following up, it regranted the permissions but is still end up with same result, that tab does nothing when it shows a completion.

intitni commented 1 month ago

@zenangst But how did you get code suggestions when the app fails to observe to AXNotifications. Do you still see the errors about AXObserver?

Please give this version a try: https://github.com/intitni/CopilotForXcode/releases/download/0.1.0/Copilot.for.Xcode.app.debug.tabtoacceptsuggestion.202405301636.zip

I have added tons of loggings to this build. Please set the filter to

category:Debug
any:CopilotForXcodeExtensionService

If the app works as expected, you should see and only see the following logs when you tap Tab:

TabToAcceptSuggestion: handleEvent
TabToAcceptSuggestion: Tab detected, flags: ..., permission: ...
TabToAcceptSuggestion: Perform accept suggestion
koi646 commented 1 month ago

After I restarted the computer, not only did the tab stop working, but the code suggestions were also gone...

koi646 commented 1 month ago

image

intitni commented 1 month ago

@koi646 Update the language server in the host app

koi646 commented 1 month ago

sorry, what exactly should I do?

intitni commented 1 month ago

@koi646 go to the GitHub Copilot settings, if an update is available, click update and restart the service app.

If there is no update, that means it's automatically updated but the service app is not using it yet, please restart the service app.

koi646 commented 1 month ago

Thank you, code suggestions and tab completion are both working fine.🎉

zenangst commented 3 weeks ago

@intitni I tried your custom build, sadly the same result.

Console 2024-06-04 08 24 26

I still get the autocomplete to show.

Xcode 2024-06-04 08 24 23
intitni commented 3 weeks ago

@zenangst Please use the latest released build and set the filter to category:Debug. You should see logs when Xcode is activated and when you hit tab.

zenangst commented 3 weeks ago

I'm not seeing any output in Console.app if I set the category to Debug using the latest release build.

image
intitni commented 3 weeks ago

@zenangst Please remove the other filters and keep only the category:Debug

zenangst commented 3 weeks ago
image
intitni commented 3 weeks ago

@zenangst (´・ω・`)

I honestly don't know why.. Is it possible that the Console.app is not showing info or debug logs? I can find any toggle though..

zenangst commented 3 weeks ago

I found this thread https://forums.developer.apple.com/forums/thread/82736?page=2

Was able to get some additional information by using sudo log stream --level debug | grep -I copilot

https://gist.github.com/zenangst/a873439781e69ca0c78a639de626793d

intitni commented 3 weeks ago

@zenangst I found this log CopilotForXcodeExtensionService: [com.intii.CopilotForXcode:Debug] TabToAcceptSuggestion: Perform accept suggestion so it's triggered. And I don't see any error like Trigger menu item failed, so the menu item is clicked by the tab.

Can you still accept suggestion with buttons or the Xcode menu item? How does the Copilot menu look like? What happens if you turn on "Always accept suggestion with Accessibility API"

zenangst commented 3 weeks ago

Nothing happens when I click the accept button in the suggestion UI.

Enabling Always accept suggestion with Accessibility API seems to work but it jumps around and looses the scrolling position in the document.

intitni commented 3 weeks ago

@zenangst Please turn off that toggle and try Trigger command with Accessibility API

zenangst commented 3 weeks ago

@intitni now we are talking, that did the trick

intitni commented 3 weeks ago

@zenangst I think I should remove the toggle later

zenangst commented 3 weeks ago

@intitni thanks for your patience ❤️