continue icon indicating copy to clipboard operation
continue copied to clipboard

initial commit for InlineCompletionProvider

Open sestinj opened this issue 7 months ago • 4 comments

WIP migrating to the native JetBrains InlineCompletionProvider API. This may not be picked up again for a week or two. If anyone comes across this and has interest in cleaning up more of the details to get it across the finish line earlier, please feel free to help out!

sestinj avatar Apr 25 '25 05:04 sestinj

Deploy Preview for continuedev canceled.

Name Link
Latest commit a17d29a16755ab25a2fd064ccbf053e1be63e945
Latest deploy log https://app.netlify.com/sites/continuedev/deploys/680b228e0089a400081028d2

netlify[bot] avatar Apr 25 '25 05:04 netlify[bot]

Hi! Sorry to bother you, I'm one of the authors of the Inline Completion API in IntelliJ. I noticed that you're using an older version of the API, which was part of a highly experimental stage and is no longer available in the platform. I recommend switching to the version introduced in IntelliJ 2024.1. It's much more stable and production-ready now. Please let me know if you have any questions.

kkarnauk avatar May 05 '25 14:05 kkarnauk

Thanks for reaching out @kkarnauk! The purpose of this PR is to migrate to the new API, which we are very excited to do. We need a bit more time to be able to prioritize finishing this, but plan to get to it very soon

sestinj avatar May 06 '25 19:05 sestinj

😱 Found 1 issue. Time to roll up your sleeves! 😱

recurseml[bot] avatar Jun 13 '25 21:06 recurseml[bot]

@kkarnauk is the newest API version enabled by using platform and platformVersion set to 2023.3 and documented here?

coinzz avatar Jul 18 '25 16:07 coinzz

@coinzz I'd suggest to use the API starting from 2024.1. The one in 2023.3 has lots of deprecated methods/classes. They may be removed at some point of time (since almost 2 years already passed).

Unfortunately, there is no documentation on the IJ page. There are lots of KDocs in the code, though.

kkarnauk avatar Jul 24 '25 12:07 kkarnauk

Unfortunately, there is no documentation on the IJ page. There are lots of KDocs in the code, though.

@kkarnauk ah no worries, do you have a link to the current implementation with the KDocs for me then? I have scheduled a meeting with a colleague to take a look on that next friday 🙂

coinzz avatar Jul 24 '25 13:07 coinzz

@coinzz great to hear, thanks a lot for that!

Basically, you need to implement this interface.

A brief overview:

  • Implement isEnabled(event) to let the platform know whether your provider is applicable in the current context.
    • The implementation should be fast as it's called on EDT.
    • Usually, a provider is enabled on InlineCompletionEvent.DocumentChange (== a typing in an editor) and InlineCompletionEvent.DirectCall (== a user invokes the inline completion by shortcut).
    • There are also other built-in events. If you lack of the default events, please use InlineCompletionEvent.ManualCall.
    • If the completion of your plugin is disabled by some setting, please return false in this case. It's important to let other providers work in case your provider is unavailable.
  • Implement getSuggestion(request).
    • It is called on a background thread, so it may do some heavy stuff/internet access.
    • The result is basically a flow of some elements. If you need to render gray text, please use InlineCompletionGrayTextElement
    • There is InlineCompletionTextElement to provide colorful suggestions.
    • If you need to jump over a few symbols in the editor (e.g., a suggestion inserts text at several close offsets in the editor), please use InlineCompletionSkipTextElement.
    • Please do not create your own implementations of InlineCompletionElement. Otherwise, it would not work in the Remote Development setup.
  • If you need a custom handling when your suggestion is inserted into the editor, please override insertHandler.
  • A bonus. There is a native support for the Remote Development setup.

kkarnauk avatar Jul 24 '25 18:07 kkarnauk

I had some build problems which I figured out now. But @kkarnauk I still was not able to take a deeper look at your brief overview, because I still try to create a testable environment. So far I figured out:

  • I guess I need to use:
    • platformVersion=2024.3
    • key="ORG_GRADLE_PROJECT_platformVersion" value="2024.3.6"
    • I need to install the Jetbrains AI Plugin to test, since the Full Line Code Completion Plugin is an Ultimate Plugin (I did this manually in the sandbox env, because I was not able to add this plugin via gradle yet). Without any Inline Completion Plugin the settings look like this: 2024 3 6_no-plugin

When I start the intellij sandbox env with version 2024.2.6 and the AI Assistant Plugin I get this message:

2024 2 6

When I start the intellij sandbox env with version 2024.3.6 and the AI Assistant Plugin I get this message:

2024 3 6 Only this one is talking about "Built-in local inline completion", therfore I guessed that I need to update this far. But it could be only a textual issue as well? I guess the goal is as described in the ticket (#2061) to disable the "Enable Tab autocompletion" and then being able to enable "Enable cloud completion suggestions" on one of the screenshots. So which version do you think @kkarnauk ?

And @sestinj should I fork this branch and do a draft PR into this branch, because I guess I am not allowed to push directly here and this is your branch?

coinzz avatar Aug 05 '25 22:08 coinzz

Closing in favor of https://github.com/continuedev/continue/pull/6947

RomneyDa avatar Aug 06 '25 23:08 RomneyDa