Skip to content
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

Tab completion can't work #528

Open
2 tasks done
koi646 opened this issue May 29, 2024 · 36 comments
Open
2 tasks done

Tab completion can't work #528

koi646 opened this issue May 29, 2024 · 36 comments
Labels
help wanted Extra attention is needed

Comments

@koi646
Copy link

koi646 commented May 29, 2024

Before Reporting

  • I have checked FAQ, and there is no solution to my issue
  • I have searched the existing issues, and there is no existing issue for my issue

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.

@koi646 koi646 added the help wanted Extra attention is needed label May 29, 2024
@zenangst
Copy link

I’m seeing the same thing.

@intitni
Copy link
Owner

intitni commented May 29, 2024

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
Copy link
Owner

intitni commented May 29, 2024

Similar issue: #500

Sometimes a reboot will fix it.

@zenangst
Copy link

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
Copy link
Owner

intitni commented May 30, 2024

@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
Copy link

@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
Copy link
Owner

intitni commented May 30, 2024

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

@zenangst
Copy link

zenangst commented May 30, 2024

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

image image image

@intitni
Copy link
Owner

intitni commented May 30, 2024

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

@zenangst
Copy link

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
Copy link
Owner

intitni commented May 30, 2024

@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
Copy link
Author

koi646 commented May 31, 2024

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

@koi646
Copy link
Author

koi646 commented May 31, 2024

image

@intitni
Copy link
Owner

intitni commented May 31, 2024

@koi646 Update the language server in the host app

@koi646
Copy link
Author

koi646 commented May 31, 2024

sorry, what exactly should I do?

@intitni
Copy link
Owner

intitni commented May 31, 2024

@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
Copy link
Author

koi646 commented May 31, 2024

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

@zenangst
Copy link

zenangst commented Jun 4, 2024

@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
Copy link
Owner

intitni commented Jun 4, 2024

@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
Copy link

zenangst commented Jun 4, 2024

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

image

@intitni
Copy link
Owner

intitni commented Jun 4, 2024

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

@zenangst
Copy link

zenangst commented Jun 4, 2024

image

@intitni
Copy link
Owner

intitni commented Jun 4, 2024

@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
Copy link

zenangst commented Jun 4, 2024

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
Copy link
Owner

intitni commented Jun 4, 2024

@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
Copy link

zenangst commented Jun 4, 2024

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
Copy link
Owner

intitni commented Jun 4, 2024

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

@zenangst
Copy link

zenangst commented Jun 4, 2024

@intitni now we are talking, that did the trick

@intitni
Copy link
Owner

intitni commented Jun 4, 2024

@zenangst I think I should remove the toggle later

@zenangst
Copy link

zenangst commented Jun 4, 2024

@intitni thanks for your patience ❤️

@lfnoise
Copy link

lfnoise commented Oct 4, 2024

Can someone summarize what needs to be done? My tab completion hasn't worked for a while. Trigger command with Accessibility API is checked. Always accept suggestion with Accessibility API is unchecked. Auto-suggestions work. Version is up to date.

Also a huge problem is the repasting of my whole file when a suggestion is accepted, it scrolls to the wrong place and the insertion point is sometimes put at the end of the file. After accepting a suggestion, clicking on an error in the left pane then selects the whole file instead of the line with the error. Another issue is the suggestion window pops up again immediately after pressing escape or reject, such that I can't get to edit the code underneath unless I quit copilot for xcode. Another intermittent issue is that pressing the Accept button just dismisses the window - nothing gets pasted in.

@intitni
Copy link
Owner

intitni commented Oct 4, 2024

@lfnoise That means the app can't find the Xcode > Editor > Copilot menu and is using the fallback solution to accept suggestions. Please check if the menu is still there, and make sure to always restart Xcode after updating the extension. Refer to the faq if you can't see the menu.

For the last issue you mentioned, it may be related to a macOS bug that is preventing the app from activating Xcode, please try the version from # 587 #585.

For the other issues, please open a new issue, and provide a video if possible.

@lfnoise
Copy link

lfnoise commented Oct 4, 2024

So I restarted Xcode, then started Copilot for Xcode -> tab doesn't work. Then tried starting them in the opposite order -> tab doesn't work. In both cases the Xcode > Editor > Copilot is present.

@intitni
Copy link
Owner

intitni commented Oct 4, 2024

@lfnoise Please do the checks listed on this webpage

Please also confirm that if you can accept suggestion with the menu item "Accept Suggestion" or the accept button.

@lfnoise
Copy link

lfnoise commented Oct 4, 2024

  1. How do you accept a suggestion without Xcode being activated already?
  2. spaces are inserted when I press tab.
  3. Accept suggestion with tab is checked with no modifiers checked.
  4. Yes, “Always accept suggestion with Accessibility API" is false and “Trigger command with Accessibility API” is true.
  5. Xcode > Editor > Copilot > Accept Suggestion is available. Choosing it dismisses the suggestion dialog without pasting the suggested text. (edit: It sometimes pastes the text and sometimes not.)
  6. It is not greyed out.
  7. & 8: An activate,deactivate pair of lines shows up whenever I press the Accept button, but not if I press Tab.
file: /Users/intitni/Developer/Projects/CopilotForXcodePro/CopilotForXcode/Core/Sources/KeyBindingManager/TabToAcceptSuggestion.swift
line: 16
function: TabToAcceptSuggestion
debug	15:48:14.238866-0700	CopilotForXcodeExtensionService	TabToAcceptSuggestion: Deactivate.
file: /Users/intitni/Developer/Projects/CopilotForXcodePro/CopilotForXcode/Core/Sources/KeyBindingManager/TabToAcceptSuggestion.swift
line: 16
function: TabToAcceptSuggestion
debug	15:48:18.552927-0700	CopilotForXcodeExtensionService	TabToAcceptSuggestion: Activated.
file: /Users/intitni/Developer/Projects/CopilotForXcodePro/CopilotForXcode/Core/Sources/KeyBindingManager/TabToAcceptSuggestion.swift
line: 16
function: TabToAcceptSuggestion
debug	15:48:30.966155-0700	CopilotForXcodeExtensionService	TabToAcceptSuggestion: Deactivate.
file: /Users/intitni/Developer/Projects/CopilotForXcodePro/CopilotForXcode/Core/Sources/KeyBindingManager/TabToAcceptSuggestion.swift
line: 16
function: TabToAcceptSuggestion

@intitni
Copy link
Owner

intitni commented Oct 5, 2024

@lfnoise Please try this version

https://github.com/intitni/CopilotForXcode/releases/download/0.5.0/Copilot.for.Xcode.debug.20241005.1.zip

I have added a lot of logs. Please use the same console filter. If tab to accept eventually triggers, you will see TabToAcceptSuggestion: Accept suggestion, otherwise you will see other logs indicating what is not right.

If you don't see any log other that activate and deactivate, it's probably a macOS bug. Please try regranting permission or restarting the Mac.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants